diff --git a/app/[locale]/line/[slug]/page.tsx b/app/[locale]/line/[slug]/page.tsx index 3b61af0..324acf2 100644 --- a/app/[locale]/line/[slug]/page.tsx +++ b/app/[locale]/line/[slug]/page.tsx @@ -46,48 +46,47 @@ export async function generateMetadata({ // 页面主组件 - 仅保留字段展示+修复 Hydration 错误 export default async function ProductDetailPage({ params }: { params: Params }) { - // 🔴 修复:params 是同步对象,移除不必要的 await const { locale, slug } = await params; const line = await getLine(locale, slug); if (!line) return
404 - 产线不存在
; return ( -
- {/* 标题 */} -

- {line.title} -

- - {/* 产品描述 */} -

- {line.desc} -

- - {/* 封面图 */} - {line.cover && ( -
- {`${line.title} +
+ {/* 标题和描述区域,分为左右布局 */} +
+ {/* 左侧:标题和描述 */} +
+

+ {line.title} +

+

+ {line.desc} +

- )} - {/* 产品图片列表 */} + {/* 右侧:封面图 */} + {line.cover && ( +
+ {`${line.title} +
+ )} +
+ + {/* 产品图片列表区域 */} {line.images && line.images.length > 0 && ( -
-

+
+

产品图片

-
+
{line.images.map((imgUrl, index) => ( -
+
{`${line.title} )} - {/* 产品特性/参数 */} + {/* 产品特性/参数区域 */} {line.properties && line.properties.length > 0 && ( -
-

+
+

产品参数

-
    +
      {line.properties.map((prop, index) => (
    • {/* 处理参数中的换行符 \n */} -
      - {/* 封面图:优化属性,确保服务端/客户端渲染一致 */} -
      - {coverAlt} +
      +
      +
      +
      +
      + {coverAlt} +
      - - {/* 车间信息 */} -
      -

      {product.title || "未命名产品线"}

      -

      {product.desc || "暂无描述"}

      +
      +
      + {product.title} +
      + {/* 最多四行,超过四行溢出隐藏 */} +

      + {product.desc} +

      + ); } diff --git a/app/[locale]/product/page.tsx b/app/[locale]/product/page.tsx index c45db66..be3dc33 100644 --- a/app/[locale]/product/page.tsx +++ b/app/[locale]/product/page.tsx @@ -89,17 +89,55 @@ export default async function Page({ prefetch={false} className="block bg-white border border-gray-100 rounded-lg overflow-hidden shadow-sm hover:shadow-md transition-all duration-300" > -
      - {product.title} -
      -
      -

      {product.title}

      -
      - {t("learnMore")} > +
      +
      +
      +
      +
      + +
      +
      +
      +
      + {product.title} +
      +

      + {product.detail} +

      +
      +
      +
      diff --git a/app/[locale]/workshop/[slug]/page.tsx b/app/[locale]/workshop/[slug]/page.tsx index eba438b..00660d5 100644 --- a/app/[locale]/workshop/[slug]/page.tsx +++ b/app/[locale]/workshop/[slug]/page.tsx @@ -20,9 +20,6 @@ export async function generateMetadata({ }: MetadataProps): Promise { const { locale, slug } = await params; const workShop = await getWorkShop(locale, slug); - console.log(workShop); - - console.log(workShop?.slug); if (!workShop) { return constructMetadata({ @@ -46,7 +43,6 @@ export async function generateMetadata({ // 页面主组件 - 仅保留字段展示+修复 Hydration 错误 export default async function WorkshopDetailPage({ params }: { params: Params }) { - // 🔴 核心修复1:移除不必要的 await(params 是同步对象) const { locale, slug } = await params; const workShop = await getWorkShop(locale, slug); @@ -58,32 +54,29 @@ export default async function WorkshopDetailPage({ params }: { params: Params }) const workshopDesc = workShop.desc || "暂无车间描述"; return ( -
      -
      - {/* 封面图区域 - 🔴 修复布局属性不一致 */} -
      +
      +
      + {/* 封面图区域 - 强化背景效果 */} +
      {coverAlt} +
      {/* 标题+描述区域 */} -
      -

      - {workShop.title} -

      -

      - {workshopDesc} -

      +
      +

      {workShop.title}

      +

      {workshopDesc}

      + {/* 图片展示区域 */} {workShop.images?.length > 0 && ( -
      +

      车间图片

      @@ -94,12 +87,12 @@ export default async function WorkshopDetailPage({ params }: { params: Params }) return (
      {imgAlt} @@ -126,7 +119,7 @@ export async function generateStaticParams() { })) ); } catch (error) { - console.error("生成产品静态参数失败:", error); + console.error("生成车间静态参数失败:", error); return []; } -} \ No newline at end of file +} diff --git a/app/[locale]/workshop/page.tsx b/app/[locale]/workshop/page.tsx index d69571c..ca9f49e 100644 --- a/app/[locale]/workshop/page.tsx +++ b/app/[locale]/workshop/page.tsx @@ -2,13 +2,14 @@ import { Link as I18nLink, LOCALES } from "@/i18n/routing"; import { constructMetadata } from "@/lib/metadata"; import { getWorkShops } from "@/lib/workshop"; import { WorkShop } from "@/types/workShop"; +import clsx from "clsx"; import { Metadata } from "next"; import { getTranslations } from "next-intl/server"; // 强制静态生成 export const dynamic = "force-static"; -// 明确 Params 类型(静态生成的参数) +// 明确 Params 类型(静态生成的参数) type Params = { locale: string }; type MetadataProps = { @@ -16,9 +17,7 @@ type MetadataProps = { }; // 生成页面元数据(确保服务端/客户端翻译一致) -export async function generateMetadata({ - params, -}: MetadataProps): Promise { +export async function generateMetadata({ params }: MetadataProps): Promise { const { locale } = params; const t = await getTranslations({ locale, namespace: "Workshop" }); @@ -44,35 +43,27 @@ function EmptyState() { return
      暂无车间数据
      ; } -// 单个车间卡片组件(Client Component 标记,避免 Hydration 冲突) -// 'use client'; // 仅当需要添加交互时启用,当前纯展示可不用 - function WorkshopCard({ workshop }: { workshop: WorkShop }) { - // 为 Image 组件添加默认值,避免属性缺失导致不匹配 + // 为 img 标签添加默认值,避免属性缺失导致不匹配 const coverSrc = workshop.cover || "/default-workshop-cover.png"; // 兜底封面图 const coverAlt = workshop.title || "车间封面"; return ( - -
      - {/* 封面图:优化属性,确保服务端/客户端渲染一致 */} + +
      + {/* 封面图:使用原生 img 标签,确保图片尺寸一致 */}
      {coverAlt}
      {/* 车间信息 */} -
      -

      {workshop.title || "未命名车间"}

      +
      +

      {workshop.title || "未命名车间"}

      {workshop.desc || "暂无描述"}

      @@ -81,11 +72,7 @@ function WorkshopCard({ workshop }: { workshop: WorkShop }) { } // 页面主组件(Server Component) -export default async function Page({ - params, -}: { - params: Params; -}) { +export default async function Page({ params }: { params: Params }) { const { locale } = await params; // 获取翻译(确保服务端/客户端一致) const t = await getTranslations({ locale, namespace: "Workshop" }); @@ -97,22 +84,21 @@ export default async function Page({ const pageTitle = t("pageTitle", { defaultValue: "车间展示" }); return ( -
      - {/* 页面标题(纯静态渲染,无动态属性) */} -

      {pageTitle}

      +
      + {/* 页面标题 */} +

      {pageTitle}

      - {/* 移除不必要的 Suspense:Server Component 顶层 await 无需 Suspense */} - {workShops.length > 0 ? ( -
      - {workShops.map((workshop) => { - // 用稳定的 key(优先用唯一标识,如 id;无 id 则用 title+locale 避免 index 导致的问题) + {/* 展示车间卡片 */} +
      + {workShops.length > 0 ? ( + workShops.map((workshop) => { const stableKey = `${workshop.title}-${workshop.locale}`; return ; - })} -
      - ) : ( - - )} + }) + ) : ( + + )} +
      ); -} \ No newline at end of file +} diff --git a/content/workshop/en/assembly.mdx b/content/workshop/en/assembly.mdx index 9de4bb4..039b2ce 100644 --- a/content/workshop/en/assembly.mdx +++ b/content/workshop/en/assembly.mdx @@ -1,9 +1,9 @@ --- title: Assembly Workshop desc: An assembly workshop is a specialized facility responsible for the quality inspection, assembly, pre-installation and commissioning of equipment components. It plays an important role in the production process. -cover: machine.jpg +cover: /images/workshop/assembly1.png slug: assembly images: - - machine.jpg - - machine2.jpg + - /images/workshop/assembly1.png + - /images/workshop/assembly2.png --- \ No newline at end of file diff --git a/content/workshop/en/heat-treatment.mdx b/content/workshop/en/heat-treatment.mdx index fabdaca..41adc69 100644 --- a/content/workshop/en/heat-treatment.mdx +++ b/content/workshop/en/heat-treatment.mdx @@ -1,9 +1,9 @@ --- title: Heat Treatment Workshop desc: A heat treatment workshop is a specialized facility dedicated to the heat treatment of metal materials. Its main processes include quenching, tempering, normalizing, isothermal quenching, annealing and hardening. -cover: machine.jpg +cover: /images/workshop/treatment1.png slug: heat-treatment images: - - machine.jpg - - machine2.jpg + - /images/workshop/treatment1.png + - /images/workshop/treatment2.png --- \ No newline at end of file diff --git a/content/workshop/en/machine.mdx b/content/workshop/en/machine.mdx index aba48aa..226883e 100644 --- a/content/workshop/en/machine.mdx +++ b/content/workshop/en/machine.mdx @@ -1,9 +1,9 @@ --- title: Machining Workshop desc: The machining workshop of this machinery factory covers an area of 4,000 square meters and is equipped with dozens of processing equipment, including milling machines, lathes, grinding machines, drilling machines and so on. -cover: machine.jpg +cover: /images/workshop/machine1.png slug: machine images: - - machine.jpg - - machine2.jpg + - /images/workshop/machine1.png + - /images/workshop/machine2.png --- \ No newline at end of file diff --git a/content/workshop/zh/assembly.mdx b/content/workshop/zh/assembly.mdx index 00be6f7..36d8dda 100644 --- a/content/workshop/zh/assembly.mdx +++ b/content/workshop/zh/assembly.mdx @@ -1,9 +1,9 @@ --- title: 装配车间 desc: 装配车间是一种专门的设施,负责设备组件的质量检验、组装、预安装和调试。在生产过程中起着重要作用。 -cover: machine.jpg +cover: /images/workshop/assembly1.png slug: assembly images: - - machine.jpg - - machine2.jpg + - /images/workshop/assembly1.png + - /images/workshop/assembly2.png --- \ No newline at end of file diff --git a/content/workshop/zh/heat-treatment.mdx b/content/workshop/zh/heat-treatment.mdx index 33b0c16..cf5bc45 100644 --- a/content/workshop/zh/heat-treatment.mdx +++ b/content/workshop/zh/heat-treatment.mdx @@ -1,9 +1,9 @@ --- title: 热处理车间 desc: 热处理车间是专门从事金属材料热处理的工厂。主要工艺包括淬火、回火、正火、等温淬火、退火和硬化。 -cover: machine.jpg +cover: /images/workshop/treatment1.png slug: heat-treatment images: - - machine.jpg - - machine2.jpg + - /images/workshop/treatment1.png + - /images/workshop/treatment2.png --- \ No newline at end of file diff --git a/content/workshop/zh/machine.mdx b/content/workshop/zh/machine.mdx index c0da4d4..fb5d46d 100644 --- a/content/workshop/zh/machine.mdx +++ b/content/workshop/zh/machine.mdx @@ -1,9 +1,9 @@ --- title: 机械加工车间 desc: 该机械加工厂的机械车间占地面积4000平方米,配备有数十台加工设备,包括铣床、车床、磨床、钻床等。 -cover: machine.jpg +cover: /images/workshop/machine1.png slug: machine images: - - machine.jpg - - machine2.jpg + - /images/workshop/machine1.png + - /images/workshop/machine2.png --- \ No newline at end of file diff --git a/public/images/workshop/assembly1.png b/public/images/workshop/assembly1.png new file mode 100644 index 0000000..354cb0c Binary files /dev/null and b/public/images/workshop/assembly1.png differ diff --git a/public/images/workshop/assembly2.png b/public/images/workshop/assembly2.png new file mode 100644 index 0000000..ee2112e Binary files /dev/null and b/public/images/workshop/assembly2.png differ diff --git a/public/images/workshop/machine1.png b/public/images/workshop/machine1.png new file mode 100644 index 0000000..18aa573 Binary files /dev/null and b/public/images/workshop/machine1.png differ diff --git a/public/images/workshop/machine2.png b/public/images/workshop/machine2.png new file mode 100644 index 0000000..b44a0d2 Binary files /dev/null and b/public/images/workshop/machine2.png differ diff --git a/public/images/workshop/machine3.png b/public/images/workshop/machine3.png new file mode 100644 index 0000000..3fa688e Binary files /dev/null and b/public/images/workshop/machine3.png differ diff --git a/public/images/workshop/machine4.png b/public/images/workshop/machine4.png new file mode 100644 index 0000000..7304ec4 Binary files /dev/null and b/public/images/workshop/machine4.png differ diff --git a/public/images/workshop/machine5.png b/public/images/workshop/machine5.png new file mode 100644 index 0000000..c603047 Binary files /dev/null and b/public/images/workshop/machine5.png differ diff --git a/public/images/workshop/treatment1.png b/public/images/workshop/treatment1.png new file mode 100644 index 0000000..7ddc84d Binary files /dev/null and b/public/images/workshop/treatment1.png differ diff --git a/public/images/workshop/treatment2.png b/public/images/workshop/treatment2.png new file mode 100644 index 0000000..d2e2363 Binary files /dev/null and b/public/images/workshop/treatment2.png differ