From 3682904ad4223dc16942532f64dbb4c56b73dafa Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 06 八月 2025 11:02:12 +0800 Subject: [PATCH] feat: 更新框架 --- src/hooks/dic.ts | 54 ------------------------------------------------------ 1 files changed, 0 insertions(+), 54 deletions(-) diff --git a/src/hooks/dic.ts b/src/hooks/dic.ts index e256f01..e69de29 100644 --- a/src/hooks/dic.ts +++ b/src/hooks/dic.ts @@ -1,54 +0,0 @@ -import * as searchSettingServices from '@/services/api/SearchSetting'; -import { useQuery } from '@tanstack/vue-query'; -import { useQueryClient } from '@tanstack/vue-query'; - -type UseSearchSettingTypeOptions = { - searchType: number; - belongType?: number; - onSuccess?: (data: API.GetTypeSearchSettingList[]) => any; -}; - -export function useSearchSettingType({ - searchType, - belongType = null, - onSuccess, -}: UseSearchSettingTypeOptions) { - const { data, refetch } = useQuery({ - queryKey: ['searchSettingServices/getTypeSearchSettingList', { searchType, belongType }], - queryFn: async () => { - return await searchSettingServices.getTypeSearchSettingList( - { - searchType: searchType, - belongType: belongType, - }, - { showLoading: false } - ); - }, - placeholderData: () => [] as API.GetTypeSearchSettingList[], - onSuccess(data) { - onSuccess?.(data); - }, - }); - - const queryClient = useQueryClient(); - - async function ensureSearchSettingType() { - return await queryClient.ensureQueryData({ - queryKey: [ - 'searchSettingServices/getTypeSearchSettingList', - { searchType: searchType, belongType: belongType }, - ], - }); - } - - function getSearchSettingTypeNameById(id: string) { - return data.value.find((x) => x.id === id)?.name ?? ''; - } - - return { - searchSettingTypeList: data, - ensureSearchSettingType, - refetchSearchSettingType: refetch, - getSearchSettingTypeNameById, - }; -} -- Gitblit v1.9.1