refactor: env detail

This commit is contained in:
jialin
2026-01-30 18:48:55 +08:00
parent 577996f507
commit 667751dc5f
18 changed files with 377 additions and 187 deletions
+8 -1
View File
@@ -84,11 +84,12 @@ export function useQueryDataList<ListItem, Params = any>(option: {
export function useQueryData<Detail, Params = any>(option: {
key: string;
delay?: number;
fetchDetail: (params: Params, options?: any) => Promise<Detail>;
getData?: (response: Detail) => any;
errorMsg?: string;
}) {
const { key, fetchDetail, getData, errorMsg } = option;
const { key, fetchDetail, getData, errorMsg, delay } = option;
const axiosTokenRef = useRef<CancelTokenSource | null>(null);
const [detailData, setDetailData] = useState<Detail>({} as Detail);
@@ -105,6 +106,12 @@ export function useQueryData<Detail, Params = any>(option: {
...(extra || {})
});
if (delay) {
await new Promise((resolve) => {
setTimeout(resolve, delay);
});
}
setDetailData(getData ? getData(res) : res);
return res;