瀏覽代碼

feat(mobile): 手机端 AI 设计盒子支持 3D 预览(1.8.26)

- 新增共享刀版几何模块 boxdieline.js,box.js 编辑器与手机端同源,避免几何逻辑两份漂移
- m.html 引入 boxdieline + box3d,新增 #mBox3d 舞台(与袋子舞台互斥切换,切换即释放另一个引擎)
- m.js 新增盒子分支:box3d 合拢渲染、初始自转、拖动停转,WebGL/几何失败回退 2D 六面缩略图
- 盒子 chips 显示中文盒型名;盒子暂无去下单(保持原有去微调入口)
wenhongquan 1 月之前
父節點
當前提交
9b8856e1e3
共有 12 個文件被更改,包括 592 次插入 和 326 次删除
  1. 13 13
      admin.html
  2. 9 0
      assets/css/m.css
  3. 4 207
      assets/js/box.js
  4. 346 0
      assets/js/boxdieline.js
  5. 118 8
      assets/js/m.js
  6. 22 21
      box.html
  7. 1 1
      deploy/k8s/pouchlab.yaml
  8. 18 18
      index.html
  9. 19 16
      m.html
  10. 18 18
      orders.html
  11. 2 2
      server/main.py
  12. 22 22
      studio.html

+ 13 - 13
admin.html

@@ -7,22 +7,22 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>后台管理 — 袋研社 POUCHLAB</title>
   <meta name="robots" content="noindex,nofollow">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/orders.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/admin.css?v=1.8.25">
-  <script src="assets/js/i18n-en.js?v=1.8.25"></script>
-  <script src="assets/js/i18n.js?v=1.8.25"></script>
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/orders.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/admin.css?v=1.8.26">
+  <script src="assets/js/i18n-en.js?v=1.8.26"></script>
+  <script src="assets/js/i18n.js?v=1.8.26"></script>
 </head>
 <body class="pl-admin-body">
   <div id="root"></div>
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.25"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.25"></script>
-  <script src="assets/js/api.js?v=1.8.25"></script>
-  <script src="assets/js/admin.js?v=1.8.25"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.26"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.26"></script>
+  <script src="assets/js/api.js?v=1.8.26"></script>
+  <script src="assets/js/admin.js?v=1.8.26"></script>
 </body>
 </html>

+ 9 - 0
assets/css/m.css

@@ -76,6 +76,15 @@
 .m-agentpreview { margin: 10px 12px 0; }
 .m-agentpreview[hidden] { display: none; }
 .m-faces { display: flex; gap: 8px; }
