feat(logging): add loglevel package and implement logger utility
refactor(document): update document list filtering and API request handling
This commit is contained in:
@@ -17,8 +17,8 @@ export interface UseDocumentListState {
|
||||
|
||||
// 文档列表Hook返回值接口
|
||||
export interface UseDocumentListReturn extends UseDocumentListState {
|
||||
fetchDocuments: (params?: IFetchKnowledgeListRequestParams) => Promise<void>;
|
||||
fetchDocumentsFilter: () => Promise<IDocumentInfoFilter | undefined>;
|
||||
fetchDocuments: (params?: IFetchKnowledgeListRequestParams, body?: IFetchDocumentListRequestBody) => Promise<void>;
|
||||
fetchDocumentsFilter: () => Promise<{ filter?: IDocumentInfoFilter, total?: number } | undefined>;
|
||||
setKeywords: (keywords: string) => void;
|
||||
setCurrentPage: (page: number) => void;
|
||||
setPageSize: (size: number) => void;
|
||||
@@ -44,7 +44,9 @@ export const useDocumentList = (
|
||||
/**
|
||||
* 获取文档列表
|
||||
*/
|
||||
const fetchDocuments = useCallback(async (params?: IFetchKnowledgeListRequestParams) => {
|
||||
const fetchDocuments = useCallback(async (
|
||||
params?: IFetchKnowledgeListRequestParams,
|
||||
body?: IFetchDocumentListRequestBody) => {
|
||||
if (!kbId) return;
|
||||
|
||||
try {
|
||||
@@ -61,6 +63,13 @@ export const useDocumentList = (
|
||||
// 构建请求体
|
||||
const requestBody: IFetchDocumentListRequestBody = {};
|
||||
|
||||
if (body?.suffix) {
|
||||
requestBody.suffix = body.suffix;
|
||||
}
|
||||
if (body?.run_status) {
|
||||
requestBody.run_status = body.run_status;
|
||||
}
|
||||
|
||||
// 构建查询参数
|
||||
const requestParams: IFetchKnowledgeListRequestParams = {
|
||||
kb_id: kbId,
|
||||
@@ -108,7 +117,7 @@ export const useDocumentList = (
|
||||
kb_id: kbId,
|
||||
});
|
||||
if (response.data.code === 0) {
|
||||
const data: IDocumentInfoFilter = response.data.data;
|
||||
const data: { filter?: IDocumentInfoFilter, total?: number } = response.data.data;
|
||||
return data;
|
||||
} else {
|
||||
throw new Error(response.data.message || '获取文档过滤器失败');
|
||||
@@ -189,7 +198,7 @@ export const useDocumentOperations = () => {
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('kb_id', kbId);
|
||||
|
||||
|
||||
files.forEach((file) => {
|
||||
formData.append('file', file);
|
||||
});
|
||||
@@ -221,7 +230,7 @@ export const useDocumentOperations = () => {
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('kb_id', kbId);
|
||||
|
||||
|
||||
files.forEach((file) => {
|
||||
formData.append('file', file);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user