feat: solution页composable API
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m22s

This commit is contained in:
2025-10-17 16:24:13 +08:00
parent 568701a80e
commit 0ccd855472
3 changed files with 68 additions and 0 deletions

View File

@ -2,3 +2,5 @@ export * from './useDirectusImage';
export * from './useDirectusFiles';
export * from './useProductList';
export * from './useProduct';
export * from './useSolutionList';
export * from './useSolution';

View File

@ -0,0 +1,28 @@
import { readItem } from '@directus/sdk';
export const useSolution = (id: string) => {
const { $directus } = useNuxtApp();
const { getDirectusLocale } = useLocalizations();
const locale = getDirectusLocale();
return useAsyncData(`solution-${id}-${locale}`, async () => {
return await $directus.request(
readItem('solutions', id, {
fields: [
'id',
{
translations: ['*'],
},
'create_at',
],
deep: {
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
})
);
});
};

View File

@ -0,0 +1,38 @@
import { readItems } from '@directus/sdk';
export const useSolutionList = () => {
const { $directus } = useNuxtApp();
const { getDirectusLocale } = useLocalizations();
const locale = getDirectusLocale();
return useAsyncData(`solution-list-${locale}`, async () => {
return await $directus.request(
readItems('solutions', {
fields: [
'id',
'cover',
{
type: ['id', { translations: ['id', 'name'] }],
},
{
translations: ['id', 'title', 'summary'],
},
],
deep: {
type: {
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
})
);
});
};