+.m-faces.box {
+  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
+}
+.m-faces.box .m-face { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; padding: 6px; }
+.m-boxface {
+  width: 100%; height: 100%; border-radius: 8px;
+  display: flex; align-items: center; justify-content: center; overflow: hidden;
+}
+.m-boxface b { max-width: 90%; text-align: center; line-height: 1.2; word-break: break-word; }
 .m-face { flex: 1; background: #fff; border: 1px solid #e8e2d5; border-radius: 12px; padding: 8px; position: relative; }
 .m-face svg { width: 100%; height: auto; display: block; }
 .m-face i { position: absolute; right: 8px; top: 8px; font-style: normal; font-size: 9px; color: #a79d8d; }

+ 4 - 207
assets/js/box.js

@@ -299,215 +299,12 @@
     return pts;
   }
 
+  /* 刀版几何构建:共享 assets/js/boxdieline.js(与手机端 3D 预览同源,避免两份几何漂移) */
   function buildDieline(type, w, d, hh, params) {
-    const t = material().thickness;
-    const W = w + t * 2, D2 = d + t * 2, H = hh + t * 2;
-    const P = params || state.smart;
-    const panels = [];
-
-    if (type === 'card') {
-      const isRound = state.boxNo === '260040' || state.boxNo === '270020' || state.boxNo === '261002';
-      const hole = P.holeR || 0;
-      const p1 = isRound
-        ? poly(circlePoly(W / 2, H / 2, Math.min(W, H) / 2), 'front', 'body')
-        : poly(roundedRectPoly(0, 0, W, H, P.cornerR || 0), 'front', 'body');
-      if (hole && !isRound) {
-        p1.holes = [{ x: W / 2, y: hole + 4, r: hole }];
-        p1.holeH = hole * 2 + 8;
-      }
-      panels.push(p1);
-      const back = isRound
-        ? poly(circlePoly(W / 2, H / 2, Math.min(W, H) / 2), 'back', 'body')
-        : poly(roundedRectPoly(W + 10, 0, W, H, P.cornerR || 0), 'back', 'body');
-      panels.push(back);
-      return finishDieline(panels);
-    }
-
-    if (type === 'sleeve') {
-      const glue = P.glue;
-      let x = 0;
-      panels.push(rect(x, 0, glue, H, null, 'glue')); x += glue;
-      panels.push(rect(x, 0, W, H, 'front', 'body')); x += W;
-      panels.push(rect(x, 0, D2, H, null, 'flap')); x += D2;
-      panels.push(rect(x, 0, W, H, 'back', 'body')); x += W;
-      panels.push(rect(x, 0, D2, H, null, 'flap'));
-      return finishDieline(panels);
-    }
-
-    if (type === 'bag') {
-      const tf = P.topFold || 20;
-      const holeR = P.holeR || 4;
-      const gus = D2 / 2;
-      let x = 0;
-      panels.push(rect(x, 0, W, H, 'front', 'body'));
-      panels.push(rect(x, -tf, W, tf, null, 'flap'));
-      const fP = panels[0], fT = panels[1];
-      fP.holes = []; fT.holes = [{ x: x + W * 0.22, y: -tf + tf / 2, r: holeR }, { x: x + W * 0.78, y: -tf + tf / 2, r: holeR }];
-      x += W;
-      panels.push(rect(x, 0, gus, H, null, 'body')); x += gus;
-      panels.push(rect(x, 0, gus, H, null, 'body')); x += gus;
-      panels.push(rect(x, 0, W, H, 'back', 'body'));
-      panels.push(rect(x, -tf, W, tf, null, 'flap'));
-      panels[panels.length - 1].holes = [{ x: x + W * 0.22, y: -tf + tf / 2, r: holeR }, { x: x + W * 0.78, y: -tf + tf / 2, r: holeR }];
-      x += W;
-      panels.push(rect(x, 0, gus, H, null, 'body')); x += gus;
-      panels.push(rect(x, 0, gus, H, null, 'body'));
-      panels.push(rect(0, H, W, D2, 'bottom', 'body'));
-      return finishDieline(panels);
-    }
+    const P = Object.assign({ boxNo: state.boxNo }, params || state.smart);
+    return PL.boxDieline.build(type, w, d, hh, P, material());
+  }
 
-    // 管式盒族
-    const glue = P.glue;
-    const ch = Math.max(3, Math.min(8, D2 * 0.06)) * (1 - Math.min(1, (P.cornerR || 0) / 8) * 0.5);
-    const half = D2 / 2;
-    const xF = glue, xR = xF + W, xB = xR + D2, xL = xB + W;
-    panels.push(rect(0, 0, glue, H, null, 'glue'));
-    panels.push(rect(xF, 0, W, H, 'front', 'body'));
-    panels.push(rect(xR, 0, D2, H, 'right', 'body'));
-    panels.push(rect(xB, 0, W, H, 'back', 'body'));
-    panels.push(rect(xL, 0, D2, H, 'left', 'body'));
-    const big = function (x, y, face, dir) {
-      const yy = dir * (half + 2);
-      return poly([[x, y], [x + ch, y + yy], [x + W - ch, y + yy], [x + W, y]], face, 'flap');
-    };
-    const dust = function (x, y, dir) {
-      const yy = dir * (half - 2);
-      return poly([[x, y], [x + ch, y + yy], [x + D2 - ch, y + yy], [x + D2, y]], null, 'dust');
-    };
-    const tuckH = P.tuckH;
-
-    if (type === 'rsc') {
-      [[xF, W, 'top', true], [xR, D2, null, false], [xB, W, null, false], [xL, D2, null, false]].forEach(function (f) {
-        const top = rect(f[0], -half, f[1], half, f[2], 'flap');
-        if (!f[2]) top.paint = 'top';
-        panels.push(top);
-        const bottom = rect(f[0], H, f[1], half, f[3] ? 'bottom' : null, 'flap');
-        if (!f[3]) bottom.paint = 'bottom';
-        panels.push(bottom);
-      });
-    } else if (type === 'carton') {
-      panels.push(big(xF, 0, 'top', -1));
-      const topBack = big(xB, 0, null, -1);
-      topBack.paint = 'top';
-      panels.push(topBack);
-      panels.push(dust(xR, 0, -1));
-      panels.push(dust(xL, 0, -1));
-      panels.push(big(xF, H, 'bottom', 1));
-      const bottomBack = big(xB, H, null, 1);
-      bottomBack.paint = 'bottom';
-      panels.push(bottomBack);
-      panels.push(dust(xR, H, 1));
-      panels.push(dust(xL, H, 1));
-    } else if (type === 'mailer') {
-      const dustW = P.dustW;
-      panels.push(poly([[xB, 0], [xB + ch, -(D2 + 2)], [xB + W - ch, -(D2 + 2)], [xB + W, 0]], 'top', 'flap'));
-      const mt = rect(xB + dustW, -(D2 + 2) - tuckH, W - dustW * 2, tuckH, null, 'tuck');
-      if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
-        mt.holes = [{ x: xB + dustW + (W - dustW * 2) / 2, y: -(D2 + 2) - tuckH / 2, r: P.holeR }];
-      }
-      panels.push(mt);
-      panels.push(rect(xB - dustW, -(D2 + 2), dustW, D2, null, 'dust'));
-      panels.push(rect(xB + W, -(D2 + 2), dustW, D2, null, 'dust'));
-      panels.push(poly([[xF, H], [xF + ch, H + D2 + 2], [xF + W - ch, H + D2 + 2], [xF + W, H]], 'bottom', 'flap'));
-      const mb = rect(xF + dustW, H + D2 + 2, W - dustW * 2, tuckH, null, 'tuck');
-      if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
-        mb.holes = [{ x: xF + dustW + (W - dustW * 2) / 2, y: H + D2 + 2 + tuckH / 2, r: P.holeR }];
-      }
-      panels.push(mb);
-      panels.push(rect(xF - dustW, H + D2 + 2, dustW, D2, null, 'dust'));
-      panels.push(rect(xF + W, H + D2 + 2, dustW, D2, null, 'dust'));
-    } else {
-      // tuck / straight / autobottom:上盖挂后板
-      const lidD = D2 + 2;
-      panels.push(poly([[xB, 0], [xB + ch, -lidD], [xB + W - ch, -lidD], [xB + W, 0]], 'top', 'flap'));
-      const tuckTop = rect(xB + 18, -lidD - tuckH, W - 36, tuckH, null, 'tuck');
-      if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
-        tuckTop.holes = [{ x: xB + W / 2, y: -lidD - tuckH / 2, r: P.holeR }];
-      }
-      panels.push(tuckTop);
-      panels.push(dust(xR, 0, -1));
-      panels.push(dust(xL, 0, -1));
-      if (type === 'straight') {
-        panels.push(poly([[xB, H], [xB + ch, H + lidD], [xB + W - ch, H + lidD], [xB + W, H]], 'bottom', 'flap'));
-        const tuckBot = rect(xB + 18, H + lidD, W - 36, tuckH, null, 'tuck');
-        if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
-          tuckBot.holes = [{ x: xB + W / 2, y: H + lidD + tuckH / 2, r: P.holeR }];
-        }
-        panels.push(tuckBot);
-        panels.push(dust(xR, H, 1));
-        panels.push(dust(xL, H, 1));
-      } else if (type === 'autobottom') {
-        const d1 = half + 5, d2 = half + 2, c2 = ch * 0.6;
-        panels.push(poly([
-          [xF, H], [xF + c2, H + d1], [xF + W * 0.32, H + d1], [xF + W * 0.32, H + d1 - 4],
-          [xF + W * 0.68, H + d1 - 4], [xF + W * 0.68, H + d1], [xF + W - c2, H + d1], [xF + W, H]
-        ], 'bottom', 'flap'));
-        const bottomBack = poly([[xB, H], [xB + c2, H + d2], [xB + W - c2, H + d2], [xB + W, H]], null, 'flap');
-        bottomBack.paint = 'bottom';
-        panels.push(bottomBack);
-        const bottomR = poly([[xR, H], [xR + D2, H], [xR + D2 / 2, H + half + 3]], null, 'dust');
-        bottomR.paint = 'bottom';
-        panels.push(bottomR);
-        const bottomL = poly([[xL, H], [xL + D2, H], [xL + D2 / 2, H + half + 3]], null, 'dust');
-        bottomL.paint = 'bottom';
-        panels.push(bottomL);
-      } else {
-        // tuck 反向插锁:下盖挂前板
-        panels.push(poly([[xF, H], [xF + ch, H + lidD], [xF + W - ch, H + lidD], [xF + W, H]], 'bottom', 'flap'));
-        panels.push(rect(xF + 18, H + lidD, W - 36, tuckH, null, 'tuck'));
-        panels.push(dust(xR, H, 1));
-        panels.push(dust(xL, H, 1));
-      }
-    }
-    return finishDieline(panels);
-  }
-
-  if (state.structure === 'mailbox') {
-    // mailbox 在 buildDieline 主流程外定义,包装一次
-  }
-  const _buildDielineBase = buildDieline;
-  buildDieline = function (type, w, d, hh, params) {
-    if (type === 'mailbox') {
-      const t = material().thickness;
-      const W = w + t * 2, D2 = d + t * 2, H = hh + t * 2;
-      const P = params || state.smart;
-      const lipW = P.lipW;
-      const xRw = 0, xB = D2, xSpine = xB + W, xF = xSpine + D2;
-      const panels = [
-        rect(xRw, 0, D2, H, 'right', 'body'),
-        rect(xB, 0, W, H, 'back', 'body'),
-        rect(xSpine, 0, D2, H, 'left', 'body'),
-        rect(xF, 0, W, H, 'front', 'body'),
-        rect(xF + W, 0, lipW, H, null, 'lip'),
-        rect(xB, -D2, W, D2, 'top', 'body'),
-        rect(xB, H, W, D2, 'bottom', 'body')
-      ];
-      return finishDieline(panels);
-    }
-    if (type === 'drawer') {
-      const t = material().thickness;
-      const W = w + t * 2, D2 = d + t * 2, H = hh + t * 2;
-      const glue = (params || state.smart).glue;
-      const xF = glue, xR = xF + W, xB = xR + D2, xL = xB + W;
-      const panels = [
-        rect(0, 0, glue, H, null, 'glue'),
-        rect(xF, 0, W, H, 'front', 'body'),
-        rect(xR, 0, D2, H, 'right', 'body'),
-        rect(xB, 0, W, H, 'back', 'body'),
-        rect(xL, 0, D2, H, 'left', 'body')
-      ];
-      const W2 = Math.max(10, W - 2), D3 = Math.max(10, D2 - 2), TH = Math.max(10, H - 8);
-      const ty = H + 26, tx0 = 24, txF = tx0 + glue, txR = txF + W2, txB = txR + D3, txL = txB + W2;
-      panels.push(rect(tx0, ty, glue, TH, null, 'glue'));
-      panels.push(rect(txF, ty, W2, TH, 'front', 'tray'));
-      panels.push(rect(txR, ty, D3, TH, null, 'tray'));
-      panels.push(rect(txB, ty, W2, TH, null, 'tray'));
-      panels.push(rect(txL, ty, D3, TH, null, 'tray'));
-      panels.push(rect(txF, ty + TH, W2, D3, null, 'bottom'));
-      return finishDieline(panels);
-    }
-    return _buildDielineBase(type, w, d, hh, params);
-  };
 
   function dieline() { return buildDieline(state.structure, state.w, state.d, state.h); }
   function outerSize() {

+ 346 - 0
assets/js/boxdieline.js

@@ -0,0 +1,346 @@
+/**
+ * boxdieline.js — 纸盒刀版几何构建(共享)
+ * 由 box.js 抽出:不依赖设计器 state,纯函数输入盒型/尺寸/材质/结构参数,
+ * 输出 { panels, folds, size, minX, minY, bounds },供 box3d.js 折叠 3D 使用。
+ * box.js 编辑器与 m.js 手机端 3D 预览共用同一份几何逻辑。
+ */
+(function () {
+  'use strict';
+
+  /* 材质(与 box.js MATERIALS 保持一致,仅几何所需字段) */
+  const MATERIALS = [
+    { id: 'card', name: '350g白卡(0.5mm)', thickness: 0.5, paper: '#fbf7ee', paperEdge: '#e6ddcc', edgeW: 1, matte: false, grain: '', grainOpacity: 0, flute: '#e2d8c5' },
+    { id: 'grey', name: '灰板2mm', thickness: 2.0, paper: '#c9c1b2', paperEdge: '#8f877a', edgeW: 4, matte: true, grainOpacity: 0.5, grain: '', flute: '#b3aa9a' },
+    { id: 'kraft', name: '牛皮纸(0.4mm)', thickness: 0.4, paper: '#d7b17c', paperEdge: '#a97c4e', edgeW: 2, matte: true, grainOpacity: 0.75, grain: '', flute: '#b98a56' },
+    { id: 'corrugated', name: 'E楞瓦楞(1.5mm)', thickness: 1.5, paper: '#d3aa74', paperEdge: '#a97c4e', edgeW: 3, matte: true, grainOpacity: 0.85, grain: '', flute: '#a97c4e', edgePattern: true }
+  ];
+
+  /* 结构参数默认值(与 box.js state.smart 一致) */
+  const DEFAULT_PARAMS = { bleed: 3, glue: 15, tuckH: 12, cornerR: 1.5, dustW: 14, lipW: 16, topFold: 22, holeR: 4 };
+
+  function materialById(id) {
+    return MATERIALS.find(function (m) { return m.id === id; }) || MATERIALS[0];
+  }
+
+  function rect(x, y, w, hh, face, kind) { return { x: x, y: y, w: w, h: hh, face: face, kind: kind || 'body' }; }
+  function poly(points, face, kind) {
+    return { poly: points, face: face, kind: kind || 'flap', x: Math.min.apply(null, points.map(function (p) { return p[0]; })), y: Math.min.apply(null, points.map(function (p) { return p[1]; })), w: 0, h: 0 };
+  }
+  function panelBounds(p) {
+    if (!p.poly) return { x: p.x, y: p.y, w: p.w, h: p.h };
+    const xs = p.poly.map(function (pt) { return pt[0]; });
+    const ys = p.poly.map(function (pt) { return pt[1]; });
+    const x = Math.min.apply(null, xs), y = Math.min.apply(null, ys);
+    return { x: x, y: y, w: Math.max.apply(null, xs) - x, h: Math.max.apply(null, ys) - y };
+  }
+
+  const ACCESSORY = { glue: 1, flap: 1, dust: 1, tuck: 1, lip: 1 };
+  function isBodyKind(k) { return !ACCESSORY[k]; }
+
+  function panelEdges(p) {
+    const pts = p.poly || [[p.x, p.y], [p.x + p.w, p.y], [p.x + p.w, p.y + p.h], [p.x, p.y + p.h]];
+    const out = [];
+    for (let i = 0; i < pts.length; i += 1) {
+      const a = pts[i], b = pts[(i + 1) % pts.length];
+      if (Math.abs(a[0] - b[0]) < 0.05) out.push({ axis: 'v', c: a[0], lo: Math.min(a[1], b[1]), hi: Math.max(a[1], b[1]) });
+      else if (Math.abs(a[1] - b[1]) < 0.05) out.push({ axis: 'h', c: a[1], lo: Math.min(a[0], b[0]), hi: Math.max(a[0], b[0]) });
+    }
+    return out;
+  }
+  function sharedEdge(a, b) {
+    let best = null;
+    panelEdges(a).forEach(function (ea) {
+      panelEdges(b).forEach(function (eb) {
+        if (ea.axis !== eb.axis || Math.abs(ea.c - eb.c) > 0.6) return;
+        const lo = Math.max(ea.lo, eb.lo), hi = Math.min(ea.hi, eb.hi), len = hi - lo;
+        if (len <= 2) return;
+        if (!best || len > best.len) best = { axis: ea.axis, c: ea.c, lo: lo, hi: hi, len: len };
+      });
+    });
+    return best;
+  }
+  function canHinge(a, b) {
+    const ka = a.kind || 'body', kb = b.kind || 'body';
+    if (isBodyKind(ka) !== isBodyKind(kb)) return true;
+    if (isBodyKind(ka) && isBodyKind(kb)) return true;
+    return (ka === 'tuck' && kb === 'flap') || (ka === 'flap' && kb === 'tuck');
+  }
+  function autoFolds(panels) {
+    const out = [];
+    for (let i = 0; i < panels.length; i += 1) for (let j = i + 1; j < panels.length; j += 1) {
+      if (!canHinge(panels[i], panels[j])) continue;
+      const e = sharedEdge(panels[i], panels[j]);
+      if (!e) continue;
+      if (e.axis === 'v') out.push({ x1: e.c, y1: e.lo, x2: e.c, y2: e.hi });
+      else out.push({ x1: e.lo, y1: e.c, x2: e.hi, y2: e.c });
+    }
+    return out;
+  }
+  function finishDieline(panels) {
+    let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
+    panels.forEach(function (p) {
+      const b = panelBounds(p);
+      minX = Math.min(minX, b.x); minY = Math.min(minY, b.y);
+      maxX = Math.max(maxX, b.x + b.w); maxY = Math.max(maxY, b.y + b.h);
+    });
+    return { panels: panels, folds: autoFolds(panels), size: { w: maxX - minX, h: maxY - minY }, minX: minX, minY: minY, bounds: { w: maxX - minX, h: maxY - minY, minX: minX, minY: minY } };
+  }
+
+  function roundedRectPoly(x, y, w, hh, r) {
+    r = Math.min(r, w / 2, hh / 2);
+    if (r <= 0.05) return [[x, y], [x + w, y], [x + w, y + hh], [x, y + hh]];
+    const pts = [];
+    const arc = function (cx, cy, a0, a1) {
+      for (let i = 0; i <= 6; i += 1) {
+        const a = a0 + (a1 - a0) * i / 6;
+        pts.push([cx + r * Math.cos(a), cy + r * Math.sin(a)]);
+      }
+    };
+    arc(x + w - r, y + r, -Math.PI / 2, 0);
+    arc(x + w - r, y + hh - r, 0, Math.PI / 2);
+    arc(x + r, y + hh - r, Math.PI / 2, Math.PI);
+    arc(x + r, y + r, Math.PI, Math.PI * 1.5);
+    return pts;
+  }
+  function circlePoly(cx, cy, r) {
+    const pts = [];
+    for (let i = 0; i < 36; i += 1) {
+      const a = i / 36 * Math.PI * 2;
+      pts.push([cx + r * Math.cos(a), cy + r * Math.sin(a)]);
+    }
+    return pts;
+  }
+
+  /* 卡袋/封套等异形结构的盒号白名单(圆角卡盒) */
+  const ROUND_CARD_BOXNOS = { '260040': 1, '270020': 1, '261002': 1 };
+
+  function buildBase(type, w, d, hh, params, mat) {
+    const t = mat.thickness;
+    const W = w + t * 2, D2 = d + t * 2, H = hh + t * 2;
+    const P = params || DEFAULT_PARAMS;
+    const panels = [];
+
+    if (type === 'card') {
+      const isRound = !!ROUND_CARD_BOXNOS[P.boxNo || ''];
+      const hole = P.holeR || 0;
+      const p1 = isRound
+        ? poly(circlePoly(W / 2, H / 2, Math.min(W, H) / 2), 'front', 'body')
+        : poly(roundedRectPoly(0, 0, W, H, P.cornerR || 0), 'front', 'body');
+      if (hole && !isRound) {
+        p1.holes = [{ x: W / 2, y: hole + 4, r: hole }];
+        p1.holeH = hole * 2 + 8;
+      }
+      panels.push(p1);
+      const back = isRound
+        ? poly(circlePoly(W / 2, H / 2, Math.min(W, H) / 2), 'back', 'body')
+        : poly(roundedRectPoly(W + 10, 0, W, H, P.cornerR || 0), 'back', 'body');
+      panels.push(back);
+      return finishDieline(panels);
+    }
+
+    if (type === 'sleeve') {
+      const glue = P.glue;
+      let x = 0;
+      panels.push(rect(x, 0, glue, H, null, 'glue')); x += glue;
+      panels.push(rect(x, 0, W, H, 'front', 'body')); x += W;
+      panels.push(rect(x, 0, D2, H, null, 'flap')); x += D2;
+      panels.push(rect(x, 0, W, H, 'back', 'body')); x += W;
+      panels.push(rect(x, 0, D2, H, null, 'flap'));
+      return finishDieline(panels);
+    }
+
+    if (type === 'bag') {
+      const tf = P.topFold || 20;
+      const holeR = P.holeR || 4;
+      const gus = D2 / 2;
+      let x = 0;
+      panels.push(rect(x, 0, W, H, 'front', 'body'));
+      panels.push(rect(x, -tf, W, tf, null, 'flap'));
+      const fP = panels[0], fT = panels[1];
+      fP.holes = []; fT.holes = [{ x: x + W * 0.22, y: -tf + tf / 2, r: holeR }, { x: x + W * 0.78, y: -tf + tf / 2, r: holeR }];
+      x += W;
+      panels.push(rect(x, 0, gus, H, null, 'body')); x += gus;
+      panels.push(rect(x, 0, gus, H, null, 'body')); x += gus;
+      panels.push(rect(x, 0, W, H, 'back', 'body'));
+      panels.push(rect(x, -tf, W, tf, null, 'flap'));
+      panels[panels.length - 1].holes = [{ x: x + W * 0.22, y: -tf + tf / 2, r: holeR }, { x: x + W * 0.78, y: -tf + tf / 2, r: holeR }];
+      x += W;
+      panels.push(rect(x, 0, gus, H, null, 'body')); x += gus;
+      panels.push(rect(x, 0, gus, H, null, 'body'));
+      panels.push(rect(0, H, W, D2, 'bottom', 'body'));
+      return finishDieline(panels);
+    }
+
+    // 管式盒族
+    const glue = P.glue;
+    const ch = Math.max(3, Math.min(8, D2 * 0.06)) * (1 - Math.min(1, (P.cornerR || 0) / 8) * 0.5);
+    const half = D2 / 2;
+    const xF = glue, xR = xF + W, xB = xR + D2, xL = xB + W;
+    panels.push(rect(0, 0, glue, H, null, 'glue'));
+    panels.push(rect(xF, 0, W, H, 'front', 'body'));
+    panels.push(rect(xR, 0, D2, H, 'right', 'body'));
+    panels.push(rect(xB, 0, W, H, 'back', 'body'));
+    panels.push(rect(xL, 0, D2, H, 'left', 'body'));
+    const big = function (x, y, face, dir) {
+      const yy = dir * (half + 2);
+      return poly([[x, y], [x + ch, y + yy], [x + W - ch, y + yy], [x + W, y]], face, 'flap');
+    };
+    const dust = function (x, y, dir) {
+      const yy = dir * (half - 2);
+      return poly([[x, y], [x + ch, y + yy], [x + D2 - ch, y + yy], [x + D2, y]], null, 'dust');
+    };
+    const tuckH = P.tuckH;
+
+    if (type === 'rsc') {
+      [[xF, W, 'top', true], [xR, D2, null, false], [xB, W, null, false], [xL, D2, null, false]].forEach(function (f) {
+        const top = rect(f[0], -half, f[1], half, f[2], 'flap');
+        if (!f[2]) top.paint = 'top';
+        panels.push(top);
+        const bottom = rect(f[0], H, f[1], half, f[3] ? 'bottom' : null, 'flap');
+        if (!f[3]) bottom.paint = 'bottom';
+        panels.push(bottom);
+      });
+    } else if (type === 'carton') {
+      panels.push(big(xF, 0, 'top', -1));
+      const topBack = big(xB, 0, null, -1);
+      topBack.paint = 'top';
+      panels.push(topBack);
+      panels.push(dust(xR, 0, -1));
+      panels.push(dust(xL, 0, -1));
+      panels.push(big(xF, H, 'bottom', 1));
+      const bottomBack = big(xB, H, null, 1);
+      bottomBack.paint = 'bottom';
+      panels.push(bottomBack);
+      panels.push(dust(xR, H, 1));
+      panels.push(dust(xL, H, 1));
+    } else if (type === 'mailer') {
+      const dustW = P.dustW;
+      panels.push(poly([[xB, 0], [xB + ch, -(D2 + 2)], [xB + W - ch, -(D2 + 2)], [xB + W, 0]], 'top', 'flap'));
+      const mt = rect(xB + dustW, -(D2 + 2) - tuckH, W - dustW * 2, tuckH, null, 'tuck');
+      if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
+        mt.holes = [{ x: xB + dustW + (W - dustW * 2) / 2, y: -(D2 + 2) - tuckH / 2, r: P.holeR }];
+      }
+      panels.push(mt);
+      panels.push(rect(xB - dustW, -(D2 + 2), dustW, D2, null, 'dust'));
+      panels.push(rect(xB + W, -(D2 + 2), dustW, D2, null, 'dust'));
+      panels.push(poly([[xF, H], [xF + ch, H + D2 + 2], [xF + W - ch, H + D2 + 2], [xF + W, H]], 'bottom', 'flap'));
+      const mb = rect(xF + dustW, H + D2 + 2, W - dustW * 2, tuckH, null, 'tuck');
+      if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
+        mb.holes = [{ x: xF + dustW + (W - dustW * 2) / 2, y: H + D2 + 2 + tuckH / 2, r: P.holeR }];
+      }
+      panels.push(mb);
+      panels.push(rect(xF - dustW, H + D2 + 2, dustW, D2, null, 'dust'));
+      panels.push(rect(xF + W, H + D2 + 2, dustW, D2, null, 'dust'));
+    } else {
+      // tuck / straight / autobottom:上盖挂后板
+      const lidD = D2 + 2;
+      panels.push(poly([[xB, 0], [xB + ch, -lidD], [xB + W - ch, -lidD], [xB + W, 0]], 'top', 'flap'));
+      const tuckTop = rect(xB + 18, -lidD - tuckH, W - 36, tuckH, null, 'tuck');
+      if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
+        tuckTop.holes = [{ x: xB + W / 2, y: -lidD - tuckH / 2, r: P.holeR }];
+      }
+      panels.push(tuckTop);
+      panels.push(dust(xR, 0, -1));
+      panels.push(dust(xL, 0, -1));
+      if (type === 'straight') {
+        panels.push(poly([[xB, H], [xB + ch, H + lidD], [xB + W - ch, H + lidD], [xB + W, H]], 'bottom', 'flap'));
+        const tuckBot = rect(xB + 18, H + lidD, W - 36, tuckH, null, 'tuck');
+        if ((P.holeR || 0) > 1 && tuckH > (P.holeR || 4) * 2 + 1) {
+          tuckBot.holes = [{ x: xB + W / 2, y: H + lidD + tuckH / 2, r: P.holeR }];
+        }
+        panels.push(tuckBot);
+        panels.push(dust(xR, H, 1));
+        panels.push(dust(xL, H, 1));
+      } else if (type === 'autobottom') {
+        const d1 = half + 5, d2 = half + 2, c2 = ch * 0.6;
+        panels.push(poly([
+          [xF, H], [xF + c2, H + d1], [xF + W * 0.32, H + d1], [xF + W * 0.32, H + d1 - 4],
+          [xF + W * 0.68, H + d1 - 4], [xF + W * 0.68, H + d1], [xF + W - c2, H + d1], [xF + W, H]
+        ], 'bottom', 'flap'));
+        const bottomBack = poly([[xB, H], [xB + c2, H + d2], [xB + W - c2, H + d2], [xB + W, H]], null, 'flap');
+        bottomBack.paint = 'bottom';
+        panels.push(bottomBack);
+        const bottomR = poly([[xR, H], [xR + D2, H], [xR + D2 / 2, H + half + 3]], null, 'dust');
+        bottomR.paint = 'bottom';
+        panels.push(bottomR);
+        const bottomL = poly([[xL, H], [xL + D2, H], [xL + D2 / 2, H + half + 3]], null, 'dust');
+        bottomL.paint = 'bottom';
+        panels.push(bottomL);
+      } else {
+        // tuck 反向插锁:下盖挂前板
+        panels.push(poly([[xF, H], [xF + ch, H + lidD], [xF + W - ch, H + lidD], [xF + W, H]], 'bottom', 'flap'));
+        panels.push(rect(xF + 18, H + lidD, W - 36, tuckH, null, 'tuck'));
+        panels.push(dust(xR, H, 1));
+        panels.push(dust(xL, H, 1));
+      }
+    }
+    return finishDieline(panels);
+  }
+
+  function buildMailbox(type, w, d, hh, params, mat) {
+    const t = mat.thickness;
+    const W = w + t * 2, D2 = d + t * 2, H = hh + t * 2;
+    const P = params || DEFAULT_PARAMS;
+    if (type === 'mailbox') {
+      const lipW = P.lipW;
+      const xRw = 0, xB = D2, xSpine = xB + W, xF = xSpine + D2;
+      const panels = [
+        rect(xRw, 0, D2, H, 'right', 'body'),
+        rect(xB, 0, W, H, 'back', 'body'),
+        rect(xSpine, 0, D2, H, 'left', 'body'),
+        rect(xF, 0, W, H, 'front', 'body'),
+        rect(xF + W, 0, lipW, H, null, 'lip'),
+        rect(xB, -D2, W, D2, 'top', 'body'),
+        rect(xB, H, W, D2, 'bottom', 'body')
+      ];
+      return finishDieline(panels);
+    }
+    if (type === 'drawer') {
+      const glue = P.glue;
+      const xF = glue, xR = xF + W, xB = xR + D2, xL = xB + W;
+      const panels = [
+        rect(0, 0, glue, H, null, 'glue'),
+        rect(xF, 0, W, H, 'front', 'body'),
+        rect(xR, 0, D2, H, 'right', 'body'),
+        rect(xB, 0, W, H, 'back', 'body'),
+        rect(xL, 0, D2, H, 'left', 'body')
+      ];
+      const W2 = Math.max(10, W - 2), D3 = Math.max(10, D2 - 2), TH = Math.max(10, H - 8);
+      const ty = H + 26, tx0 = 24, txF = tx0 + glue, txR = txF + W2, txB = txR + D3, txL = txB + W2;
+      panels.push(rect(tx0, ty, glue, TH, null, 'glue'));
+      panels.push(rect(txF, ty, W2, TH, 'front', 'tray'));
+      panels.push(rect(txR, ty, D3, TH, null, 'tray'));
+      panels.push(rect(txB, ty, W2, TH, null, 'tray'));
+      panels.push(rect(txL, ty, D3, TH, null, 'tray'));
+      panels.push(rect(txF, ty + TH, W2, D3, null, 'bottom'));
+      return finishDieline(panels);
+    }
+    return null;
+  }
+
+  /**
+   * @param {string} type   盒型 id(carton/rsc/tuck/straight/autobottom/mailer/mailbox/drawer/card/sleeve/bag)
+   * @param {number} w      内宽 mm
+   * @param {number} d      内深 mm
+   * @param {number} hh     内高 mm
+   * @param {object} [params] 结构参数(glue/tuckH/cornerR/dustW/lipW/topFold/holeR/boxNo)
+   * @param {string|object} [material] 材质 id 或材质对象(默认白卡)
+   */
+  function build(type, w, d, hh, params, material) {
+    const mat = typeof material === 'object' && material
+      ? material
+      : materialById(typeof material === 'string' ? material : 'card');
+    const P = Object.assign({}, DEFAULT_PARAMS, params || {});
+    return buildMailbox(type, w, d, hh, P, mat) || buildBase(type, w, d, hh, P, mat);
+  }
+
+  window.PL = window.PL || {};
+  window.PL.boxDieline = {
+    build: build,
+    MATERIALS: MATERIALS,
+    DEFAULT_PARAMS: DEFAULT_PARAMS,
+    materialById: materialById,
+    finishDieline: finishDieline,
+    panelBounds: panelBounds
+  };
+})();

