style: 知识库新列表 (#2448)

* style: 知识库新列表

* i18n adjust

* fix:  i18n
This commit is contained in:
papapatrick
2024-08-20 17:29:41 +08:00
committed by GitHub
parent 2d0e6bd085
commit 40b1d22d9d
12 changed files with 215 additions and 111 deletions

View File

@@ -37,6 +37,8 @@ export type DatasetContextType = {
setEditedDataset: (data?: EditResourceInfoFormType) => void;
onDelDataset: (id: string) => Promise<void>;
onUpdateDataset: (data: DatasetUpdateBody) => Promise<void>;
searchKey: string;
setSearchKey: React.Dispatch<React.SetStateAction<string>>;
};
export const DatasetsContext = createContext<DatasetContextType>({
@@ -57,7 +59,11 @@ export const DatasetsContext = createContext<DatasetContextType>({
onUpdateDataset: function (_data: DatasetUpdateBody): Promise<void> {
throw new Error('Function not implemented.');
},
myDatasets: []
myDatasets: [],
searchKey: '',
setSearchKey: function (value: React.SetStateAction<string>): void {
throw new Error('Function not implemented.');
}
});
function DatasetContextProvider({ children }: { children: React.ReactNode }) {
@@ -65,7 +71,7 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
const { commonT } = useI18n();
const { t } = useTranslation();
const [moveDatasetId, setMoveDatasetId] = useState<string>();
const [searchKey, setSearchKey] = useState('');
const { parentId = null } = router.query as { parentId?: string | null };
const {
@@ -75,11 +81,12 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
} = useRequest2(
() =>
getDatasets({
searchKey,
parentId
}),
{
manual: false,
refreshDeps: [parentId]
refreshDeps: [parentId, searchKey]
}
);
@@ -145,7 +152,9 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
onDelDataset,
onUpdateDataset,
myDatasets,
loadMyDatasets
loadMyDatasets,
searchKey,
setSearchKey
};
return (