feat: 将/support/documents路由的数据获取由Strapi转为Directus
- 修改/support/documents.vue,将相关数据获取迁移到Directus - 增添相应的视图模型与映射方法
This commit is contained in:
@ -5,3 +5,4 @@ export * from './useProduct';
|
||||
export * from './useSolutionList';
|
||||
export * from './useSolution';
|
||||
export * from './useQuestionList';
|
||||
export * from './useDocumentList';
|
||||
|
||||
67
app/composables/directus/useDocumentList.ts
Normal file
67
app/composables/directus/useDocumentList.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { readItems } from '@directus/sdk';
|
||||
|
||||
export const useDocumentList = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`document-list-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItems('product_documents', {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
file: ['id', 'filesize', 'filename_download'],
|
||||
},
|
||||
{
|
||||
translations: ['id', 'title'],
|
||||
},
|
||||
{
|
||||
products: [
|
||||
'id',
|
||||
{
|
||||
products_id: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name'],
|
||||
},
|
||||
{
|
||||
product_type: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
products: {
|
||||
products_id: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
product_type: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user