mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-13 05:55:54 +00:00
fix: fix the bug of the router
This commit is contained in:
parent
b75d901895
commit
1be075248c
@ -1,22 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Router from 'next/router'
|
import { useSearchParams } from 'next/navigation'
|
||||||
import { withRouter } from 'next/router'
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Table, Popover } from 'antd';
|
import { Table, Popover } from 'antd';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
const ChunkList = ({ router }) => {
|
const ChunkList = () => {
|
||||||
|
const spaceName = useSearchParams().get('spacename');
|
||||||
|
const documentId = useSearchParams().get('documentid');
|
||||||
const [chunkList, setChunkList] = useState<any>([]);
|
const [chunkList, setChunkList] = useState<any>([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchChunks() {
|
async function fetchChunks() {
|
||||||
const res = await fetch(`http://localhost:8000/knowledge/${router.query.spacename}/chunk/list`, {
|
const res = await fetch(`http://localhost:8000/knowledge/${spaceName}/chunk/list`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
document_id: router.query.documentid
|
document_id: documentId
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@ -61,4 +62,4 @@ const ChunkList = ({ router }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(ChunkList);
|
export default ChunkList;
|
@ -1,16 +1,18 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Router from 'next/router'
|
import Link from 'next/link'
|
||||||
import { withRouter } from 'next/router'
|
import { useRouter, useSearchParams } from 'next/navigation'
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Table, Button } from 'antd';
|
import { Table, Button } from 'antd';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
const Documents = ({ router }) => {
|
const Documents = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const spaceName = useSearchParams().get('name');
|
||||||
const [documents, setDocuments] = useState<any>([]);
|
const [documents, setDocuments] = useState<any>([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchDocuments() {
|
async function fetchDocuments() {
|
||||||
const res = await fetch(`http://localhost:8000/knowledge/${router.query.name}/document/list`, {
|
const res = await fetch(`http://localhost:8000/knowledge/${spaceName}/document/list`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -67,7 +69,7 @@ const Documents = ({ router }) => {
|
|||||||
render: (_: any, label: any) => {
|
render: (_: any, label: any) => {
|
||||||
return (
|
return (
|
||||||
<Button onClick={() => {
|
<Button onClick={() => {
|
||||||
Router.push(`/datastores/documents/chunklist?spacename=${router.query.name}&documentid=${label.id}`)
|
router.push(`/datastores/documents/chunklist?spacename=${spaceName}&documentid=${label.id}`)
|
||||||
}}>Detail of Chunks</Button>
|
}}>Detail of Chunks</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -79,4 +81,4 @@ const Documents = ({ router }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(Documents);
|
export default Documents;
|
@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import Router from 'next/router'
|
import { useRouter } from 'next/navigation'
|
||||||
import type { ProFormInstance } from '@ant-design/pro-components';
|
import type { ProFormInstance } from '@ant-design/pro-components';
|
||||||
import React, { useState, useRef, useEffect } from 'react'
|
import React, { useState, useRef, useEffect } from 'react'
|
||||||
import {
|
import {
|
||||||
@ -17,6 +17,7 @@ import {
|
|||||||
import { Button, Modal, Table, message } from 'antd'
|
import { Button, Modal, Table, message } from 'antd'
|
||||||
|
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
|
const router = useRouter();
|
||||||
const formRef = useRef<ProFormInstance>();
|
const formRef = useRef<ProFormInstance>();
|
||||||
const [knowledgeSpaceList, setKnowledgeSpaceList] = useState<any>([]);
|
const [knowledgeSpaceList, setKnowledgeSpaceList] = useState<any>([]);
|
||||||
const [isAddKnowledgeSpaceModalShow, setIsAddKnowledgeSpaceModalShow] =
|
const [isAddKnowledgeSpaceModalShow, setIsAddKnowledgeSpaceModalShow] =
|
||||||
@ -56,7 +57,7 @@ const Index = () => {
|
|||||||
key: 'name',
|
key: 'name',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: (text: string) => {
|
render: (text: string) => {
|
||||||
return <a href='javascript:;' onClick={() => Router.push(`/datastores/documents?name=${text}`)}>{text}</a>
|
return <a href='javascript:;' onClick={() => router.push(`/datastores/documents?name=${text}`)}>{text}</a>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user