From dd7ac909fb7efb4b16245e1966e4ea2d23b4d5f8 Mon Sep 17 00:00:00 2001 From: R2m1liA <15258427350@163.com> Date: Fri, 31 Oct 2025 15:06:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=80=BCproduct=5Fspec=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - subItem.value => subItem.key - 调整后端CMS的结构,将规格值移入translations中 --- app/components/pages/products/SpecTable.vue | 2 +- app/composables/directus/useProduct.ts | 3 +- app/models/mappers/productMapper.ts | 3 +- shared/types/directus/my-schema.ts | 37 +++++++++++++++------ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/components/pages/products/SpecTable.vue b/app/components/pages/products/SpecTable.vue index c08c2a0..7914e44 100644 --- a/app/components/pages/products/SpecTable.vue +++ b/app/components/pages/products/SpecTable.vue @@ -11,7 +11,7 @@ {{ subItem.value }} diff --git a/app/composables/directus/useProduct.ts b/app/composables/directus/useProduct.ts index afe1d03..67c18ed 100644 --- a/app/composables/directus/useProduct.ts +++ b/app/composables/directus/useProduct.ts @@ -34,9 +34,8 @@ export const useProduct = (id: string) => { specs: [ 'id', { - translations: ['id', 'key'], + translations: ['id', 'key', 'value'], }, - 'value', ], }, ], diff --git a/app/models/mappers/productMapper.ts b/app/models/mappers/productMapper.ts index a40e284..5eefde8 100644 --- a/app/models/mappers/productMapper.ts +++ b/app/models/mappers/productMapper.ts @@ -61,12 +61,13 @@ export function toProductSpecGroupView( export function toProductSpecView(raw: ProductSpec): ProductSpecView { const trans = raw.translations?.[0] ?? { key: '', + value: '', }; return { id: raw.id, key: trans.key, - value: raw.value, + value: trans.value, }; } diff --git a/shared/types/directus/my-schema.ts b/shared/types/directus/my-schema.ts index de139c3..e7c279d 100644 --- a/shared/types/directus/my-schema.ts +++ b/shared/types/directus/my-schema.ts @@ -26,13 +26,6 @@ export interface ContactInfoTranslation { content?: string | null; } -export interface DocumentsTranslation { - /** @primaryKey */ - id: number; - languages_code?: Language | string | null; - title?: string | null; -} - export interface Homepage { /** @primaryKey */ id: number; @@ -55,6 +48,28 @@ export interface Language { direction?: 'ltr' | 'rtl' | null; } +export interface MeiliIndexConfig { + /** @primaryKey */ + id: number; + /** @description 要索引的集合名 */ + collection_name?: string | null; + /** @description MeiliSearch 索引名称 */ + index_name?: string | null; + /** @description 要索引的字段数组 */ + fields?: 'json' | null; + /** @description 是否启用 */ + enabled?: boolean | null; +} + +export interface MeiliSearchConfig { + /** @primaryKey */ + id: number; + /** @description MeiliSearch 主机地址 */ + host?: string | null; + /** @description MeiliSearch API Key */ + api_key?: string | null; +} + export interface ProductDocument { /** @primaryKey */ id: number; @@ -110,7 +125,6 @@ export interface ProductSpec { id: number; group?: ProductSpecGroup | string | null; sort?: number | null; - value?: string | null; translations?: ProductSpecsTranslation[] | null; } @@ -120,6 +134,7 @@ export interface ProductSpecsTranslation { product_specs_id?: ProductSpec | string | null; languages_code?: Language | string | null; key?: string | null; + value?: string | null; } export interface ProductType { @@ -728,10 +743,11 @@ export interface Schema { company_profile_translations: CompanyProfileTranslation[]; contact_info: ContactInfo; contact_info_translations: ContactInfoTranslation[]; - documents_translations: DocumentsTranslation[]; homepage: Homepage; homepage_files: HomepageFile[]; languages: Language[]; + meili_index_configs: MeiliIndexConfig[]; + meili_search_config: MeiliSearchConfig; product_documents: ProductDocument[]; product_documents_translations: ProductDocumentsTranslation[]; product_images: ProductImage[]; @@ -787,10 +803,11 @@ export enum CollectionNames { company_profile_translations = 'company_profile_translations', contact_info = 'contact_info', contact_info_translations = 'contact_info_translations', - documents_translations = 'documents_translations', homepage = 'homepage', homepage_files = 'homepage_files', languages = 'languages', + meili_index_configs = 'meili_index_configs', + meili_search_config = 'meili_search_config', product_documents = 'product_documents', product_documents_translations = 'product_documents_translations', product_images = 'product_images', -- 2.49.0