From ea409d49b0e565179b1fc0885627a2555bde2032 Mon Sep 17 00:00:00 2001
From: R2m1liA <15258427350@163.com>
Date: Thu, 4 Sep 2025 14:55:32 +0800
Subject: [PATCH] =?UTF-8?q?refactor(production):=20=E9=87=8D=E6=9E=84?=
=?UTF-8?q?=E4=BA=A7=E5=93=81=E9=A1=B5=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 将Production的documents类型改写为单独的interface:ProductionDocument
---
app/pages/productions/[...slug].vue | 7 ++++---
app/pages/productions/index.vue | 10 +++-------
app/types/strapi/common.ts | 4 +++-
app/types/strapi/production.ts | 11 ++++++++---
app/types/strapi/question.ts | 1 +
5 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/app/pages/productions/[...slug].vue b/app/pages/productions/[...slug].vue
index 62485d5..cc42f15 100644
--- a/app/pages/productions/[...slug].vue
+++ b/app/pages/productions/[...slug].vue
@@ -36,7 +36,7 @@
-
+
@@ -95,8 +95,8 @@ onMounted(async () => {
questions: {
populate: '*',
},
- documents: {
- populate: '*',
+ production_documents: {
+ populate: 'document',
},
},
locale: strapiLocale,
@@ -106,6 +106,7 @@ onMounted(async () => {
production.value = {
...item,
}
+ console.log('Fetched production:', production.value)
}
} catch (error) {
console.error('Failed to fetch production:', error)
diff --git a/app/pages/productions/index.vue b/app/pages/productions/index.vue
index 4ca445e..745ab4d 100644
--- a/app/pages/productions/index.vue
+++ b/app/pages/productions/index.vue
@@ -19,8 +19,7 @@ v-for="(group, type) in groupedProductions" :key="type" :title="type || '未分
@@ -65,12 +64,9 @@ onMounted(async () => {
cover: {
populate: '*',
},
- production_images: {
- populate: '*',
- },
production_type: {
- populate: '*',
- }
+ populate: '*'
+ },
},
filters: {
show_in_production_list: {
diff --git a/app/types/strapi/common.ts b/app/types/strapi/common.ts
index 135802b..2299fb4 100644
--- a/app/types/strapi/common.ts
+++ b/app/types/strapi/common.ts
@@ -44,4 +44,6 @@ export interface StrapiResponse {
total: number;
}
}
-}
\ No newline at end of file
+}
+
+export type StrapiRelation = Omit & StrapiEntity;
\ No newline at end of file
diff --git a/app/types/strapi/production.ts b/app/types/strapi/production.ts
index bf124f3..3ee3176 100644
--- a/app/types/strapi/production.ts
+++ b/app/types/strapi/production.ts
@@ -1,4 +1,4 @@
-import type { StrapiEntity, StrapiImage, StrapiMedia } from './common';
+import type { StrapiEntity, StrapiImage, StrapiMedia, StrapiRelation } from './common';
export interface ProductionType extends StrapiEntity {
type: string;
@@ -22,7 +22,12 @@ export interface Production extends StrapiEntity {
production_images: StrapiImage[];
production_details: string;
production_specs: ProductionSpecGroup[];
- questions: Question[];
- documents: StrapiMedia[];
+ production_documents: StrapiRelation[];
+ questions: StrapiRelation[];
show_in_production_list: boolean;
+}
+
+export interface ProductionDocument extends StrapiEntity {
+ document: StrapiMedia;
+ related_productions: StrapiRelation[];
}
\ No newline at end of file
diff --git a/app/types/strapi/question.ts b/app/types/strapi/question.ts
index 4204a28..564675f 100644
--- a/app/types/strapi/question.ts
+++ b/app/types/strapi/question.ts
@@ -1,4 +1,5 @@
export interface Question extends StrapiEntity {
title: string;
content: string;
+ related_productions: StrapiRelation[];
}
\ No newline at end of file