feat: 将首页由Strapi迁移至Directus

- 相关路由界面修改
- 增添响应的视图模型与转换方法
This commit is contained in:
2025-10-20 15:07:37 +08:00
parent c156d1414c
commit 05938550e6
5 changed files with 182 additions and 45 deletions

View File

@ -8,3 +8,4 @@ export * from './useQuestionList';
export * from './useDocumentList';
export * from './useContactInfo';
export * from './useCompanyProfile';
export * from './useHomepage';

View File

@ -0,0 +1,54 @@
import { readSingleton } from '@directus/sdk';
export const useHomepage = () => {
const { $directus } = useNuxtApp();
const { getDirectusLocale } = useLocalizations();
const locale = getDirectusLocale();
return useAsyncData(`homepage-${locale}`, async () => {
return await $directus.request(
readSingleton('homepage', {
fields: [
'id',
{
carousel: ['id', 'directus_files_id'],
},
{
recommend_products: [
'id',
{
translations: ['id', 'name', 'summary'],
},
'cover',
],
},
{
recommend_solutions: [
'id',
{
translations: ['id', 'title', 'summary'],
},
'cover',
],
},
],
deep: {
recommend_products: {
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
recommend_solutions: {
translations: {
_filter: {
languages_code: { _eq: locale },
},
},
},
},
})
);
});
};