refactor: 解决方案列表的API重构

This commit is contained in:
2025-11-11 16:35:20 +08:00
parent 0d77e97ad5
commit 706b754905
3 changed files with 26 additions and 30 deletions

View File

@ -1,4 +1,4 @@
import { readItems } from '@directus/sdk';
import GetSolutionList from '@/graphql/solutionList.graphql?raw';
export const useSolutionList = () => {
const { $directus } = useNuxtApp();
@ -6,33 +6,8 @@ export const useSolutionList = () => {
const locale = getDirectusLocale();
return useAsyncData(`solution-list-${locale}`, async () => {
return await $directus.request(
readItems('solutions', {
fields: [
'id',
'cover',
{
type: ['id', { translations: ['id', 'name'] }, 'sort'],
},
{
translations: ['id', 'title', 'summary'],
},
],
deep: {
type: {
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
})
);
return await $directus.query<{ solutions: Solution[] }>(GetSolutionList, {
locale: locale,
});
});
};