@@ -94,12 +87,12 @@ export default async function WorkshopDetailPage({ params }: { params: Params })
return (

@@ -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 标签,确保图片尺寸一致 */}
{/* 车间信息 */}
-
-
{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