+ 118 - 8
assets/js/m.js

@@ -104,7 +104,7 @@
       if (b.qty) chips.push(b.qty + ' 个');
     } else {
       const b = s.box;
-      chips = ['盒子 · ' + (b.structure || '')];
+      chips = ['盒子 · ' + (BOX_STRUCT_LABEL[b.structure] || b.structure || '')];
       if (b.w) chips.push(b.w + '×' + b.d + '×' + b.h + ' mm');
       if (b.qty) chips.push(b.qty + ' 个');
     }
@@ -119,9 +119,31 @@
     renderPreview();
   }
 
-  /* ---- 3D 预览(复用桌面 pouch3d:拖拽旋转/缩放,失败回退 2D) ---- */
+  /* ---- 3D 预览(复用桌面 pouch3d / box3d:拖拽旋转,失败回退 2D) ---- */
   let pouchGL = null;
+  let boxGL = null;
   let glFailed = false;
+
+  const BOX_STRUCT_LABEL = {
+    carton: '卡纸折叠盒', rsc: '平口箱', tuck: '插盖盒', straight: '直插盒',
+    autobottom: '扣底盒', mailer: '飞机盒', mailbox: '磁吸书型盒', drawer: '抽屉盒'
+  };
+
+  /* 切换 3D 容器:袋子用 #mPouch3d,盒子用 #mBox3d;切换时释放另一个引擎 */
+  function useStage(which) {
+    const pouchStage = $('#mPouch3d');
+    const boxStage = $('#mBox3d');
+    if (which === 'box') {
+      if (pouchGL) { try { pouchGL.dispose(); } catch (e) {} pouchGL = null; pouchStage.innerHTML = ''; }
+      pouchStage.hidden = true;
+      boxStage.hidden = false;
+      return boxStage;
+    }
+    if (boxGL) { try { boxGL.dispose(); } catch (e) {} boxGL = null; boxStage.innerHTML = ''; }
+    boxStage.hidden = true;
+    pouchStage.hidden = false;
+    return pouchStage;
+  }
   function facesHTML(s) {
     const p = D.productById(s.bag.productId || 'standup') || D.products[0];
     const size = s.bag.customSize || { w: 140, h: 210 };
@@ -136,6 +158,7 @@
   function update3d(s) {
     const wrap = $('#m3dWrap');
     if (glFailed || !(window.PL.pouch3d && window.THREE)) { wrap.hidden = true; return; }
+    const stage = useStage('bag');
     const p = D.productById(s.bag.productId || 'standup') || D.products[0];
     const size = s.bag.customSize || { w: 140, h: 210 };
     const color = p.mockColor || '#e8e2d4';
@@ -144,7 +167,7 @@
     const bd = (s.bag.design.back) || { elements: [] };
     try {
       if (!pouchGL) {
-        pouchGL = PL.pouch3d.create($('#mPouch3d'), {
+        pouchGL = PL.pouch3d.create(stage, {
           onLoadError: function () {
             glFailed = true;
             try { pouchGL.dispose(); } catch (e) {}
@@ -168,17 +191,104 @@
     }
   }
 
+  /* ---- 盒子 3D(复用桌面 box3d + boxdieline,几何与 box.html 同源) ---- */
+  function boxFallbackHTML(b) {
+    const mat = (window.PL.boxDieline && PL.boxDieline.materialById(b.material)) || { paper: '#fbf7ee' };
+    const outer = (b.faces && b.faces.outer) || {};
+    const faceNames = { front: '正面', back: '背面', left: '左面', right: '右面', top: '顶面', bottom: '底面' };
+    return ['front', 'back', 'left', 'right', 'top', 'bottom'].map(function (k) {
+      const f = outer[k] || {};
+      const label = (f.items && f.items.length) ? '' : '<i>' + faceNames[k] + '</i>';
+      return '<div class="m-face"><div class="m-boxface" style="background:' + (f.color || mat.paper) + '">' +
+        boxFaceText(f) + '</div>' + label + '</div>';
+    }).join('');
+  }
+  function boxFaceText(f) {
+    const t = (f.items || []).filter(function (it) { return it.type === 'text' && it.text; })[0];
+    if (!t) return '';
+    const col = t.color || '#17140f';
+    return '<b style="color:' + col + ';font-size:' + Math.max(11, (t.size || 14) * 0.55) + 'px">' +
+      String(t.text).slice(0, 12).replace(/</g, '&lt;') + '</b>';
+  }
+
+  function updateBox3d(s) {
+    const wrap = $('#m3dWrap');
+    const b = s.box;
+    const prev = $('#mAgentPreview');
+    if (glFailed || !(window.PL.box3d && window.PL.boxDieline && window.THREE) ||
+        !b.structure || !(b.w && b.d && b.h)) {
+      wrap.hidden = true;
+      $('#mFaces').innerHTML = boxFallbackHTML(b);
+      prev.hidden = false;
+      return;
+    }
+    const stage = useStage('box');
+    const mat = PL.boxDieline.materialById(b.material || 'card');
+    const state3d = {
+      structure: b.structure, w: b.w, d: b.d, h: b.h,
+      side: 'outer',
+      faces: b.faces && Object.keys(b.faces).length ? b.faces : { outer: {} }
+    };
+    let panels;
+    try {
+      panels = PL.boxDieline.build(b.structure, b.w, b.d, b.h, null, mat).panels;
+    } catch (e) {
+      glFailed = true;
+      wrap.hidden = true;
+      $('#mFaces').innerHTML = boxFallbackHTML(b);
+      prev.hidden = false;
+      return;
+    }
+    try {
+      if (!boxGL) {
+        boxGL = PL.box3d.create(stage, {
+          mini: true,
+          onInteract: function () { boxGL.setAutoRotate(false); }
+        });
+        boxGL.setAutoRotate(true); // 初始缓慢自转,用户拖动后停住
+      }
+      wrap.hidden = false;
+      boxGL.render(state3d, mat, panels);
+      boxGL.setFold(0); // 0 = 合拢成盒(1 为展开刀版)
+      boxGL.setZoom(1.2); // 宽条舞台上拉近取景
+    } catch (e) {
+      glFailed = true;
+      try { boxGL.dispose(); } catch (e2) {}
+      boxGL = null;
+      wrap.hidden = true;
+      $('#mFaces').innerHTML = boxFallbackHTML(b);
+      prev.hidden = false;
+    }
+  }
+
   function renderPreview() {
     const prev = $('#mAgentPreview');
     const s = st.state;
     const wrap = $('#m3dWrap');
-    if (!s || s.kind !== 'bag' || !s.bag.design || !window.PL.render) {
+    if (!s || !s.kind) {
       prev.hidden = true; if (wrap) wrap.hidden = true; return;
     }
-    // 2D 正/背面缩略图始终渲染(也是 3D 失败时的兜底)
-    $('#mFaces').innerHTML = facesHTML(s);
-    prev.hidden = false;
-    update3d(s);
+    if (s.kind === 'bag') {
+      if (!s.bag.design || !window.PL.render) {
+        prev.hidden = true; if (wrap) wrap.hidden = true; return;
+      }
+      // 2D 正/背面缩略图始终渲染(也是 3D 失败时的兜底)
+      $('#mFaces').classList.remove('box');
+      $('#mFaces').innerHTML = facesHTML(s);
+      prev.hidden = false;
+      update3d(s);
+      return;
+    }
+    if (s.kind === 'box') {
+      // 盒子:先给 2D 六面兜底,WebGL 可用时叠加 3D
+      $('#mFaces').classList.add('box');
+      $('#mFaces').innerHTML = boxFallbackHTML(s.box);
+      prev.hidden = false;
+      updateBox3d(s);
+      return;
+    }
+    prev.hidden = true;
+    if (wrap) wrap.hidden = true;
   }
 
   function showTuneTip() {

+ 22 - 21
box.html

@@ -15,12 +15,12 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>3D云设计编辑器 — 袋研社 POUCHLAB</title>
   <meta name="description" content="在线 3D 纸盒设计:盒型库、模板、素材、文字、条码二维码、智能参数、动效预览与印刷下单。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/box.css?v=1.8.25">
-  <script src="assets/js/i18n-en.js?v=1.8.25"></script>
-  <script src="assets/js/i18n.js?v=1.8.25"></script>
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/box.css?v=1.8.26">
+  <script src="assets/js/i18n-en.js?v=1.8.26"></script>
+  <script src="assets/js/i18n.js?v=1.8.26"></script>
 </head>
 <body class="bx-body">
   <header class="bx-topbar">
@@ -229,20 +229,21 @@
   <!-- 弹窗挂载点 -->
   <div id="bxModals"></div>
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/three.min.js?v=1.8.25"></script>
-  <script src="assets/js/data.js?v=1.8.25"></script>
-  <script src="assets/js/pantone.js?v=1.8.25"></script>
-  <script src="assets/js/render.js?v=1.8.25"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.25"></script>
-  <script src="assets/js/api.js?v=1.8.25"></script>
-  <script src="assets/js/auth.js?v=1.8.25"></script>
-  <script src="assets/js/qr.js?v=1.8.25"></script>
-  <script src="assets/js/boxlib.js?v=1.8.25"></script>
-  <script src="assets/js/box3d.js?v=1.8.25"></script>
-  <script src="assets/js/box.js?v=1.8.25"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/three.min.js?v=1.8.26"></script>
+  <script src="assets/js/data.js?v=1.8.26"></script>
+  <script src="assets/js/pantone.js?v=1.8.26"></script>
+  <script src="assets/js/render.js?v=1.8.26"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.26"></script>
+  <script src="assets/js/api.js?v=1.8.26"></script>
+  <script src="assets/js/auth.js?v=1.8.26"></script>
+  <script src="assets/js/qr.js?v=1.8.26"></script>
+  <script src="assets/js/boxlib.js?v=1.8.26"></script>
+  <script src="assets/js/boxdieline.js?v=1.8.26"></script>
+  <script src="assets/js/box3d.js?v=1.8.26"></script>
+  <script src="assets/js/box.js?v=1.8.26"></script>
 </body>
 </html>

+ 1 - 1
deploy/k8s/pouchlab.yaml

@@ -33,7 +33,7 @@ spec:
         kubernetes.io/hostname: k8s-node1   # 数据 hostPath 固定节点(SQLite 单副本)
       containers:
         - name: pouchlab
-          image: k8s.device.wenhq.top:8583/docker_r/pouchlab:1.8.25
+          image: k8s.device.wenhq.top:8583/docker_r/pouchlab:1.8.26
           # Always:同 tag 覆盖推送后,rollout restart 可强制拉新镜像
           imagePullPolicy: Always
           env:

+ 18 - 18
index.html

@@ -15,13 +15,13 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>袋研社 POUCHLAB — 包装袋在线设计工作室</title>
   <meta name="description" content="在线设计你的包装袋:站立袋、平底袋、咖啡袋、牛皮纸袋、邮寄袋。100 个起订,3D 实时预览,刀版精准,小批量也能做出大品牌质感。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/landing.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/box.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.25">
-  <script src="assets/js/i18n-en.js?v=1.8.25"></script>
-  <script src="assets/js/i18n.js?v=1.8.25"></script>
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/landing.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/box.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.26">
+  <script src="assets/js/i18n-en.js?v=1.8.26"></script>
+  <script src="assets/js/i18n.js?v=1.8.26"></script>
 </head>
 <body>
   <header class="site-header">
@@ -268,16 +268,16 @@
     </div>
   </footer>
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.25"></script>
-  <script src="assets/js/data.js?v=1.8.25"></script>
-  <script src="assets/js/render.js?v=1.8.25"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.25"></script>
-  <script src="assets/js/api.js?v=1.8.25"></script>
-  <script src="assets/js/auth.js?v=1.8.25"></script>
-  <script src="assets/js/agent-chat.js?v=1.8.25"></script>
-  <script src="assets/js/landing.js?v=1.8.25"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.26"></script>
+  <script src="assets/js/data.js?v=1.8.26"></script>
+  <script src="assets/js/render.js?v=1.8.26"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.26"></script>
+  <script src="assets/js/api.js?v=1.8.26"></script>
+  <script src="assets/js/auth.js?v=1.8.26"></script>
+  <script src="assets/js/agent-chat.js?v=1.8.26"></script>
+  <script src="assets/js/landing.js?v=1.8.26"></script>
 </body>
 </html>

+ 19 - 16
m.html

@@ -7,11 +7,11 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>AI 设计师 — Steady Packaging</title>
   <meta name="description" content="手机端 AI 包装设计:对话式出稿、下单、查询订单物流。详细微调请到电脑网站。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/m.css?v=1.8.25">
-  <script src="assets/js/i18n-en.js?v=1.8.25"></script>
-  <script src="assets/js/i18n.js?v=1.8.25"></script>
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/m.css?v=1.8.26">
+  <script src="assets/js/i18n-en.js?v=1.8.26"></script>
+  <script src="assets/js/i18n.js?v=1.8.26"></script>
 </head>
 <body class="m-body">
   <header class="m-head">
@@ -36,7 +36,8 @@
     <div class="m-agentcard" id="mAgentCard" hidden></div>
     <div class="m-3dwrap" id="m3dWrap" hidden>
       <div class="m-3d" id="mPouch3d"></div>
-      <div class="m-3d-hint">👆 拖动旋转 · 滚轮缩放</div>
+      <div class="m-3d" id="mBox3d" hidden></div>
+      <div class="m-3d-hint">👆 拖动旋转 · 双指缩放</div>
     </div>
     <div class="m-agentpreview" id="mAgentPreview" hidden>
       <div class="m-faces" id="mFaces"></div>
@@ -103,15 +104,17 @@
 
   <div class="m-toast" id="mToast" hidden></div>
 
-  <script src="assets/vendor/dayjs.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/three.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/fflate.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/FBXLoader.js?v=1.8.25"></script>
-  <script src="assets/js/data.js?v=1.8.25"></script>
-  <script src="assets/js/render.js?v=1.8.25"></script>
-  <script src="assets/js/pouch3d.js?v=1.8.25"></script>
-  <script src="assets/js/api.js?v=1.8.25"></script>
-  <script src="assets/js/auth.js?v=1.8.25"></script>
-  <script src="assets/js/m.js?v=1.8.25"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/three.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/fflate.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/FBXLoader.js?v=1.8.26"></script>
+  <script src="assets/js/data.js?v=1.8.26"></script>
+  <script src="assets/js/render.js?v=1.8.26"></script>
+  <script src="assets/js/pouch3d.js?v=1.8.26"></script>
+  <script src="assets/js/boxdieline.js?v=1.8.26"></script>
+  <script src="assets/js/box3d.js?v=1.8.26"></script>
+  <script src="assets/js/api.js?v=1.8.26"></script>
+  <script src="assets/js/auth.js?v=1.8.26"></script>
+  <script src="assets/js/m.js?v=1.8.26"></script>
 </body>
 </html>

+ 18 - 18
orders.html

@@ -7,27 +7,27 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>我的订单 — 袋研社 POUCHLAB</title>
   <meta name="description" content="查看订单支付状态、生产进度与物流信息。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/orders.css?v=1.8.25">
-  <script src="assets/js/i18n-en.js?v=1.8.25"></script>
-  <script src="assets/js/i18n.js?v=1.8.25"></script>
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/orders.css?v=1.8.26">
+  <script src="assets/js/i18n-en.js?v=1.8.26"></script>
+  <script src="assets/js/i18n.js?v=1.8.26"></script>
 </head>
 <body class="pl-orders-body">
   <div id="root"></div>
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.25"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.25"></script>
-  <script src="assets/js/data.js?v=1.8.25"></script>
-  <script src="assets/js/qr.js?v=1.8.25"></script>
-  <script src="assets/js/boxlib.js?v=1.8.25"></script>
-  <script src="assets/js/render.js?v=1.8.25"></script>
-  <script src="assets/js/api.js?v=1.8.25"></script>
-  <script src="assets/js/auth.js?v=1.8.25"></script>
-  <script src="assets/js/orders.js?v=1.8.25"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.26"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.26"></script>
+  <script src="assets/js/data.js?v=1.8.26"></script>
+  <script src="assets/js/qr.js?v=1.8.26"></script>
+  <script src="assets/js/boxlib.js?v=1.8.26"></script>
+  <script src="assets/js/render.js?v=1.8.26"></script>
+  <script src="assets/js/api.js?v=1.8.26"></script>
+  <script src="assets/js/auth.js?v=1.8.26"></script>
+  <script src="assets/js/orders.js?v=1.8.26"></script>
 </body>
 </html>

+ 2 - 2
server/main.py

@@ -26,7 +26,7 @@ from routes_ai import router as ai_router
 from routes_factory import router as factory_router
 from routes_orders import router as orders_router
 
-app = FastAPI(title="POUCHLAB API", version="1.8.25")
+app = FastAPI(title="POUCHLAB API", version="1.8.26")
 
 # 生产为同源(本服务同时托管静态站点),CORS 仅方便本地分离调试
 app.add_middleware(
@@ -88,7 +88,7 @@ def version():
         redis_ok = bool(cache.client().ping())
     except Exception:
         redis_ok = False
-    return {"version": "1.8.25", "db": "mysql", "redis": redis_ok}
+    return {"version": "1.8.26", "db": "mysql", "redis": redis_ok}
 
 
 # 静态站点(注册在 API 路由之后,不会遮蔽 /api)

+ 22 - 22
studio.html

@@ -21,12 +21,12 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>设计工作室 — 袋研社 POUCHLAB</title>
   <meta name="description" content="在线包装袋设计工作室:选择袋型、套用模板、上传 Logo、3D 预览并下单一站完成。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.25">
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.26">
   <link rel="stylesheet" href="assets/css/studio.css?v=1.4.15">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.25">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.25">
-  <script src="assets/js/i18n-en.js?v=1.8.25"></script>
-  <script src="assets/js/i18n.js?v=1.8.25"></script>
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.26">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.26">
+  <script src="assets/js/i18n-en.js?v=1.8.26"></script>
+  <script src="assets/js/i18n.js?v=1.8.26"></script>
 </head>
 <body class="studio-body">
   <header class="studio-topbar">
@@ -301,22 +301,22 @@
 
   <div class="toast" id="toast"><span class="dot"></span><span id="toastText"></span></div>
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/three.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/fflate.min.js?v=1.8.25"></script>
-  <script src="assets/vendor/FBXLoader.js?v=1.8.25"></script>
-  <script src="assets/js/data.js?v=1.8.25"></script>
-  <script src="assets/js/pantone.js?v=1.8.25"></script>
-  <script src="assets/js/qr.js?v=1.8.25"></script>
-  <script src="assets/js/boxlib.js?v=1.8.25"></script>
-  <script src="assets/js/render.js?v=1.8.25"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.25"></script>
-  <script src="assets/js/api.js?v=1.8.25"></script>
-  <script src="assets/js/auth.js?v=1.8.25"></script>
-  <script src="assets/js/pouch3d.js?v=1.8.25"></script>
-  <script src="assets/js/studio.js?v=1.8.25"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/three.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/fflate.min.js?v=1.8.26"></script>
+  <script src="assets/vendor/FBXLoader.js?v=1.8.26"></script>
+  <script src="assets/js/data.js?v=1.8.26"></script>
+  <script src="assets/js/pantone.js?v=1.8.26"></script>
+  <script src="assets/js/qr.js?v=1.8.26"></script>
+  <script src="assets/js/boxlib.js?v=1.8.26"></script>
+  <script src="assets/js/render.js?v=1.8.26"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.26"></script>
+  <script src="assets/js/api.js?v=1.8.26"></script>
+  <script src="assets/js/auth.js?v=1.8.26"></script>
+  <script src="assets/js/pouch3d.js?v=1.8.26"></script>
+  <script src="assets/js/studio.js?v=1.8.26"></script>
 </body>
 </html>