From 10e01aa71d494ece26214bd57017e045f13b2a08 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 06 八月 2025 09:12:34 +0800 Subject: [PATCH] fix: 修改功能模块 --- src/hooks/dic.ts | 51 ++------------------------------------------------- 1 files changed, 2 insertions(+), 49 deletions(-) diff --git a/src/hooks/dic.ts b/src/hooks/dic.ts index d55c72f..25dd1c8 100644 --- a/src/hooks/dic.ts +++ b/src/hooks/dic.ts @@ -1,55 +1,8 @@ -import * as searchSettingServices from '@/services/api/SearchSetting'; -import { useQuery } from '@tanstack/vue-query'; -import { useQueryClient } from '@tanstack/vue-query'; +import { useQuery, useQueryClient } from '@tanstack/vue-query'; import { SearchType } from '@/constants'; type UseSearchSettingTypeOptions = { searchType: number; belongType?: number; - onSuccess?: (data: API.GetTypeSearchSettingList[]) => any; + onSuccess?: (data: any[]) => 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