diff --git a/backend/db.sqlite3 b/backend/db.sqlite3
index 1d3123d..6e2c1da 100644
Binary files a/backend/db.sqlite3 and b/backend/db.sqlite3 differ
diff --git a/frontend/src/components/ModelViewer.jsx b/frontend/src/components/ModelViewer.jsx
index db7a4b4..969ae84 100644
--- a/frontend/src/components/ModelViewer.jsx
+++ b/frontend/src/components/ModelViewer.jsx
@@ -7,6 +7,42 @@ import { Spin } from 'antd';
import JSZip from 'jszip';
import * as THREE from 'three';
+class ErrorBoundary extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = { hasError: false };
+ }
+
+ static getDerivedStateFromError(error) {
+ return { hasError: true };
+ }
+
+ componentDidCatch(error, errorInfo) {
+ console.error("3D Model Viewer Error:", error, errorInfo);
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return (
+
+ 3D 模型加载失败
+
+ );
+ }
+
+ return this.props.children;
+ }
+}
+
const Model = ({ objPath, mtlPath, scale = 1 }) => {
// If mtlPath is provided, load materials first
const materials = mtlPath ? useLoader(MTLLoader, mtlPath) : null;
@@ -158,21 +194,23 @@ const ModelViewer = ({ objPath, mtlPath, scale = 1, autoRotate = true }) => {
return (
-
-
+
+
+
+
);
};
diff --git a/frontend/src/pages/ProductDetail.jsx b/frontend/src/pages/ProductDetail.jsx
index 1f106f5..08de8b4 100644
--- a/frontend/src/pages/ProductDetail.jsx
+++ b/frontend/src/pages/ProductDetail.jsx
@@ -82,20 +82,6 @@ const ProductDetail = () => {
return { obj: p.model_3d_url };
}
- // 如果有静态图,且没有特定的 3D 模型 URL,则优先显示静态图,不进入下方的通用 3D 模板匹配
- if (p.static_image_url) {
- return null;
- }
-
- const text = (p.name + p.description).toLowerCase();
-
- if (text.includes('mini')) {
- return { obj: '/3dmimi/3D_PCB_V3-mini.obj', mtl: '/3dmimi/3D_PCB_V3-mini.mtl' };
- } else if (text.includes('v2')) {
- return { obj: '/3dV2/xiaoliangV2.obj', mtl: '/3dV2/xiaoliangV2.mtl' };
- } else if (text.includes('vision') || text.includes('视觉') || text.includes('camera')) {
- return { obj: '/3dmodo/xiaoliang1.obj', mtl: '/3dmodo/xiaoliang1.mtl' };
- }
return null;
};
@@ -207,8 +193,15 @@ const ProductDetail = () => {
)}
{product.display_detail_image ? (
-
-

+
+
) : (
diff --git a/frontend/src/pages/ServiceDetail.jsx b/frontend/src/pages/ServiceDetail.jsx
index cd523bb..fcbc1da 100644
--- a/frontend/src/pages/ServiceDetail.jsx
+++ b/frontend/src/pages/ServiceDetail.jsx
@@ -132,16 +132,18 @@ const ServiceDetail = () => {
{service.display_detail_image ? (
) : (