feat(template): 添加模板搜索功能和优化数据获取

- 添加 keyword 参数支持模板名称和描述模糊搜索
- 在 useFetchData hook 中添加 filterParamMapper 参数用于过滤参数映射
- 为模板列表页面实现内置标志过滤器映射功能
- 优化模板配置更新逻辑,改进数据验证和转换流程
- 完善模板服务中的条件查询,支持多字段模糊匹配
- 更新数据获取 hook 的依赖数组以正确处理轮询逻辑
This commit is contained in:
2026-01-22 21:25:04 +08:00
parent d22d677efe
commit ccb581d501
4 changed files with 305 additions and 245 deletions

View File

@@ -56,6 +56,31 @@ const TemplateList: React.FC = () => {
},
];
const BUILT_IN_FLAG = {
TRUE: "true",
FALSE: "false",
} as const;
const mapTemplateFilters = (filters: Record<string, string[]>) => {
const getFirstValue = (values?: string[]) =>
values && values.length > 0 ? values[0] : undefined;
const builtInRaw = getFirstValue(filters.builtIn);
const builtIn =
builtInRaw === BUILT_IN_FLAG.TRUE
? true
: builtInRaw === BUILT_IN_FLAG.FALSE
? false
: undefined;
return {
category: getFirstValue(filters.category),
dataType: getFirstValue(filters.dataType),
labelingType: getFirstValue(filters.labelingType),
builtIn,
};
};
// Modals
const [isFormVisible, setIsFormVisible] = useState(false);
const [isDetailVisible, setIsDetailVisible] = useState(false);
@@ -71,7 +96,15 @@ const TemplateList: React.FC = () => {
fetchData,
handleFiltersChange,
handleKeywordChange,
} = useFetchData(queryAnnotationTemplatesUsingGet, undefined, undefined, undefined, undefined, 0);
} = useFetchData(
queryAnnotationTemplatesUsingGet,
undefined,
undefined,
undefined,
undefined,
0,
mapTemplateFilters
);
const handleCreate = () => {
setFormMode("create");