Переглянути джерело

feat: 全站中英双语 i18n(运行时 DOM 翻译 + 服务端错误翻译);镜像 1.8.22 含 m.html 打包修复

wenhongquan 1 місяць тому
батько
коміт
89cc03ef85
23 змінених файлів з 3263 додано та 272 видалено
  1. 13 11
      admin.html
  2. 58 8
      assets/css/box.css
  3. 52 1
      assets/css/studio.css
  4. 18 3
      assets/js/antd-bridge.js
  5. 16 6
      assets/js/api.js
  6. 289 98
      assets/js/box.js
  7. 24 0
      assets/js/box3d.js
  8. 1593 0
      assets/js/i18n-en.js
  9. 308 0
      assets/js/i18n.js
  10. 182 15
      assets/js/orders.js
  11. 1 1
      assets/js/pouch3d.js
  12. 45 1
      assets/js/render.js
  13. 416 50
      assets/js/studio.js
  14. 22 19
      box.html
  15. 1 1
      deploy/Dockerfile
  16. 1 1
      deploy/k8s/pouchlab.yaml
  17. 19 16
      index.html
  18. 11 8
      m.html
  19. 18 12
      orders.html
  20. 1 1
      server/agent_service.py
  21. 128 0
      server/i18n.py
  22. 18 1
      server/main.py
  23. 29 19
      studio.html

+ 13 - 11
admin.html

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

+ 58 - 8
assets/css/box.css

@@ -94,28 +94,39 @@ html, body { height: 100%; }
 .bx-mode-switch {
 .bx-mode-switch {
   margin: 0 auto;
   margin: 0 auto;
   background: #f1f1f1; border-radius: 8px; padding: 3px; display: flex; gap: 2px;
   background: #f1f1f1; border-radius: 8px; padding: 3px; display: flex; gap: 2px;
+  flex: 0 0 auto;
 }
 }
 .bx-mode-switch button {
 .bx-mode-switch button {
   border: none; background: none; padding: 6px 20px; font-size: 13.5px; border-radius: 6px;
   border: none; background: none; padding: 6px 20px; font-size: 13.5px; border-radius: 6px;
-  cursor: pointer; color: #555; font-weight: 600;
+  cursor: pointer; color: #555; font-weight: 600; white-space: nowrap;
 }
 }
 .bx-mode-switch button.on { background: var(--bx-orange); color: #fff; }
 .bx-mode-switch button.on { background: var(--bx-orange); color: #fff; }
 
 
-.bx-top-actions { display: flex; align-items: center; gap: 8px; }
+.bx-top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
 .btn-print {
 .btn-print {
   display: flex; align-items: center; gap: 6px;
   display: flex; align-items: center; gap: 6px;
   background: var(--bx-orange); color: #fff; border: none; border-radius: 8px;
   background: var(--bx-orange); color: #fff; border: none; border-radius: 8px;
   padding: 8px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer;
   padding: 8px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer;
+  white-space: nowrap;
 }
 }
 .btn-print:hover { background: var(--bx-orange-deep); }
 .btn-print:hover { background: var(--bx-orange-deep); }
 .btn-print svg { width: 15px; height: 15px; }
 .btn-print svg { width: 15px; height: 15px; }
 .btn-plain, .btn-export {
 .btn-plain, .btn-export {
   border: 1px solid #e2e2e2; background: #fff; color: var(--bx-ink);
   border: 1px solid #e2e2e2; background: #fff; color: var(--bx-ink);
   border-radius: 8px; padding: 7.5px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer;
   border-radius: 8px; padding: 7.5px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer;
+  white-space: nowrap;
 }
 }
 .btn-plain:hover { border-color: var(--bx-orange); color: var(--bx-orange); }
 .btn-plain:hover { border-color: var(--bx-orange); color: var(--bx-orange); }
 .btn-export { border-color: var(--bx-orange); color: var(--bx-orange); }
 .btn-export { border-color: var(--bx-orange); color: var(--bx-orange); }
 .btn-export:hover { background: #fff4ec; }
 .btn-export:hover { background: #fff4ec; }
+
+@media (max-width: 1180px) {
+  .bx-topbar { gap: 6px; padding: 0 10px; }
+  .bx-brand .logo-type { display: none; }
+  .bx-mode-switch button { padding: 6px 10px; font-size: 13px; }
+  .btn-print, .btn-plain, .btn-export { padding: 7px 10px; font-size: 13px; }
+  .btn-print { gap: 4px; }
+}
 .bx-avatar {
 .bx-avatar {
   width: 34px; height: 34px; border-radius: 50%; border: none; background: #fff1e5; cursor: pointer;
   width: 34px; height: 34px; border-radius: 50%; border: none; background: #fff1e5; cursor: pointer;
   display: grid; place-items: center; padding: 0;
   display: grid; place-items: center; padding: 0;
@@ -206,8 +217,8 @@ html, body { height: 100%; }
 .bx-tpl-card .nm { font-size: 10.5px; opacity: 0.72; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
 .bx-tpl-card .nm { font-size: 10.5px; opacity: 0.72; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
 .bx-tpl-card .pro { position: absolute; right: 7px; top: 7px; margin: 0; }
 .bx-tpl-card .pro { position: absolute; right: 7px; top: 7px; margin: 0; }
 
 
-.bx-asset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
-.bx-asset-card { position: relative; text-align: center; }
+.bx-asset-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
+.bx-asset-card { position: relative; text-align: center; min-width: 0; }
 .bx-asset-card .thumb {
 .bx-asset-card .thumb {
   width: 100%; aspect-ratio: 1; border: 1px solid #efefef; border-radius: 9px; background: #fafafa;
   width: 100%; aspect-ratio: 1; border: 1px solid #efefef; border-radius: 9px; background: #fafafa;
   display: grid; place-items: center; cursor: pointer; padding: 0; overflow: hidden;
   display: grid; place-items: center; cursor: pointer; padding: 0; overflow: hidden;
@@ -264,11 +275,39 @@ html, body { height: 100%; }
 .box-illus::after {
 .box-illus::after {
   content: ''; position: absolute; inset: 12px 16px; border: 2px dashed #d8d2c4; border-radius: 5px;
   content: ''; position: absolute; inset: 12px 16px; border: 2px dashed #d8d2c4; border-radius: 5px;
 }
 }
+.bx-upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
+.bx-upload-card { position: relative; }
+.bx-upload-card .thumb {
+  width: 100%; aspect-ratio: 1; border: 1px solid #efefef; border-radius: 9px;
+  background: #fafafa; padding: 0; overflow: hidden; cursor: pointer; display: grid; place-items: center;
+}
+.bx-upload-card .thumb:hover { border-color: var(--bx-orange); }
+.bx-upload-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
+.bx-upload-card .nm {
+  display: block; font-size: 10px; color: var(--bx-sub); margin-top: 4px;
+  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
+}
+.bx-upload-card .del {
+  position: absolute; right: 3px; top: 3px; border: none; width: 18px; height: 18px; border-radius: 50%;
+  background: rgba(23, 20, 15, 0.55); color: #fff; font-size: 10px; line-height: 1; cursor: pointer;
+}
+.bx-upload-card .del:hover { background: #c2451f; }
 .bx-capacity { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--bx-sub); margin-top: 14px; }
 .bx-capacity { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--bx-sub); margin-top: 14px; }
 .bx-capacity a { color: var(--bx-orange); cursor: pointer; }
 .bx-capacity a { color: var(--bx-orange); cursor: pointer; }
 .bx-cap-bar { height: 4px; background: #f0ede7; border-radius: 3px; margin-top: 7px; overflow: hidden; }
 .bx-cap-bar { height: 4px; background: #f0ede7; border-radius: 3px; margin-top: 7px; overflow: hidden; }
 .bx-cap-bar i { display: block; height: 100%; background: var(--bx-orange); border-radius: 3px; }
 .bx-cap-bar i { display: block; height: 100%; background: var(--bx-orange); border-radius: 3px; }
 
 
+.bx-layer-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 9px; }
+.bx-layer-head .bx-sec-title { margin: 0; }
+.bx-layer-clear { border: none; background: none; color: #c2451f; font-size: 12px; cursor: pointer; padding: 0; }
+.bx-layer-clear:hover { text-decoration: underline; }
+.bx-clear-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
+.bx-clear-opt {
+  width: 100%; padding: 10px 12px; border: 1px solid #e8e2d6; border-radius: 9px;
+  background: #fff; color: var(--bx-ink); font-size: 13px; font-weight: 600; cursor: pointer;
+}
+.bx-clear-opt:hover { border-color: var(--bx-orange); color: var(--bx-orange); }
+.bx-clear-opt.danger { color: #c2451f; border-color: #f1c9bb; background: #fff7f4; }
 .bx-layer-list { display: flex; flex-direction: column; gap: 6px; }
 .bx-layer-list { display: flex; flex-direction: column; gap: 6px; }
 .bx-layer-row {
 .bx-layer-row {
   display: flex; align-items: center; gap: 4px; border: 1px solid #efefef; border-radius: 8px;
   display: flex; align-items: center; gap: 4px; border: 1px solid #efefef; border-radius: 8px;
@@ -296,6 +335,7 @@ html, body { height: 100%; }
 .bx-flat-inner { min-width: 100%; min-height: 100%; display: grid; place-items: center; padding: 40px; }
 .bx-flat-inner { min-width: 100%; min-height: 100%; display: grid; place-items: center; padding: 40px; }
 .dieline-wrap { transform-origin: center center; }
 .dieline-wrap { transform-origin: center center; }
 .dieline-panel { stroke: #7d88c4; stroke-width: 0.8; }
 .dieline-panel { stroke: #7d88c4; stroke-width: 0.8; }
+.dieline-panel.is-picked { stroke: #ff5c2b; stroke-width: 1.8; }
 .dieline-fold { stroke: #9db4d8; stroke-width: 0.7; stroke-dasharray: 4 2.6; fill: none; }
 .dieline-fold { stroke: #9db4d8; stroke-width: 0.7; stroke-dasharray: 4 2.6; fill: none; }
 .dieline-hit { cursor: pointer; }
 .dieline-hit { cursor: pointer; }
 .dieline-hit:hover { fill: rgba(255,106,0,.06); }
 .dieline-hit:hover { fill: rgba(255,106,0,.06); }
@@ -478,13 +518,14 @@ html, body { height: 100%; }
 #bxModals .ant-modal-title { font-weight: 700; }
 #bxModals .ant-modal-title { font-weight: 700; }
 
 
 /* 智能参数宝 */
 /* 智能参数宝 */
-.sp-wrap { display: flex; gap: 0; min-height: 480px; margin: -12px -24px -6px; }
-.sp-left { flex: 1.35; background: #f4f4f6; padding: 18px; overflow: auto; }
+.sp-wrap { display: flex; gap: 0; min-height: 480px; max-height: min(640px, 72vh); margin: -12px -24px -6px; }
+.sp-left { flex: 1 1 auto; min-width: 0; background: #f4f4f6; padding: 18px; overflow: auto; }
 .sp-dieline svg { width: 100%; height: auto; }
 .sp-dieline svg { width: 100%; height: auto; }
-.sp-right { flex: 1; padding: 16px 18px; overflow-y: auto; max-height: 560px; border-left: 1px solid var(--bx-line); }
+.sp-right { flex: 0 0 410px; padding: 16px 20px 28px; overflow-y: auto; border-left: 1px solid var(--bx-line); }
 .sp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
 .sp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
 .sp-row label { width: 104px; font-size: 12.5px; color: var(--bx-sub); flex: 0 0 auto; }
 .sp-row label { width: 104px; font-size: 12.5px; color: var(--bx-sub); flex: 0 0 auto; }
-.sp-row .unit { font-size: 12px; color: #b0aaa0; width: 20px; }
+.sp-row .ant-input-number { flex: 1 1 auto; min-width: 0; }
+.sp-row .unit { font-size: 12px; color: #b0aaa0; min-width: 20px; white-space: nowrap; flex: 0 0 auto; }
 .sp-group-title {
 .sp-group-title {
   font-size: 13px; font-weight: 700; background: #f7f5f0; border-radius: 6px; padding: 6px 10px;
   font-size: 13px; font-weight: 700; background: #f7f5f0; border-radius: 6px; padding: 6px 10px;
   margin: 12px 0 10px;
   margin: 12px 0 10px;
@@ -501,6 +542,15 @@ html, body { height: 100%; }
 .ex-file-body { display: flex; min-height: 480px; }
 .ex-file-body { display: flex; min-height: 480px; }
 .ex-preview { flex: 1.4; background: #f4f4f6; margin: 18px 0 18px 22px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; padding: 12px; position: relative; }
 .ex-preview { flex: 1.4; background: #f4f4f6; margin: 18px 0 18px 22px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; padding: 12px; position: relative; }
 .ex-preview svg { max-width: 100%; max-height: 100%; }
 .ex-preview svg { max-width: 100%; max-height: 100%; }
+.ex-preview .ex-snap { max-width: 100%; max-height: 100%; border-radius: 8px; }
+.ex-preview .ex-preview-empty { color: #b0aaa0; font-size: 13px; }
+.ex-preview.3d { position: relative; }
+.ex-preview.3d .ex-fold-row {
+  position: absolute; left: 16px; right: 16px; bottom: 12px;
+  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
+  background: rgba(255, 255, 255, 0.82); border-radius: 9px; font-size: 12px; color: var(--bx-sub);
+}
+.ex-preview.3d .ex-fold-row input { flex: 1; accent-color: var(--bx-orange); }
 .ex-preview .dieline-panel { stroke: #7d88c4; }
 .ex-preview .dieline-panel { stroke: #7d88c4; }
 .ex-side { width: 300px; padding: 18px 22px; overflow-y: auto; max-height: 560px; }
 .ex-side { width: 300px; padding: 18px 22px; overflow-y: auto; max-height: 560px; }
 .ex-label { font-size: 12.5px; font-weight: 700; margin: 14px 0 8px; }
 .ex-label { font-size: 12.5px; font-weight: 700; margin: 14px 0 8px; }

+ 52 - 1
assets/css/studio.css

@@ -353,6 +353,13 @@
   gap: 8px;
   gap: 8px;
 }
 }
 .props-head h3 { font-size: 13px; font-weight: 700; }
 .props-head h3 { font-size: 13px; font-weight: 700; }
+.props-close {
+  display: none;
+  width: 24px; height: 24px; border: 1px solid var(--line-2); border-radius: 50%;
+  background: var(--white); color: var(--muted); font-size: 15px; line-height: 1;
+  place-items: center; cursor: pointer;
+}
+.props-close:hover { color: var(--ink); border-color: var(--ink-2); }
 .props-head .type-chip {
 .props-head .type-chip {
   font-family: var(--font-mono);
   font-family: var(--font-mono);
   font-size: 8.5px;
   font-size: 8.5px;
@@ -585,6 +592,35 @@
 .shape-btn .shape-ico.line { height: 0; border-width: 1.5px 0 0; }
 .shape-btn .shape-ico.line { height: 0; border-width: 1.5px 0 0; }
 .shape-btn .shape-ico.star { border: 0; background: var(--ink); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
 .shape-btn .shape-ico.star { border: 0; background: var(--ink); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
 .shape-btn .shape-ico.badge { border-radius: 50%; border-style: dashed; }
 .shape-btn .shape-ico.badge { border-radius: 50%; border-style: dashed; }
+.shape-btn .shape-ico.triangle { border: 0; background: var(--ink); clip-path: polygon(50% 4%, 96% 94%, 4% 94%); }
+
+.asset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
+.asset-btn {
+  aspect-ratio: 1;
+  border: 1px solid var(--line);
+  border-radius: 8px;
+  background: var(--white);
+  display: grid;
+  place-items: center;
+  padding: 7px;
+  transition: border-color 0.2s, transform 0.2s;
+}
+.asset-btn:hover { border-color: var(--ink); transform: translateY(-2px); }
+.asset-btn svg { width: 100%; height: 100%; display: block; }
+
+.plan-save { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
+.plan-save .ant-input { font-size: 11.5px; }
+.plan-list { display: flex; flex-direction: column; gap: 7px; }
+.plan-item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 6px; background: var(--white); }
+.plan-thumb { width: 42px; height: 54px; flex: none; border-radius: 5px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); }
+.plan-thumb svg { width: 100%; height: 100%; display: block; }
+.plan-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
+.plan-meta b { font-size: 11px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.plan-meta span { font-size: 9px; color: var(--muted); }
+.plan-actions { display: flex; flex-direction: column; gap: 3px; }
+.plan-actions button { font-size: 9.5px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink-2); font-family: inherit; }
+.plan-actions button:hover { border-color: var(--ink); color: var(--ink); }
+.plan-actions button.del:hover { border-color: #ffc3b2; color: #d63d13; background: #fff0ec; }
 
 
 .sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
 .sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
 .sticker-btn {
 .sticker-btn {
@@ -1027,6 +1063,21 @@
 @media (max-width: 1100px) {
 @media (max-width: 1100px) {
   .design-view { grid-template-columns: 68px 240px minmax(0, 1fr); }
   .design-view { grid-template-columns: 68px 240px minmax(0, 1fr); }
   .props-panel { display: none; }
   .props-panel { display: none; }
+  /* 窄屏下选中元素时以浮层抽屉展示属性,避免属性面板被隐藏后无法编辑 */
+  body.props-open .props-panel {
+    display: flex;
+    position: fixed;
+    top: 70px;
+    right: 12px;
+    bottom: 12px;
+    width: 286px;
+    max-width: calc(100vw - 24px);
+    z-index: 70;
+    border: 1px solid var(--line);
+    border-radius: 16px;
+    box-shadow: 0 20px 55px rgba(40, 30, 10, 0.18);
+  }
+  body.props-open .props-close { display: grid; }
   .studio-title-wrap { display: none; }
   .studio-title-wrap { display: none; }
   .summary-inner { grid-template-columns: 1fr; gap: 30px; }
   .summary-inner { grid-template-columns: 1fr; gap: 30px; }
   .summary-right { position: static; }
   .summary-right { position: static; }
@@ -1169,7 +1220,7 @@
   border-radius: 14px; padding: 14px; box-shadow: 0 24px 60px rgba(23,20,15,0.18);
   border-radius: 14px; padding: 14px; box-shadow: 0 24px 60px rgba(23,20,15,0.18);
 }
 }
 .pl-ai-panel[hidden] { display: none; }
 .pl-ai-panel[hidden] { display: none; }
-.pl-ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
+.pl-ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; cursor: move; user-select: none; touch-action: none; }
 .pl-ai-head b { font-size: 14px; }
 .pl-ai-head b { font-size: 14px; }
 .pl-ai-quota { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 8px; }
 .pl-ai-quota { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 8px; }
 .pl-ai-close { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 13px; }
 .pl-ai-close { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 13px; }

+ 18 - 3
assets/js/antd-bridge.js

@@ -114,6 +114,13 @@
   };
   };
 
 
   const roots = new Map();
   const roots = new Map();
+  const lastRender = new Map();
+
+  function currentLocale() {
+    const lang = window.PL && window.PL.i18n ? window.PL.i18n.getLang() : 'zh';
+    if (!antd.locale) return undefined;
+    return lang === 'en' && antd.locale.enUS ? antd.locale.enUS : antd.locale.zhCN;
+  }
 
 
   function render(container, element) {
   function render(container, element) {
     if (!container) return;
     if (!container) return;
@@ -122,8 +129,15 @@
       root = ReactDOM.createRoot(container);
       root = ReactDOM.createRoot(container);
       roots.set(container, root);
       roots.set(container, root);
     }
     }
-    const locale = antd.locale ? antd.locale.zhCN : undefined;
-    root.render(h(antd.ConfigProvider, { theme: theme, prefixCls: 'ant', locale: locale }, element));
+    lastRender.set(container, element);
+    root.render(h(antd.ConfigProvider, { theme: theme, prefixCls: 'ant', locale: currentLocale() }, element));
+  }
+
+  function retheme() {
+    roots.forEach(function (root, container) {
+      if (!container || !container.isConnected) return;
+      root.render(h(antd.ConfigProvider, { theme: theme, prefixCls: 'ant', locale: currentLocale() }, lastRender.get(container)));
+    });
   }
   }
 
 
   function reset(container) {
   function reset(container) {
@@ -174,10 +188,11 @@
     render: render,
     render: render,
     reset: reset,
     reset: reset,
     hydrate: hydrate,
     hydrate: hydrate,
+    retheme: retheme,
     antd: antd,
     antd: antd,
     theme: theme,
     theme: theme,
     message: antd.message,
     message: antd.message,
     notification: antd.notification,
     notification: antd.notification,
-    locale: antd.locale ? antd.locale.zhCN : null
+    get locale() { return currentLocale(); }
   };
   };
 })();
 })();

+ 16 - 6
assets/js/api.js

@@ -1,6 +1,15 @@
 (function () {
 (function () {
   const TOKEN_KEY = 'pouchlab.token.v1';
   const TOKEN_KEY = 'pouchlab.token.v1';
 
 
+  function langHeader() {
+    const lang = window.PL && window.PL.i18n ? window.PL.i18n.getLang() : 'zh';
+    return lang === 'en' ? 'en' : 'zh-CN';
+  }
+
+  function tr(s) {
+    return window.PL && window.PL.t ? window.PL.t(s) : s;
+  }
+
   function token() {
   function token() {
     try { return localStorage.getItem(TOKEN_KEY) || ''; } catch (e) { return ''; }
     try { return localStorage.getItem(TOKEN_KEY) || ''; } catch (e) { return ''; }
   }
   }
@@ -16,6 +25,7 @@
     opts = opts || {};
     opts = opts || {};
     const headers = {};
     const headers = {};
     if (body !== undefined) headers['Content-Type'] = 'application/json';
     if (body !== undefined) headers['Content-Type'] = 'application/json';
+    headers['Accept-Language'] = langHeader();
     const t = token();
     const t = token();
     if (t) headers['Authorization'] = 'Bearer ' + t;
     if (t) headers['Authorization'] = 'Bearer ' + t;
     const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
     const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
@@ -33,7 +43,7 @@
       }
       }
       return res.json().catch(function () { return {}; }).then(function (data) {
       return res.json().catch(function () { return {}; }).then(function (data) {
         if (!res.ok) {
         if (!res.ok) {
-          const err = new Error(data.detail || ('请求失败(' + res.status + ')'));
+          const err = new Error(data.detail || tr('请求失败(' + res.status + ')'));
           err.status = res.status;
           err.status = res.status;
           throw err;
           throw err;
         }
         }
@@ -42,11 +52,11 @@
     }, function (e) {
     }, function (e) {
       if (timer) clearTimeout(timer);
       if (timer) clearTimeout(timer);
       if (e && e.name === 'AbortError') {
       if (e && e.name === 'AbortError') {
-        const err = new Error('请求超时,请重试');
+        const err = new Error(tr('请求超时,请重试'));
         err.network = true;
         err.network = true;
         throw err;
         throw err;
       }
       }
-      const err = new Error('无法连接服务器');
+      const err = new Error(tr('无法连接服务器'));
       err.network = true;
       err.network = true;
       throw err;
       throw err;
     });
     });
@@ -55,10 +65,10 @@
   // 带鉴权的文件下载(DXF/预览图/设计稿),转为浏览器下载
   // 带鉴权的文件下载(DXF/预览图/设计稿),转为浏览器下载
   function download(path, filename) {
   function download(path, filename) {
     const t = token();
     const t = token();
-    return fetch('/api' + path, { headers: t ? { Authorization: 'Bearer ' + t } : {} }).then(function (res) {
+    return fetch('/api' + path, { headers: Object.assign({ 'Accept-Language': langHeader() }, t ? { Authorization: 'Bearer ' + t } : {}) }).then(function (res) {
       if (!res.ok) {
       if (!res.ok) {
         return res.json().catch(function () { return {}; }).then(function (d) {
         return res.json().catch(function () { return {}; }).then(function (d) {
-          throw new Error(d.detail || '下载失败(' + res.status + ')');
+          throw new Error(d.detail || tr('下载失败(' + res.status + ')'));
         });
         });
       }
       }
       return res.blob();
       return res.blob();
@@ -94,7 +104,7 @@
       };
       };
       img.onerror = function () {
       img.onerror = function () {
         URL.revokeObjectURL(url);
         URL.revokeObjectURL(url);
-        reject(new Error('预览图生成失败'));
+        reject(new Error(tr('预览图生成失败')));
       };
       };
       img.src = url;
       img.src = url;
     });
     });

+ 289 - 98
assets/js/box.js

@@ -102,6 +102,7 @@
     mode: '2d',
     mode: '2d',
     showLines: true,
     showLines: true,
     autoRotate: false,
     autoRotate: false,
+    uploads: [],
     view2d: { zoom: 0.6, panX: 0, panY: 0, preview: false }
     view2d: { zoom: 0.6, panX: 0, panY: 0, preview: false }
   };
   };
 
 
@@ -123,6 +124,7 @@
         });
         });
       });
       });
       state.faces = f;
       state.faces = f;
+      if (!Array.isArray(state.uploads)) state.uploads = [];
     }
     }
   } catch (e) {}
   } catch (e) {}
 
 
@@ -520,25 +522,34 @@
   function itemSvg(it, bx, by, bw, bh, mm2px) {
   function itemSvg(it, bx, by, bw, bh, mm2px) {
     const cx = bx + (it.x / 100) * bw, cy = by + (it.y / 100) * bh;
     const cx = bx + (it.x / 100) * bw, cy = by + (it.y / 100) * bh;
     if (it.hidden) return { art: '', hit: '' };
     if (it.hidden) return { art: '', hit: '' };
-    const hit = '<circle class="bx-item-hit" data-item-id="' + it.id + '" data-item-face="' + (it._face || '') + '" cx="' + cx.toFixed(2) + '" cy="' + cy.toFixed(2) + '" r="' + Math.max(6, bw * 0.03).toFixed(2) + '"/>';
+    // 内侧版面整体镜像(相当于从背面看印刷面),元素随之翻转
+    function hitRect(x, y, w, h) {
+      return '<rect class="bx-item-hit" data-item-id="' + it.id + '" data-item-face="' + (it._face || '') + '" x="' + (x - 3).toFixed(2) + '" y="' + (y - 3).toFixed(2) + '" width="' + (w + 6).toFixed(2) + '" height="' + (h + 6).toFixed(2) + '" fill="transparent" pointer-events="all"/>';
+    }
     if (it.type === 'text') {
     if (it.type === 'text') {
       const anchor = it.align === 'center' ? 'middle' : it.align === 'right' ? 'end' : 'start';
       const anchor = it.align === 'center' ? 'middle' : it.align === 'right' ? 'end' : 'start';
       const lines = String(it.text || '').split('\n');
       const lines = String(it.text || '').split('\n');
       const fs = it.size * mm2px;
       const fs = it.size * mm2px;
       const lh = (it.lineHeight || 1.25) * fs;
       const lh = (it.lineHeight || 1.25) * fs;
-      let out = '';
+      let out = '', maxW = 0;
       lines.forEach(function (line, li) {
       lines.forEach(function (line, li) {
+        const tw = String(line).split('').reduce(function (s, ch) { return s + (/[\x00-\xff]/.test(ch) ? 0.56 : 1) * fs; }, 0);
+        if (tw > maxW) maxW = tw;
         out += '<text x="' + cx.toFixed(2) + '" y="' + (cy + (li - (lines.length - 1) / 2) * lh).toFixed(2) + '" text-anchor="' + anchor + '" dominant-baseline="middle" font-size="' + fs.toFixed(2) + '" fill="' + (it.color || '#17140f') + '" font-family="Helvetica Neue, PingFang SC, sans-serif" font-weight="' + (it.weight || 400) + '"' + (it.italic ? ' font-style="italic"' : '') + '>' + R.esc(line) + '</text>';
         out += '<text x="' + cx.toFixed(2) + '" y="' + (cy + (li - (lines.length - 1) / 2) * lh).toFixed(2) + '" text-anchor="' + anchor + '" dominant-baseline="middle" font-size="' + fs.toFixed(2) + '" fill="' + (it.color || '#17140f') + '" font-family="Helvetica Neue, PingFang SC, sans-serif" font-weight="' + (it.weight || 400) + '"' + (it.italic ? ' font-style="italic"' : '') + '>' + R.esc(line) + '</text>';
       });
       });
-      return { art: out, hit: hit };
+      maxW = Math.max(maxW, fs * 2);
+      const totalH = Math.max(lines.length * lh, fs);
+      const left = anchor === 'start' ? cx : anchor === 'end' ? cx - maxW : cx - maxW / 2;
+      return { art: out, hit: hitRect(left, cy - totalH / 2, maxW, totalH) };
     }
     }
     if (it.type === 'image' || it.type === 'asset') {
     if (it.type === 'image' || it.type === 'asset') {
       const iw = ((it.w == null ? 60 : it.w) / 100) * bw;
       const iw = ((it.w == null ? 60 : it.w) / 100) * bw;
-      return { art: '<image href="' + it.src + '" x="' + (cx - iw / 2).toFixed(2) + '" y="' + (cy - iw / 2).toFixed(2) + '" width="' + iw.toFixed(2) + '" height="' + iw.toFixed(2) + '" preserveAspectRatio="xMidYMid meet"/>', hit: hit };
+      return { art: '<image href="' + it.src + '" x="' + (cx - iw / 2).toFixed(2) + '" y="' + (cy - iw / 2).toFixed(2) + '" width="' + iw.toFixed(2) + '" height="' + iw.toFixed(2) + '" preserveAspectRatio="xMidYMid meet"/>', hit: hitRect(cx - iw / 2, cy - iw / 2, iw, iw) };
     }
     }
     if (it.type === 'barcode') {
     if (it.type === 'barcode') {
       const iw = ((it.w || 40) / 100) * bw;
       const iw = ((it.w || 40) / 100) * bw;
-      return { art: '<image href="' + it.src + '" x="' + (cx - iw / 2).toFixed(2) + '" y="' + (cy - iw * 0.42).toFixed(2) + '" width="' + iw.toFixed(2) + '" height="' + (iw * 0.84).toFixed(2) + '"/>', hit: hit };
+      const ih = iw * 0.84;
+      return { art: '<image href="' + it.src + '" x="' + (cx - iw / 2).toFixed(2) + '" y="' + (cy - ih / 2).toFixed(2) + '" width="' + iw.toFixed(2) + '" height="' + ih.toFixed(2) + '"/>', hit: hitRect(cx - iw / 2, cy - ih / 2, iw, ih) };
     }
     }
     return { art: '', hit: '' };
     return { art: '', hit: '' };
   }
   }
@@ -550,55 +561,58 @@
     const pad = 30;
     const pad = 30;
     const bleed = state.smart.bleed || 0;
     const bleed = state.smart.bleed || 0;
     const inner = state.side === 'inner';
     const inner = state.side === 'inner';
+    const uid = opts.idPrefix || 'dl';
     const vbW = dl.size.w + pad * 2 + bleed * 2;
     const vbW = dl.size.w + pad * 2 + bleed * 2;
     const vbH = dl.size.h + pad * 2 + bleed * 2 + (opts.noLegend ? 0 : 56);
     const vbH = dl.size.h + pad * 2 + bleed * 2 + (opts.noLegend ? 0 : 56);
     const off = function (x, y) { return [x - dl.minX + pad + bleed, y - dl.minY + pad + bleed]; };
     const off = function (x, y) { return [x - dl.minX + pad + bleed, y - dl.minY + pad + bleed]; };
-    let body = '', defs = '', art = '', hit = '', itemHits = '';
+    let body = '', defs = '', art = '', hit = '', itemHits = '', notes = '';
     const useMatPattern = state.material === 'corrugated' || state.material === 'kraft';
     const useMatPattern = state.material === 'corrugated' || state.material === 'kraft';
     if (useMatPattern) {
     if (useMatPattern) {
-      defs += '<pattern id="matPat" width="5" height="5" patternUnits="userSpaceOnUse">' +
+      defs += '<pattern id="' + uid + '-mat" width="5" height="5" patternUnits="userSpaceOnUse">' +
         '<rect width="5" height="5" fill="' + mat.paper + '"/>' +
         '<rect width="5" height="5" fill="' + mat.paper + '"/>' +
         '<line x1="0.6" y1="0" x2="0.6" y2="5" stroke="' + mat.flute + '" stroke-width="1" opacity="0.55"/></pattern>';
         '<line x1="0.6" y1="0" x2="0.6" y2="5" stroke="' + mat.flute + '" stroke-width="1" opacity="0.55"/></pattern>';
     }
     }
-    const matFill = useMatPattern ? 'url(#matPat)' : mat.paper;
+    const matFill = useMatPattern ? 'url(#' + uid + '-mat)' : mat.paper;
     // 结构件(防尘翼/插舌/糊口等)不印刷:素纸色 + 45° 斜线纹理,与印刷面区分
     // 结构件(防尘翼/插舌/糊口等)不印刷:素纸色 + 45° 斜线纹理,与印刷面区分
-    defs += '<pattern id="accPat" width="7" height="7" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">' +
+    defs += '<pattern id="' + uid + '-acc" width="7" height="7" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">' +
       '<rect width="7" height="7" fill="' + mat.paper + '"/>' +
       '<rect width="7" height="7" fill="' + mat.paper + '"/>' +
       '<line x1="0" y1="0" x2="0" y2="7" stroke="' + mat.flute + '" stroke-width="1.4" opacity="0.5"/></pattern>';
       '<line x1="0" y1="0" x2="0" y2="7" stroke="' + mat.flute + '" stroke-width="1.4" opacity="0.5"/></pattern>';
     dl.panels.forEach(function (p, i) {
     dl.panels.forEach(function (p, i) {
       const pts = p.poly ? p.poly.map(function (pt) { return off(pt[0], pt[1]); }) : [off(p.x, p.y), off(p.x + p.w, p.y), off(p.x + p.w, p.y + p.h), off(p.x, p.y + p.h)];
       const pts = p.poly ? p.poly.map(function (pt) { return off(pt[0], pt[1]); }) : [off(p.x, p.y), off(p.x + p.w, p.y), off(p.x + p.w, p.y + p.h), off(p.x, p.y + p.h)];
-      const cid = 'p' + i;
+      const cid = uid + '-p' + i;
       const f = p.face ? curFaces()[p.face] : null;
       const f = p.face ? curFaces()[p.face] : null;
       const plain = curFaces()._plain || {};
       const plain = curFaces()._plain || {};
       const isAcc = ACCESSORY[p.kind] && !p.face;  // 有 face 的面(如飞机盒顶/底盖)可印刷,不算结构件
       const isAcc = ACCESSORY[p.kind] && !p.face;  // 有 face 的面(如飞机盒顶/底盖)可印刷,不算结构件
       let panelFill;
       let panelFill;
       if (isAcc) {
       if (isAcc) {
-        panelFill = 'url(#accPat)';
+        panelFill = 'url(#' + uid + '-acc)';
       } else if (f) {
       } else if (f) {
-        panelFill = f.color || (f.texture ? 'url(#tex' + i + ')' : matFill);
+        panelFill = f.color || (f.texture ? 'url(#' + uid + '-tex' + i + ')' : matFill);
       } else {
       } else {
         panelFill = plain.color || matFill;
         panelFill = plain.color || matFill;
       }
       }
       if (f && f.texture) {
       if (f && f.texture) {
-        defs += '<pattern id="tex' + i + '" width="60" height="60" patternUnits="userSpaceOnUse"><image href="' + f.texture + '" width="60" height="60"/></pattern>';
+        defs += '<pattern id="' + uid + '-tex' + i + '" width="60" height="60" patternUnits="userSpaceOnUse"><image href="' + f.texture + '" width="60" height="60"/></pattern>';
       }
       }
       const points = pts.map(function (pt) { return pt[0].toFixed(2) + ',' + pt[1].toFixed(2); }).join(' ');
       const points = pts.map(function (pt) { return pt[0].toFixed(2) + ',' + pt[1].toFixed(2); }).join(' ');
       const shape = p.poly ? '<polygon points="' + points + '"/>' : '<rect x="' + pts[0][0] + '" y="' + pts[0][1] + '" width="' + (p.w || 0) + '" height="' + (p.h || 0) + '"/>';
       const shape = p.poly ? '<polygon points="' + points + '"/>' : '<rect x="' + pts[0][0] + '" y="' + pts[0][1] + '" width="' + (p.w || 0) + '" height="' + (p.h || 0) + '"/>';
       defs += '<clipPath id="' + cid + '">' + shape + '</clipPath>';
       defs += '<clipPath id="' + cid + '">' + shape + '</clipPath>';
-      body += '<polygon class="dieline-panel" data-face="' + (p.face || '') + '" data-panel="' + i + '" fill="' + panelFill + '" points="' + points + '"/>';
+      const picked = p.face && p.face === state.selectedFace ? ' is-picked' : '';
+      body += '<polygon class="dieline-panel' + picked + '" data-face="' + (p.face || '') + '" data-panel="' + i + '" fill="' + panelFill + '" points="' + points + '"/>';
       if (p.holes) {
       if (p.holes) {
         p.holes.forEach(function (ho, hi) {
         p.holes.forEach(function (ho, hi) {
           const c = off(ho.x, ho.y);
           const c = off(ho.x, ho.y);
           art += '<circle cx="' + c[0].toFixed(2) + '" cy="' + c[1].toFixed(2) + '" r="' + ho.r + '" fill="#fff" stroke="#c2451f" stroke-width="0.5"/>';
           art += '<circle cx="' + c[0].toFixed(2) + '" cy="' + c[1].toFixed(2) + '" r="' + ho.r + '" fill="#fff" stroke="#c2451f" stroke-width="0.5"/>';
           if (!opts.clean) {
           if (!opts.clean) {
-            // 圆心十字定位线(超出孔径 2.5mm)+ 孔径标注
+            // 圆心十字定位线(超出孔径 2.5mm)+ 孔径标注;标注放在镜像组外,避免文字反写
             const ext = ho.r + 2.5;
             const ext = ho.r + 2.5;
-            art += '<g class="dieline-dim">' +
-              '<path d="M' + (c[0] - ext).toFixed(2) + ' ' + c[1].toFixed(2) + 'H' + (c[0] + ext).toFixed(2) + '"/>' +
-              '<path d="M' + c[0].toFixed(2) + ' ' + (c[1] - ext).toFixed(2) + 'V' + (c[1] + ext).toFixed(2) + '"/>' +
-              '<circle cx="' + c[0].toFixed(2) + '" cy="' + c[1].toFixed(2) + '" r="0.5" fill="#c2451f" stroke="none"/>' +
+            const mx = inner ? vbW - c[0] : c[0];
+            notes += '<g class="dieline-dim">' +
+              '<path d="M' + (mx - ext).toFixed(2) + ' ' + c[1].toFixed(2) + 'H' + (mx + ext).toFixed(2) + '"/>' +
+              '<path d="M' + mx.toFixed(2) + ' ' + (c[1] - ext).toFixed(2) + 'V' + (c[1] + ext).toFixed(2) + '"/>' +
+              '<circle cx="' + mx.toFixed(2) + '" cy="' + c[1].toFixed(2) + '" r="0.5" fill="#c2451f" stroke="none"/>' +
               '</g>' +
               '</g>' +
-              '<text class="dieline-dim" x="' + (c[0] + ext + 1.2).toFixed(2) + '" y="' + (c[1] - 0.8).toFixed(2) + '" font-size="' + Math.max(4, Math.min(6, ho.r * 1.1)) + '" fill="#c2451f">Ø' + (ho.r * 2).toFixed(1) + ' 开孔</text>';
+              '<text data-ui="1" class="dieline-dim" x="' + (inner ? mx - ext - 1.2 : mx + ext + 1.2).toFixed(2) + '" y="' + (c[1] - 0.8).toFixed(2) + '" text-anchor="' + (inner ? 'end' : 'start') + '" font-size="' + Math.max(4, Math.min(6, ho.r * 1.1)) + '" fill="#c2451f">Ø' + (ho.r * 2).toFixed(1) + ' 开孔</text>';
           }
           }
         });
         });
       }
       }
@@ -612,7 +626,7 @@
           itemHits += '<g clip-path="url(#' + cid + ')"><g transform="' + tx + '">' + r.hit + '</g></g>';
           itemHits += '<g clip-path="url(#' + cid + ')"><g transform="' + tx + '">' + r.hit + '</g></g>';
         });
         });
         const cx = off(b.x + b.w / 2, b.y + b.h / 2);
         const cx = off(b.x + b.w / 2, b.y + b.h / 2);
-        if (state.showLines && !opts.clean) art += '<text class="dieline-face-label" x="' + cx[0] + '" y="' + (cx[1] + 1) + '" text-anchor="middle">' + faceName(p.face) + '</text>';
+        if (state.showLines && !opts.clean) notes += '<text data-ui="1" class="dieline-face-label" x="' + (inner ? vbW - cx[0] : cx[0]) + '" y="' + (cx[1] + 1) + '" text-anchor="middle">' + faceName(p.face) + '</text>';
         hit += '<polygon class="dieline-hit" data-face="' + p.face + '" points="' + points + '" fill="transparent"/>';
         hit += '<polygon class="dieline-hit" data-face="' + p.face + '" points="' + points + '" fill="transparent"/>';
       }
       }
     });
     });
@@ -628,9 +642,9 @@
       const dimTop = pad, dimBottom = pad + dl.size.h;
       const dimTop = pad, dimBottom = pad + dl.size.h;
       dims =
       dims =
         '<g class="dieline-dim"><path d="M' + (pad - 8) + ' ' + dimTop + 'V' + dimBottom + '"/><path d="M' + (pad - 11) + ' ' + dimTop + 'h6M' + (pad - 11) + ' ' + dimBottom + 'h6"/></g>' +
         '<g class="dieline-dim"><path d="M' + (pad - 8) + ' ' + dimTop + 'V' + dimBottom + '"/><path d="M' + (pad - 11) + ' ' + dimTop + 'h6M' + (pad - 11) + ' ' + dimBottom + 'h6"/></g>' +
-        '<text class="dieline-label" x="' + (pad - 14) + '" y="' + ((dimTop + dimBottom) / 2) + '" text-anchor="middle" transform="rotate(-90 ' + (pad - 14) + ' ' + ((dimTop + dimBottom) / 2) + ')">' + Math.round(dl.size.h) + ' mm</text>' +
+        '<text data-ui="1" class="dieline-label" x="' + (pad - 14) + '" y="' + ((dimTop + dimBottom) / 2) + '" text-anchor="middle" transform="rotate(-90 ' + (pad - 14) + ' ' + ((dimTop + dimBottom) / 2) + ')">' + Math.round(dl.size.h) + ' mm</text>' +
         '<g class="dieline-dim"><path d="M' + pad + ' ' + (dimBottom + 10) + 'H' + (pad + dl.size.w) + '"/><path d="M' + pad + ' ' + (dimBottom + 7) + 'v6M' + (pad + dl.size.w) + ' ' + (dimBottom + 7) + 'v6"/></g>' +
         '<g class="dieline-dim"><path d="M' + pad + ' ' + (dimBottom + 10) + 'H' + (pad + dl.size.w) + '"/><path d="M' + pad + ' ' + (dimBottom + 7) + 'v6M' + (pad + dl.size.w) + ' ' + (dimBottom + 7) + 'v6"/></g>' +
-        '<text class="dieline-label" x="' + (pad + dl.size.w / 2) + '" y="' + (dimBottom + 22) + '" text-anchor="middle">' + Math.round(dl.size.w) + ' mm</text>';
+        '<text data-ui="1" class="dieline-label" x="' + (pad + dl.size.w / 2) + '" y="' + (dimBottom + 22) + '" text-anchor="middle">' + Math.round(dl.size.w) + ' mm</text>';
       // 每个印刷面内标注该面的宽 × 高(mm);poly 面(梯形盖等)动态算外接框、文字置于底部
       // 每个印刷面内标注该面的宽 × 高(mm);poly 面(梯形盖等)动态算外接框、文字置于底部
       const FACE_NAMES = { front: '正面', back: '背面', left: '左', right: '右', top: '顶', bottom: '底' };
       const FACE_NAMES = { front: '正面', back: '背面', left: '左', right: '右', top: '顶', bottom: '底' };
       dl.panels.forEach(function (p) {
       dl.panels.forEach(function (p) {
@@ -650,18 +664,21 @@
         const fs = Math.max(4.2, Math.min(8, bw / 9));
         const fs = Math.max(4.2, Math.min(8, bw / 9));
         const label = FACE_NAMES[p.face] ? FACE_NAMES[p.face] + ' ' : '';
         const label = FACE_NAMES[p.face] ? FACE_NAMES[p.face] + ' ' : '';
         const cy = isPoly ? by + bh - fs * 0.9 : by + bh / 2;
         const cy = isPoly ? by + bh - fs * 0.9 : by + bh / 2;
-        dims += '<text class="dieline-dim" x="' + cx.toFixed(1) + '" y="' + cy.toFixed(1) + '" text-anchor="middle" font-size="' + fs.toFixed(1) + '" fill="#6f6a5e" opacity="0.9">' + label + Math.round(bw) + ' × ' + Math.round(bh) + '</text>';
+        dims += '<text data-ui="1" class="dieline-dim" x="' + (inner ? vbW - cx : cx).toFixed(1) + '" y="' + cy.toFixed(1) + '" text-anchor="middle" font-size="' + fs.toFixed(1) + '" fill="#6f6a5e" opacity="0.9">' + label + Math.round(bw) + ' × ' + Math.round(bh) + '</text>';
       });
       });
       if (bleed) {
       if (bleed) {
         dims += '<rect class="dieline-bleed" x="' + (pad - bleed) + '" y="' + (pad - bleed) + '" width="' + (dl.size.w + bleed * 2) + '" height="' + (dl.size.h + bleed * 2) + '"/>';
         dims += '<rect class="dieline-bleed" x="' + (pad - bleed) + '" y="' + (pad - bleed) + '" width="' + (dl.size.w + bleed * 2) + '" height="' + (dl.size.h + bleed * 2) + '"/>';
       }
       }
     }
     }
-    const legend = opts.clean ? '' : '<g><line x1="' + (pad + 70) + '" y1="' + (pad + dl.size.h + 32) + '" x2="' + (pad + 94) + '" y2="' + (pad + dl.size.h + 32) + '" stroke="#c2451f" stroke-width="0.6"/><text class="dieline-cut-label" x="' + (pad + 100) + '" y="' + (pad + dl.size.h + 33) + '">裁切线</text></g>' +
-      '<g><line class="dieline-fold" x1="' + (pad + 6) + '" y1="' + (pad + dl.size.h + 32) + '" x2="' + (pad + 30) + '" y2="' + (pad + dl.size.h + 32) + '"/><text class="dieline-cut-label" x="' + (pad + 36) + '" y="' + (pad + dl.size.h + 33) + '">折叠线</text></g>' +
-      '<g><rect x="' + (pad + 170) + '" y="' + (pad + dl.size.h + 27) + '" width="24" height="10" fill="url(#accPat)" stroke="#c9bfae" stroke-width="0.5"/><text class="dieline-cut-label" x="' + (pad + 200) + '" y="' + (pad + dl.size.h + 33) + '">防尘翼/插舌(不印刷)</text></g>' +
-      '<text class="dieline-cut-label" x="' + (pad + 330) + '" y="' + (pad + dl.size.h + 33) + '">' + (inner ? '内侧设计 · 镜像' : '外侧设计') + ' · 模型ID ' + state.boxNo + '</text>';
+    const legend = opts.clean ? '' : '<g><line x1="' + (pad + 70) + '" y1="' + (pad + dl.size.h + 32) + '" x2="' + (pad + 94) + '" y2="' + (pad + dl.size.h + 32) + '" stroke="#c2451f" stroke-width="0.6"/><text data-ui="1" class="dieline-cut-label" x="' + (pad + 100) + '" y="' + (pad + dl.size.h + 33) + '">裁切线</text></g>' +
+      '<g><line class="dieline-fold" x1="' + (pad + 6) + '" y1="' + (pad + dl.size.h + 32) + '" x2="' + (pad + 30) + '" y2="' + (pad + dl.size.h + 32) + '"/><text data-ui="1" class="dieline-cut-label" x="' + (pad + 36) + '" y="' + (pad + dl.size.h + 33) + '">折叠线</text></g>' +
+      '<g><rect x="' + (pad + 170) + '" y="' + (pad + dl.size.h + 27) + '" width="24" height="10" fill="url(#' + uid + '-acc)" stroke="#c9bfae" stroke-width="0.5"/><text data-ui="1" class="dieline-cut-label" x="' + (pad + 200) + '" y="' + (pad + dl.size.h + 33) + '">防尘翼/插舌(不印刷)</text></g>' +
+      '<text data-ui="1" class="dieline-cut-label" x="' + (pad + 330) + '" y="' + (pad + dl.size.h + 33) + '">' + (inner ? '内侧设计 · 镜像' : '外侧设计') + ' · 模型ID ' + state.boxNo + '</text>';
     const mirror = inner ? ' transform="translate(' + vbW + ',0) scale(-1,1)"' : '';
     const mirror = inner ? ' transform="translate(' + vbW + ',0) scale(-1,1)"' : '';
-    return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ' + vbW + ' ' + vbH + '"><defs>' + defs + '</defs><g' + mirror + '>' + body + foldBody + art + hit + itemHits + dims + legend + '</g></svg>';
+    // 只有几何与画面内容参与镜像;文字标注、尺寸、图例放在镜像组外,保持可读
+    return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ' + vbW + ' ' + vbH + '"><defs>' + defs + '</defs>' +
+      '<g' + mirror + '>' + body + foldBody + art + hit + itemHits + '</g>' +
+      notes + dims + legend + '</svg>';
   }
   }
 
 
   /* ---------------- 保存 / 方案 ---------------- */
   /* ---------------- 保存 / 方案 ---------------- */
@@ -783,10 +800,21 @@
   function fit2d() {
   function fit2d() {
     const stage = $('#bxFlat');
     const stage = $('#bxFlat');
     const dl = dieline();
     const dl = dieline();
-    const availW = Math.max(200, stage.clientWidth - 120);
+    // 窄屏下左右面板改为悬浮覆盖,需按可视区(扣除面板遮挡)居中,避免刀版被面板盖住
+    const stageRect = stage.getBoundingClientRect();
+    let occlL = 0, occlR = 0;
+    const panelEl = document.querySelector('.bx-panel');
+    const propsEl = document.querySelector('.bx-props');
+    if (panelEl && getComputedStyle(panelEl).position === 'absolute') {
+      occlL = Math.max(0, Math.min(stage.clientWidth, panelEl.getBoundingClientRect().right - stageRect.left));
+    }
+    if (propsEl && getComputedStyle(propsEl).position === 'absolute') {
+      occlR = Math.max(0, Math.min(stage.clientWidth - occlL, stageRect.right - propsEl.getBoundingClientRect().left));
+    }
+    const availW = Math.max(160, stage.clientWidth - occlL - occlR - 80);
     const availH = Math.max(200, stage.clientHeight - 120);
     const availH = Math.max(200, stage.clientHeight - 120);
     state.view2d.zoom = clamp(Math.min(availW / dl.size.w, availH / dl.size.h), 0.1, 2.4);
     state.view2d.zoom = clamp(Math.min(availW / dl.size.w, availH / dl.size.h), 0.1, 2.4);
-    state.view2d.panX = 0;
+    state.view2d.panX = Math.round((occlL - occlR) / 2);
     state.view2d.panY = 0;
     state.view2d.panY = 0;
     renderDieline();
     renderDieline();
   }
   }
@@ -808,7 +836,6 @@
     state.selectedItemId = it.id;
     state.selectedItemId = it.id;
     UI.message.success('素材已添加到「' + faceName(state.selectedFace) + '」');
     UI.message.success('素材已添加到「' + faceName(state.selectedFace) + '」');
     commit();
     commit();
-    setTab('layers');
   }
   }
 
 
   function panelBox() {
   function panelBox() {
@@ -1204,7 +1231,6 @@
     face.items.push(it);
     face.items.push(it);
     state.selectedItemId = it.id;
     state.selectedItemId = it.id;
     commit();
     commit();
-    setTab('layers');
   }
   }
 
 
   /* ---- 工具面板(条码 + 二维码) ---- */
   /* ---- 工具面板(条码 + 二维码) ---- */
@@ -1316,13 +1342,29 @@
   function uploadPanel() {
   function uploadPanel() {
     const used = storageUsed();
     const used = storageUsed();
     const pct = Math.min(100, used / (100 * 1024 * 1024) * 100);
     const pct = Math.min(100, used / (100 * 1024 * 1024) * 100);
+    const uploads = state.uploads || [];
     return h('div', null,
     return h('div', null,
       h(A.Upload, {
       h(A.Upload, {
         accept: 'image/*', showUploadList: false, customRequest: uploadToFace,
         accept: 'image/*', showUploadList: false, customRequest: uploadToFace,
         children: h('button', { className: 'bx-primary-btn' }, '上传图片')
         children: h('button', { className: 'bx-primary-btn' }, '上传图片')
       }),
       }),
       h('div', { className: 'p-hint' }, '支持上传JPG/PNG/SVG等格式文件'),
       h('div', { className: 'p-hint' }, '支持上传JPG/PNG/SVG等格式文件'),
-      h('div', { className: 'bx-upload-empty' },
+      uploads.length ? h('div', { className: 'bx-upload-grid' }, uploads.map(function (u) {
+        return h('div', { key: u.id, className: 'bx-upload-card' },
+          h('button', {
+            className: 'thumb', title: '添加到当前面',
+            onClick: function () { addAssetToFace({ type: 'image', name: u.name, src: u.src, w: 70 }); }
+          }, h('img', { src: u.src, alt: u.name })),
+          h('span', { className: 'nm', title: u.name }, u.name),
+          h('button', {
+            className: 'del', title: '从上传记录中移除',
+            onClick: function () {
+              state.uploads = (state.uploads || []).filter(function (x) { return x.id !== u.id; });
+              commit();
+            }
+          }, '✕')
+        );
+      })) : h('div', { className: 'bx-upload-empty' },
         h('div', { className: 'box-illus' }),
         h('div', { className: 'box-illus' }),
         h('span', null, '上传的稿件会放置到当前选中的面')
         h('span', null, '上传的稿件会放置到当前选中的面')
       ),
       ),
@@ -1343,7 +1385,7 @@
     reader.onload = function () {
     reader.onload = function () {
       const img = new Image();
       const img = new Image();
       img.onload = function () {
       img.onload = function () {
-        const max = 1400;
+        const max = 900;
         let w = img.width, hh = img.height;
         let w = img.width, hh = img.height;
         if (Math.max(w, hh) > max) {
         if (Math.max(w, hh) > max) {
           const k = max / Math.max(w, hh);
           const k = max / Math.max(w, hh);
@@ -1352,8 +1394,12 @@
         const canvas = document.createElement('canvas');
         const canvas = document.createElement('canvas');
         canvas.width = w; canvas.height = hh;
         canvas.width = w; canvas.height = hh;
         canvas.getContext('2d').drawImage(img, 0, 0, w, hh);
         canvas.getContext('2d').drawImage(img, 0, 0, w, hh);
-        const src = canvas.toDataURL(file.type === 'image/png' ? 'image/png' : 'image/jpeg', 0.88);
+        const src = canvas.toDataURL(file.type === 'image/png' ? 'image/png' : 'image/jpeg', 0.84);
+        // 保留上传记录,便于重复使用;最多保留 8 张,避免 localStorage 超限
+        const up = { id: 'u' + Date.now().toString(36) + Math.random().toString(36).slice(2, 5), name: file.name, src: src, time: Date.now() };
+        state.uploads = [up].concat(state.uploads || []).slice(0, 8);
         addAssetToFace({ type: 'image', name: file.name, src: src, w: 70 });
         addAssetToFace({ type: 'image', name: file.name, src: src, w: 70 });
+        if (currentTab === 'upload') renderTool();
       };
       };
       img.src = reader.result;
       img.src = reader.result;
     };
     };
@@ -1365,7 +1411,10 @@
     const face = curFace();
     const face = curFace();
     const items = (face.items || []).slice().reverse();
     const items = (face.items || []).slice().reverse();
     return h('div', null,
     return h('div', null,
-      h('div', { className: 'bx-sec-title' }, faceName(state.selectedFace) + ' · ' + items.length + ' 个图层'),
+      h('div', { className: 'bx-layer-head' },
+        h('div', { className: 'bx-sec-title' }, faceName(state.selectedFace) + ' · ' + items.length + ' 个图层'),
+        items.length ? h('button', { className: 'bx-layer-clear', onClick: clearLayers }, '一键清空') : null
+      ),
       items.length ? h('div', { className: 'bx-layer-list' }, items.map(function (it) {
       items.length ? h('div', { className: 'bx-layer-list' }, items.map(function (it) {
         const typeNames = { text: '文字', image: '图片', asset: '素材', barcode: it.codeType === 'qrcode' ? '二维码' : '条形码' };
         const typeNames = { text: '文字', image: '图片', asset: '素材', barcode: it.codeType === 'qrcode' ? '二维码' : '条形码' };
         return h('div', { key: it.id, className: 'bx-layer-row' + (state.selectedItemId === it.id ? ' on' : ''), 'data-layer-id': it.id },
         return h('div', { key: it.id, className: 'bx-layer-row' + (state.selectedItemId === it.id ? ' on' : ''), 'data-layer-id': it.id },
@@ -1383,6 +1432,44 @@
       )
       )
     );
     );
   }
   }
+  function clearLayers() {
+    const face = curFace();
+    const count = (face.items || []).length;
+    let total = 0;
+    FACES.forEach(function (ff) { total += (curFaces()[ff.id].items || []).length; });
+    if (!total) return;
+    let close;
+    close = mountModal(h(A.Modal, {
+      title: '清空图层', open: true, footer: null, onCancel: function () { close(); }
+    }, h('div', null,
+      h('p', null, '当前面有 ' + count + ' 个图层,全部面共 ' + total + ' 个图层。'),
+      h('div', { className: 'bx-clear-actions' },
+        h('button', {
+          className: 'bx-clear-opt', disabled: !count,
+          onClick: function () {
+            pushUndo();
+            face.items = [];
+            state.selectedItemId = null;
+            commit();
+            close();
+            UI.message.success('已清空「' + faceName(state.selectedFace) + '」图层');
+          }
+        }, '清空当前面(' + count + ')'),
+        h('button', {
+          className: 'bx-clear-opt danger',
+          onClick: function () {
+            pushUndo();
+            FACES.forEach(function (ff) { curFaces()[ff.id].items = []; });
+            state.selectedItemId = null;
+            commit();
+            close();
+            UI.message.success('已清空全部面图层');
+          }
+        }, '清空全部面(' + total + ')')
+      ),
+      h('div', { className: 'p-hint', style: { marginTop: '10px' } }, '清空后可通过 Ctrl+Z 撤销。')
+    )));
+  }
   function findItem(id) {
   function findItem(id) {
     const face = curFace();
     const face = curFace();
     return (face.items || []).find(function (x) { return x.id === id; }) || null;
     return (face.items || []).find(function (x) { return x.id === id; }) || null;
@@ -1541,7 +1628,13 @@
         }),
         }),
         h('div', { className: 'bx-row2' },
         h('div', { className: 'bx-row2' },
           h('div', { className: 'p-field' }, h('label', null, '字号 (mm)'), h(A.InputNumber, { value: item.size, min: 2, max: 120, style: { width: '100%' }, onChange: function (v) { if (v) { item.size = v; commit(); } } })),
           h('div', { className: 'p-field' }, h('label', null, '字号 (mm)'), h(A.InputNumber, { value: item.size, min: 2, max: 120, style: { width: '100%' }, onChange: function (v) { if (v) { item.size = v; commit(); } } })),
-          h('div', { className: 'p-field' }, h('label', null, '颜色'), h(A.ColorPicker, { value: item.color || '#17140f', showText: true, onChange: function (c) { item.color = c.toHexString(); commit(); } }))
+          h('div', { className: 'p-field' }, h('label', null, '颜色'), h(A.ColorPicker, {
+            key: 'tc-' + item.id,
+            defaultValue: item.color || '#17140f',
+            showText: true,
+            onChange: function (c) { item.color = c.toHexString(); save(true); renderDieline(); render3d(); renderMini(); },
+            onChangeComplete: function (c) { item.color = c.toHexString(); commit(); }
+          }))
         ),
         ),
         h('div', { className: 'bx-row2' },
         h('div', { className: 'bx-row2' },
           h('div', { className: 'p-field' }, h('label', null, '对齐'), h(A.Segmented, { value: item.align || 'center', block: true, options: [{ label: '左', value: 'left' }, { label: '中', value: 'center' }, { label: '右', value: 'right' }], onChange: function (v) { item.align = v; commit(); } })),
           h('div', { className: 'p-field' }, h('label', null, '对齐'), h(A.Segmented, { value: item.align || 'center', block: true, options: [{ label: '左', value: 'left' }, { label: '中', value: 'center' }, { label: '右', value: 'right' }], onChange: function (v) { item.align = v; commit(); } })),
@@ -1658,10 +1751,11 @@
     UI.render(div, node);
     UI.render(div, node);
     return close;
     return close;
   }
   }
-  function modalConfirm(title, content, onOk, okText) {
+  function modalConfirm(title, content, onOk, okText, width) {
     let close;
     let close;
     close = mountModal(h(A.Modal, {
     close = mountModal(h(A.Modal, {
       title: title, open: true, onCancel: function () { close(); },
       title: title, open: true, onCancel: function () { close(); },
+      width: width || undefined,
       okText: okText || '确认调整',
       okText: okText || '确认调整',
       onOk: function () { if (onOk) onOk(); close(); },
       onOk: function () { if (onOk) onOk(); close(); },
       okButtonProps: { style: { background: '#ff6a00', borderColor: '#ff6a00' } }
       okButtonProps: { style: { background: '#ff6a00', borderColor: '#ff6a00' } }
@@ -1745,7 +1839,7 @@
       Object.assign(state.smart, params);
       Object.assign(state.smart, params);
       commit();
       commit();
       UI.message.success('参数已调整,刀版与 3D 已更新');
       UI.message.success('参数已调整,刀版与 3D 已更新');
-    }, '确认调整');
+    }, '确认调整', 980);
 
 
     function renderSmart() {
     function renderSmart() {
       const keep = { w: state.w, d: state.d, h: state.h, smart: state.smart };
       const keep = { w: state.w, d: state.d, h: state.h, smart: state.smart };
@@ -1792,6 +1886,24 @@
     const div = document.createElement('div');
     const div = document.createElement('div');
     $('#bxModals').appendChild(div);
     $('#bxModals').appendChild(div);
     const close = function () { UI.reset(div); div.remove(); renderAll(); };
     const close = function () { UI.reset(div); div.remove(); renderAll(); };
+    let snapRaf = null;
+    // 导出弹窗内的静态 3D 快照;用当前设计实时渲染,避免预览空白
+    function snapSrc(w, h) {
+      if (!main3d || !main3d.ready()) return '';
+      try {
+        main3d.render(state, material(), currentPanels());
+        main3d.setFold(foldValue / 100);
+        return main3d.snapshot(w, h, exportBg === 'transparent');
+      } catch (e) { return ''; }
+    }
+    function refreshSnap() {
+      if (snapRaf) return;
+      snapRaf = requestAnimationFrame(function () {
+        snapRaf = null;
+        const im = div.querySelector('.ex-preview.3d .ex-snap');
+        if (im) im.src = snapSrc(760, 480);
+      });
+    }
 
 
     function renderExport() {
     function renderExport() {
       let body;
       let body;
@@ -1821,10 +1933,12 @@
         const ratio = { '16:9': 16 / 9, '4:3': 4 / 3, '1:1': 1 }[exportRatio];
         const ratio = { '16:9': 16 / 9, '4:3': 4 / 3, '1:1': 1 }[exportRatio];
         const rw = Math.round(Math.min(dims[0], dims[1] * ratio));
         const rw = Math.round(Math.min(dims[0], dims[1] * ratio));
         const rh = Math.round(rw / ratio);
         const rh = Math.round(rw / ratio);
+        const pv = snapSrc(760, 480);
         body = h('div', { className: 'ex-file-body' },
         body = h('div', { className: 'ex-file-body' },
           h('div', { className: 'ex-preview 3d' },
           h('div', { className: 'ex-preview 3d' },
+            pv ? h('img', { className: 'ex-snap', src: pv, alt: '' }) : h('div', { className: 'ex-preview-empty' }, '3D 预览加载中…'),
             h('div', { className: 'ex-fold-row' },
             h('div', { className: 'ex-fold-row' },
-              h('span', null, '开'), h('input', { type: 'range', min: 0, max: 100, value: Math.round(foldValue), onInput: function (e) { setFold(Number(e.target.value)); } }), h('span', null, '合')
+              h('span', null, '开'), h('input', { type: 'range', min: 0, max: 100, value: Math.round(foldValue), onInput: function (e) { setFold(Number(e.target.value)); refreshSnap(); } }), h('span', null, '合')
             )
             )
           ),
           ),
           h('div', { className: 'ex-side' },
           h('div', { className: 'ex-side' },
@@ -1840,8 +1954,9 @@
           )
           )
         );
         );
       } else {
       } else {
+        const pvVid = snapSrc(760, 480);
         body = h('div', { className: 'ex-file-body' },
         body = h('div', { className: 'ex-file-body' },
-          h('div', { className: 'ex-preview 3d' }),
+          h('div', { className: 'ex-preview 3d' }, pvVid ? h('img', { className: 'ex-snap', src: pvVid, alt: '' }) : null),
           h('div', { className: 'ex-side' },
           h('div', { className: 'ex-side' },
             h('div', { className: 'ex-anim-grid' }, LB.ANIMS.map(function (a) {
             h('div', { className: 'ex-anim-grid' }, LB.ANIMS.map(function (a) {
               return h('button', { key: a.id, className: 'ex-anim' + (exportAnim === a.id ? ' on' : ''), onClick: function () { exportAnim = a.id; renderExport(); } },
               return h('button', { key: a.id, className: 'ex-anim' + (exportAnim === a.id ? ' on' : ''), onClick: function () { exportAnim = a.id; renderExport(); } },
@@ -1859,8 +1974,7 @@
             [['file', '设计文件'], ['image', '效果图'], ['video', '视频']].map(function (t) {
             [['file', '设计文件'], ['image', '效果图'], ['video', '视频']].map(function (t) {
               return h('button', { key: t[0], className: exportTab === t[0] ? 'on' : '', onClick: function () { exportTab = t[0]; renderExport(); } }, t[1]);
               return h('button', { key: t[0], className: exportTab === t[0] ? 'on' : '', onClick: function () { exportTab = t[0]; renderExport(); } }, t[1]);
             }),
             }),
-            h('button', { className: 'ex-log-btn', onClick: showExportLog }, '⏱ 导出记录'),
-            h('button', { className: 'ex-close', onClick: close }, '✕')
+            h('button', { className: 'ex-log-btn', onClick: showExportLog }, '⏱ 导出记录')
           ),
           ),
           body
           body
         )
         )
@@ -1937,25 +2051,36 @@
     const rh = Math.round(rw / ratio);
     const rh = Math.round(rw / ratio);
     const wasMode = state.mode;
     const wasMode = state.mode;
     if (wasMode !== '3d') setMode('3d');
     if (wasMode !== '3d') setMode('3d');
-    const url = main3d.snapshot(rw, rh, exportBg === 'transparent');
-    const img = new Image();
-    img.onload = function () {
-      const c = document.createElement('canvas');
-      c.width = rw; c.height = rh;
-      const ctx = c.getContext('2d');
-      if (exportBg !== 'transparent') {
-        const g = ctx.createLinearGradient(0, 0, 0, rh);
-        g.addColorStop(0, '#f3f1ec'); g.addColorStop(1, '#e7e4dd');
-        ctx.fillStyle = g; ctx.fillRect(0, 0, rw, rh);
+    main3d.render(state, material(), currentPanels());
+    main3d.setFold(foldValue / 100);
+    if (UI.message.loading) UI.message.loading({ content: '正在渲染 ' + exportRes.toUpperCase() + ' 效果图…', key: 'boxhd', duration: 0 });
+    const grab = function () {
+      const url = main3d.snapshot(rw, rh, exportBg === 'transparent');
+      if (!url || url.length < 1000) {
+        setTimeout(grab, 220);
+        return;
       }
       }
-      ctx.drawImage(img, 0, 0, rw, rh);
-      c.toBlob(function (b) {
-        downloadBlob(b, state.name + '-' + exportRes.toUpperCase() + '.png');
-        logExport('效果图', state.name + ' ' + exportRes.toUpperCase());
-        UI.message.success(exportRes.toUpperCase() + ' 效果图已下载');
-      }, 'image/png');
+      const img = new Image();
+      img.onload = function () {
+        const c = document.createElement('canvas');
+        c.width = rw; c.height = rh;
+        const ctx = c.getContext('2d');
+        if (exportBg !== 'transparent') {
+          const g = ctx.createLinearGradient(0, 0, 0, rh);
+          g.addColorStop(0, '#f3f1ec'); g.addColorStop(1, '#e7e4dd');
+          ctx.fillStyle = g; ctx.fillRect(0, 0, rw, rh);
+        }
+        ctx.drawImage(img, 0, 0, rw, rh);
+        c.toBlob(function (b) {
+          downloadBlob(b, state.name + '-' + exportRes.toUpperCase() + '.png');
+          logExport('效果图', state.name + ' ' + exportRes.toUpperCase());
+          UI.message.success({ content: exportRes.toUpperCase() + ' 效果图已下载', key: 'boxhd' });
+        }, 'image/png');
+      };
+      img.src = url;
     };
     };
-    img.src = url;
+    // 等贴图/字体加载完成后再截图,避免 4K 图空白
+    setTimeout(function () { requestAnimationFrame(function () { requestAnimationFrame(grab); }); }, 320);
   }
   }
   function exportVideo() {
   function exportVideo() {
     if (!main3d || !main3d.ready()) { UI.message.warning('3D 渲染器未就绪'); return; }
     if (!main3d || !main3d.ready()) { UI.message.warning('3D 渲染器未就绪'); return; }
@@ -2131,13 +2256,25 @@
                   dieline: dlJson,
                   dieline: dlJson,
                   previews: {}
                   previews: {}
                 };
                 };
+                // 3D 效果图随订单一起提交,订单列表/详情可直接看到设计效果
+                let boxShot = '';
+                if (main3d && main3d.ready()) {
+                  try {
+                    main3d.render(state, material(), currentPanels());
+                    main3d.setFold(foldValue / 100);
+                    boxShot = main3d.snapshot(1200, 900, false);
+                  } catch (e) { boxShot = ''; }
+                }
                 PL.api.svgToPng(dielineSVG({ clean: true, noLegend: true }), 1200).then(function (png) {
                 PL.api.svgToPng(dielineSVG({ clean: true, noLegend: true }), 1200).then(function (png) {
                   payload.previews = { dieline: png };
                   payload.previews = { dieline: png };
-                }, function () {}).then(function () {
+                  if (boxShot) payload.previews.box3d = boxShot;
+                }, function () {
+                  if (boxShot) payload.previews.box3d = boxShot;
+                }).then(function () {
                   return PL.api.post('/orders', payload, { timeout: 60000 });
                   return PL.api.post('/orders', payload, { timeout: 60000 });
                 }).then(function (r) {
                 }).then(function (r) {
                   const orders = JSON.parse(localStorage.getItem('pouchlab.box.orders') || '[]');
                   const orders = JSON.parse(localStorage.getItem('pouchlab.box.orders') || '[]');
-                  orders.unshift({ no: r.orderNo, time: Date.now(), name: state.name, qty: state.qty, total: price.total, boxNo: state.boxNo });
+                  orders.unshift({ no: r.orderNo, time: Date.now(), name: state.name, qty: state.qty, total: price.total, boxNo: state.boxNo, type: 'box', summary: payload.summary, previews: payload.previews });
                   localStorage.setItem('pouchlab.box.orders', JSON.stringify(orders.slice(0, 30)));
                   localStorage.setItem('pouchlab.box.orders', JSON.stringify(orders.slice(0, 30)));
                   UI.reset(div); div.remove();
                   UI.reset(div); div.remove();
                   modalInfo('下单成功', h('div', { className: 'bx-help-steps' },
                   modalInfo('下单成功', h('div', { className: 'bx-help-steps' },
@@ -2154,7 +2291,7 @@
                     // 离线回退:沿用旧的本地保存
                     // 离线回退:沿用旧的本地保存
                     const orderNo = 'PL' + Date.now().toString().slice(-10);
                     const orderNo = 'PL' + Date.now().toString().slice(-10);
                     const orders = JSON.parse(localStorage.getItem('pouchlab.box.orders') || '[]');
                     const orders = JSON.parse(localStorage.getItem('pouchlab.box.orders') || '[]');
-                    orders.unshift({ no: orderNo, time: Date.now(), name: state.name, qty: state.qty, total: price.total, boxNo: state.boxNo });
+                    orders.unshift({ no: orderNo, time: Date.now(), name: state.name, qty: state.qty, total: price.total, boxNo: state.boxNo, type: 'box', summary: payload.summary, previews: payload.previews, offline: true });
                     localStorage.setItem('pouchlab.box.orders', JSON.stringify(orders.slice(0, 30)));
                     localStorage.setItem('pouchlab.box.orders', JSON.stringify(orders.slice(0, 30)));
                     UI.reset(div); div.remove();
                     UI.reset(div); div.remove();
                     modalInfo('下单成功(离线保存)', h('div', { className: 'bx-help-steps' },
                     modalInfo('下单成功(离线保存)', h('div', { className: 'bx-help-steps' },
@@ -2265,7 +2402,8 @@
   function renderSideThumb() {
   function renderSideThumb() {
     const el = $('#bxSideThumb');
     const el = $('#bxSideThumb');
     if (el) {
     if (el) {
-      el.innerHTML = '<div class="side-thumb-svg">' + structThumbSvg(state.structure, state.boxNo) + '</div>';
+      // 使用真实设计稿缩略图,与 2D/3D 画面保持一致,并支持点击选面
+      el.innerHTML = '<div class="side-thumb-svg">' + dielineSVG({ clean: true, noLegend: true, idPrefix: 'side' }) + '</div>';
     }
     }
     const mid = $('#bxModelId');
     const mid = $('#bxModelId');
     if (mid) mid.textContent = '模型ID: ' + state.boxNo;
     if (mid) mid.textContent = '模型ID: ' + state.boxNo;
@@ -2592,65 +2730,118 @@
 
 
     // 2D 刀版元素拖拽(编辑在 2D 平铺上完成,迷你 3D 实时预览)
     // 2D 刀版元素拖拽(编辑在 2D 平铺上完成,迷你 3D 实时预览)
     const dielineEl = $('#boxDieline');
     const dielineEl = $('#boxDieline');
-    let itemDrag = null;
+    let itemDrag = null, lastDragAt = 0;
+    function svgLoc(svg, e) {
+      if (!svg) return null;
+      const ctm = svg.getScreenCTM();
+      if (!ctm) return null;
+      const pt = svg.createSVGPoint();
+      pt.x = e.clientX;
+      pt.y = e.clientY;
+      return pt.matrixTransform(ctm.inverse());
+    }
+    function locToPct(svg, loc, face) {
+      const dl = dieline();
+      const panel = dl.panels.find(function (p) { return p.face === face; });
+      if (!panel) return null;
+      const fb = panelBounds(panel);
+      const pad = 30 + (state.smart.bleed || 0);
+      const lx = state.side === 'inner' ? svg.viewBox.baseVal.width - loc.x : loc.x;
+      return {
+        x: (lx - pad + dl.minX - fb.x) / fb.w * 100,
+        y: (loc.y - pad + dl.minY - fb.y) / fb.h * 100
+      };
+    }
     dielineEl.addEventListener('pointerdown', function (e) {
     dielineEl.addEventListener('pointerdown', function (e) {
       const hitEl = e.target.closest('.bx-item-hit');
       const hitEl = e.target.closest('.bx-item-hit');
       if (!hitEl) return;
       if (!hitEl) return;
       e.preventDefault();
       e.preventDefault();
-      const it = findItem(hitEl.dataset.itemId);
+      const face = hitEl.dataset.itemFace || state.selectedFace;
+      // 元素可能位于未选中的面,按命中面查找,避免必须先点面再点文字
+      const faceObj = state.faces[state.side] && state.faces[state.side][face];
+      const it = faceObj && (faceObj.items || []).find(function (x) { return x.id === hitEl.dataset.itemId; });
       if (!it) return;
       if (!it) return;
+      const svg = dielineEl.querySelector('svg');
+      const loc = svgLoc(svg, e);
+      const pct = loc && locToPct(svg, loc, face);
       pushUndo();
       pushUndo();
       state.selectedItemId = it.id;
       state.selectedItemId = it.id;
-      state.selectedFace = hitEl.dataset.itemFace || state.selectedFace;
+      state.selectedFace = face;
       renderProps();
       renderProps();
       itemDrag = {
       itemDrag = {
-        it: it,
-        face: hitEl.dataset.itemFace,
-        svg: dielineEl.querySelector('svg'),
-        moved: false
+        id: it.id,
+        face: face,
+        // 记录抓取点相对元素中心的偏移,拖动时不再让元素跳到指针下
+        ox: pct ? pct.x - it.x : 0,
+        oy: pct ? pct.y - it.y : 0,
+        moved: false,
+        pointerId: e.pointerId
       };
       };
+      try { dielineEl.setPointerCapture(e.pointerId); } catch (err) {}
     });
     });
     dielineEl.addEventListener('pointermove', function (e) {
     dielineEl.addEventListener('pointermove', function (e) {
       if (!itemDrag) return;
       if (!itemDrag) return;
-      const svg = itemDrag.svg;
-      if (!svg) return;
-      const ctm = svg.getScreenCTM();
-      if (!ctm) return;
-      const pt = svg.createSVGPoint();
-      pt.x = e.clientX;
-      pt.y = e.clientY;
-      const loc = pt.matrixTransform(ctm.inverse());
-      const vb = svg.viewBox.baseVal;
-      let lx = loc.x;
-      if (state.side === 'inner') lx = vb.width - lx;
-      const pad = 30 + (state.smart.bleed || 0);
-      const dl = dieline();
-      const mmX = lx - pad + dl.minX;
-      const mmY = loc.y - pad + dl.minY;
-      const panel = dl.panels.find(function (p) { return p.face === itemDrag.face; });
-      if (!panel) return;
-      const fb = panelBounds(panel);
-      itemDrag.it.x = clamp(Math.round((mmX - fb.x) / fb.w * 100), 0, 100);
-      itemDrag.it.y = clamp(Math.round((mmY - fb.y) / fb.h * 100), 0, 100);
+      e.preventDefault();
+      const svg = dielineEl.querySelector('svg');
+      const loc = svgLoc(svg, e);
+      if (!loc) return;
+      const pct = locToPct(svg, loc, itemDrag.face);
+      const it = findItem(itemDrag.id);
+      if (!pct || !it) return;
+      const nx = clamp(pct.x - itemDrag.ox, 0, 100);
+      const ny = clamp(pct.y - itemDrag.oy, 0, 100);
+      if (Math.abs(nx - it.x) < 0.05 && Math.abs(ny - it.y) < 0.05) return;
+      it.x = Math.round(nx * 10) / 10;
+      it.y = Math.round(ny * 10) / 10;
       itemDrag.moved = true;
       itemDrag.moved = true;
       renderDieline();
       renderDieline();
+      if (mini3d && mini3d.ready()) { mini3d.render(state, material(), currentPanels()); mini3d.setFold(foldValue / 100); }
       if (main3d && main3d.ready()) { main3d.render(state, material(), currentPanels()); main3d.setFold(foldValue / 100); }
       if (main3d && main3d.ready()) { main3d.render(state, material(), currentPanels()); main3d.setFold(foldValue / 100); }
-      renderMini();
     });
     });
-    dielineEl.addEventListener('pointerup', function () {
+    dielineEl.addEventListener('pointerup', function (e) {
+      if (!itemDrag) return;
+      const wasMoved = itemDrag.moved;
+      try { dielineEl.releasePointerCapture(itemDrag.pointerId); } catch (err) {}
+      itemDrag = null;
+      if (wasMoved) {
+        lastDragAt = Date.now();
+        commit(false);
+        renderProps();
+        renderSideThumb();
+      }
+    });
+    dielineEl.addEventListener('pointercancel', function () {
       if (itemDrag) {
       if (itemDrag) {
-        if (itemDrag.moved) commit(false);
+        try { dielineEl.releasePointerCapture(itemDrag.pointerId); } catch (err) {}
         itemDrag = null;
         itemDrag = null;
       }
       }
     });
     });
-    $('#boxDieline').addEventListener('click', function (e) {
+    dielineEl.addEventListener('click', function (e) {
+      if (Date.now() - lastDragAt < 300) return;
       if (e.target.closest('.bx-item-hit')) return;
       if (e.target.closest('.bx-item-hit')) return;
       const f = e.target.closest('[data-face]');
       const f = e.target.closest('[data-face]');
       if (!f || !f.dataset.face) return;
       if (!f || !f.dataset.face) return;
       state.selectedFace = f.dataset.face;
       state.selectedFace = f.dataset.face;
       state.selectedItemId = null;
       state.selectedItemId = null;
       commit(false);
       commit(false);
-      setTab('layers');
+      // 选中面后让迷你 3D 自动转向该面,保持 2D/3D 视角一致
+      if (state.mode === '2d') {
+        if (miniAuto) setMiniAuto(false);
+        if (mini3d && mini3d.focusFace) mini3d.focusFace(f.dataset.face);
+      }
+    });
+    // 缩略图选面:与 2D 刀版同步
+    const sideThumbEl = $('#bxSideThumb');
+    sideThumbEl.addEventListener('click', function (e) {
+      const f = e.target.closest('[data-face]');
+      if (!f || !f.dataset.face) return;
+      state.selectedFace = f.dataset.face;
+      state.selectedItemId = null;
+      commit(false);
+      if (state.mode === '2d') {
+        if (miniAuto) setMiniAuto(false);
+        if (mini3d && mini3d.focusFace) mini3d.focusFace(f.dataset.face);
+      }
     });
     });
     // 滚轮缩放 2D
     // 滚轮缩放 2D
     flat.addEventListener('wheel', function (e) {
     flat.addEventListener('wheel', function (e) {
@@ -2698,8 +2889,8 @@
           state.selectedFace = face;
           state.selectedFace = face;
           state.selectedItemId = null;
           state.selectedItemId = null;
           commit(false);
           commit(false);
+          renderSideThumb();
           setMode('2d');
           setMode('2d');
-          setTab('layers');
         }
         }
       });
       });
       mini3d = window.PL.box3d.create($('#bxMiniStage'), {
       mini3d = window.PL.box3d.create($('#bxMiniStage'), {

+ 24 - 0
assets/js/box3d.js

@@ -862,6 +862,30 @@
       isAutoRotate: function () { return !!autoRotate; },
       isAutoRotate: function () { return !!autoRotate; },
       setZoom: function (z) { orbit.zoom = Math.max(0.4, Math.min(3.2, Number(z) || 1)); applyCamera(); flush(); },
       setZoom: function (z) { orbit.zoom = Math.max(0.4, Math.min(3.2, Number(z) || 1)); applyCamera(); flush(); },
       setLines: function (v) { showLines = v !== false; applyLines(); flush(); },
       setLines: function (v) { showLines = v !== false; applyLines(); flush(); },
+      // 自动转向指定面:2D 选中面时让 3D 视角同步
+      focusFace: function (face) {
+        const target = {
+          front: [0, Math.PI / 2], back: [Math.PI, Math.PI / 2],
+          right: [Math.PI / 2, Math.PI / 2], left: [-Math.PI / 2, Math.PI / 2],
+          top: [0, 0.32], bottom: [0, Math.PI - 0.32]
+        }[face];
+        if (!target) return;
+        const fromT = orbit.theta, fromP = orbit.phi;
+        let toT = target[0];
+        while (toT - fromT > Math.PI) toT -= Math.PI * 2;
+        while (toT - fromT < -Math.PI) toT += Math.PI * 2;
+        const dur = 420, t0 = performance.now();
+        function step(now) {
+          const p = Math.min(1, (now - t0) / dur);
+          const e = p < 0.5 ? 2 * p * p : 1 - Math.pow(-2 * p + 2, 2) / 2;
+          orbit.theta = fromT + (toT - fromT) * e;
+          orbit.phi = fromP + (target[1] - fromP) * e;
+          applyCamera();
+          flush();
+          if (p < 1) requestAnimationFrame(step);
+        }
+        requestAnimationFrame(step);
+      },
       resetView: function () {
       resetView: function () {
         orbit.theta = orbitHome.theta;
         orbit.theta = orbitHome.theta;
         orbit.phi = orbitHome.phi;
         orbit.phi = orbitHome.phi;

+ 1593 - 0
assets/js/i18n-en.js

@@ -0,0 +1,1593 @@
+/* 英文文案字典:中文为 key,英文为 value。只做整串精确匹配,避免误伤用户内容。 */
+window.PLI18N_EN = window.PLI18N_EN || { dict: {}, rules: [] };
+(function (D) {
+  Object.assign(D.dict, {
+    /* ---------- 站点通用 / 导航 ---------- */
+    "袋研社": "PouchLab",
+    "袋研社 POUCHLAB": "PouchLab",
+    "袋研社 POUCHLAB — 包装袋在线设计工作室": "POUCHLAB — Online Packaging Design Studio",
+    "产品中心": "Products",
+    "设计工作室": "Studio",
+    "模板灵感": "Templates",
+    "工艺材质": "Materials",
+    "纸盒设计": "Box Design",
+    "我的订单": "My Orders",
+    "登录": "Log in",
+    "主导航": "Main navigation",
+
+    /* ---------- 首页 ---------- */
+    "让你的包装袋": "Make your packaging",
+    "先被看见。": "seen first.",
+    "从袋型、刀版到成品效果,在线完成包装设计。100 个起订,小批量也能做出大品牌的质感。": "From pouch style to dieline to final look — design it all online. MOQ 100, so a small batch can still feel like a big brand.",
+    "品牌正在使用": "Trusted by brands",
+    "100 个": "100 pcs",
+    "起订": "MOQ",
+    "3D 实时预览已开启": "3D live preview on",
+    "200+ 袋型": "200+ pouch styles",
+    "48H 打样": "48h sampling",
+    "100% 可回收材质": "100% recyclable",
+    "免费刀版线": "Free dielines",
+    "3D 实时预览": "3D live preview",
+    "从一个袋型,": "Start with a pouch,",
+    "开始表达。": "start expressing.",
+    "六种常用袋型,覆盖咖啡、食品、茶、宠物、服饰与电商。每一种都提供精准刀版与真实样机。": "Six popular pouch styles for coffee, food, tea, pets, apparel and e-commerce — each with a precise dieline and a realistic mockup.",
+    "像设计师一样,": "Design packaging",
+    "在线做包装。": "like a pro, online.",
+    "不用安装软件。上传 Logo、挑选模板、拖拽排版,实时看到袋子上的印刷效果。刀版线、安全区、出血位,都已经替你算好。": "No software to install. Upload your logo, pick a template, drag to lay out and see the print live. Dielines, safe zones and bleed are all handled for you.",
+    "设计": "Design",
+    "预览": "Preview",
+    "下一步": "Next",
+    "已自动保存": "Autosaved",
+    "挑一个模板,": "Pick a template,",
+    "改改就能用。": "make it yours.",
+    "不止袋子,": "Not just pouches —",
+    "纸盒同样在线设计。": "boxes are online too.",
+    "卡纸折叠盒、磁吸书型盒、飞机盒、抽屉盒——选结构、改尺寸、配稿件,3D 立体预览与精确展开图同步生成,报价实时可算。": "Folding cartons, magnetic book-style boxes, mailer boxes, drawer boxes — pick a structure, set dimensions, add artwork. 3D previews and precise dielines generate together, with instant pricing.",
+    "4 种盒型": "4 box styles",
+    "标准刀版自动生成": "Standard dielines auto-generated",
+    "6 个面": "6 faces",
+    "逐面配色与稿件": "Per-face color & artwork",
+    "实时报价": "Instant pricing",
+    "按展开面积计算": "Based on flat area",
+    "开始设计纸盒": "Start box design",
+    "好看的背后,": "Behind the looks,",
+    "是": "is",
+    "认真的工艺。": "real craftsmanship.",
+    "从 300dpi 的印刷精度,到 3mm 的出血位;从哑光触感膜,到可堆肥的植物基材料。我们把这些看不见的细节,做成你拿在手里的质感。": "From 300dpi print to 3mm bleed; from soft-touch matte film to compostable plant-based materials. We turn the details you can't see into the quality you can feel.",
+    "四步,从想法到成品。": "Four steps from idea to product.",
+    "今天,": "Today,",
+    "就把你的袋子设计出来。": "design your pouch.",
+    "无需注册,免费使用全部模板与刀版。设计稿可随时保存、下载。": "No sign-up required. All templates and dielines are free. Save and download anytime.",
+    "为小批量品牌而生的包装设计工作室。让每一个袋子,都值得被拿在手里。": "A packaging studio built for small-batch brands — so every pouch is worth holding.",
+    "站立袋": "Stand-up Pouch",
+    "平底袋": "Flat-bottom Pouch",
+    "咖啡袋": "Coffee Bag",
+    "牛皮纸袋": "Kraft Paper Bag",
+    "邮寄袋": "Mailer Bag",
+    "在线设计": "Design online",
+    "上传 Logo": "Upload logo",
+    "尺寸指南": "Size guide",
+    "每月一封包装灵感与材料趋势,不打扰。": "A monthly note on packaging ideas and material trends. No spam.",
+    "© 2026 POUCHLAB · 袋研社": "© 2026 POUCHLAB",
+    "隐私政策": "Privacy Policy",
+    "服务条款": "Terms of Service",
+    "联系我们": "Contact",
+    "沪 ICP 备 2026000000 号": "ICP Filing No. 2026000000 (Shanghai)",
+    "免费设计 →": "Design free →",
+    "开始免费设计": "Start designing free",
+    "浏览模板": "Browse templates",
+    "进入设计工作室": "Open the studio",
+    "查看全部模板 →": "View all templates →",
+    "开始设计 →": "Start designing →",
+    "先看模板": "Browse templates first",
+    "在线设计你的包装袋:站立袋、平底袋、咖啡袋、牛皮纸袋、邮寄袋。100 个起订,3D 实时预览,刀版精准,小批量也能做出大品牌质感。": "Design your packaging online: stand-up pouches, flat-bottom pouches, coffee bags, kraft paper bags, mailer bags. MOQ 100, live 3D preview, precise dielines — small batches with a big-brand feel.",
+
+    /* ---------- 手机端 ---------- */
+    "AI 设计师 — 袋研社 POUCHLAB": "AI Designer — POUCHLAB",
+    "☕ 咖啡袋": "☕ Coffee bag",
+    "🎁 礼盒": "🎁 Gift box",
+    "📦 飞机盒": "📦 Mailer box",
+    "确认下单": "Confirm order",
+    "详细微调请到电脑网站": "Fine-tune on desktop",
+    "手机端完成智能出稿与下单。文字排版、逐面编辑、刀版微调等精细操作,请在电脑浏览器打开设计工作台继续。": "Use mobile for AI drafts and ordering. For typography, per-face editing and dieline tweaks, continue in the designer on a desktop browser.",
+    "复制网站链接": "Copy site link",
+    "知道了": "Got it",
+    "AI 设计": "AI Design",
+    "订单": "Orders",
+    "说出你的包装需求…": "Describe your packaging needs…",
+    "发送": "Send",
+    "下单": "Order",
+    "手机端 AI 包装设计:对话式出稿、下单、查询订单物流。详细微调请到电脑网站。": "Mobile AI packaging design: chat-to-design, ordering, and shipment tracking. For fine-tuning, use the desktop site.",
+
+    /* ---------- 袋子编辑器 ---------- */
+    "设计工作室 — 袋研社 POUCHLAB": "Studio — POUCHLAB",
+    "站立袋 · M · 100 个": "Stand-up Pouch · M · 100 pcs",
+    "设置": "Settings",
+    "已保存": "Saved",
+    "3D 预览": "3D Preview",
+    "继续设计 →": "Continue →",
+    "实时样机": "Live mockup",
+    "袋身颜色": "Pouch color",
+    "印刷效果以最终打样为准": "Final print follows the approved proof",
+    "100 个起订,小批量也能开机": "MOQ 100 — small batches welcome",
+    "48 小时数码打样,颜色先确认": "48-hour digital proof to confirm colors",
+    "可降解膜与再生牛皮纸可选": "Compostable film and recycled kraft available",
+    "需要帮助?": "Need help?",
+    "把产品尺寸和数量发给在线顾问,我们帮你选袋型。": "Send your dimensions and quantity to our online advisor and we'll help you choose a pouch.",
+    "产品": "Product",
+    "模板": "Templates",
+    "上传": "Upload",
+    "文字": "Text",
+    "图形": "Shapes",
+    "图层": "Layers",
+    "产品设置": "Product settings",
+    "当前袋型、尺寸与印刷信息": "Current pouch, size and print details",
+    "正面": "Front",
+    "背面": "Back",
+    "刀版线": "Dieline",
+    "适应": "Fit",
+    "空白画布": "Blank canvas",
+    "套用模板": "Use template",
+    "或": "or",
+    "下载效果图": "Download preview",
+    "下载 4K": "Download 4K",
+    "导出 DXF": "Export DXF",
+    "画布设置": "Canvas settings",
+    "确认你的设计": "Confirm your design",
+    "下单前请检查文字、条码与颜色。提交后设计师会再次与你确认。": "Check text, barcodes and colors before ordering. Our designer will confirm with you after submission.",
+    "← 继续编辑": "← Continue editing",
+    "查看 3D 预览": "View 3D preview",
+    "订单信息": "Order details",
+    "提交订单": "Place order",
+    "提交即表示同意服务条款。我们不会发送垃圾邮件。": "By submitting you agree to the Terms of Service. We never send spam.",
+    "封口": "Seal",
+    "开口": "Opening",
+    "拖动画面可旋转 · 实时印刷效果": "Drag to rotate · live print preview",
+    "⌘/Ctrl + Enter 完成": "⌘/Ctrl + Enter to finish",
+    "完成": "Done",
+    "订单已提交": "Order submitted",
+    "我们已收到你的设计。1 个工作日内,设计师会联系你确认刀版与打样细节。": "We've received your design. A designer will contact you within 1 business day to confirm dielines and sampling.",
+    "网络不可达,订单已离线保存在本机。": "Network unavailable — your order was saved locally.",
+    "查看我的订单": "View my orders",
+    "返回首页": "Back to home",
+    "设计名称": "Design name",
+    "设计步骤": "Design steps",
+    "撤销 ⌘Z": "Undo ⌘Z",
+    "撤销": "Undo",
+    "重做 ⇧⌘Z": "Redo ⇧⌘Z",
+    "重做": "Redo",
+    "设计工具": "Design tools",
+    "收起面板": "Collapse panel",
+    "缩小": "Zoom out",
+    "放大": "Zoom in",
+    "关闭属性面板": "Close properties panel",
+    "联系人": "Contact name",
+    "手机号": "Phone",
+    "邮箱(选填)": "Email (optional)",
+    "收货地址(省市区 + 详细地址)": "Shipping address (province/city/district + street)",
+    "备注:颜色、工艺、交期或其他要求": "Notes: color, finish, lead time or other requests",
+    "关闭": "Close",
+    "切换袋型模型": "Switch pouch model",
+    "旋转角度": "Rotation",
+    "输入文字…": "Enter text…",
+    "在线包装袋设计工作室:选择袋型、套用模板、上传 Logo、3D 预览并下单一站完成。": "Online pouch design studio: choose a style, use a template, upload your logo, preview in 3D and order — all in one place.",
+
+    /* ---------- 纸盒编辑器 ---------- */
+    "3D云设计编辑器 — 袋研社 POUCHLAB": "3D Box Designer — POUCHLAB",
+    "文件": "File",
+    "未命名纸盒": "Untitled box",
+    "新建设计方案": "New design",
+    "创建副本": "Duplicate",
+    "查看我的设计方案": "My designs",
+    "历史版本记录": "Version history",
+    "保存": "Save",
+    "导入PSD/AI/PDF": "Import PSD/AI/PDF",
+    "导入CAD": "Import CAD",
+    "投稿至模板中心": "Submit to template gallery",
+    "2D设计": "2D Design",
+    "3D预览": "3D Preview",
+    "印刷下单": "Order print",
+    "渲 染": "Render",
+    "导出": "Export",
+    "✨ AI 排版": "✨ AI Layout",
+    "盒型": "Box types",
+    "素材": "Assets",
+    "工具": "Tools",
+    "帮助": "Help",
+    "外侧": "Outside",
+    "内侧": "Inside",
+    "开": "Open",
+    "合": "Close",
+    "下载4K图片": "Download 4K image",
+    "分享": "Share",
+    "AI 排版(登录后可用)": "AI Layout (sign in required)",
+    "登录 / 账号": "Log in / Account",
+    "预览(隐藏刀版线)": "Preview (hide dielines)",
+    "平移画布": "Pan canvas",
+    "适应画布": "Fit canvas",
+    "盒身颜色": "Box color",
+    "自定义颜色": "Custom color",
+    "无颜色": "No color",
+    "折叠程度": "Fold level",
+    "重置视角": "Reset view",
+    "自动播放": "Auto play",
+    "播放开合": "Play open/close",
+    "放大预览": "Enlarge preview",
+    "在线 3D 纸盒设计:盒型库、模板、素材、文字、条码二维码、智能参数、动效预览与印刷下单。": "Online 3D box design: box library, templates, assets, text, barcodes/QR codes, smart parameters, animated preview and print ordering.",
+
+    /* ---------- 订单 / 后台 ---------- */
+    "我的订单 — 袋研社 POUCHLAB": "My Orders — POUCHLAB",
+    "查看订单支付状态、生产进度与物流信息。": "Track payment status, production progress and shipping.",
+    "后台管理 — 袋研社 POUCHLAB": "Admin — POUCHLAB"
+  });
+
+  /* 含数字/变量的动态文案 */
+  D.rules.push(
+    [/^(\d+)\s*个图层$/, function (m) { return m[1] + ' layers'; }],
+    [/^印刷区\s*([\d.]+)\s*×\s*([\d.]+)\s*mm$/, function (m) { return 'Print area ' + m[1] + ' × ' + m[2] + ' mm'; }],
+    [/^模型ID:\s*(\d+)$/, function (m) { return 'Model ID: ' + m[1]; }],
+    [/^(\d+(?:\.\d+)?)\s*mm\s*×\s*(\d+(?:\.\d+)?)\s*mm\s*·\s*(正面|背面|左侧面|右侧面|侧面|顶面|底面|封口|开口)$/, function (m) {
+      var face = { '正面': 'Front', '背面': 'Back', '左侧面': 'Left', '右侧面': 'Right', '侧面': 'Side', '顶面': 'Top', '底面': 'Bottom', '封口': 'Seal', '开口': 'Opening' }[m[3]] || m[3];
+      return m[1] + ' mm × ' + m[2] + ' mm · ' + face;
+    }],
+    [/^剩余\s*(\d+)\s*次$/, function (m) { return m[1] + ' left'; }],
+    [/^(\d+)\s*个$/, function (m) { return m[1] + ' pcs'; }]
+  );
+})(window.PLI18N_EN);
+(function (D) {
+  /* ---------- 袋子编辑器:设置 / 工具 / AI ---------- */
+  Object.assign(D.dict, {
+    "未命名设计": "Untitled design",
+    "未命名方案": "Untitled design",
+    "方案数据已损坏": "This design file is corrupted",
+    "方案已删除": "Design deleted",
+    "保存中…": "Saving…",
+    "本地空间不足,请先删除旧方案": "Local storage is full. Delete old designs first.",
+    "本地存储空间不足,建议下载效果图备份": "Local storage is full. Download a preview as backup.",
+    "已载入 AI 设计师方案,可继续微调": "AI designer draft loaded — keep refining",
+    "自定义": "Custom",
+    "个": "pcs",
+    "只": "pcs",
+    "次": "left",
+    "/ 个": "/ pc",
+    "袋型": "Pouch style",
+    "尺寸": "Size",
+    "材质": "Material",
+    "工艺": "Finish",
+    "数量": "Quantity",
+    "单价": "Unit price",
+    "可调尺寸": "Adjustable",
+    "选择你的袋子": "Choose your pouch",
+    "袋型、尺寸、材质与数量都会影响最终报价。": "Style, size, material and quantity all affect the final price.",
+    "6 种可选": "6 options",
+    "自定义尺寸": "Custom size",
+    "宽": "W",
+    "高": "H",
+    "宽 30–1200 mm,高 30–1600 mm,按面积计价。": "W 30–1200 mm, H 30–1600 mm, priced by area.",
+    "材质与工艺": "Material & finish",
+    "100 个起订": "MOQ 100",
+    "自定义数量": "Custom quantity",
+    "个 · 100 起订": "pcs · min 100",
+    "需要纸盒?": "Need a box?",
+    "打开纸盒设计器 →": "Open box designer →",
+    "预计总价": "Estimated total",
+    "含税,不含运费": "Tax included, shipping excluded",
+    "免费设计 · 免费刀版 · 不满意随时修改": "Free design · free dielines · revise anytime",
+    "mm · 正面预览": "mm · front preview",
+    "已切换袋型,设计已等比适配": "Pouch style changed — design scaled to fit",
+    "印刷区": "Print area",
+    "图片": "Image",
+    "矩形": "Rectangle",
+    "圆形": "Circle",
+    "三角形": "Triangle",
+    "线条": "Line",
+    "贴纸 ·": "Sticker ·",
+    "圆形徽章": "Round badge",
+    "条码 ·": "Barcode ·",
+    "二维码 ·": "QR code ·",
+    "素材 ·": "Asset ·",
+    "模板库": "Template library",
+    "套用后可继续自由修改": "Apply, then edit freely",
+    "上传素材": "Upload asset",
+    "建议使用透明背景 PNG 或 SVG": "Transparent PNG or SVG recommended",
+    "文字工具": "Text tool",
+    "标题、正文与字体选择": "Headline, body copy and fonts",
+    "图形与贴纸": "Shapes & stickers",
+    "用图形建立视觉层次": "Build hierarchy with shapes",
+    "图层管理": "Layer management",
+    "从上到下即前后顺序": "Top to bottom = front to back",
+    "点击套用 · 会覆盖当前画布,可用撤销恢复。": "Click to apply · replaces the canvas; undo to restore.",
+    "AI 排版": "AI Layout",
+    "✨ AI 排版": "✨ AI Layout",
+    "双面同款": "Both sides",
+    "描述你想要的排版,如: 极简咖啡包装,暖米底色,顶部衬线体品牌名,中部咖啡豆贴纸,底部一行英文 slogan 生成后可继续说:文字再大一点 / 换深色背景": "Describe the layout you want, e.g.: minimalist coffee packaging, warm beige background, serif brand name at top, coffee bean sticker in the middle, one-line English slogan at the bottom. After generating: make the text bigger / dark background",
+    "生成排版": "Generate layout",
+    "清空本面": "Clear this side",
+    "AI 结果直接应用到画布,可随时撤销(⌘Z)。每次生成消耗 1 次额度。": "AI results apply straight to the canvas and can be undone (⌘Z). Each generation uses 1 credit.",
+    "登录后可用 AI 排版": "Sign in to use AI Layout",
+    "剩余": "Remaining",
+    "AI 未配置": "AI not configured",
+    "AI 需要联网登录后使用": "AI requires an internet connection and sign-in",
+    "先描述一下排版需求": "Describe what you'd like first",
+    "AI 生成中…": "Generating…",
+    "AI 正在设计中,通常 10~60 秒,请勿关闭面板或刷新页面…": "AI is designing — usually 10–60s. Please don't close the panel or refresh.",
+    "AI 结果已应用到画布,可继续提修改意见(每次生成消耗 1 次额度)。": "AI result applied. Keep refining with more feedback (each generation uses 1 credit).",
+    "AI 这次没能生成有效排版(未扣次数),换个说法再试": "AI couldn't produce a valid layout this time (no credit used). Try rephrasing.",
+    "AI 排版已应用,可继续提修改意见": "AI layout applied — keep refining",
+    "AI 生成失败": "AI generation failed",
+    "你的标题": "Your headline",
+    "一句打动人的副标题": "A subtitle that resonates",
+    "在这里输入产品说明、配料或品牌故事。": "Add product details, ingredients or your brand story here.",
+    "已添加文字 · 双击画布可直接编辑": "Text added · double-click the canvas to edit",
+    "已添加": "Added",
+    "条码": "Barcode",
+    "二维码": "QR code",
+    "徽章": "Badge",
+    "图片已放置到画布": "Image placed on canvas",
+    "已清空": "Cleared",
+    "已清空全部设计 · 可撤销": "All design cleared · undoable",
+    "已删除 · 可撤销": "Deleted · undoable",
+    "已撤销": "Undone",
+    "已重做": "Redone",
+    "设计已保存到本地": "Design saved locally",
+    "合计": "Total",
+    "刀版 DXF 已导出 · CUT/FOLD/BLEED": "Dieline DXF exported · CUT/FOLD/BLEED",
+    "已下载": "Downloaded",
+    "效果图已下载": "Preview downloaded",
+    "已下载 SVG 文件": "SVG downloaded",
+    "先添加一些内容,再确认订单": "Add some content before confirming the order",
+    "请选择图片文件": "Please choose an image file",
+    "图片过大,请使用 12MB 以内的文件": "Image too large — use a file under 12 MB",
+    "4K 效果图": "4K preview",
+    "订单已离线保存(服务器不可达)": "Order saved offline (server unreachable)",
+    "订单已提交,可前往「我的订单」支付": "Order submitted — go to My Orders to pay",
+    "正在提交订单…": "Submitting order…",
+    "订单提交失败,请重试": "Order submission failed. Please try again.",
+    "参考潘通色": "PANTONE reference",
+    "— 袋研社 POUCHLAB": " — POUCHLAB"
+  });
+
+  D.rules.push(
+    [/^下一步\s*·\s*¥\s*(.+)$/, function (m) { return 'Next · ¥' + m[1]; }],
+    [/^提交订单\s*·\s*¥\s*(.+)$/, function (m) { return 'Place order · ¥' + m[1]; }],
+    [/^方案已保存\s*·\s*(.+)$/, function (m) { return 'Design saved · ' + m[1]; }],
+    [/^已载入方案\s*·\s*(.+)$/, function (m) { return 'Design loaded · ' + m[1]; }],
+    [/^已选择「(.+)」$/, function (m) { return 'Selected “' + (D.dict[m[1]] || m[1]) + '”'; }],
+    [/^已套用模板「(.+)」\s*·\s*可撤销$/, function (m) { return 'Template “' + (D.dict[m[1]] || m[1]) + '” applied · undoable'; }],
+    [/^已添加素材\s*·\s*(.+)$/, function (m) { return 'Asset added · ' + m[1]; }],
+    [/^已添加(.+)$/, function (m) { return m[1] + ' added'; }],
+    [/^已复制到\s*(.+)$/, function (m) { return 'Copied to ' + m[1]; }],
+    [/^已清空(.+)$/, function (m) { return m[1] + ' cleared'; }],
+    [/^AI 生成中…\s*(\d+)s$/, function (m) { return 'Generating… ' + m[1] + 's'; }],
+    [/^个\s*·\s*(.+)$/, function (m) { return 'pcs · ' + m[1]; }]
+  );
+})(window.PLI18N_EN);
+(function (D) {
+  /* ---------- 纸盒编辑器 ---------- */
+  Object.assign(D.dict, {
+    "前面": "Front", "右面": "Right", "左面": "Left", "顶面": "Top", "底面": "Bottom",
+    "左": "L", "右": "R", "顶": "T", "底": "B",
+    "350g白卡(0.5mm)": "350g white card (0.5mm)",
+    "挺括细腻,适合彩印": "Sturdy and smooth, great for color printing",
+    "灰板2mm": "2mm grey board",
+    "硬挺,适合精装礼盒": "Rigid, for premium gift boxes",
+    "牛皮纸(0.4mm)": "Kraft paper (0.4mm)",
+    "自然原色,环保质感": "Natural tone, eco feel",
+    "E楞瓦楞(1.5mm)": "E-flute corrugated (1.5mm)",
+    "缓冲抗压,电商发货": "Cushioning strength for e-commerce shipping",
+    "四色": "CMYK",
+    "四色+1专": "CMYK + 1 spot",
+    "四色+2专": "CMYK + 2 spots",
+    "不印刷": "No printing",
+    "胶印合版": "Offset (gang run)",
+    "胶印专版": "Offset (dedicated)",
+    "数码印刷": "Digital printing",
+    "卡纸折叠盒": "Folding carton",
+    "平口箱": "Slotted carton",
+    "反向插锁盒": "Reverse tuck box",
+    "直插盒": "Straight tuck box",
+    "扣底盒": "Snap-lock bottom box",
+    "磁吸书型盒": "Magnetic book-style box",
+    "飞机盒": "Mailer box",
+    "抽屉盒": "Drawer box",
+    "手提袋": "Paper bag",
+    "封套": "Sleeve",
+    "卡牌/吊牌/标签": "Cards / tags / labels",
+    "糊口长": "Glue flap",
+    "插舌长": "Tuck flap",
+    "倒角": "Corner cut",
+    "槽口宽": "Slot width",
+    "沿口宽": "Lip width",
+    "顶折边": "Top fold",
+    "孔半径": "Hole radius",
+    "开孔": "Hole",
+    "已载入 AI 设计师整套方案,可继续微调": "AI designer's full set loaded — keep refining",
+    "内侧设计 · 镜像": "Inside design · mirrored",
+    "外侧设计": "Outside design",
+    "本地保存空间不足": "Local storage is full",
+    "热门": "Popular",
+    "更多": "More",
+    "纸箱": "Carton",
+    "导入 CAD": "Import CAD",
+    "上传盒型结构个性化设计": "Upload a custom box structure",
+    "输入盒型关键字": "Search box types",
+    "推荐盒型": "Recommended",
+    "我的盒型": "My box types",
+    "我的盒型(导入的 CAD 结构会保存在这里)": "My box types (imported CAD structures are saved here)",
+    "· 暂无": " · none",
+    "种固定尺寸": "fixed sizes",
+    "可改尺寸": "Adjustable",
+    "不可印刷": "Not printable",
+    "找不到盒型": "No box types found",
+    "输入模板关键字": "Search templates",
+    "全部": "All",
+    "分类": "Categories",
+    "形状": "Shapes",
+    "图标": "Icons",
+    "礼盒插画": "Gift box illustrations",
+    "插画": "Illustrations",
+    "咖啡杯插画": "Coffee cup illustrations",
+    "透明徽章": "Clear badge",
+    "抠图": "Cut-outs",
+    "透明箭头": "Clear arrows",
+    "收藏": "Favorites",
+    "已购": "Purchased",
+    "输入素材关键字": "Search assets",
+    "素材分类": "Asset categories",
+    "暂无购买记录": "No purchases yet",
+    "没找到你想要的结果": "No results found",
+    "素材点击即添加到当前选中的面,可于图层面板调整。": "Click an asset to add it to the selected face; adjust it in the Layers panel.",
+    "标准": "Standard",
+    "描边": "Outline",
+    "阴影": "Shadow",
+    "斜体": "Italic",
+    "衬线": "Serif",
+    "圆润": "Rounded",
+    "品牌 + 品类": "Brand + category",
+    "品牌名称": "Brand name",
+    "日期 + 系列": "Date + series",
+    "主标题 + 卖点": "Headline + selling point",
+    "大促特惠": "Sale promotion",
+    "买二送一 · 限时": "Buy 2 get 1 · limited",
+    "竖排签名": "Vertical signature",
+    "点击添加文字": "Click to add text",
+    "基础文字": "Basic text",
+    "输入文字": "Enter text",
+    "文字组合": "Text presets",
+    "文字组合已添加": "Text preset added",
+    "整套 6 面": "All 6 faces",
+    "外": "Outside",
+    "内": "Inside",
+    "侧)": "side)",
+    "仅当前面(": "Current face only (",
+    "描述这个面的排版需求;生成后再说\"文字再大点/换个位置\"可继续调整。": "Describe the layout for this face; after generating, say \"make the text bigger / move it\" to keep refining.",
+    "如:极简茶叶礼盒,居中大字品牌名,下方一行英文,底部小字净含量": "e.g. minimalist tea gift box, large centered brand name, one line of English below, net weight in small type at the bottom",
+    "将清除": "will clear",
+    "的全部文字与图形(含背景色),可撤销": "'s text and shapes (including background) — undoable",
+    "已清空(可 ⌘Z 撤销)": "Cleared (⌘Z to undo)",
+    "生成并应用": "Generate & apply",
+    "请先描述需求": "Describe what you want first",
+    "AI 正在设计中,通常 10~60 秒,请勿关闭弹窗…": "AI is designing — usually 10–60s. Please don't close the dialog.",
+    "AI 这次没能生成有效成套设计(未扣次数),换个说法再试": "AI couldn't produce a valid full-set design this time (no credit used). Try rephrasing.",
+    "条形码": "Barcode",
+    "快速生成一堆码支持4种码制": "Generate codes quickly — 4 symbologies supported",
+    "快速生成二维码设计使用": "Generate QR codes for your design",
+    "码制": "Symbology",
+    "EAN-13 商品码": "EAN-13 product code",
+    "EAN-8 短码": "EAN-8 short code",
+    "内容": "Content",
+    "条码内容": "Barcode content",
+    "生成条形码": "Generate barcode",
+    "二维码内容(网址或文字)": "QR content (URL or text)",
+    "生成二维码": "Generate QR code",
+    "内容过长": "Content too long",
+    "一键清空": "Clear all",
+    "元素": "Element",
+    "显示": "Show",
+    "隐藏": "Hide",
+    "移到最顶层": "Bring to front",
+    "上移一层": "Move up",
+    "下移一层": "Move down",
+    "移到最底层": "Send to back",
+    "删除": "Delete",
+    "图层为空": "No layers",
+    "清空图层": "Clear layers",
+    "当前面有": "This face has",
+    "个图层,全部面共": "layers; all faces:",
+    "已清空全部面图层": "All faces cleared",
+    "清空全部面(": "Clear all faces (",
+    "清空后可通过 Ctrl+Z 撤销。": "Undo with Ctrl+Z after clearing.",
+    "演示环境:可发送邮件至 support@pouchlab.design": "Demo: email support@pouchlab.design",
+    "咨询客服": "Contact support",
+    "工作日 9:00-18:00": "Weekdays 9:00–18:00",
+    "快速上手": "Quick start",
+    "3 步完成盒子设计": "Design a box in 3 steps",
+    "快捷键": "Shortcuts",
+    "常用操作快捷键列表": "Common shortcuts",
+    "1. 在「盒型」面板选择盒型与尺寸,或点「编辑」打开智能参数宝精确调参; 2. 在 2D 设计里点选面,用「文字 / 素材 / 上传」添加内容,右侧换颜色与纹理; 3. 切到「3D预览」拖拽查看,播放动效,最后「导出」或「印刷下单」。": "1. Choose a box type and size in the Box types panel, or click Edit to fine-tune in Smart parameters. 2. In 2D Design, select a face and add content via Text / Assets / Upload; change color and texture on the right. 3. Switch to 3D Preview to drag and play the motion, then Export or Order print.",
+    "Ctrl/⌘ + Z\u3000撤销": "Ctrl/⌘ + Z  Undo",
+    "Ctrl/⌘ + Shift + Z\u3000重做": "Ctrl/⌘ + Shift + Z  Redo",
+    "Ctrl/⌘ + S\u3000保存": "Ctrl/⌘ + S  Save",
+    "Delete\u3000删除选中元素": "Delete  remove selected",
+    "Tab\u3000切换外侧 / 内侧": "Tab  switch outside / inside",
+    "空格拖拽\u3000平移画布": "Space + drag  pan canvas",
+    "尺寸/材质": "Size / material",
+    "内尺寸为盒体内部净尺寸": "Inner size is the box's internal clearance",
+    "编辑": "Edit",
+    "内尺寸(mm)": "Inner size (mm)",
+    "厚度": "Thickness",
+    "颜色 / 背景": "Color / background",
+    "颜色": "Color",
+    "纹理": "Texture",
+    "清空颜色": "Clear color",
+    "清空纹理": "Clear texture",
+    "画布": "Canvas",
+    "展开": "Flat",
+    "外侧尺寸": "Outer size",
+    "当前设计": "Current design",
+    "文字属性": "Text properties",
+    "图片属性": "Image properties",
+    "素材属性": "Asset properties",
+    "二维码属性": "QR code properties",
+    "条形码属性": "Barcode properties",
+    "元素属性": "Element properties",
+    "完成选择": "Done",
+    "文字内容": "Text content",
+    "字号 (mm)": "Font size (mm)",
+    "对齐": "Align",
+    "中": "Center",
+    "字重": "Weight",
+    "常规": "Regular",
+    "粗": "Bold",
+    "样式": "Style",
+    "宽度": "Width",
+    "水平": "Horizontal",
+    "垂直": "Vertical",
+    "图层顺序": "Layer order",
+    "⤒ 置顶": "⤒ Front",
+    "↑ 上移": "↑ Up",
+    "↓ 下移": "↓ Down",
+    "⤓ 置底": "⤓ Back",
+    "动效": "Motion",
+    "点击预览": "Click to preview",
+    "停止": "Stop",
+    "视角": "View",
+    "自动旋转": "Auto-rotate",
+    "确认调整": "Apply changes",
+    "我知道了": "Got it",
+    "内尺寸": "Inner size",
+    "标注方式": "Dimension style",
+    "数值": "Values",
+    "无标注": "None",
+    "基础参数": "Basic parameters",
+    "以内尺寸或外尺寸为基准调整": "Adjust from inner or outer size",
+    "基准尺寸": "Base size",
+    "输出制造尺寸口径": "Output manufacturing size",
+    "输出尺寸": "Output size",
+    "长 (L)": "Length (L)",
+    "宽 (W)": "Width (W)",
+    "高 (H)": "Height (H)",
+    "出血线 (BL)": "Bleed (BL)",
+    "厚度(0.2~3mm)": "Thickness (0.2–3mm)",
+    "高级参数": "Advanced",
+    "智能参数宝": "Smart parameters",
+    "参数已调整,刀版与 3D 已更新": "Parameters updated — dieline and 3D refreshed",
+    "支持 DXF 盒型结构文件上传,上传后在「我的盒型」中管理。": "DXF box structures are supported; manage them under My box types.",
+    "演示环境:本版本以内置参数化盒型库代替 CAD 解析,选择盒型后可在智能参数宝中精调结构参数。": "Demo: this version uses the built-in parametric box library instead of CAD parsing. Pick a box type, then fine-tune the structure in Smart parameters.",
+    "文件类型": "File type",
+    "印刷PDF": "Print PDF",
+    "AI 源文件暂不支持,可导出 PDF / DXF / SVG 矢量文件": "AI source files aren't supported yet — export PDF / DXF / SVG vectors instead",
+    "印刷AI": "Print AI",
+    "刀版PDF": "Dieline PDF",
+    "刀版DXF": "Dieline DXF",
+    "预览JPG": "Preview JPG",
+    "色彩模式": "Color mode",
+    "CMYK模式": "CMYK",
+    "屏幕预览为 RGB,交付印刷文件请选 CMYK": "Screens preview in RGB; choose CMYK for print files",
+    "RGB模式": "RGB",
+    "刀线和设计元素独立分层": "Dielines and artwork on separate layers",
+    "导出即视为已阅读并同意《授权许可协议》": "Exporting means you've read and agree to the License Agreement",
+    "3D 预览加载中…": "Loading 3D preview…",
+    "高清": "HD",
+    "超清": "FHD",
+    "超高清": "UHD",
+    "构图比例": "Aspect ratio",
+    "背景": "Background",
+    "场景": "Scene",
+    "透明": "Transparent",
+    "导出效果图": "Export preview",
+    "导出视频": "Export video",
+    "设计文件": "Design file",
+    "效果图": "Preview",
+    "视频": "Video",
+    "⏱ 导出记录": "⏱ Export history",
+    "浏览器拦截了新窗口,请允许弹窗": "Your browser blocked a new window — allow pop-ups",
+    "印刷文件": "Print file",
+    "刀版": "Dieline",
+    "预览 JPG 已下载": "Preview JPG downloaded",
+    "刀版 DXF 已下载": "Dieline DXF downloaded",
+    "3D 渲染器未就绪": "3D renderer not ready",
+    "正在渲染": "Rendering",
+    "效果图…": "preview…",
+    "当前浏览器不支持视频录制": "This browser doesn't support video recording",
+    "动效视频已下载": "Motion video downloaded",
+    "导出记录": "Export history",
+    "暂无导出记录": "No exports yet",
+    "刀版结构完整(": "Dieline structure complete (",
+    "出血线": "Bleed",
+    "(建议 ≥3mm)": "(≥3mm recommended)",
+    "图片清晰度": "Image resolution",
+    "(检测到低分辨率图片,印刷可能模糊)": "(low-resolution images detected — print may be blurry)",
+    "最小字号": "Minimum font size",
+    "(有 <2mm 文字,印刷可能不清晰)": "(text under 2mm — print may be unclear)",
+    "色彩模式:CMYK 印刷色域": "Color mode: CMYK gamut",
+    "印前检测": "Preflight check",
+    "限免": "Free for now",
+    "智能印刷引擎在您检测设计问题": "Smart print engine is checking your design",
+    "智能印刷引擎正在为您检测中…": "Smart print engine is checking…",
+    "印刷报价": "Print quote",
+    "确认印刷配置,沿用原设计与刀版": "Confirm print settings; reuse the original design and dieline",
+    "返回继续编辑 ⇱": "← Back to editing",
+    "制造尺寸": "Manufacturing size",
+    "生产主材": "Primary material",
+    "印面": "Print sides",
+    "单面(外)": "Single (outside)",
+    "单面(内)": "Single (inside)",
+    "订购数量 ⇱": "Order quantity",
+    "印刷配置": "Print settings",
+    "印色": "Ink colors",
+    "印刷方式": "Printing method",
+    "收货信息": "Shipping details",
+    "备注(选填)": "Notes (optional)",
+    "演示环境:400-000-0000": "Demo: 400-000-0000",
+    "🎧 人工咨询": "🎧 Talk to us",
+    "预计加工时间:4 个工作日": "Est. production: 4 business days",
+    "印刷费 ¥": "Printing ¥",
+    "(运费待计算)": "(shipping calculated later)",
+    "报价明细": "Quote breakdown",
+    "展开面积:": "Flat area:",
+    "材质单价:": "Material rate:",
+    "元/m²": "CNY/m²",
+    "印色系数:": "Ink factor:",
+    "结构费:": "Structure fee:",
+    "数量折扣:": "Quantity discount:",
+    "单价:¥": "Unit price: ¥",
+    "请完整填写联系人、手机号和收货地址": "Please fill in contact name, phone and shipping address",
+    "下单成功": "Order placed",
+    "订单号:": "Order no.:",
+    "数量:": "Quantity:",
+    "支付与生产进度请在「我的订单」查看": "Track payment and production in My Orders",
+    "前往我的订单 →": "Go to My Orders →",
+    "下单成功(离线保存)": "Order placed (saved offline)",
+    "服务器暂不可达,订单已保存在本地,联网后请重新提交。": "The server is unreachable; your order was saved locally. Resubmit once you're online.",
+    "下单失败,请重试": "Order failed. Please try again.",
+    "正在提交…": "Submitting…",
+    "立即下单": "Place order",
+    "当前方案已自动保存到「我的设计方案」,新建后将开始一个空白方案。": "Your design was autosaved to My designs. A new blank design will start.",
+    "已新建设计方案": "New design created",
+    "新建": "New",
+    "副本": "Copy",
+    "我的设计方案": "My designs",
+    "打开": "Open",
+    "已删除": "Deleted",
+    "暂无保存的方案": "No saved designs",
+    "方案数据缺失": "Design data missing",
+    "方案打开失败": "Failed to open design",
+    "版本": "Version",
+    "已恢复历史版本": "Restored historical version",
+    "恢复": "Restore",
+    "暂无历史版本": "No versions yet",
+    "模型ID:": "Model ID:",
+    "— 3D云设计编辑器 · 袋研社": " — 3D Box Designer · PouchLab",
+    "方案已保存": "Design saved",
+    "演示环境:支持上传 JPG/PNG/SVG(上传面板)": "Demo: JPG/PNG/SVG uploads supported (Upload panel)",
+    "演示环境:投稿至模板中心需要登录账号": "Demo: sign in to submit to the template gallery",
+    "重命名方案": "Rename design",
+    "确定": "OK",
+    "分享链接已复制": "Share link copied",
+    "分享链接:": "Share link:",
+    "本地实时渲染:正在播放「折叠展开」动效": "Local live render: playing “fold/unfold” motion",
+    "反向插锁盒 · 120×80×180mm": "Reverse tuck box · 120×80×180mm"
+  });
+
+  D.rules.push(
+    [/^·\s*模型ID\s*(\d+)$/, function (m) { return ' · Model ID ' + m[1]; }],
+    [/^已切换到「(.+)」$/, function (m) { return 'Switched to “' + (D.dict[m[1]] || m[1]) + '”'; }],
+    [/^模板「(.+)」已套用到(.+)$/, function (m) { return 'Template “' + (D.dict[m[1]] || m[1]) + '” applied to ' + (D.dict[m[2]] || m[2]); }],
+    [/^已添加到「(.+)」$/, function (m) { return 'Added to “' + m[1] + '”'; }],
+    [/^AI 已完成整套 6 面设计(剩余\s*(\d+)\s*次),可撤销$/, function (m) { return 'AI finished all 6 faces (' + m[1] + ' credits left) · undoable'; }],
+    [/^AI 排版已应用到(.+)(剩余\s*(\d+)\s*次)$/, function (m) { return 'AI layout applied to ' + m[1] + ' (' + m[2] + ' credits left)'; }],
+    [/^已清空「(.+)」图层$/, function (m) { return 'Cleared layers of “' + m[1] + '”'; }],
+    [/^清空当前面((\d+) 个图层)$/, function (m) { return 'Clear this face (' + m[1] + ' layers)'; }],
+    [/^清空全部面((\d+) 个图层)$/, function (m) { return 'Clear all faces (' + m[1] + ' layers)'; }],
+    [/^已创建副本:(.+)$/, function (m) { return 'Copy created: ' + m[1]; }],
+    [/^已打开「(.+)」$/, function (m) { return 'Opened “' + m[1] + '”'; }],
+    [/^正在录制「(.+)」…$/, function (m) { return 'Recording “' + m[1] + '”…'; }],
+    [/^(\d+)\s*个\s*·\s*金额:¥(.+)$/, function (m) { return m[1] + ' pcs · ¥' + m[2]; }],
+    [/^当前面有 (\d+) 个图层,全部面共 (\d+) 个图层。$/, function (m) { return 'This face has ' + m[1] + ' layers; all faces: ' + m[2] + '.'; }],
+    [/^(\d+)\s*种固定尺寸$/, function (m) { return m[1] + ' fixed sizes'; }],
+    [/^AI 排版 · (.+)$/, function (m) { return 'AI Layout · ' + m[1]; }]
+  );
+})(window.PLI18N_EN);
+(function (D) {
+  Object.assign(D.dict, {
+    /* ---- orders.js ---- */
+    '我的订单': 'My Orders',
+    '订单列表': 'Orders',
+    '订单详情': 'Order details',
+    '登录': 'Sign in',
+    '退出登录': 'Sign out',
+    '登录已失效,请重新登录': 'Session expired, please sign in again',
+    '登录后可查看订单的支付状态、生产进度与物流信息': 'Sign in to view payment status, production progress and tracking.',
+    '手机号登录': 'Sign in with phone',
+    '包装袋': 'Pouch',
+    '纸盒': 'Box',
+    '包装袋设计': 'Pouch design',
+    '纸盒设计': 'Box design',
+    '数量': 'Quantity',
+    '件': 'pcs',
+    '单价': 'Unit price',
+    '总额': 'Total',
+    '订单状态': 'Order status',
+    '支付状态': 'Payment status',
+    '收货信息': 'Shipping info',
+    '联系人': 'Contact',
+    '手机号': 'Phone',
+    '地址': 'Address',
+    '备注': 'Notes',
+    '物流信息': 'Tracking',
+    '承运商': 'Carrier',
+    '运单号': 'Tracking no.',
+    '复制': 'Copy',
+    '进度时间线': 'Progress timeline',
+    '取消': 'Cancel',
+    '取消订单': 'Cancel order',
+    '确定取消该订单吗?': 'Cancel this order?',
+    '立即支付': 'Pay now',
+    '确认支付': 'Confirm payment',
+    '模拟支付': 'Pay (demo)',
+    '还没有订单,去设计一款包装吧': 'No orders yet — design a package to get started.',
+    '还没有订单': 'No orders yet',
+    '开始设计': 'Start designing',
+    '订单加载失败': 'Failed to load orders',
+    '详情加载失败': 'Failed to load order details',
+    '该订单保存在本机,尚未同步到服务器': 'This order is stored locally and has not synced to the server yet.',
+    '服务器未收到该订单,联网后请在设计页重新提交': 'The server has not received this order. Please resubmit from the design page once online.',
+    '联网后可在设计页重新提交;设计稿与预览图已随订单保存在本机。': 'Resubmit from the design page once online; the artwork and previews are saved locally with this order.',
+    '本机保存': 'Saved locally',
+    '订单保存在本机': 'Order saved locally',
+    '订单已取消': 'Order cancelled',
+    '取消失败': 'Failed to cancel',
+    '运单号已复制': 'Tracking number copied',
+    '支付成功(模拟),订单已进入生产': 'Payment successful (demo) — order is now in production',
+    '支付失败': 'Payment failed',
+    '尚未发货': 'Not shipped yet',
+    '物流信息录入中': 'Tracking info pending',
+    '工厂发货后将在此展示快递公司与运单号,可直接复制查询。': 'Once shipped, the carrier and tracking number appear here for you to copy.',
+    '(本机订单未记录地址)': '(No address recorded for this local order)',
+    '待支付': 'Awaiting payment',
+    '生产中': 'In production',
+    '已发货': 'Shipped',
+    '已完成': 'Completed',
+    '已取消': 'Cancelled',
+    '未支付': 'Unpaid',
+    '已支付': 'Paid',
+    '已退款': 'Refunded',
+    '自定义': 'Custom',
+    '效果': 'Preview',
+    '视图': 'View',
+
+    /* ---- auth.js ---- */
+    '手机号': 'Phone number',
+    '验证码': 'Verification code',
+    '6 位验证码': '6-digit code',
+    '请输入 11 位手机号': 'Enter an 11-digit phone number',
+    '请输入 6 位验证码': 'Enter the 6-digit code',
+    '获取验证码': 'Send code',
+    '发送中…': 'Sending…',
+    '输入手机号获取验证码登录;演示环境验证码会直接弹出显示。': 'Enter your phone to receive a sign-in code. In demo mode the code pops up directly.',
+    '登录 / 注册': 'Sign in / Sign up',
+    '登录即表示同意《服务条款》与《隐私政策》': 'By signing in you agree to the Terms of Service and Privacy Policy.',
+    '登录后可保存设计、同步订单进度与下载记录。': 'Sign in to save designs, sync order progress and download records.',
+    '关闭': 'Close',
+    '登录成功': 'Signed in',
+    '登录失败,请重试': 'Sign-in failed, please try again',
+    '离线演示模式登录(数据不会上传)': 'Signed in offline (demo mode, no data uploaded)',
+    '已退出登录': 'Signed out',
+    '点击退出登录': 'Click to sign out',
+    '服务器暂不可达,离线演示验证码:123456': 'Server unreachable. Offline demo code: 123456',
+    '验证码已发送,请注意查收短信': 'Code sent — please check your SMS.',
+    '演示验证码:': 'Demo code: ',
+    '(已自动填入)': ' (auto-filled)',
+    '用户': 'User',
+
+    /* ---- agent-chat.js ---- */
+    'AI 设计师': 'AI Designer',
+    '说出需求,一步步帮你设计包装': 'Tell us what you need and we design it step by step',
+    '发送': 'Send',
+    '描述你的包装需求,或继续调整…': 'Describe your packaging needs, or keep refining…',
+    '你好!我是 AI 设计师 👋 告诉我你要做什么包装,比如:': 'Hi! I am your AI designer 👋 Tell me what packaging you need, for example:',
+    '我会逐步选型、定尺寸、配材质并生成图案,右侧实时预览,满意后点「去微调」。': 'I will pick the type, set the size, choose materials and generate artwork. Preview updates live on the right — click Fine-tune when happy.',
+    '✏️ 去微调': '✏️ Fine-tune',
+    '✏️ 去微调 →': '✏️ Fine-tune →',
+    '去微调': 'Fine-tune',
+    '去下单 →': 'Order →',
+    '拖拽旋转 · 点击进入微调': 'Drag to rotate · Click to fine-tune',
+    '点击进入微调': 'Click to fine-tune',
+    '点击': 'Click',
+    '正在理解需求…': 'Understanding your request…',
+    '继续执行中…': 'Still working…',
+    '任务启动失败': 'Failed to start the task',
+    '执行出错了,请重试': 'Something went wrong, please try again',
+    '剩余': 'Remaining',
+    'AI 未配置': 'AI not configured',
+    '正面': 'Front',
+    '背面': 'Back',
+    '袋子': 'Pouch',
+    '盒子': 'Box',
+    '客服': 'Support',
+
+    /* ---- materials & products used by chat/order panels ---- */
+    '哑光膜': 'Matte film',
+    '亮光膜': 'Gloss film',
+    '再生牛皮': 'Recycled kraft',
+    '可降解膜': 'Compostable film',
+    '350g白卡': '350g white card',
+    'E楞瓦楞': 'E-flute corrugated',
+    '灰板2mm': '2mm greyboard',
+    '触感膜': 'Soft-touch film',
+    '局部UV': 'Spot UV',
+    '烫金': 'Hot foil',
+    '牛皮纸袋': 'Kraft pouch',
+    '站立袋': 'Stand-up pouch',
+    '平底袋': 'Flat-bottom pouch',
+    '邮寄袋': 'Mailer pouch',
+    '服装袋': 'Garment bag',
+    '咖啡袋': 'Coffee pouch',
+    '卡纸折叠盒': 'Folding carton',
+    '抽屉盒': 'Drawer box',
+    '插盖盒': 'Tuck-top box',
+    '磁吸书型盒': 'Magnetic book box',
+    '飞机盒': 'Mailer box',
+    '平口箱': 'Flat-top box',
+    '立方体预览(可拖拽旋转,点击进微调)': '3D preview (drag to rotate, click to fine-tune)',
+
+    /* ---- landing.js ---- */
+    '选袋型': 'Choose a pouch',
+    '选择袋型': 'Choose a pouch type',
+    '尺寸与材质实时报价': 'Live pricing by size and material',
+    '做设计': 'Design',
+    '模板 / 上传 / 文字 / 图形': 'Templates / Upload / Text / Graphics',
+    '看效果': 'Preview',
+    '3D 预览,一键下载': '3D preview, one-click download',
+    '3D 预览、下载效果图,检查每一个细节。': '3D preview and export; check every detail.',
+    '在线设计': 'Design online',
+    '套用模板或从空白开始,上传 Logo,拖拽排版。': 'Start from a template or blank canvas, upload a logo and drag to lay out.',
+    '确认效果': 'Confirm look',
+    '下单印刷': 'Place print order',
+    '按产品与容量选袋型、尺寸与材质,价格实时计算。': 'Pick pouch type, size and material by product and capacity — price updates live.',
+    '100 个起订,48 小时打样,生产进度全程可查。': 'MOQ 100 pcs, 48-hour proofing, track production end to end.',
+    'DPI 印刷精度': 'DPI print precision',
+    'MM 刀版误差': 'MM dieline tolerance',
+    '种表面工艺': 'surface finishes',
+    '精准刀版线': 'Precise dielines',
+    '每种袋型都有独立刀版,安全区、出血位与折线自动生成,设计不会印偏。': 'Every pouch type gets its own dieline with auto safe area, bleed and fold lines — nothing prints off-register.',
+    '3D 实时样机': 'Real-time 3D mockups',
+    '设计完成即可查看立体效果,模拟袋身弧度与光泽,所见即所得。': 'See the 3D result instantly, with pouch curvature and gloss simulated — what you see is what you get.',
+    '48 小时打样': '48-hour proofing',
+    '数码打样快速确认颜色与材质,100 个即可开机,小批量不再将就。': 'Digital proofs confirm color and material fast; runs start at 100 pcs, so small batches are no compromise.',
+    '环保材料': 'Eco materials',
+    '可降解膜、再生牛皮纸与大豆油墨。包装好看,也可以对地球友好。': 'Compostable film, recycled kraft and soy ink. Great packaging that is kinder to the planet.',
+    '你的邮箱': 'Your email',
+    '请输入有效的邮箱地址': 'Please enter a valid email address',
+    '订阅成功,下一封灵感见': 'Subscribed — see you in the next issue',
+    '/ 个起': '/ pc min.',
+
+    /* ---- m.js ---- */
+    '手机版': 'Mobile',
+    '完整设计工作台请用电脑访问': 'Open the full design studio on a desktop',
+    '账号': 'Account',
+    '姓名': 'Name',
+    '收货联系手机': 'Contact phone',
+    '省市区 + 详细地址': 'Region + full address',
+    '收货地址': 'Shipping address',
+    '实时报价': 'Live quote',
+    '提交订单': 'Place order',
+    '提交中…': 'Submitting…',
+    '提交后可在「订单」中支付并跟踪生产/物流': 'After ordering, pay and track production/shipping in Orders',
+    '(无设计稿,下单后由设计师对接)': ' (No artwork — a designer will follow up after ordering)',
+    '请填写联系人和手机号': 'Please fill in contact name and phone',
+    '请填写收货地址': 'Please fill in the shipping address',
+    '下单成功:': 'Order placed: ',
+    '下单失败,请重试': 'Failed to place order, please try again',
+    'AI 设计 ·': 'AI design ·',
+    '标准白袋 ·': 'Standard white pouch ·',
+    '支付中…': 'Paying…',
+    '支付成功,进入生产': 'Payment successful — in production',
+    '金额': 'Amount',
+    '详情': 'Details',
+    '返回列表': 'Back to list',
+    '物流轨迹': 'Tracking history',
+    '登录后查看订单': 'Sign in to view orders',
+    '登录可同步订单、支付并跟踪生产物流。': 'Sign in to sync orders, pay and track production and shipping.',
+    '立即登录': 'Sign in now',
+    '网站链接已复制': 'Site link copied',
+    '恢复上次会话': 'Restore last session',
+    '宽 (mm)': 'Width (mm)',
+    '高 (mm)': 'Height (mm)',
+    '袋型': 'Pouch type',
+    '材质': 'Material',
+
+    /* ---- api.js ---- */
+    '请求超时,请重试': 'Request timed out, please try again',
+    '无法连接服务器': 'Cannot reach the server',
+    '预览图生成失败': 'Failed to generate preview',
+
+    /* ---- pantone.js ---- */
+    '参考潘通色': 'Pantone reference',
+    '参考潘通色 · 屏幕色值为模拟参考,实际以打样效果为准': 'Pantone reference · Screen colors are simulated; final proofing prevails',
+    '实际颜色以实物色卡与打样效果为准。': 'Actual colors follow the physical swatch book and proofing.'
+  });
+
+  D.rules.push(
+    [/^共 (\d+) 单$/, function (m) { return m[1] + ' orders'; }],
+    [/^模拟支付 ¥([\d.]+)$/, function (m) { return 'Pay (demo) ¥' + m[1]; }],
+    [/^确认支付 ¥([\d.]+)?(演示环境不会真实扣款)$/, function (m) { return 'Confirm payment of ¥' + m[1] + '? (No real charge in demo mode)'; }],
+    [/^已登录 · (.+)$/, function (m) { return 'Signed in · ' + m[1]; }],
+    [/^用户(\d+)$/, function (m) { return 'User ' + m[1]; }],
+    [/^(\d+)s 后重发$/, function (m) { return 'Resend in ' + m[1] + 's'; }],
+    [/^演示验证码:(\d+)(已自动填入)$/, function (m) { return 'Demo code: ' + m[1] + ' (auto-filled)'; }],
+    [/^演示验证码:(\d+)$/, function (m) { return 'Demo code: ' + m[1]; }],
+    [/^AI 剩余 (\d+) 次$/, function (m) { return 'AI: ' + m[1] + ' left'; }],
+    [/^剩余 (\d+) 次$/, function (m) { return m[1] + ' left'; }],
+    [/^下单成功:(.+)$/, function (m) { return 'Order placed: ' + m[1]; }],
+    [/^袋子 · (.+)$/, function (m) { return 'Pouch · ' + m[1]; }],
+    [/^盒子 · (.+)$/, function (m) { return 'Box · ' + m[1]; }],
+    [/^AI 设计 · (.+)$/, function (m) { return 'AI design · ' + m[1]; }],
+    [/^标准白袋 · (.+)$/, function (m) { return 'Standard white pouch · ' + m[1]; }],
+    [/^请求失败((\d+))$/, function (m) { return 'Request failed (' + m[1] + ')'; }],
+    [/^下载失败((\d+))$/, function (m) { return 'Download failed (' + m[1] + ')'; }]
+  );
+})(window.PLI18N_EN);
+(function (D) {
+  Object.assign(D.dict, {
+    /* ---- data.js: fonts ---- */
+    '现代黑体': 'Modern Sans',
+    '优雅宋体': 'Elegant Serif',
+    '圆润黑体': 'Rounded Sans',
+    '英文无衬线': 'Latin Sans',
+    '英文衬线': 'Latin Serif',
+    '等宽字体': 'Monospace',
+    '手写体': 'Handwriting',
+
+    /* ---- data.js: products ---- */
+    '会站立的货架主角': 'The shelf star that stands on its own',
+    '自带拉链与站立袋底,适合咖啡豆、零食、宠物粮与茶叶。密封性好,陈列稳定。': 'Built-in zip and stand-up base for coffee beans, snacks, pet food and tea. Excellent sealing and stable shelf display.',
+    '人气款': 'Bestseller',
+    '可降解': 'Compostable',
+    '拉链封口': 'Zip seal',
+    '自封拉链': 'Self-sealing zip',
+    '站立袋底': 'Stand-up base',
+    '可选排气阀': 'Optional valve',
+    '货架上的高级感': 'Premium shelf presence',
+    '方正的平底结构,容量大、站立稳。适合精品咖啡、谷物与礼盒装产品。': 'Square flat-bottom structure with high capacity and stable standing. Ideal for specialty coffee, grains and gift sets.',
+    '精品首选': 'Premium pick',
+    '大容量': 'High capacity',
+    '平整印刷': 'Flat print',
+    '六边封合': 'Six-side seal',
+    '平底结构': 'Flat-bottom structure',
+    '可加手提孔': 'Optional handle hole',
+    '锁住新鲜与风味': 'Locks in freshness and flavor',
+    '带单向排气阀与加厚铝膜,避光防潮。为精品咖啡与冷萃打造的专业袋型。': 'One-way degassing valve and thickened foil keep light and moisture out. A pro pouch for specialty coffee and cold brew.',
+    '含排气阀': 'With degassing valve',
+    '避光': 'Light-proof',
+    '单向阀': 'One-way valve',
+    '单向排气阀': 'Degassing valve',
+    '加厚铝膜': 'Thickened foil',
+    '拉链密封': 'Zip seal',
+    '自然的触感': 'Natural touch',
+    '原色牛皮纸与环保油墨,质感温润。适合烘焙、茶叶、杂货与手作品牌。': 'Natural kraft paper with eco ink for a warm feel. Great for bakery, tea, groceries and craft brands.',
+    '环保材质': 'Eco material',
+    '原色牛皮': 'Natural kraft',
+    '可回收': 'Recyclable',
+    '食品级内层': 'Food-grade liner',
+    '侧边风琴褶': 'Side gusset',
+    '环保油墨': 'Eco ink',
+    '轻量、耐撕、好寄': 'Light, tear-resistant, easy to ship',
+    '轻量耐撕的邮寄包装,适合服饰、配件与小件电商。可定制整面单色印刷。': 'Lightweight, tear-resistant mailer for apparel, accessories and small e-commerce items. Full-surface mono printing available.',
+    '电商常用': 'E-commerce favorite',
+    '防水': 'Waterproof',
+    '撕拉条': 'Tear strip',
+    '自粘封口': 'Self-adhesive seal',
+    '撕拉开袋': 'Tear-open',
+    '防水耐撕': 'Waterproof & tear-resistant',
+    '让衣服体面出门': 'Send garments out in style',
+    '半透明磨砂质感,配挂孔与自粘封口。适合服装、家纺与品牌工作室。': 'Translucent frosted finish with hang hole and self-adhesive seal. Suits apparel, home textiles and brand studios.',
+    '小批量': 'Small batch',
+    '磨砂': 'Frosted',
+    '挂孔': 'Hang hole',
+    '挂孔设计': 'Hang-hole design',
+    '磨砂质感': 'Frosted finish',
+
+    /* ---- data.js: materials & finishes ---- */
+    '细腻高级,触感柔和': 'Refined and soft to the touch',
+    '色彩饱和,货架吸睛': 'Saturated color that pops on shelf',
+    '自然原色,环保质感': 'Natural tone, eco feel',
+    '植物基材料,可堆肥': 'Plant-based and compostable',
+    '标准印刷': 'Standard print',
+    '四色 / 专色': 'CMYK / spot',
+    '高光点缀': 'Gloss accents',
+    '烫金 / 烫银': 'Hot foil (gold / silver)',
+    '金属光泽': 'Metallic sheen',
+    '丝绒手感': 'Velvet feel',
+
+    /* ---- data.js: templates & nav ---- */
+    '青柠气泡': 'Lime Pop',
+    '晨光咖啡': 'Morning Coffee',
+    '花间茶事': 'Tea Bloom',
+    '极简黑': 'Minimal Black',
+    '汪汪零食': 'Woof Treats',
+    '麦田烘焙': 'Bakery Field',
+    '柔光护肤': 'Glow Skincare',
+    '周末市集': 'Sunday Market',
+    '食品饮料': 'Food & Drink',
+    '咖啡': 'Coffee',
+    '茶': 'Tea',
+    '极简': 'Minimal',
+    '宠物': 'Pets',
+    '烘焙': 'Bakery',
+    '美妆': 'Beauty',
+    '零售': 'Retail',
+    '产品中心': 'Products',
+    '设计工作室': 'Design Studio',
+    '模板灵感': 'Template Inspiration',
+    '工艺材质': 'Craft & Materials',
+
+    /* ---- boxlib.js: structures ---- */
+    '热门': 'Popular',
+    '纸盒': 'Folding boxes',
+    '精装盒': 'Rigid boxes',
+    '手提袋': 'Paper bags',
+    '封套/卡片/文件': 'Sleeves / Cards / Docs',
+    '更多': 'More',
+    '反向插锁盒': 'Reverse tuck box',
+    '直插盒': 'Straight tuck box',
+    '卡纸折叠盒': 'Folding carton',
+    '飞机式插锁盒': 'Mailer box',
+    '扣底盒': 'Auto-bottom box',
+    '平口箱': 'RSC shipper',
+    '四折边对盖盒': 'Four-flap box',
+    '异型书型精品翻盖礼盒': 'Shaped book-style gift box',
+    '翻盖精品礼盒': 'Flip-top gift box',
+    '到底V槽天地盖盒': 'V-groove lid-and-base box',
+    '抽屉盒': 'Drawer box',
+    '平口手提袋': 'Flat-top paper bag',
+    '弧形孔手提袋': 'Arc-handle paper bag',
+    '免提手袋': 'Handle-free bag',
+    '封套': 'Sleeve',
+    '梯形盒套': 'Tapered sleeve',
+    '快餐盒封套': 'Fast-food sleeve',
+    '矩形卡牌': 'Rectangular card',
+    '圆形卡牌': 'Round card',
+    '矩形吊牌': 'Rectangular hang tag',
+    '椭圆形吊牌': 'Oval hang tag',
+    '矩形标签': 'Rectangular label',
+    '圆形标签': 'Round label',
+
+    /* ---- boxlib.js: box templates ---- */
+    '苹果果汁软糖塑料袋包装设计': 'Apple gummy pouch design',
+    '西瓜味雪糕包装设计': 'Watermelon ice cream design',
+    '橙汁饮料玻璃瓶包装设计': 'Orange juice bottle design',
+    '巧克力冰淇淋': 'Chocolate ice cream',
+    '数码家电开箱盒': 'Electronics unboxing box',
+    '蓝牙耳机天地盖盒': 'Earbuds lid-and-base box',
+    '乌龙茶饮包装': 'Oolong tea packaging',
+    '香氛蜡烛礼盒': 'Scented candle gift box',
+    '美妆精华简约盒': 'Minimal skincare serum box',
+    '电商发货飞机盒': 'E-commerce mailer box',
+    '精品手提袋': 'Premium paper bag',
+    '中秋月饼礼盒': 'Mooncake gift box',
+    '数码家电': 'Electronics',
+    '日常用品': 'Everyday',
+
+    /* ---- boxlib.js: asset library ---- */
+    '全部': 'All',
+    '形状': 'Shapes',
+    '图标': 'Icons',
+    '插画': 'Illustrations',
+    '抠图': 'Cutouts',
+    '回收标志': 'Recycle symbol',
+    '向上': 'This way up',
+    '防雨': 'Keep dry',
+    '防潮 / 保持干燥': 'Moisture-proof / keep dry',
+    '易碎品(酒杯)': 'Fragile (glass)',
+    '堆码层数': 'Stack limit',
+    '小心棱角': 'Mind sharp edges',
+    'CE 认证': 'CE mark',
+    'FC 认证': 'FC mark',
+    '绿点回收': 'Green dot',
+    'ISO 质量': 'ISO quality',
+    '请勿乱扔': 'Do not litter',
+    '电子回收': 'Battery recycling',
+    '苹果': 'Apple',
+    '叶子环保': 'Eco leaf',
+    '爱心': 'Heart',
+    '星星': 'Star',
+    '方形': 'Square',
+    '圆形': 'Circle',
+    '三角形': 'Triangle',
+    '圆环': 'Ring',
+    '横线': 'Line',
+    '丝带横幅': 'Ribbon banner',
+    '圆形徽章': 'Round badge',
+    '圆角框': 'Rounded frame',
+
+    /* ---- boxlib.js: textures & animations ---- */
+    '牛皮纸纹': 'Kraft texture',
+    '圆点': 'Dots',
+    '斜条纹': 'Diagonal stripes',
+    '亚麻': 'Linen',
+    '碎花': 'Floral',
+    '大理石': 'Marble',
+    '折叠展开': 'Fold-out',
+    '物体平视自转一圈': 'Object spin (eye level)',
+    '物体俯视自转一周': 'Object spin (top view)',
+    '旋转掉落': 'Spin & drop',
+    '由远到近': 'Zoom in',
+    '掉落后放大细节': 'Drop & zoom detail',
+    '由远到近放大细节': 'Zoom in to detail',
+    '从左侧旋转入场': 'Rotate in from left',
+    '由远到近曲线入场': 'Curved zoom in',
+    '折叠动画弹跳入场': 'Fold bounce entrance',
+
+    /* ---- admin.js: login / shell ---- */
+    '用户名': 'Username',
+    '密码': 'Password',
+    '管理员账号': 'Admin account',
+    '登 录': 'Sign in',
+    '默认账号 admin / admin123,登录后请尽快修改密码': 'Default account admin / admin123 — change the password right after signing in',
+    '袋研社 · 后台管理': 'POUCHLAB · Admin',
+    '袋研社后台': 'POUCHLAB Admin',
+    '工厂协作端': 'Factory Portal',
+    '仪表盘': 'Dashboard',
+    '订单管理': 'Orders',
+    '用户管理': 'Users',
+    'AI 设置': 'AI Settings',
+    '生产订单': 'Production orders',
+    '退出': 'Sign out',
+    '(协作工厂)': ' (Factory)',
+    '(管理员)': ' (Admin)',
+    '该账号无后台权限': 'This account has no admin access',
+    '请输入用户名和密码': 'Enter username and password',
+    '请填写用户名和密码': 'Enter username and password',
+    '登录失败': 'Sign-in failed',
+    '登录失败,请重试': 'Sign-in failed, please try again',
+
+    /* ---- admin.js: dashboard & orders ---- */
+    '订单总数': 'Total orders',
+    '今日新增订单': 'New today',
+    '待发货': 'To ship',
+    '已支付金额': 'Paid amount',
+    '注册用户': 'Registered users',
+    '今日 AI 排版': 'AI layouts today',
+    '最新订单': 'Latest orders',
+    '全部订单 →': 'All orders →',
+    '订单号': 'Order no.',
+    '类型': 'Type',
+    '规格': 'Spec',
+    '规格摘要': 'Spec summary',
+    '下单时间': 'Placed at',
+    '下单': 'Placed',
+    '操作': 'Actions',
+    '搜索订单号': 'Search order no.',
+    '搜索订单号 / 联系人 / 手机号': 'Search order no. / contact / phone',
+    '搜索手机号 / 昵称': 'Search phone / nickname',
+    '用户:': 'User:',
+    '昵称': 'Nickname',
+    '订单数': 'Orders',
+    '消费额': 'Spent',
+    'AI 用量': 'AI usage',
+    '注册时间': 'Registered',
+    '正常': 'Active',
+    '已禁用': 'Disabled',
+    '禁用': 'Disable',
+    '启用': 'Enable',
+    'AI 额度': 'AI quota',
+    '查看订单': 'View orders',
+    '工厂名称': 'Factory name',
+    '分配订单数': 'Assigned orders',
+    '创建时间': 'Created',
+    '改名/重置密码': 'Rename / reset password',
+    '工厂账号': 'Factory accounts',
+    '+ 新建工厂账号': '+ New factory account',
+    '一家协作工厂一个账号;订单在「订单详情 → 分配工厂」指定后,对应工厂才能看到该订单(用户隐私自动脱敏)': 'One account per partner factory. After a factory is assigned in Order details → Assign factory, only that factory can see the order (customer privacy is masked).',
+    '新建工厂账号': 'New factory account',
+    '创建': 'Create',
+    '保存': 'Save',
+    '登录用户名(3-30 位字母/数字/下划线)': 'Username (3-30 letters / digits / underscore)',
+    '如 hangzhou-box': 'e.g. hangzhou-box',
+    '工厂名称(对外显示)': 'Factory name (public)',
+    '如 杭州彩印包装厂': 'e.g. Hangzhou Color Print Packaging',
+    '初始密码(至少 6 位)': 'Initial password (min. 6 characters)',
+    '重置密码(留空则不修改)': 'Reset password (leave blank to keep)',
+    '至少 6 位': 'At least 6 characters',
+    '新密码至少 6 位': 'New password must be at least 6 characters',
+    '工厂用此账号在 admin.html 登录,仅见分配给它的订单': 'Factory signs in with this account on admin.html and only sees assigned orders',
+    '工厂账号已创建': 'Factory account created',
+    '工厂账号加载失败': 'Failed to load factory accounts',
+
+    /* ---- admin.js: order drawer ---- */
+    '尺寸': 'Size',
+    '工艺': 'Finish',
+    '盒型': 'Box type',
+    '内尺寸': 'Inner size',
+    '厚': 'Thickness',
+    '印色': 'Print colors',
+    '印刷方式': 'Print method',
+    '摘要': 'Summary',
+    '规格与金额': 'Spec & amount',
+    '下单与联系': 'Order & contact',
+    '收货地址': 'Shipping address',
+    '用户备注': 'Customer note',
+    '订单操作': 'Order actions',
+    '分配工厂(分配后该工厂才能看到此订单)': 'Assign factory (it can see this order after assignment)',
+    '未分配': 'Unassigned',
+    '管理员备注': 'Admin note',
+    '内部备注(用户不可见)': 'Internal note (hidden from customers)',
+    '保存修改': 'Save changes',
+    '生产图纸 PDF': 'Production drawing PDF',
+    '矢量刀版 1:1': 'Vector dieline 1:1',
+    'CAD 预览': 'CAD preview',
+    '设计稿': 'Artwork',
+    '物流发货': 'Shipping',
+    '快递公司(如 顺丰速运)': 'Carrier (e.g. SF Express)',
+    '发货': 'Ship',
+    '设计问题反馈': 'Design issue feedback',
+    '工厂协作': 'Factory collaboration',
+    '管理员': 'Admin',
+    '工厂': 'Factory',
+    '回复': 'Reply',
+    '提交反馈': 'Submit feedback',
+    '回复工厂…': 'Reply to factory…',
+    '描述设计问题(如:正面文字超出安全区 2mm,建议内移…)': 'Describe the issue (e.g. front text exceeds the safe area by 2mm — move it inward…)',
+    '如发现设计问题(出血不足、图文越界、工艺冲突等),请在下方提交,平台会转达用户。': 'If you spot design issues (insufficient bleed, text outside the safe area, process conflicts), submit below and the platform will relay it to the customer.',
+    '工厂的反馈会显示在这里,可选择将问题整理成邮件通知用户。': 'Factory feedback appears here; you can turn it into an email to notify the customer.',
+    '✉ 邮件通知用户(模板)': '✉ Email customer (template)',
+    '操作时间线': 'Activity timeline',
+    '邮件通知用户(模板已生成,可编辑)': 'Email customer (template ready, editable)',
+    '发送': 'Send',
+    '收件人:': 'To:',
+    '未留邮箱': 'No email on file',
+    '(未留邮箱)': '(No email on file)',
+    '未配置 SMTP 或订单未留邮箱时,内容将存档到反馈线程,可复制到其他渠道': 'If SMTP is not configured or the order has no email, the content is archived to the feedback thread and can be copied elsewhere',
+    '邮件主题': 'Email subject',
+    '邮件正文(模板已按工厂反馈自动生成)': 'Email body (auto-generated from factory feedback)',
+    '工厂 CAD 图纸': 'Factory CAD drawing',
+    '滚轮缩放 · 拖拽平移 · 可点选图元查看图层': 'Scroll to zoom · Drag to pan · Click entities to inspect layers',
+    '下载 DXF': 'Download DXF',
+
+    /* ---- admin.js: statuses / toasts / config ---- */
+    '订单加载失败': 'Failed to load orders',
+    '用户加载失败': 'Failed to load users',
+    '配置加载失败': 'Failed to load configuration',
+    '详情加载失败': 'Failed to load details',
+    'AI 配置已保存': 'AI settings saved',
+    '保存失败': 'Save failed',
+    '已保存': 'Saved',
+    '额度已保存': 'Quota saved',
+    '额度已保存且用量已清零': 'Quota saved and usage reset',
+    '操作失败': 'Operation failed',
+    '已启用': 'Enabled',
+    '请填写反馈/回复内容': 'Please enter feedback or a reply',
+    '反馈已提交,等待平台处理': 'Feedback submitted — awaiting platform review',
+    '回复已发送': 'Reply sent',
+    '提交失败': 'Submit failed',
+    '请填写邮件主题与内容': 'Please enter an email subject and body',
+    '邮件已发送给用户': 'Email sent to customer',
+    '该订单未留邮箱,可编辑存档内容供其他渠道使用': 'No email on file for this order — edit the archived content for other channels',
+    '该订单未留邮箱,内容已存档到反馈线程': 'No email on file — content archived to the feedback thread',
+    'SMTP 未配置,内容已存档(可复制到其他渠道发送)': 'SMTP not configured — content archived (copy it to send elsewhere)',
+    '发送失败': 'Failed to send',
+    '请填写快递公司和运单号': 'Please enter the carrier and tracking number',
+    '已发货并通知用户': 'Shipped and customer notified',
+    '发货失败': 'Failed to ship',
+    '生成失败': 'Generation failed',
+    '下载失败': 'Download failed',
+    'CAD 预览加载失败': 'Failed to load CAD preview',
+    'CAD 图纸已下载': 'CAD drawing downloaded',
+    '生产图纸已下载': 'Production drawing downloaded',
+    '已下载': 'Downloaded',
+    'EPS 已下载:CorelDRAW 打开后「另存为 CDR」即得 .cdr 文件': 'EPS downloaded: open it in CorelDRAW and choose Save As CDR to get a .cdr file',
+    '测试失败': 'Test failed',
+    '未知错误': 'Unknown error',
+    '保存配置': 'Save settings',
+    '测试连通': 'Test connection',
+    'API 地址(Base URL,如 https://open.bigmodel.cn/api/paas/v4)': 'API URL (Base URL, e.g. https://open.bigmodel.cn/api/paas/v4)',
+    '模型名(如 glm-4-flash / glm-4.6 / deepseek-chat)': 'Model name (e.g. glm-4-flash / glm-4.6 / deepseek-chat)',
+    '留空保持不变': 'Leave blank to keep',
+    '粘贴 API Key': 'Paste API key',
+    'AI 排版未启用:未配置 API Key': 'AI layout disabled: no API key configured',
+    '配置存于数据库(后台即时生效,优先于部署环境变量)。支持任意 OpenAI 兼容接口:智谱 / ModelScope / DeepSeek / 自建 vLLM 等。': 'Settings are stored in the database (effective immediately, overriding deployment env vars). Any OpenAI-compatible API works: Zhipu / ModelScope / DeepSeek / self-hosted vLLM, etc.',
+    '用量说明': 'Usage notes',
+    '· 每位用户默认 20 次,在「用户管理 → AI 额度」按人调整(设 0 禁用)': '· Each user gets 20 runs by default; adjust per user in Users → AI quota (set 0 to disable)',
+    '· 用户每次成功生成扣 1 次,失败不扣;仪表盘显示"今日 AI 排版"': '· Each successful generation costs 1 run; failures are free. The dashboard shows "AI layouts today"',
+    '· Key 仅存储在服务端数据库,界面只回显打码值': '· Keys are stored only in the server database; the UI shows masked values',
+    '取消': 'Cancel',
+    '保存并清零用量': 'Save & reset usage',
+    '登录已失效,请重新登录': 'Session expired, please sign in again'
+  });
+
+  D.rules.push(
+    [/^共 (\d+) 位用户$/, function (m) { return m[1] + ' users'; }],
+    [/^AI 排版额度 · (.+)$/, function (m) { return 'AI layout quota · ' + m[1]; }],
+    [/^修改工厂账号((.+))$/, function (m) { return 'Edit factory account (' + m[1] + ')'; }],
+    [/^订单 (.+)$/, function (m) { return 'Order ' + m[1]; }],
+    [/^已用 (\d+) 次。设为 0 表示禁止该用户使用 AI 排版。$/, function (m) { return 'Used ' + m[1] + ' times. Set to 0 to disable AI layout for this user.'; }],
+    [/^当前物流:(.+)$/, function (m) { return 'Tracking: ' + m[1]; }],
+    [/^已发送邮件至 (.+)$/, function (m) { return 'Email sent to ' + m[1]; }],
+    [/^邮件内容已存档((.+))$/, function (m) { return 'Email archived (' + m[1] + ')'; }],
+    [/^主题:(.+)$/, function (m) { return 'Subject: ' + m[1]; }],
+    [/^(当前:(.+),留空则不修改)$/, function (m) { return ' (current: ' + m[1] + ', leave blank to keep)'; }],
+    [/^连通成功 · (.+)$/, function (m) { return 'Connected · ' + m[1]; }],
+    [/^连通失败:(.+)$/, function (m) { return 'Connection failed: ' + m[1]; }],
+    [/^AI 排版已启用(模型 (.+))$/, function (m) { return 'AI layout enabled (model ' + m[1] + ')'; }],
+    [/^(已禁用)$/, function () { return ' (disabled)'; }],
+    [/^用户:(.+)$/, function (m) { return 'User: ' + m[1]; }],
+    [/^(\d+) 件$/, function (m) { return m[1] + ' pcs'; }],
+    [/^发送失败已存档:(.+)$/, function (m) { return 'Send failed, archived: ' + m[1]; }]
+  );
+})(window.PLI18N_EN);
+
+/* 批次 6:studio 动态面板 / box 面板与提示 / m / auth / agent / admin 补充 / SVG 标注 */
+(function (D) {
+  Object.assign(D.dict, {
+    /* ---- studio.html 动态面板 ---- */
+    'Logo 请使用 1 色或透明背景 PNG;图片会自动等比缩放。上传后可在右侧属性面板调整「填满 / 完整显示」与单色印刷。': 'Use a 1-color or transparent PNG logo; images scale proportionally. After upload, adjust “Cover / Contain” and single-color printing in the right panel.',
+    'PNG · JPG · SVG · 建议 ≥ 1000px': 'PNG · JPG · SVG · Recommended ≥ 1000px',
+    '一键清空全部': 'Clear all',
+    '位置与尺寸': 'Position & size',
+    '使用建议': 'Tips',
+    '保存后可随时切换不同设计方案,最多 12 个。': 'Save designs and switch between up to 12 at any time.',
+    '刀版线外 3mm 为出血位,重要文字请放在安全区内。': 'Keep 3 mm bleed beyond the die line; place key text inside the safe area.',
+    '切换尺寸或数量后价格会实时更新。': 'Price updates instantly when size or quantity changes.',
+    '删除图层': 'Delete layer',
+    '删除方案': 'Delete design',
+    '副标题': 'Subheading',
+    '单色印刷': 'Single-color print',
+    '印刷底色': 'Print background',
+    '印刷画布': 'Print canvas',
+    '圆角': 'Corner radius',
+    '基础图形': 'Basic shapes',
+    '填充': 'Fill',
+    '填充方式': 'Fill mode',
+    '填写网址、微信号或任意文字即可生成二维码;保留浅色底可提高扫码成功率。': 'Enter a URL, WeChat ID or any text to generate a QR code; a light background improves scan reliability.',
+    '填满裁切': 'Cover (crop)',
+    '复制到': 'Copy to',
+    '复制到另一面': 'Copy to other side',
+    '外观': 'Appearance',
+    '大标题': 'Headline',
+    '字体': 'Font',
+    '字体 Aa': 'Font Aa',
+    '字号 mm': 'Size (mm)',
+    '字距': 'Letter spacing',
+    '完整显示': 'Contain (fit)',
+    '平台素材': 'Platform assets',
+    '当前袋型': 'Current pouch type',
+    '当前面': 'Current side',
+    '我的方案': 'My designs',
+    '报价': 'Quote',
+    '拖动四角可等比缩放。': 'Drag a corner to scale proportionally.',
+    '描边宽': 'Stroke width',
+    '无底色': 'No background',
+    '无衬线大写字母': 'Sans-serif caps',
+    '显示刀版线': 'Show die line',
+    '显示图层': 'Show layers',
+    '显示数字': 'Show numbers',
+    '替换图片': 'Replace image',
+    '最近上传': 'Recent uploads',
+    '条码 / SKU': 'Barcode / SKU',
+    '正文': 'Body text',
+    '浅色底': 'Light background',
+    '添加二维码': 'Add QR code',
+    '添加文字': 'Add text',
+    '添加条码': 'Add barcode',
+    '点击上传,或拖入图片': 'Click to upload or drop an image',
+    '点击应用或新建': 'Apply or create new',
+    '点击放置到画布': 'Click to place on canvas',
+    '环文字号': 'Arc text size',
+    '画布工具': 'Canvas tools',
+    '码点颜色': 'Module color',
+    '素材为矢量图标,可任意缩放;拖动四角等比调整大小。': 'Vector icons scale freely; drag a corner to resize proportionally.',
+    '给当前设计起个名字': 'Name this design',
+    '自定义底色': 'Custom background',
+    '英文标题': 'English title',
+    '行高': 'Line height',
+    '补充口味或卖点': 'Add flavor or selling point',
+    '贴纸': 'Sticker',
+    '贴纸库': 'Sticker library',
+    '载入': 'Load',
+    '载入方案': 'Load design',
+    '输入 12–13 位数字会生成真实 EAN-13 校验位;输入链接或文字会生成稳定条码。': '12–13 digits generate a valid EAN-13 check digit; a link or text produces a stable barcode.',
+    '返回设置': 'Back to settings',
+    '这一面还没有图层': 'No layers on this side yet',
+    '适合品牌名 / 产品名': 'For brand / product name',
+    '配料、说明与信息': 'Ingredients, instructions & info',
+    '隐藏图层': 'Hide layer',
+    '高度': 'Height',
+    '高度(自动)': 'Height (auto)',
+    'AI 结果直接应用到画布,可随时撤销(⌘Z)。每次生成消耗 1 次额度。': 'AI results apply directly to the canvas and can be undone (⌘Z). Each generation uses 1 credit.',
+    '袋型、尺寸、材质与数量都会影响最终报价。': 'Pouch type, size, material and quantity all affect the final quote.',
+    '实时报价': 'Live quote',
+    '个 · 100 起订': 'pcs · MOQ 100',
+    '旋转 °': 'Rotation °',
+    '正面 / 背面': 'Front / Back',
+    '已删除 · 可撤销': 'Deleted · Undoable',
+    '已清空全部设计 · 可撤销': 'All designs cleared · Undoable',
+    '已切换袋型,设计已等比适配': 'Pouch type switched, design scaled to fit',
+    '登录后可用 AI 排版': 'Sign in to use AI layout',
+    'AI 排版已应用,可继续提修改意见': 'AI layout applied. Ask for further changes anytime.',
+    '设计已保存到本地': 'Design saved locally',
+    'AI 排版(登录后可用)': 'AI layout (sign-in required)',
+
+    /* ---- box.html 面板与提示 ---- */
+    '上传图片': 'Upload image',
+    '上传的稿件会放置到当前选中的面': 'Uploads are placed on the currently selected side',
+    '从上传记录中移除': 'Remove from uploads',
+    '外尺寸': 'Outer size',
+    '内尺寸': 'Inner size',
+    '扩充容量': 'Expand storage',
+    '支持上传JPG/PNG/SVG等格式文件': 'Supports JPG / PNG / SVG files',
+    '演示环境:容量为本地浏览器存储模拟': 'Demo: storage is simulated in your browser',
+    '请输入内容': 'Enter content',
+    '添加到当前面': 'Add to current side',
+    '开孔': 'Hole',
+    '整套 6 面': 'all 6 faces',
+    '(外侧)': ' (outer)',
+    '(内侧)': ' (inner)',
+    '裁切线': 'Cut line',
+    '折叠线': 'Fold line',
+    '防尘翼/插舌(不印刷)': 'Dust flap / tuck (no print)',
+    '模型ID': 'Model ID',
+    '1. 在「盒型」面板选择盒型与尺寸,或点「编辑」打开智能参数宝精确调参;': '1. Choose a box type and size in the “Box” panel, or click “Edit” to fine-tune with the smart parameter tool;',
+    '2. 在 2D 设计里点选面,用「文字 / 素材 / 上传」添加内容,右侧换颜色与纹理;': '2. In 2D design, click a face and add content with “Text / Assets / Upload”; change colors and textures on the right;',
+    '3. 切到「3D预览」拖拽查看,播放动效,最后「导出」或「印刷下单」。': '3. Switch to “3D Preview” to drag, rotate and play animations, then “Export” or “Order print”.',
+    'Ctrl/⌘ + S 保存': 'Ctrl/⌘ + S Save',
+    'Ctrl/⌘ + Shift + Z 重做': 'Ctrl/⌘ + Shift + Z Redo',
+    'Ctrl/⌘ + Z 撤销': 'Ctrl/⌘ + Z Undo',
+    'Delete 删除选中元素': 'Delete Remove selected element',
+    'Tab 切换外侧 / 内侧': 'Tab Switch outer / inner',
+    '空格拖拽 平移画布': 'Space + drag Pan canvas',
+    '前面': 'Front',
+    '右面': 'Right',
+    '左面': 'Left',
+
+    /* ---- m.html ---- */
+    '+ 直接下单': '+ Order now',
+    '← 返回列表': '← Back to list',
+    '「做一个 140×210 的咖啡袋,牛皮纸,极简风,200 个」': '“Design a 140×210 coffee pouch, kraft paper, minimal style, 200 pcs”',
+    '加载中…': 'Loading…',
+    '加载失败': 'Load failed',
+    '在「AI 设计」里出稿后一键下单,或直接快速下单。': 'Generate a design in “AI Design” and order in one tap, or order directly.',
+    '手机版 · 完整设计工作台请用电脑访问 studio.html / box.html': 'Mobile edition · For the full design workspace, visit studio.html / box.html on desktop',
+    '收货人': 'Recipient',
+    '生产 / 物流轨迹': 'Production / logistics timeline',
+    '电话': 'Phone',
+
+    /* ---- auth / agent ---- */
+    '发送失败,请稍后再试': 'Failed to send. Please try again later.',
+    '我会逐步选型、定尺寸、配材质并生成图案,右侧实时预览,满意后点「去微调」。': 'I’ll pick the type, size and material step by step, generate artwork, and preview it live on the right. Tap “Fine-tune” when you are happy.',
+
+    /* ---- admin 补充 ---- */
+    '📊 仪表盘': '📊 Dashboard',
+    '📦 订单管理': '📦 Orders',
+    '📦 生产订单': '📦 Production',
+    '👥 用户管理': '👥 Users',
+    '🤖 AI 设置': '🤖 AI settings',
+    '状态': 'Status',
+    '支付': 'Payment',
+    'EPS 矢量(CorelDRAW 原生导入,另存为 CDR 即得 .cdr 文件)': 'EPS vector (imports natively in CorelDRAW; save as CDR to get a .cdr file)',
+    'mm 实尺矢量刀版,CorelDRAW/Illustrator 可直接打开编辑(CDR 交付替代)': 'Actual-size vector die line (mm), editable directly in CorelDRAW/Illustrator (CDR alternative)',
+    'CAD 图纸获取失败': 'Failed to get CAD drawing',
+    'CAD 预览加载失败': 'Failed to load CAD preview',
+    'CAD 图纸已下载': 'CAD drawing downloaded',
+    '正在生成 CAD 图纸…': 'Generating CAD drawing…',
+    '正在生成生产图纸…': 'Generating production PDF…',
+    '生产图纸已下载': 'Production PDF downloaded',
+    '生成失败': 'Generation failed',
+    '该订单未留邮箱,可编辑存档内容供其他渠道使用': 'No email on this order; edit the archived content for other channels',
+    '该订单未留邮箱,内容已存档到反馈线程': 'No email on this order; content archived to the feedback thread',
+    '(未留邮箱)': '(no email)',
+
+    /* ---- 数据/素材标签 ---- */
+    '局部 UV': 'Spot UV'
+  });
+
+  var SIDE = { '正面': 'Front', '背面': 'Back', '前面': 'Front', '后面': 'Back', '左面': 'Left', '右面': 'Right', '顶面': 'Top', '底面': 'Bottom', '左': 'L', '右': 'R', '顶': 'T', '底': 'B', '正': 'Front', '背': 'Back' };
+  function side(s) { return SIDE[s] || s; }
+
+  D.rules.push(
+    /* studio 动态文案 */
+    [/^下一步 · ¥([\d.]+)$/, function (m) { return 'Next · ¥' + m[1]; }],
+    [/^提交订单 · ¥([\d.]+)$/, function (m) { return 'Place order · ¥' + m[1]; }],
+    [/^合计 · (\d+) 个$/, function (m) { return 'Total · ' + m[1] + ' pcs'; }],
+    [/^图层 · (正面|背面)$/, function (m) { return 'Layers · ' + side(m[1]); }],
+    [/^(\d+) 个$/, function (m) { return m[1] + ' pcs'; }],
+    [/^不透明度 (\d+)%$/, function (m) { return 'Opacity ' + m[1] + '%'; }],
+    [/^方案已保存 · (.+)$/, function (m) { return 'Design saved · ' + m[1]; }],
+    [/^已保存 (\d{2}:\d{2})$/, function (m) { return 'Saved ' + m[1]; }],
+    [/^已载入方案 · (.+)$/, function (m) { return 'Design loaded · ' + m[1]; }],
+    [/^已选择「(.+)」$/, function (m) { return 'Selected “' + m[1] + '”'; }],
+    [/^已套用模板「(.+)」· 可撤销$/, function (m) { return 'Template “' + m[1] + '” applied · Undoable'; }],
+    [/^复制到(正面|背面)$/, function (m) { return 'Copy to ' + side(m[1]); }],
+    [/^已复制到(正面|背面)$/, function (m) { return 'Copied to ' + side(m[1]); }],
+    [/^已清空(正面|背面) · 可撤销$/, function (m) { return 'Cleared ' + side(m[1]) + ' · Undoable'; }],
+    [/^(\d+) × (\d+) mm · 正面预览$/, function (m) { return m[1] + ' × ' + m[2] + ' mm · Front preview'; }],
+    [/^描述你想要的排版/, function () { return 'Describe the layout you want, e.g.:\nMinimal coffee packaging, warm beige base, serif brand name on top, coffee-bean sticker in the middle, one line of English slogan at the bottom\nAfter generating you can say: make the text bigger / switch to a dark background'; }],
+
+    /* box 提示与操作反馈 */
+    [/^当前面有 (\d+) 个图层,全部面共 (\d+) 个图层。$/, function (m) { return 'This side has ' + m[1] + ' layers; ' + m[2] + ' in total across all sides.'; }],
+    [/^(.*) · (\d+) 个图层$/, function (m) { return (SIDE[m[1]] || m[1]) + ' · ' + m[2] + ' layers'; }],
+    [/^个人已使用 ([\d.]+)M\/100M$/, function (m) { return 'Used ' + m[1] + 'M / 100M'; }],
+    [/^素材已添加到「(.+)」$/, function (m) { return 'Asset added to “' + (SIDE[m[1]] || m[1]) + '”'; }],
+    [/^已切换到「(.+)」$/, function (m) { return 'Switched to “' + (D.dict[m[1]] || m[1]) + '”'; }],
+    [/^模板「(.+)」已套用到(.+)$/, function (m) { return 'Template “' + (D.dict[m[1]] || m[1]) + '” applied to ' + (D.dict[m[2]] || m[2]); }],
+    [/^✨ AI 排版 · (.+)$/, function (m) { return '✨ AI Layout · ' + m[1]; }],
+    [/^AI 已完成整套 6 面设计(剩余 (\d+) 次),可撤销$/, function (m) { return 'AI finished all 6 faces (' + m[1] + ' left) · Undoable'; }],
+    [/^AI 排版已应用到(.+)(剩余 (\d+) 次),可撤销$/, function (m) { return 'AI layout applied to ' + m[1] + ' (' + m[2] + ' left) · Undoable'; }],
+    [/^已清空「(.+)」图层$/, function (m) { return 'Cleared layers on “' + (SIDE[m[1]] || m[1]) + '”'; }],
+    [/^清空当前面((\d+))$/, function (m) { return 'Clear current side (' + m[1] + ')'; }],
+    [/^正在录制「(.+)」([\d.]+)s…$/, function (m) { return 'Recording “' + m[1] + '” for ' + m[2] + 's…'; }],
+    [/^已创建副本:(.+)$/, function (m) { return 'Duplicate created: ' + m[1]; }],
+    [/^已打开「(.+)」$/, function (m) { return 'Opened “' + m[1] + '”'; }],
+    [/^模型ID: (.+)$/, function (m) { return 'Model ID: ' + m[1]; }],
+
+    /* SVG 刀版标注(data-ui) */
+    [/^折边 (\d+)$/, function (m) { return 'Fold ' + m[1]; }],
+    [/^封边 (\d+)$/, function (m) { return 'Seal ' + m[1]; }],
+    [/^面 ([\d.]+) × ([\d.]+) mm$/, function (m) { return 'Face ' + m[1] + ' × ' + m[2] + ' mm'; }],
+    [/^Ø([\d.]+) 开孔$/, function (m) { return 'Ø' + m[1] + ' hole'; }],
+    [/^(正|背|左|右|顶|底) (\d+) × (\d+)$/, function (m) { return side(m[1]) + ' ' + m[2] + ' × ' + m[3]; }],
+
+    /* auth / admin 补充 */
+    [/^离线演示验证码:(\d+)$/, function (m) { return 'Offline demo code: ' + m[1]; }],
+    [/^API Key(未配置)$/, function () { return 'API Key (not configured)'; }],
+    [/^收件人:(.+?) — 未配置 SMTP 或订单未留邮箱时,内容将存档到反馈线程,可复制到其他渠道$/, function (m) { return 'To: ' + m[1] + ' — If SMTP is not configured or the order has no email, content is archived to the feedback thread and can be copied elsewhere'; }]
+  );
+})(window.PLI18N_EN);
+
+/* 批次 7:刀版组合标注 */
+(function (D) {
+  D.rules.push(
+    [/^(内侧设计 · 镜像|外侧设计) · 模型ID (.+)$/, function (m) {
+      return (m[1] === '外侧设计' ? 'Outside design' : 'Inside design · mirrored') + ' · Model ID ' + m[2];
+    }]
+  );
+})(window.PLI18N_EN);
+
+/* 批次 8:订单详情材质行 */
+(function (D) {
+  D.rules.push(
+    [/^(.+) · 厚 (.+)$/, function (m) { return (D.dict[m[1]] || m[1]) + ' · ' + m[2] + ' thick'; }]
+  );
+})(window.PLI18N_EN);
+
+/* 批次 9:价格单位、数量、页面标题组合串 */
+(function (D) {
+  Object.assign(D.dict, {
+    " / 个起": " / pc+",
+    "个起": "pc+"
+  });
+  D.rules.push(
+    [/^(.+) — 袋研社 POUCHLAB$/, function (m) { return (D.dict[m[1]] || m[1]) + ' — POUCHLAB'; }],
+    [/^¥([\d,.]+) \/ 个$/, function (m) { return '$' + m[1] + ' / pc'; }],
+    [/^¥([\d,.]+) \/ (\d[\d,]*) 个$/, function (m) { return '$' + m[1] + ' / ' + m[2] + ' pcs'; }],
+    [/^(¥([\d,.]+)\/个)$/, function (m) { return ' ($' + m[1] + '/pc)'; }],
+    [/^\/ (\d[\d,]*) 个$/, function (m) { return '/ ' + m[1] + ' pcs'; }],
+    [/^(.+) — 3D云设计编辑器 · 袋研社$/, function (m) { return (D.dict[m[1]] || m[1]) + ' — 3D Box Designer · PouchLab'; }],
+    [/^(正面|背面|前面|后面|左面|右面|顶面|底面)\s+([\d.]+ × [\d.]+)( mm)?$/, function (m) { return (D.dict[m[1]] || m[1]) + ' ' + m[2] + (m[3] || ''); }],
+    [/^展开\s+([\d.]+ × [\d.]+)( mm)?$/, function (m) { return 'Flat ' + m[1] + (m[2] || ''); }],
+    [/^(.+) · (\d[\d,]*) 个$/, function (m) { return (D.dict[m[1]] || m[1]) + ' · ' + m[2] + ' pcs'; }],
+    [/^(\d[\d,]*) 个$/, function (m) { return m[1] + ' pcs'; }]
+  );
+})(window.PLI18N_EN);
+/* __MORE_ENTRIES__ */

+ 308 - 0
assets/js/i18n.js

@@ -0,0 +1,308 @@
+/*
+ * 轻量 i18n:中文为源文案,英文通过 zh→en 字典(i18n-en.js)映射。
+ * - 静态/动态文案统一在 DOM 层翻译(MutationObserver 覆盖后插入的节点)
+ * - JS 里需要提前拿到译文时用 PL.t('中文')
+ * - 语言解析优先级:?lang= > localStorage > navigator
+ */
+(function (w, d) {
+  'use strict';
+
+  var LS_KEY = 'pouchlab.lang';
+  var SUPPORTED = ['zh', 'en'];
+  var EN = w.PLI18N_EN || {};
+  var dict = EN.dict || {};
+  var rules = EN.rules || [];
+  var SKIP = 'svg,canvas,script,style,noscript,textarea,[data-no-i18n]';
+  var ATTRS = ['placeholder', 'title', 'aria-label', 'alt'];
+
+  var lang = 'zh';
+  var observer = null;
+  var booted = false;
+
+  function norm(s) { return String(s).replace(/\s+/g, ' ').trim(); }
+
+  function resolveLang() {
+    try {
+      var q = new URLSearchParams(w.location.search).get('lang');
+      if (q && SUPPORTED.indexOf(q) >= 0) {
+        try { localStorage.setItem(LS_KEY, q); } catch (e) {}
+        return q;
+      }
+      var saved = localStorage.getItem(LS_KEY);
+      if (saved && SUPPORTED.indexOf(saved) >= 0) return saved;
+    } catch (e) {}
+    var n = (navigator.language || 'zh').toLowerCase();
+    return n.indexOf('zh') === 0 ? 'zh' : 'en';
+  }
+
+  function translate(key) {
+    if (lang === 'zh' || !key) return null;
+    var v = dict[key];
+    if (v != null) return v;
+    for (var i = 0; i < rules.length; i++) {
+      var r = rules[i];
+      if (!r || !r[0] || !r[1]) continue;
+      var m = key.match(r[0]);
+      if (m) return r[1](m);
+    }
+    return null;
+  }
+
+  function applyTextNode(node) {
+    var p = node.parentElement;
+    if (!p) return;
+    // SVG 默认跳过(画布内是用户设计内容);仅翻译带 data-ui="1" 的界面标注
+    if (p.closest('svg') ? !p.closest('[data-ui="1"]') : p.closest(SKIP)) return;
+    var raw = node.nodeValue;
+    if (!raw || !/\S/.test(raw)) return;
+
+    if (node.__pliSrc === undefined) node.__pliSrc = raw;
+    else if (node.__pliOut !== undefined && raw !== node.__pliOut) {
+      // 应用层主动改写了文本(React/JS 重渲染),重新记录源文案
+      node.__pliSrc = raw;
+      node.__pliOut = undefined;
+    }
+
+    if (lang === 'zh') {
+      if (raw !== node.__pliSrc) {
+        node.__pliOut = undefined;
+        node.nodeValue = node.__pliSrc;
+      }
+      return;
+    }
+
+    var out = translate(norm(node.__pliSrc));
+    if (out == null) return;
+    var src = String(node.__pliSrc);
+    var lead = (src.match(/^\s*/) || [''])[0];
+    var trail = (src.match(/\s*$/) || [''])[0];
+    var val = lead + out + trail;
+    if (raw !== val) {
+      node.__pliOut = val;
+      node.nodeValue = val;
+    } else {
+      node.__pliOut = val;
+    }
+  }
+
+  function applyAttrs(el) {
+    if (!el.getAttribute || !el.closest || el.closest('[data-no-i18n]')) return;
+    if (!el.__pliAttr) el.__pliAttr = {};
+    for (var i = 0; i < ATTRS.length; i++) {
+      var a = ATTRS[i];
+      var v = el.getAttribute(a);
+      if (v == null || !v) continue;
+      if (el.__pliAttr[a] === undefined) el.__pliAttr[a] = v;
+      var src = el.__pliAttr[a];
+      var next = src;
+      if (lang !== 'zh') {
+        var out = translate(norm(src));
+        if (out != null) next = out;
+      }
+      if (v !== next) el.setAttribute(a, next);
+    }
+    if (el.tagName === 'INPUT' && /^(button|submit|reset)$/i.test(el.type || '')) {
+      if (el.__pliVal === undefined) el.__pliVal = el.value;
+      var want = el.__pliVal;
+      if (lang !== 'zh') {
+        var o = translate(norm(el.__pliVal));
+        if (o != null) want = o;
+      }
+      if (el.value !== want) el.value = want;
+    }
+  }
+
+  function walk(root) {
+    if (!root) return;
+    if (root.nodeType === 3) { applyTextNode(root); return; }
+    if (root.nodeType !== 1 && root.nodeType !== 9 && root.nodeType !== 11) return;
+    if (root.nodeType === 1) applyAttrs(root);
+    var tw = d.createTreeWalker(root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null);
+    var n;
+    while ((n = tw.nextNode())) {
+      if (n.nodeType === 3) applyTextNode(n);
+      else applyAttrs(n);
+    }
+  }
+
+  function applyHead() {
+    var title = d.querySelector('title');
+    if (title) {
+      if (!title.__pliSrc) title.__pliSrc = title.textContent;
+      var tv = title.__pliSrc;
+      if (lang !== 'zh') {
+        var to = translate(norm(tv));
+        if (to != null) tv = to;
+      }
+      if (title.textContent !== tv) title.textContent = tv;
+    }
+    var meta = d.querySelector('meta[name="description"]');
+    if (meta) {
+      if (!meta.__pliSrc) meta.__pliSrc = meta.getAttribute('content') || '';
+      var cv = meta.__pliSrc;
+      if (lang !== 'zh') {
+        var co = translate(norm(cv));
+        if (co != null) cv = co;
+      }
+      if (meta.getAttribute('content') !== cv) meta.setAttribute('content', cv);
+    }
+    if (d.documentElement.lang !== (lang === 'zh' ? 'zh-CN' : 'en')) {
+      d.documentElement.lang = lang === 'zh' ? 'zh-CN' : 'en';
+    }
+  }
+
+  function refresh() {
+    walk(d.body || d.documentElement);
+    applyHead();
+  }
+
+  function onMutations(list) {
+    if (lang === 'zh') return;
+    for (var i = 0; i < list.length; i++) {
+      var m = list[i];
+      if (m.type === 'characterData') applyTextNode(m.target);
+      else if (m.type === 'attributes') { if (m.target && m.target.nodeType === 1) applyAttrs(m.target); }
+      else if (m.type === 'childList') {
+        for (var j = 0; j < m.addedNodes.length; j++) walk(m.addedNodes[j]);
+      }
+    }
+  }
+
+  function syncObserver() {
+    if (!w.MutationObserver) return;
+    if (lang === 'en') {
+      if (!observer) {
+        observer = new MutationObserver(onMutations);
+        observer.observe(d.body || d.documentElement, {
+          childList: true, subtree: true, characterData: true,
+          attributes: true, attributeFilter: ATTRS
+        });
+      }
+    } else if (observer) {
+      observer.disconnect();
+      observer = null;
+    }
+  }
+
+  function buildSwitcher() {
+    var box = d.createElement('div');
+    box.className = 'pli-switch';
+    box.setAttribute('data-no-i18n', '');
+    box.setAttribute('role', 'group');
+    box.setAttribute('aria-label', 'Language');
+    SUPPORTED.forEach(function (code) {
+      var b = d.createElement('button');
+      b.type = 'button';
+      b.setAttribute('data-lang', code);
+      b.textContent = code === 'zh' ? '中文' : 'EN';
+      b.setAttribute('aria-pressed', String(code === lang));
+      b.addEventListener('click', function () { setLang(code); });
+      box.appendChild(b);
+    });
+    return box;
+  }
+
+  function mountSwitcher() {
+    if (d.querySelector('.pli-switch')) return;
+    var el = buildSwitcher();
+    var slot = d.querySelector('[data-lang-slot]');
+    if (slot) {
+      slot.appendChild(el);
+    } else {
+      el.classList.add('pli-switch--float');
+      (d.body || d.documentElement).appendChild(el);
+    }
+  }
+
+  function updateSwitcher() {
+    var box = d.querySelector('.pli-switch');
+    if (!box) return;
+    Array.prototype.forEach.call(box.querySelectorAll('button'), function (b) {
+      b.setAttribute('aria-pressed', String(b.getAttribute('data-lang') === lang));
+    });
+  }
+
+  function setLang(code) {
+    if (SUPPORTED.indexOf(code) < 0) return;
+    if (code === lang) return;
+    lang = code;
+    try { localStorage.setItem(LS_KEY, code); } catch (e) {}
+    // 先还原中文再整体应用译文,避免残留
+    var prev = lang;
+    lang = 'zh';
+    refresh();
+    lang = prev;
+    refresh();
+    syncObserver();
+    updateSwitcher();
+    try {
+      if (w.dayjs && w.dayjs.locale) w.dayjs.locale(code === 'zh' ? 'zh-cn' : 'en');
+    } catch (e) {}
+    if (w.PL && w.PL.ui && w.PL.ui.retheme) { try { w.PL.ui.retheme(); } catch (e) {} }
+    d.dispatchEvent(new CustomEvent('pl:langchange', { detail: { lang: lang } }));
+    // 应用层可能在语言切换时重绘(如 React/SVG),重绘后再整体校正一次
+    refresh();
+  }
+
+  function injectStyle() {
+    if (d.getElementById('pli-style')) return;
+    var s = d.createElement('style');
+    s.id = 'pli-style';
+    s.textContent = [
+      '.pli-switch{display:inline-flex;align-items:center;gap:2px;padding:2px;border:1px solid #e2dacb;background:#fffdf8;border-radius:999px;font:600 12px/1 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}',
+      '.pli-switch button{border:0;background:transparent;color:#7d7466;border-radius:999px;padding:5px 9px;cursor:pointer;font:inherit;line-height:1}',
+      '.pli-switch button[aria-pressed="true"]{background:#17140f;color:#fff}',
+      '.pli-switch--float{position:fixed;right:16px;bottom:16px;z-index:9999;box-shadow:0 6px 20px rgba(23,20,15,.14)}'
+    ].join('');
+    (d.head || d.documentElement).appendChild(s);
+  }
+
+  function boot() {
+    if (booted) return;
+    booted = true;
+    injectStyle();
+    refresh();
+    mountSwitcher();
+    syncObserver();
+    updateSwitcher();
+    try {
+      if (w.dayjs && w.dayjs.locale) w.dayjs.locale(lang === 'zh' ? 'zh-cn' : 'en');
+    } catch (e) {}
+  }
+
+  lang = resolveLang();
+
+  var api = {
+    getLang: function () { return lang; },
+    setLang: setLang,
+    toggle: function () { setLang(lang === 'zh' ? 'en' : 'zh'); },
+    t: function (s, vars) {
+      if (lang === 'zh' || s == null) return s;
+      var out = translate(norm(s));
+      if (out == null) return s;
+      if (vars) out = out.replace(/\{(\w+)\}/g, function (_, k) { return vars[k] != null ? vars[k] : '{' + k + '}'; });
+      return out;
+    },
+    refresh: refresh,
+    translate: translate,
+    register: function (extra) {
+      if (!extra) return;
+      if (extra.dict) for (var k in extra.dict) dict[k] = extra.dict[k];
+      if (extra.rules) rules = rules.concat(extra.rules);
+      if (booted) refresh();
+    },
+    mounted: false
+  };
+
+  w.PL = w.PL || {};
+  w.PL.i18n = api;
+  w.PL.t = api.t;
+  w.t = w.t || api.t;
+
+  if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', boot);
+  else boot();
+
+  w.addEventListener('storage', function (e) {
+    if (e.key === LS_KEY && e.newValue && e.newValue !== lang && SUPPORTED.indexOf(e.newValue) >= 0) setLang(e.newValue);
+  });
+})(window, document);

+ 182 - 15
assets/js/orders.js

@@ -6,12 +6,13 @@
   const dayjs = window.dayjs;
   const dayjs = window.dayjs;
 
 
   const state = {
   const state = {
-    items: [], total: 0, page: 1, pageSize: 8, loading: false,
+    items: [], total: 0, local: [], page: 1, pageSize: 8, loading: false,
     drawer: null,        // 选中的订单(详情)
     drawer: null,        // 选中的订单(详情)
     detail: null,        // 详情数据(含 events)
     detail: null,        // 详情数据(含 events)
     detailBusy: false
     detailBusy: false
   };
   };
   const previewCache = new Map();  // "orderNo:key" -> objectURL
   const previewCache = new Map();  // "orderNo:key" -> objectURL
+  const localPreview = new Map();  // "orderNo:key" -> dataURL(本地订单)
 
 
   const STATUS_OPTS = {
   const STATUS_OPTS = {
     pending_payment: { label: '待支付', color: 'orange' },
     pending_payment: { label: '待支付', color: 'orange' },
@@ -56,12 +57,143 @@
     });
     });
   }
   }
 
 
+  function previewSrc(orderNo, key) {
+    if (!key) return null;
+    return localPreview.get(orderNo + ':' + key) || previewCache.get(orderNo + ':' + key) || null;
+  }
+
+  /* ---------------- 本地订单(离线下单 / 本机保存) ---------------- */
+
+  function bagPreview(no, design, side) {
+    const k = no + ':' + side;
+    if (localPreview.has(k)) return localPreview.get(k);
+    let url = null;
+    try {
+      const R = window.PL.render;
+      const D = window.PL.data;
+      if (R && D) {
+        const prod = D.productById(design.productId) || D.products[0];
+        const s = design.sizeId === 'custom' && design.customSize
+          ? { id: 'custom', label: '自定义', w: design.customSize.w, h: design.customSize.h }
+          : D.sizeOf(prod, design.sizeId);
+        const paint = design.bagColor ? Object.assign({}, prod, { mockColor: design.bagColor }) : prod;
+        const sd = (design.sides && design.sides[side]) || { bg: null, elements: [] };
+        const svg = R.bagSVG(paint, side, sd, { size: s, card: true, material: design.material, finish: design.finish });
+        url = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
+      }
+    } catch (e) { url = null; }
+    localPreview.set(k, url);
+    return url;
+  }
+
+  function bagSummary(design) {
+    if (!design) return '包装袋';
+    const D = window.PL.data;
+    if (!D) return '包装袋';
+    try {
+      const p = D.productById(design.productId);
+      const s = design.sizeId === 'custom' && design.customSize
+        ? design.customSize
+        : D.sizeOf(p, design.sizeId);
+      return [p ? p.name : '包装袋', s ? (s.w + '×' + s.h + 'mm') : '', design.qty ? design.qty + ' 只' : '']
+        .filter(Boolean).join(' · ');
+    } catch (e) {
+      return '包装袋';
+    }
+  }
+
+  function bagLocalOrder(raw, key) {
+    let design = raw.design;
+    if (typeof design === 'string') {
+      try { design = JSON.parse(design); } catch (e) { design = null; }
+    }
+    const no = raw.order || key.replace('pouchlab.order.', '');
+    const qty = (raw.spec && raw.spec.qty) || raw.qty || (design && design.qty) || 0;
+    const total = Number(raw.total || 0);
+    const previews = [];
+    if (design) {
+      ['front', 'back'].forEach(function (side) {
+        if (bagPreview(no, design, side)) previews.push(side);
+      });
+    } else if (raw.previews) {
+      Object.keys(raw.previews).forEach(function (k) {
+        const v = raw.previews[k];
+        if (!v) return;
+        localPreview.set(no + ':' + k, /^data:/.test(v) ? v : 'data:image/png;base64,' + v);
+        previews.push(k);
+      });
+    }
+    return {
+      orderNo: no, type: 'bag', local: true,
+      summary: raw.summary || bagSummary(design),
+      spec: { qty: qty },
+      total: total, unitPrice: qty ? total / qty : 0,
+      contactName: raw.name || '-', contactPhone: raw.phone || '-', contactEmail: raw.email || '',
+      address: raw.address || '(本机订单未记录地址)', note: raw.note || '',
+      payStatus: 'unpaid', status: 'pending_payment',
+      createdAt: Math.floor((raw.at || Date.now()) / 1000),
+      previews: previews
+    };
+  }
+
+  function boxLocalOrder(raw) {
+    const no = raw.no || ('PLX' + (raw.time || Date.now()));
+    const previews = [];
+    Object.keys(raw.previews || {}).forEach(function (k) {
+      const v = raw.previews[k];
+      if (!v) return;
+      localPreview.set(no + ':' + k, /^data:/.test(v) ? v : 'data:image/png;base64,' + v);
+      previews.push(k);
+    });
+    // 列表缩略图优先展示 3D 效果
+    const shot = previews.indexOf('box3d');
+    if (shot > 0) previews.unshift(previews.splice(shot, 1)[0]);
+    const qty = Number(raw.qty || 0);
+    const total = Number(raw.total || 0);
+    return {
+      orderNo: no, type: 'box', local: true,
+      summary: raw.summary || ('纸盒 ' + (raw.boxNo || '') + ' · ' + qty + ' 个'),
+      spec: { qty: qty },
+      total: total, unitPrice: qty ? total / qty : 0,
+      contactName: raw.name || '-', contactPhone: '', contactEmail: '',
+      address: '(本机订单未记录地址)', note: '',
+      payStatus: 'unpaid', status: 'pending_payment',
+      createdAt: Math.floor((raw.time || Date.now()) / 1000),
+      previews: previews
+    };
+  }
+
+  function buildLocalOrders() {
+    const list = [];
+    try {
+      for (let i = 0; i < localStorage.length; i += 1) {
+        const key = localStorage.key(i);
+        if (!key || key.indexOf('pouchlab.order.') !== 0) continue;
+        try {
+          const raw = JSON.parse(localStorage.getItem(key) || 'null');
+          if (raw) list.push(bagLocalOrder(raw, key));
+        } catch (e) {}
+      }
+    } catch (e) {}
+    try {
+      const boxOrders = JSON.parse(localStorage.getItem('pouchlab.box.orders') || '[]');
+      if (Array.isArray(boxOrders)) boxOrders.forEach(function (raw) { if (raw && raw.no) list.push(boxLocalOrder(raw)); });
+    } catch (e) {}
+    return list.sort(function (a, b) { return b.createdAt - a.createdAt; });
+  }
+
   function loadList() {
   function loadList() {
     state.loading = true;
     state.loading = true;
     render();
     render();
     PL.api.get('/orders/mine?page=' + state.page + '&page_size=' + state.pageSize).then(function (r) {
     PL.api.get('/orders/mine?page=' + state.page + '&page_size=' + state.pageSize).then(function (r) {
       state.items = r.items || [];
       state.items = r.items || [];
-      state.total = r.total || 0;
+      // 本地订单(离线保存 / 盒子本机订单)与服务端订单按单号去重
+      if (state.page === 1) {
+        state.local = buildLocalOrders().filter(function (o) {
+          return !state.items.some(function (item) { return item.orderNo === o.orderNo; });
+        });
+      }
+      state.total = (r.total || 0) + state.local.length;
       state.loading = false;
       state.loading = false;
       render();
       render();
       // 预取每行首图
       // 预取每行首图
@@ -69,6 +201,9 @@
         if (o.previews && o.previews.length) loadPreview(o.orderNo, o.previews[0]).then(function () { render(); });
         if (o.previews && o.previews.length) loadPreview(o.orderNo, o.previews[0]).then(function () { render(); });
       });
       });
     }, function (err) {
     }, function (err) {
+      state.items = [];
+      if (state.page === 1) state.local = buildLocalOrders();
+      state.total = state.local.length;
       state.loading = false;
       state.loading = false;
       if (!err.network) UI.message.error(err.message || '订单加载失败');
       if (!err.network) UI.message.error(err.message || '订单加载失败');
       render();
       render();
@@ -79,6 +214,17 @@
     state.drawer = order;
     state.drawer = order;
     state.detail = null;
     state.detail = null;
     render();
     render();
+    if (order.local) {
+      state.detail = Object.assign({}, order, {
+        events: [{
+          kind: 'status', title: '订单保存在本机',
+          detail: '服务器未收到该订单,联网后请在设计页重新提交',
+          createdAt: order.createdAt
+        }]
+      });
+      render();
+      return;
+    }
     PL.api.get('/orders/mine/' + order.orderNo).then(function (d) {
     PL.api.get('/orders/mine/' + order.orderNo).then(function (d) {
       state.detail = d;
       state.detail = d;
       render();
       render();
@@ -92,6 +238,15 @@
     });
     });
   }
   }
 
 
+  function refreshDetail(order) {
+    PL.api.get('/orders/mine/' + order.orderNo).then(function (full) {
+      if (state.drawer && state.drawer.orderNo === order.orderNo) {
+        state.detail = full;
+        render();
+      }
+    }, function () {});
+  }
+
   function doPay(order) {
   function doPay(order) {
     state.detailBusy = true;
     state.detailBusy = true;
     render();
     render();
@@ -100,6 +255,7 @@
       state.detail = d;
       state.detail = d;
       UI.message.success('支付成功(模拟),订单已进入生产');
       UI.message.success('支付成功(模拟),订单已进入生产');
       loadList();
       loadList();
+      refreshDetail(order);
     }, function (err) {
     }, function (err) {
       state.detailBusy = false;
       state.detailBusy = false;
       UI.message.error(err.message || '支付失败');
       UI.message.error(err.message || '支付失败');
@@ -115,6 +271,7 @@
       state.detail = d;
       state.detail = d;
       UI.message.success('订单已取消');
       UI.message.success('订单已取消');
       loadList();
       loadList();
+      refreshDetail(order);
     }, function (err) {
     }, function (err) {
       state.detailBusy = false;
       state.detailBusy = false;
       UI.message.error(err.message || '取消失败');
       UI.message.error(err.message || '取消失败');
@@ -166,12 +323,13 @@
 
 
   function OrderCard(order) {
   function OrderCard(order) {
     const key = order.previews && order.previews.length ? order.previews[0] : null;
     const key = order.previews && order.previews.length ? order.previews[0] : null;
-    const thumb = key ? previewCache.get(order.orderNo + ':' + key) : null;
+    const thumb = previewSrc(order.orderNo, key);
     return h('div', { className: 'pl-orders-card', key: order.orderNo, onClick: function () { openDetail(order); } },
     return h('div', { className: 'pl-orders-card', key: order.orderNo, onClick: function () { openDetail(order); } },
       h('div', { className: 'pl-orders-thumb' }, thumb ? h('img', { src: thumb }) : null),
       h('div', { className: 'pl-orders-thumb' }, thumb ? h('img', { src: thumb }) : null),
       h('div', { className: 'pl-orders-info' },
       h('div', { className: 'pl-orders-info' },
         h('div', { className: 'pl-orders-no' }, order.orderNo,
         h('div', { className: 'pl-orders-no' }, order.orderNo,
-          h(A.Tag, { style: { marginLeft: 10 } }, TYPE_LABEL[order.type] || order.type)),
+          h(A.Tag, { style: { marginLeft: 10 } }, TYPE_LABEL[order.type] || order.type),
+          order.local ? h(A.Tag, { color: 'orange', style: { marginLeft: 6 } }, '本机保存') : null),
         h('div', { className: 'pl-orders-summary' }, order.summary || '-'),
         h('div', { className: 'pl-orders-summary' }, order.summary || '-'),
         h('div', { className: 'pl-orders-time' }, '下单时间 ' + fmtTime(order.createdAt))
         h('div', { className: 'pl-orders-time' }, '下单时间 ' + fmtTime(order.createdAt))
       ),
       ),
@@ -189,8 +347,8 @@
     const order = state.detail || state.drawer || {};
     const order = state.detail || state.drawer || {};
     const d = state.detail;
     const d = state.detail;
     const spec = order.spec || {};
     const spec = order.spec || {};
-    const canPay = order.payStatus === 'unpaid' && (order.status === 'pending_payment');
-    const canCancel = order.payStatus === 'unpaid' && ['pending_payment', 'producing'].indexOf(order.status) >= 0;
+    const canPay = !order.local && order.payStatus === 'unpaid' && (order.status === 'pending_payment');
+    const canCancel = !order.local && order.payStatus === 'unpaid' && ['pending_payment', 'producing'].indexOf(order.status) >= 0;
     const events = d ? d.events || [] : [];
     const events = d ? d.events || [] : [];
     const shipped = d && d.carrier;
     const shipped = d && d.carrier;
 
 
@@ -200,9 +358,16 @@
       footer: null
       footer: null
     },
     },
       d ? h('div', null,
       d ? h('div', null,
+        order.local ? h(A.Alert, {
+          type: 'warning', showIcon: true,
+          message: '该订单保存在本机,尚未同步到服务器',
+          description: '联网后可在设计页重新提交;设计稿与预览图已随订单保存在本机。',
+          style: { marginBottom: 14 }
+        }) : null,
+
         (d.previews || []).length ? h('div', { className: 'pl-preview-grid' },
         (d.previews || []).length ? h('div', { className: 'pl-preview-grid' },
           d.previews.map(function (key) {
           d.previews.map(function (key) {
-            const url = previewCache.get(d.orderNo + ':' + key);
+            const url = previewSrc(d.orderNo, key);
             return url ? h('img', { key: key, src: url, title: key }) : null;
             return url ? h('img', { key: key, src: url, title: key }) : null;
           })
           })
         ) : null,
         ) : null,
@@ -218,7 +383,7 @@
         ),
         ),
 
 
         h(A.Descriptions, { title: '收货信息', column: 1, size: 'small', bordered: true, style: { marginTop: 18 } },
         h(A.Descriptions, { title: '收货信息', column: 1, size: 'small', bordered: true, style: { marginTop: 18 } },
-          h(A.Descriptions.Item, { label: '联系人' }, d.contactName + ' · ' + d.contactPhone),
+          h(A.Descriptions.Item, { label: '联系人' }, d.contactName + (d.contactPhone ? ' · ' + d.contactPhone : '')),
           h(A.Descriptions.Item, { label: '地址' }, d.address || '-'),
           h(A.Descriptions.Item, { label: '地址' }, d.address || '-'),
           d.note ? h(A.Descriptions.Item, { label: '备注' }, d.note) : null
           d.note ? h(A.Descriptions.Item, { label: '备注' }, d.note) : null
         ),
         ),
@@ -265,6 +430,8 @@
 
 
   function App() {
   function App() {
     const user = window.PL.auth ? window.PL.auth.user() : null;
     const user = window.PL.auth ? window.PL.auth.user() : null;
+    const locals = state.page === 1 ? state.local : [];
+    const list = locals.concat(state.items);
     return h('div', null,
     return h('div', null,
       Header(user),
       Header(user),
       h('main', { className: 'pl-orders-main' },
       h('main', { className: 'pl-orders-main' },
@@ -273,17 +440,17 @@
             h('div', { style: { display: 'flex', alignItems: 'center', marginBottom: 16 } },
             h('div', { style: { display: 'flex', alignItems: 'center', marginBottom: 16 } },
               h('h2', { style: { margin: 0, fontSize: 22, letterSpacing: '-0.02em' } }, '我的订单'),
               h('h2', { style: { margin: 0, fontSize: 22, letterSpacing: '-0.02em' } }, '我的订单'),
               h('span', { style: { color: '#a79d8d', fontSize: 12.5, marginLeft: 10 } }, '共 ' + state.total + ' 单')),
               h('span', { style: { color: '#a79d8d', fontSize: 12.5, marginLeft: 10 } }, '共 ' + state.total + ' 单')),
-            state.loading && !state.items.length
+            state.loading && !list.length
               ? h('div', { style: { padding: 80, textAlign: 'center' } }, h(A.Spin, null))
               ? h('div', { style: { padding: 80, textAlign: 'center' } }, h(A.Spin, null))
-              : (state.items.length
+              : (list.length
                 ? h('div', null,
                 ? h('div', null,
-                    state.items.map(OrderCard),
-                    h('div', { style: { textAlign: 'center', marginTop: 20 } },
+                    list.map(OrderCard),
+                    state.total > state.pageSize ? h('div', { style: { textAlign: 'center', marginTop: 20 } },
                       h(A.Pagination, {
                       h(A.Pagination, {
                         current: state.page, total: state.total, pageSize: state.pageSize,
                         current: state.page, total: state.total, pageSize: state.pageSize,
                         showSizeChanger: false,
                         showSizeChanger: false,
                         onChange: function (p) { state.page = p; loadList(); }
                         onChange: function (p) { state.page = p; loadList(); }
-                      })))
+                      })) : null)
                 : h(A.Empty, { description: '还没有订单,去设计一款包装吧', image: A.Empty.PRESENTED_IMAGE_SIMPLE },
                 : h(A.Empty, { description: '还没有订单,去设计一款包装吧', image: A.Empty.PRESENTED_IMAGE_SIMPLE },
                     h(A.Button, { type: 'primary', href: 'studio.html' }, '开始设计'))),
                     h(A.Button, { type: 'primary', href: 'studio.html' }, '开始设计'))),
             DetailDrawer()
             DetailDrawer()
@@ -298,11 +465,11 @@
 
 
   document.addEventListener('pl:auth', function () {
   document.addEventListener('pl:auth', function () {
     const user = window.PL.auth ? window.PL.auth.user() : null;
     const user = window.PL.auth ? window.PL.auth.user() : null;
-    if (user) { state.page = 1; loadList(); } else { state.items = []; state.total = 0; }
+    if (user) { state.page = 1; loadList(); } else { state.items = []; state.local = []; state.total = 0; }
     render();
     render();
   });
   });
   document.addEventListener('pl:auth-expired', function () {
   document.addEventListener('pl:auth-expired', function () {
-    state.items = []; state.total = 0; state.drawer = null; state.detail = null;
+    state.items = []; state.local = []; state.total = 0; state.drawer = null; state.detail = null;
     UI.message.warning('登录已失效,请重新登录');
     UI.message.warning('登录已失效,请重新登录');
     render();
     render();
   });
   });

+ 1 - 1
assets/js/pouch3d.js

@@ -344,7 +344,7 @@
         const dx = e.clientX - drag.x;
         const dx = e.clientX - drag.x;
         const dy = e.clientY - drag.y;
         const dy = e.clientY - drag.y;
         if (Math.abs(dx) + Math.abs(dy) > 3) moved = true;
         if (Math.abs(dx) + Math.abs(dy) > 3) moved = true;
-        orbit.theta = drag.theta - dx * 0.4;
+        orbit.theta = drag.theta + dx * 0.4;
         applyOrbit();
         applyOrbit();
         flush();
         flush();
       });
       });

+ 45 - 1
assets/js/render.js

@@ -103,7 +103,8 @@
     let w = el.w || 0;
     let w = el.w || 0;
     let h = el.h || 0;
     let h = el.h || 0;
     if (el.type === 'text') h = textHeight(el);
     if (el.type === 'text') h = textHeight(el);
-    if (el.type === 'badge') { w = el.w || 40; h = w; }
+    if (el.type === 'badge' || el.type === 'qr') { w = el.w || 40; h = w; }
+    if (el.type === 'asset') { w = el.w || 30; h = w; }
     if (el.type === 'line') h = Math.max(4, el.h || 0);
     if (el.type === 'line') h = Math.max(4, el.h || 0);
     return { w: Math.max(1, w), h: Math.max(1, h) };
     return { w: Math.max(1, w), h: Math.max(1, h) };
   }
   }
@@ -157,6 +158,43 @@
     return rects + text;
     return rects + text;
   }
   }
 
 
+  function renderQR(el) {
+    const size = el.w || 40;
+    const color = el.color || '#17140f';
+    const light = el.light === 'none' ? null : (el.light || '#ffffff');
+    let qr = null;
+    try {
+      if (window.PL && window.PL.qrcode && window.PL.qrcode.build) qr = window.PL.qrcode.build(String(el.value || ' '));
+    } catch (e) { qr = null; }
+    const bg = light ? '<rect width="' + size + '" height="' + size + '" fill="' + light + '"/>' : '';
+    if (!qr) {
+      return bg + '<rect x="1" y="1" width="' + (size - 2) + '" height="' + (size - 2) + '" fill="none" stroke="' + color + '" stroke-width="0.6" stroke-dasharray="1 1"/>';
+    }
+    const quiet = 2;
+    const total = qr.size + quiet * 2;
+    const unit = size / total;
+    let d = '';
+    for (let y = 0; y < qr.size; y += 1) {
+      for (let x = 0; x < qr.size; x += 1) {
+        if (!qr.matrix[y][x]) continue;
+        const px = (x + quiet) * unit;
+        const py = (y + quiet) * unit;
+        d += 'M' + px.toFixed(3) + ' ' + py.toFixed(3) + 'h' + unit.toFixed(3) + 'v' + unit.toFixed(3) + 'h-' + unit.toFixed(3) + 'z';
+      }
+    }
+    return bg + '<path d="' + d + '" fill="' + color + '"/>';
+  }
+
+  function renderAsset(el) {
+    const lib = window.PL && window.PL.boxlib;
+    if (!lib || !lib.assetSvg || !el.asset) return '';
+    const svg = lib.assetSvg(el.asset, el.color || '#17140f');
+    if (!svg) return '';
+    const inner = svg.replace(/^<svg[^>]*>/, '').replace(/<\/svg>\s*$/, '');
+    const scale = (el.w || 24) / 24;
+    return '<g transform="scale(' + scale.toFixed(4) + ')">' + inner + '</g>';
+  }
+
   function renderSticker(el) {
   function renderSticker(el) {
     const def = D.stickers[el.sticker] || D.stickers.star;
     const def = D.stickers[el.sticker] || D.stickers.star;
     const color = el.color || '#17140f';
     const color = el.color || '#17140f';
@@ -223,6 +261,10 @@
       body = renderBadge(el, ctx);
       body = renderBadge(el, ctx);
     } else if (el.type === 'barcode') {
     } else if (el.type === 'barcode') {
       body = renderBarcode(el, ctx);
       body = renderBarcode(el, ctx);
+    } else if (el.type === 'qr') {
+      body = renderQR(el);
+    } else if (el.type === 'asset') {
+      body = renderAsset(el);
     } else if (el.type === 'sticker') {
     } else if (el.type === 'sticker') {
       body = renderSticker(el);
       body = renderSticker(el);
     } else if (el.type === 'shape') {
     } else if (el.type === 'shape') {
@@ -230,6 +272,8 @@
       const stroke = el.stroke && el.stroke !== 'none' ? ' stroke="' + el.stroke + '" stroke-width="' + (el.strokeWidth || 0.5) + '"' : '';
       const stroke = el.stroke && el.stroke !== 'none' ? ' stroke="' + el.stroke + '" stroke-width="' + (el.strokeWidth || 0.5) + '"' : '';
       if (el.shape === 'circle') {
       if (el.shape === 'circle') {
         body = '<ellipse cx="' + box.w / 2 + '" cy="' + box.h / 2 + '" rx="' + box.w / 2 + '" ry="' + box.h / 2 + '" fill="' + fill + '"' + stroke + '/>';
         body = '<ellipse cx="' + box.w / 2 + '" cy="' + box.h / 2 + '" rx="' + box.w / 2 + '" ry="' + box.h / 2 + '" fill="' + fill + '"' + stroke + '/>';
+      } else if (el.shape === 'triangle') {
+        body = '<polygon points="' + (box.w / 2) + ',0 ' + box.w + ',' + box.h + ' 0,' + box.h + '" fill="' + fill + '"' + stroke + '/>';
       } else if (el.shape === 'line') {
       } else if (el.shape === 'line') {
         body = '<line x1="0" y1="' + box.h / 2 + '" x2="' + box.w + '" y2="' + box.h / 2 + '" stroke="' + (el.stroke || el.fill || '#17140f') + '" stroke-width="' + (el.strokeWidth || 0.6) + '" stroke-linecap="round"/>';
         body = '<line x1="0" y1="' + box.h / 2 + '" x2="' + box.w + '" y2="' + box.h / 2 + '" stroke="' + (el.stroke || el.fill || '#17140f') + '" stroke-width="' + (el.strokeWidth || 0.6) + '" stroke-linecap="round"/>';
       } else {
       } else {

+ 416 - 50
assets/js/studio.js

@@ -5,6 +5,7 @@
   const h = UI.h;
   const h = UI.h;
   const A = UI.antd;
   const A = UI.antd;
   const KEY = 'pouchlab.design.v1';
   const KEY = 'pouchlab.design.v1';
+  const PLANS_KEY = 'pouchlab.bag.plans.v1';
   const $ = function (s, root) { return (root || document).querySelector(s); };
   const $ = function (s, root) { return (root || document).querySelector(s); };
   const $$ = function (s, root) { return Array.prototype.slice.call((root || document).querySelectorAll(s)); };
   const $$ = function (s, root) { return Array.prototype.slice.call((root || document).querySelectorAll(s)); };
 
 
@@ -41,6 +42,13 @@
     state.customSize = { w: savedSize.w, h: savedSize.h };
     state.customSize = { w: savedSize.w, h: savedSize.h };
   }
   }
 
 
+  let plans = [];
+  try {
+    const savedPlans = JSON.parse(localStorage.getItem(PLANS_KEY) || '[]');
+    if (Array.isArray(savedPlans)) plans = savedPlans.filter(function (p) { return p && p.id && p.snap; });
+  } catch (e) { plans = []; }
+  let planName = state.name;
+
   /* AI 设计师(首页 Agent)交接:应用其生成的袋子方案 */
   /* AI 设计师(首页 Agent)交接:应用其生成的袋子方案 */
   (function applyAgentHandoff() {
   (function applyAgentHandoff() {
     try {
     try {
@@ -125,6 +133,7 @@
     elementCount: $('#elementCount'),
     elementCount: $('#elementCount'),
     propsChip: $('#propsChip'),
     propsChip: $('#propsChip'),
     propsBody: $('#propsBody'),
     propsBody: $('#propsBody'),
+    propsClose: $('#propsClose'),
     summaryPreview: $('#summaryPreview'),
     summaryPreview: $('#summaryPreview'),
     summaryThumbs: $('#summaryThumbs'),
     summaryThumbs: $('#summaryThumbs'),
     summaryOrder: $('#summaryOrder'),
     summaryOrder: $('#summaryOrder'),
@@ -242,6 +251,73 @@
     selectedId = null;
     selectedId = null;
   }
   }
 
 
+  function persistPlans() {
+    try {
+      localStorage.setItem(PLANS_KEY, JSON.stringify(plans));
+      return true;
+    } catch (e) {
+      toast('本地空间不足,请先删除旧方案');
+      return false;
+    }
+  }
+
+  function planThumb(plan) {
+    try {
+      const s = JSON.parse(plan.snap);
+      const prod = D.productById(s.productId);
+      const size = s.sizeId === 'custom' && s.customSize
+        ? { id: 'custom', label: '自定义', w: s.customSize.w, h: s.customSize.h }
+        : D.sizeOf(prod, s.sizeId);
+      const design = (s.sides && s.sides.front) || { bg: null, elements: [] };
+      return R.bagSVG(prod, 'front', design, { size: size, card: true, material: s.material, finish: s.finish });
+    } catch (e) {
+      return '';
+    }
+  }
+
+  function savePlan() {
+    const name = (planName || state.name || '未命名方案').trim().slice(0, 30) || '未命名方案';
+    const plan = { id: R.uid('plan'), name: name, savedAt: Date.now(), snap: snapshot() };
+    const same = plans.findIndex(function (p) { return p.name === name; });
+    if (same >= 0) plan.id = plans[same].id;
+    plans = plans.filter(function (p) { return p.name !== name; });
+    plans.unshift(plan);
+    if (plans.length > 12) plans = plans.slice(0, 12);
+    if (!persistPlans()) return;
+    state.name = name;
+    planName = name;
+    if (els.designName) els.designName.value = name;
+    updateMeta();
+    renderTool();
+    toast('方案已保存 · ' + name);
+  }
+
+  function loadPlan(id) {
+    const plan = plans.find(function (p) { return p.id === id; });
+    if (!plan) return;
+    try {
+      applySnapshot(plan.snap);
+    } catch (e) {
+      toast('方案数据已损坏');
+      return;
+    }
+    state.name = plan.name;
+    planName = plan.name;
+    if (els.designName) els.designName.value = plan.name;
+    selectedId = null;
+    commit();
+    if (mode === 'design') renderDesign();
+    else renderSettings();
+    toast('已载入方案 · ' + plan.name);
+  }
+
+  function removePlan(id) {
+    plans = plans.filter(function (p) { return p.id !== id; });
+    if (!persistPlans()) return;
+    renderTool();
+    toast('方案已删除');
+  }
+
   function pushHistory() {
   function pushHistory() {
     const snap = snapshot();
     const snap = snapshot();
     if (history[hIndex] === snap) return;
     if (history[hIndex] === snap) return;
@@ -257,7 +333,10 @@
     els.redoBtn.disabled = hIndex >= history.length - 1;
     els.redoBtn.disabled = hIndex >= history.length - 1;
   }
   }
 
 
-  function saveState(silent) {
+  let stateDirty = false;
+  let stateSaveTimer = null;
+
+  function writeStateNow(silent) {
     try {
     try {
       const payload = {
       const payload = {
         version: 1, name: state.name, productId: state.productId, sizeId: state.sizeId, customSize: state.customSize,
         version: 1, name: state.name, productId: state.productId, sizeId: state.sizeId, customSize: state.customSize,
@@ -281,6 +360,26 @@
     }
     }
   }
   }
 
 
+  // 合并短时间内的多次保存,避免大图 dataURL 同步写 localStorage 卡住删除/拖动
+  function saveState(silent) {
+    stateDirty = true;
+    clearTimeout(stateSaveTimer);
+    stateSaveTimer = setTimeout(function () {
+      if (!stateDirty) return;
+      stateDirty = false;
+      writeStateNow(silent);
+    }, 160);
+  }
+
+  function flushStateSave() {
+    if (!stateDirty) return;
+    clearTimeout(stateSaveTimer);
+    stateDirty = false;
+    writeStateNow(true);
+  }
+  window.addEventListener('beforeunload', flushStateSave);
+  window.addEventListener('pagehide', flushStateSave);
+
   function commit(message) {
   function commit(message) {
     pushHistory();
     pushHistory();
     saveState();
     saveState();
@@ -723,10 +822,12 @@
   function elementLabel(el) {
   function elementLabel(el) {
     if (el.type === 'text') return (el.text || '文字').slice(0, 16);
     if (el.type === 'text') return (el.text || '文字').slice(0, 16);
     if (el.type === 'image') return el.name || '图片';
     if (el.type === 'image') return el.name || '图片';
-    if (el.type === 'shape') return { rect: '矩形', circle: '圆形', line: '线条' }[el.shape] || '图形';
+    if (el.type === 'shape') return { rect: '矩形', circle: '圆形', triangle: '三角形', line: '线条' }[el.shape] || '图形';
     if (el.type === 'sticker') return '贴纸 · ' + el.sticker;
     if (el.type === 'sticker') return '贴纸 · ' + el.sticker;
     if (el.type === 'badge') return '圆形徽章';
     if (el.type === 'badge') return '圆形徽章';
     if (el.type === 'barcode') return '条码 · ' + (el.value || '');
     if (el.type === 'barcode') return '条码 · ' + (el.value || '');
+    if (el.type === 'qr') return '二维码 · ' + (el.value || '');
+    if (el.type === 'asset') return '素材 · ' + (el.name || el.asset || '');
     return '图层';
     return '图层';
   }
   }
 
 
@@ -737,7 +838,9 @@
       shape: '<rect x="4" y="4" width="16" height="16" rx="3"/>',
       shape: '<rect x="4" y="4" width="16" height="16" rx="3"/>',
       sticker: '<path d="M20 4C11 4 4 9 4 17c0 2 1 3 3 3 8 0 13-7 13-16Z"/>',
       sticker: '<path d="M20 4C11 4 4 9 4 17c0 2 1 3 3 3 8 0 13-7 13-16Z"/>',
       badge: '<circle cx="12" cy="12" r="8" stroke-dasharray="2 2"/><circle cx="12" cy="12" r="3"/>',
       badge: '<circle cx="12" cy="12" r="8" stroke-dasharray="2 2"/><circle cx="12" cy="12" r="3"/>',
-      barcode: '<path d="M4 5v14M8 5v14M12 5v10M16 5v14M20 5v14"/>'
+      barcode: '<path d="M4 5v14M8 5v14M12 5v10M16 5v14M20 5v14"/>',
+      qr: '<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M14 14h3v3h-3zM19 14h2M14 19h2M19 19h2"/>',
+      asset: '<path d="M12 3.5 14.6 9l6 .7-4.4 4 1.2 5.8L12 16.6 6.6 19.5l1.2-5.8-4.4-4 6-.7L12 3.5Z"/>'
     };
     };
     return '<svg class="icon" viewBox="0 0 24 24">' + (icons[el.type] || icons.shape) + '</svg>';
     return '<svg class="icon" viewBox="0 0 24 24">' + (icons[el.type] || icons.shape) + '</svg>';
   }
   }
@@ -761,6 +864,7 @@
   }
   }
 
 
   const barcodeIcon = h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><path d="M4 5v14M8 5v14M12 5v10M16 5v14M20 5v14"/></svg>' } });
   const barcodeIcon = h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><path d="M4 5v14M8 5v14M12 5v10M16 5v14M20 5v14"/></svg>' } });
+  const qrIcon = h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M14 14h7v7h-7z"/></svg>' } });
   const copyIcon = h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3"/></svg>' } });
   const copyIcon = h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3"/></svg>' } });
   function eyeIcon(hidden) {
   function eyeIcon(hidden) {
     return h('span', {
     return h('span', {
@@ -821,12 +925,20 @@
         state.uploads.length ? h('div', { className: 'tool-section' },
         state.uploads.length ? h('div', { className: 'tool-section' },
           h('div', { className: 'tool-section-title' }, '最近上传', h('span', null, state.uploads.length + '')),
           h('div', { className: 'tool-section-title' }, '最近上传', h('span', null, state.uploads.length + '')),
           h('div', { className: 'uploaded-grid' }, state.uploads.map(function (up) {
           h('div', { className: 'uploaded-grid' }, state.uploads.map(function (up) {
-            return h('div', { className: 'uploaded-item', key: up.id },
+            return h('div', {
+              className: 'uploaded-item', key: up.id, title: '点击放置到画布',
+              onClick: function (e) {
+                if (e.target.closest('button')) return;
+                addImageFromUpload(up);
+              }
+            },
               h('img', { src: up.src, alt: up.name }),
               h('img', { src: up.src, alt: up.name }),
               h('button', {
               h('button', {
-                onClick: function () {
+                onClick: function (e) {
+                  e.stopPropagation();
                   state.uploads = state.uploads.filter(function (x) { return x.id !== up.id; });
                   state.uploads = state.uploads.filter(function (x) { return x.id !== up.id; });
                   commit();
                   commit();
+                  renderTool();
                 }
                 }
               }, '✕')
               }, '✕')
             );
             );
@@ -870,9 +982,11 @@
       const shapes = [
       const shapes = [
         { id: 'rect', name: '矩形' },
         { id: 'rect', name: '矩形' },
         { id: 'circle', name: '圆形' },
         { id: 'circle', name: '圆形' },
-        { id: 'line', name: '线条' },
-        { id: 'badge', name: '徽章' }
+        { id: 'triangle', name: '三角形' },
+        { id: 'line', name: '线条' }
       ];
       ];
+      const lib = window.PL && window.PL.boxlib;
+      const icons = lib && lib.ICONS ? lib.ICONS : {};
       return h('div', null,
       return h('div', null,
         h('div', { className: 'tool-section' },
         h('div', { className: 'tool-section' },
           h('div', { className: 'tool-section-title' }, '基础图形'),
           h('div', { className: 'tool-section-title' }, '基础图形'),
@@ -881,8 +995,21 @@
               h('span', { className: 'shape-ico ' + s.id })
               h('span', { className: 'shape-ico ' + s.id })
             );
             );
           })),
           })),
-          h(A.Button, { block: true, style: { marginTop: '8px' }, icon: barcodeIcon, onClick: function () { addShape('barcode'); } }, '添加条码')
+          h('div', { className: 'p-actions', style: { marginTop: '8px' } },
+            h(A.Button, { block: true, icon: barcodeIcon, onClick: function () { addShape('barcode'); } }, '添加条码'),
+            h(A.Button, { block: true, icon: qrIcon, onClick: function () { addShape('qr'); } }, '添加二维码')
+          )
         ),
         ),
+        Object.keys(icons).length ? h('div', { className: 'tool-section' },
+          h('div', { className: 'tool-section-title' }, '平台素材', h('span', null, Object.keys(icons).length + '')),
+          h('div', { className: 'asset-grid' }, Object.keys(icons).map(function (id) {
+            return h('button', {
+              key: id, className: 'asset-btn', title: icons[id].name,
+              onClick: function () { addAsset(id); },
+              dangerouslySetInnerHTML: { __html: lib.assetSvg(id, '#17140f') }
+            });
+          }))
+        ) : null,
         h('div', { className: 'tool-section' },
         h('div', { className: 'tool-section' },
           h('div', { className: 'tool-section-title' }, '贴纸库', h('span', null, Object.keys(D.stickers).length + '')),
           h('div', { className: 'tool-section-title' }, '贴纸库', h('span', null, Object.keys(D.stickers).length + '')),
           h('div', { className: 'sticker-grid' }, Object.keys(D.stickers).map(function (k) {
           h('div', { className: 'sticker-grid' }, Object.keys(D.stickers).map(function (k) {
@@ -943,7 +1070,9 @@
           }) : h(A.Empty, { description: '这一面还没有图层', image: A.Empty.PRESENTED_IMAGE_SIMPLE })
           }) : h(A.Empty, { description: '这一面还没有图层', image: A.Empty.PRESENTED_IMAGE_SIMPLE })
         ),
         ),
         h('div', { className: 'p-actions' },
         h('div', { className: 'p-actions' },
-          h(A.Button, { block: true, icon: copyIcon, onClick: duplicateSide }, '复制到另一面')
+          h(A.Button, { block: true, icon: copyIcon, onClick: duplicateSide }, '复制到另一面'),
+          h(A.Button, { block: true, danger: true, onClick: function () { clearSide(); } }, '清空本面'),
+          h(A.Button, { block: true, danger: true, onClick: clearAllSides }, '一键清空全部')
         )
         )
       );
       );
     }
     }
@@ -1032,6 +1161,32 @@
         h('div', { className: 'p-price-line' }, h('span', null, '单价'), h('b', null, '¥' + price.unit.toFixed(2) + ' / 个')),
         h('div', { className: 'p-price-line' }, h('span', null, '单价'), h('b', null, '¥' + price.unit.toFixed(2) + ' / 个')),
         h('div', { className: 'p-price-line' }, h('span', null, '合计 · ' + state.qty + ' 个'), h('b', null, '¥' + price.total.toFixed(2)))
         h('div', { className: 'p-price-line' }, h('span', null, '合计 · ' + state.qty + ' 个'), h('b', null, '¥' + price.total.toFixed(2)))
       ),
       ),
+      h('div', { className: 'tool-section' },
+        h('div', { className: 'tool-section-title' }, '我的方案', h('span', null, plans.length + ' 个')),
+        h('div', { className: 'plan-save' },
+          h(A.Input, {
+            defaultValue: planName,
+            placeholder: '给当前设计起个名字',
+            maxLength: 30,
+            onChange: function (e) { planName = e.target.value; },
+            onPressEnter: savePlan
+          }),
+          h(A.Button, { type: 'primary', onClick: savePlan }, '保存')
+        ),
+        plans.length ? h('div', { className: 'plan-list' }, plans.map(function (plan) {
+          return h('div', { className: 'plan-item', key: plan.id },
+            h('div', { className: 'plan-thumb', dangerouslySetInnerHTML: { __html: planThumb(plan) } }),
+            h('div', { className: 'plan-meta' },
+              h('b', null, plan.name),
+              h('span', null, new Date(plan.savedAt).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }))
+            ),
+            h('div', { className: 'plan-actions' },
+              h('button', { onClick: function () { loadPlan(plan.id); }, title: '载入方案' }, '载入'),
+              h('button', { className: 'del', onClick: function () { removePlan(plan.id); }, title: '删除方案' }, '✕')
+            )
+          );
+        })) : h('div', { className: 'p-hint' }, '保存后可随时切换不同设计方案,最多 12 个。')
+      ),
       h('div', { className: 'p-actions', style: { marginTop: '12px' } },
       h('div', { className: 'p-actions', style: { marginTop: '12px' } },
         h(A.Button, { block: true, onClick: function () { setMode('settings'); } }, '返回设置'),
         h(A.Button, { block: true, onClick: function () { setMode('settings'); } }, '返回设置'),
         h(A.Button, { block: true, danger: true, onClick: function () { clearSide(); } }, '清空本面')
         h(A.Button, { block: true, danger: true, onClick: function () { clearSide(); } }, '清空本面')
@@ -1041,6 +1196,7 @@
 
 
   function renderProps() {
   function renderProps() {
     UI.render(els.propsBody, propsTree());
     UI.render(els.propsBody, propsTree());
+    document.body.classList.toggle('props-open', !!selectedEl());
   }
   }
 
 
   function propsTree() {
   function propsTree() {
@@ -1082,9 +1238,11 @@
           h('div', { className: 'p-row', style: { marginTop: '10px' } },
           h('div', { className: 'p-row', style: { marginTop: '10px' } },
             h('div', { className: 'p-field' }, h('label', null, '自定义底色'),
             h('div', { className: 'p-field' }, h('label', null, '自定义底色'),
               h(A.ColorPicker, {
               h(A.ColorPicker, {
-                value: side.bg || '#f7f2e7',
+                key: 'bg-' + activeSide + '-' + (side.bg || 'none'),
+                defaultValue: side.bg || '#f7f2e7',
                 showText: true,
                 showText: true,
-                onChange: function (c) { side.bg = c.toHexString(); commit(); renderCanvas(); }
+                onChange: function (c) { side.bg = c.toHexString(); renderCanvas(); },
+                onChangeComplete: function (c) { side.bg = c.toHexString(); commit(); renderCanvas(); }
               })
               })
             )
             )
           ),
           ),
@@ -1134,11 +1292,16 @@
       );
       );
     };
     };
     const colorField = function (label, prop, value) {
     const colorField = function (label, prop, value) {
+      const hex = value && value !== 'none' ? value : '#17140f';
       return h('div', { className: 'p-field' }, h('label', null, label),
       return h('div', { className: 'p-field' }, h('label', null, label),
         h(A.ColorPicker, {
         h(A.ColorPicker, {
-          value: value && value !== 'none' ? value : '#17140f',
+          // 非受控:拖动色相时由组件自身维护 HSV,避免每次 onChange 重建导致色相回弹
+          key: 'cp-' + prop + '-' + (selectedId || '') + '-' + hex,
+          defaultValue: hex,
           showText: true,
           showText: true,
-          onChange: function (c) { updateSelected(prop, c.toHexString()); commit(); renderCanvas(); }
+          onChange: function (c) { updateSelected(prop, c.toHexString()); renderCanvas(); },
+          // 提交时不再 renderProps,避免重建 ColorPicker 导致取色面板关闭
+          onChangeComplete: function (c) { updateSelected(prop, c.toHexString()); commit(); renderCanvas(); }
         })
         })
       );
       );
     };
     };
@@ -1260,7 +1423,31 @@
           h(A.Switch, { size: 'small', checked: el.showText !== false, onChange: function (v) { updateSelected('showText', v); commit(); renderCanvas(); renderProps(); } })
           h(A.Switch, { size: 'small', checked: el.showText !== false, onChange: function (v) { updateSelected('showText', v); commit(); renderCanvas(); renderProps(); } })
         ),
         ),
         h('div', { className: 'p-row' }, colorField('颜色', 'color', el.color)),
         h('div', { className: 'p-row' }, colorField('颜色', 'color', el.color)),
-        h('div', { className: 'p-hint' }, '输入 12–13 位数字会生成真实 EAN-13 校验位。')
+        h('div', { className: 'p-hint' }, '输入 12–13 位数字会生成真实 EAN-13 校验位;输入链接或文字会生成稳定条码。')
+      );
+    } else if (el.type === 'qr') {
+      specific = h('div', { className: 'p-section' },
+        h('div', { className: 'p-section-title' }, '二维码'),
+        h(TextField, {
+          multiline: true,
+          value: el.value || '',
+          extra: { autoSize: { minRows: 2, maxRows: 4 } },
+          onInput: function (v) { updateSelected('value', v); renderCanvas(); },
+          onCommit: function () { commit(); renderTool(); }
+        }),
+        h('div', { className: 'p-row', style: { marginTop: '9px' } },
+          colorField('码点颜色', 'color', el.color),
+          h('div', { className: 'p-field' }, h('label', null, '浅色底'),
+            h(A.Switch, { size: 'small', checked: el.light !== 'none', onChange: function (v) { updateSelected('light', v ? '#ffffff' : 'none'); commit(); renderCanvas(); renderProps(); } })
+          )
+        ),
+        h('div', { className: 'p-hint' }, '填写网址、微信号或任意文字即可生成二维码;保留浅色底可提高扫码成功率。')
+      );
+    } else if (el.type === 'asset') {
+      specific = h('div', { className: 'p-section' },
+        h('div', { className: 'p-section-title' }, '平台素材'),
+        h('div', { className: 'p-row' }, colorField('颜色', 'color', el.color)),
+        h('div', { className: 'p-hint' }, '素材为矢量图标,可任意缩放;拖动四角等比调整大小。')
       );
       );
     }
     }
 
 
@@ -1274,7 +1461,7 @@
         ),
         ),
         h('div', { className: 'p-row' },
         h('div', { className: 'p-row' },
           numField('宽度', 'w', el.w, 2, 9999),
           numField('宽度', 'w', el.w, 2, 9999),
-          el.type === 'text'
+          (el.type === 'text' || el.type === 'qr' || el.type === 'badge' || el.type === 'asset')
             ? h('div', { className: 'p-field' }, h('label', null, '高度(自动)'), h(A.Input, { value: box.h.toFixed(1) + ' mm', readOnly: true }))
             ? h('div', { className: 'p-field' }, h('label', null, '高度(自动)'), h(A.Input, { value: box.h.toFixed(1) + ' mm', readOnly: true }))
             : numField('高度', 'h', el.h, 1, 9999)
             : numField('高度', 'h', el.h, 1, 9999)
         ),
         ),
@@ -1283,9 +1470,9 @@
           h('div', { className: 'p-field' }, h('label', null, '不透明度 ' + Math.round((el.opacity == null ? 1 : el.opacity) * 100) + '%'),
           h('div', { className: 'p-field' }, h('label', null, '不透明度 ' + Math.round((el.opacity == null ? 1 : el.opacity) * 100) + '%'),
             h(A.Slider, {
             h(A.Slider, {
               value: (el.opacity == null ? 1 : el.opacity) * 100,
               value: (el.opacity == null ? 1 : el.opacity) * 100,
-              min: 10,
+              min: 0,
               max: 100,
               max: 100,
-              onChange: function (v) { updateSelected('opacity', v / 100); renderCanvas(); },
+              onChange: function (v) { updateSelected('opacity', v); renderCanvas(); },
               onAfterChange: function () { commit(); renderProps(); }
               onAfterChange: function () { commit(); renderProps(); }
             })
             })
           )
           )
@@ -1328,6 +1515,31 @@
         '<button type="button" class="pl-ai-clear" id="plAiClear">清空本面</button></div>' +
         '<button type="button" class="pl-ai-clear" id="plAiClear">清空本面</button></div>' +
       '<p class="pl-ai-tip">AI 结果直接应用到画布,可随时撤销(⌘Z)。每次生成消耗 1 次额度。</p>';
       '<p class="pl-ai-tip">AI 结果直接应用到画布,可随时撤销(⌘Z)。每次生成消耗 1 次额度。</p>';
     document.body.appendChild(wrap);
     document.body.appendChild(wrap);
+    (function makePanelDraggable() {
+      const head = wrap.querySelector('.pl-ai-head');
+      let drag = null;
+      head.style.touchAction = 'none';
+      head.addEventListener('pointerdown', function (e) {
+        if (e.target.closest('button')) return;
+        const r = wrap.getBoundingClientRect();
+        drag = { dx: e.clientX - r.left, dy: e.clientY - r.top };
+        wrap.style.left = r.left + 'px';
+        wrap.style.top = r.top + 'px';
+        wrap.style.right = 'auto';
+        wrap.style.bottom = 'auto';
+        if (head.setPointerCapture) head.setPointerCapture(e.pointerId);
+        e.preventDefault();
+      });
+      head.addEventListener('pointermove', function (e) {
+        if (!drag) return;
+        const maxX = Math.max(6, window.innerWidth - 100);
+        const maxY = Math.max(6, window.innerHeight - 60);
+        wrap.style.left = clamp(e.clientX - drag.dx, 6, maxX) + 'px';
+        wrap.style.top = clamp(e.clientY - drag.dy, 6, maxY) + 'px';
+      });
+      head.addEventListener('pointerup', function () { drag = null; });
+      head.addEventListener('pointercancel', function () { drag = null; });
+    })();
     wrap.querySelector('#plAiClose').addEventListener('click', function () { aiPanelToggle(false); });
     wrap.querySelector('#plAiClose').addEventListener('click', function () { aiPanelToggle(false); });
     wrap.querySelector('#plAiSides').addEventListener('click', function (e) {
     wrap.querySelector('#plAiSides').addEventListener('click', function (e) {
       const b = e.target.closest('[data-ai-side]');
       const b = e.target.closest('[data-ai-side]');
@@ -1337,9 +1549,10 @@
     });
     });
     wrap.querySelector('#plAiGen').addEventListener('click', aiGenerate);
     wrap.querySelector('#plAiGen').addEventListener('click', aiGenerate);
     wrap.querySelector('#plAiClear').addEventListener('click', function () {
     wrap.querySelector('#plAiClear').addEventListener('click', function () {
-      sideData().elements = [];
-      if (state.sides[ai.side === 'back' ? 'back' : 'front']) state.sides[ai.side === 'back' ? 'back' : 'front'].bg = null;
-      commit(); renderCanvas(); renderSummarySafe();
+      const targets = ai.side === 'both' ? ['front', 'back'] : [ai.side === 'back' ? 'back' : 'front'];
+      targets.forEach(function (k) { state.sides[k] = { bg: null, elements: [] }; });
+      selectedId = null;
+      commit(); renderCanvas(); renderSummarySafe(); renderProps();
     });
     });
   }
   }
 
 
@@ -1370,13 +1583,56 @@
     }, function () {});
     }, function () {});
   }
   }
 
 
+  function clampElementToCanvas(el, s) {
+    const square = el.type === 'qr' || el.type === 'asset' || el.type === 'badge';
+    let box = R.elementBox(el);
+    let w = box.w;
+    let h = box.h;
+    const maxW = Math.max(6, s.w);
+    const maxH = Math.max(6, s.h);
+    if (w > maxW) {
+      const k = maxW / w;
+      w = maxW;
+      if (!square && el.type !== 'text') h = Math.max(4, h * k);
+    }
+    if (h > maxH) {
+      const k = maxH / h;
+      h = maxH;
+      if (!square) w = Math.max(4, w * k);
+    }
+    if (square) h = w;
+    if (el.type === 'text') {
+      el.w = Math.round(w * 10) / 10;
+      h = R.elementBox(el).h;
+    } else if (square) {
+      el.w = Math.round(w * 10) / 10;
+    } else {
+      el.w = Math.round(w * 10) / 10;
+      el.h = Math.round(h * 10) / 10;
+    }
+    const rot = ((num(el.rotation, 0) % 360) + 360) % 360;
+    const rad = rot * Math.PI / 180;
+    const bw = Math.abs(w * Math.cos(rad)) + Math.abs(h * Math.sin(rad));
+    const bh = Math.abs(w * Math.sin(rad)) + Math.abs(h * Math.cos(rad));
+    const halfW = Math.min(bw, s.w) / 2;
+    const halfH = Math.min(bh, s.h) / 2;
+    const cx = num(el.x, 0) + w / 2;
+    const cy = num(el.y, 0) + h / 2;
+    const ncx = Math.min(Math.max(cx, halfW), Math.max(halfW, s.w - halfW));
+    const ncy = Math.min(Math.max(cy, halfH), Math.max(halfH, s.h - halfH));
+    el.x = Math.round((ncx - w / 2) * 10) / 10;
+    el.y = Math.round((ncy - h / 2) * 10) / 10;
+    return el;
+  }
+
   function aiApplyTo(sideKey, result) {
   function aiApplyTo(sideKey, result) {
     const sd = state.sides[sideKey];
     const sd = state.sides[sideKey];
     if (!sd) return;
     if (!sd) return;
+    const s = size();
     sd.elements = (result.elements || []).map(function (el) {
     sd.elements = (result.elements || []).map(function (el) {
       el.id = R.uid('el');
       el.id = R.uid('el');
       el.opacity = el.opacity == null ? 1 : el.opacity;
       el.opacity = el.opacity == null ? 1 : el.opacity;
-      return el;
+      return clampElementToCanvas(el, s);
     });
     });
     sd.bg = result.bg || null;
     sd.bg = result.bg || null;
   }
   }
@@ -1486,15 +1742,30 @@
       el = Object.assign(base, { shape: 'circle', w: s.w * 0.36, h: s.w * 0.36, fill: '#d9f07c' });
       el = Object.assign(base, { shape: 'circle', w: s.w * 0.36, h: s.w * 0.36, fill: '#d9f07c' });
     } else if (kind === 'line') {
     } else if (kind === 'line') {
       el = Object.assign(base, { shape: 'line', w: s.w * 0.7, h: 4, fill: 'none', stroke: '#17140f', strokeWidth: 1 });
       el = Object.assign(base, { shape: 'line', w: s.w * 0.7, h: 4, fill: 'none', stroke: '#17140f', strokeWidth: 1 });
+    } else if (kind === 'triangle') {
+      el = Object.assign(base, { shape: 'triangle', w: s.w * 0.36, h: s.w * 0.32, fill: '#ff5c2b' });
     } else if (kind === 'badge') {
     } else if (kind === 'badge') {
       el = { type: 'badge', w: s.w * 0.34, text: 'SMALL BATCH · POUCHLAB · ', color: '#17140f', size: s.w * 0.028, rotation: 0, opacity: 1 };
       el = { type: 'badge', w: s.w * 0.34, text: 'SMALL BATCH · POUCHLAB · ', color: '#17140f', size: s.w * 0.028, rotation: 0, opacity: 1 };
     } else if (kind === 'barcode') {
     } else if (kind === 'barcode') {
       el = { type: 'barcode', w: s.w * 0.5, h: s.h * 0.12, value: '6971234567890', color: '#17140f', showText: true, rotation: 0, opacity: 1 };
       el = { type: 'barcode', w: s.w * 0.5, h: s.h * 0.12, value: '6971234567890', color: '#17140f', showText: true, rotation: 0, opacity: 1 };
+    } else if (kind === 'qr') {
+      el = { type: 'qr', w: s.w * 0.34, value: 'https://pouchlab.cn', color: '#17140f', light: '#ffffff', rotation: 0, opacity: 1 };
     } else {
     } else {
       el = Object.assign(base, { shape: 'rect', w: s.w * 0.44, h: s.h * 0.22, fill: '#ff5c2b' });
       el = Object.assign(base, { shape: 'rect', w: s.w * 0.44, h: s.h * 0.22, fill: '#ff5c2b' });
     }
     }
     addElement(el);
     addElement(el);
-    toast('已添加' + (kind === 'barcode' ? '条码' : kind === 'badge' ? '徽章' : '图形'));
+    toast('已添加' + (kind === 'barcode' ? '条码' : kind === 'qr' ? '二维码' : kind === 'badge' ? '徽章' : '图形'));
+  }
+
+  function addAsset(id) {
+    const s = size();
+    const lib = window.PL && window.PL.boxlib;
+    const def = lib && lib.ICONS ? lib.ICONS[id] : null;
+    addElement({
+      type: 'asset', asset: id, name: def ? def.name : id,
+      w: s.w * 0.2, h: s.w * 0.2, color: '#17140f', rotation: 0, opacity: 1
+    });
+    toast('已添加素材 · ' + (def ? def.name : id));
   }
   }
 
 
   function addSticker(name) {
   function addSticker(name) {
@@ -1504,11 +1775,12 @@
 
 
   function addImageFromUpload(up) {
   function addImageFromUpload(up) {
     const s = size();
     const s = size();
+    const ratio = up.w && up.h ? up.h / up.w : 1;
     let w = s.w * 0.55;
     let w = s.w * 0.55;
-    let h = w * (up.h / up.w);
+    let h = w * ratio;
     if (h > s.h * 0.7) {
     if (h > s.h * 0.7) {
       h = s.h * 0.7;
       h = s.h * 0.7;
-      w = h * (up.w / up.h);
+      w = h / ratio;
     }
     }
     addElement({ type: 'image', src: up.src, name: up.name, w: w, h: h, fit: 'contain', mono: false, rotation: 0, opacity: 1 });
     addElement({ type: 'image', src: up.src, name: up.name, w: w, h: h, fit: 'contain', mono: false, rotation: 0, opacity: 1 });
     toast('图片已放置到画布');
     toast('图片已放置到画布');
@@ -1524,6 +1796,15 @@
     toast('已清空' + (target === 'front' ? '正面' : '背面') + ' · 可撤销');
     toast('已清空' + (target === 'front' ? '正面' : '背面') + ' · 可撤销');
   }
   }
 
 
+  function clearAllSides() {
+    state.sides = { front: { bg: null, elements: [] }, back: { bg: null, elements: [] } };
+    selectedId = null;
+    commit();
+    renderDesign();
+    renderSettings();
+    toast('已清空全部设计 · 可撤销');
+  }
+
   function duplicateSide() {
   function duplicateSide() {
     const from = activeSide;
     const from = activeSide;
     const to = from === 'front' ? 'back' : 'front';
     const to = from === 'front' ? 'back' : 'front';
@@ -1658,7 +1939,7 @@
     if (prop === 'x' || prop === 'y' || prop === 'w' || prop === 'h' || prop === 'rotation' || prop === 'opacity' || prop === 'size' || prop === 'spacing' || prop === 'lineHeight' || prop === 'strokeWidth' || prop === 'radius') {
     if (prop === 'x' || prop === 'y' || prop === 'w' || prop === 'h' || prop === 'rotation' || prop === 'opacity' || prop === 'size' || prop === 'spacing' || prop === 'lineHeight' || prop === 'strokeWidth' || prop === 'radius') {
       const n = Number(value);
       const n = Number(value);
       if (isNaN(n)) return;
       if (isNaN(n)) return;
-      if (prop === 'opacity') el.opacity = clamp(n / 100, 0.1, 1);
+      if (prop === 'opacity') el.opacity = clamp(n / 100, 0, 1);
       else if (prop === 'size') el.size = Math.max(2, n);
       else if (prop === 'size') el.size = Math.max(2, n);
       else if (prop === 'w') el.w = Math.max(2, n);
       else if (prop === 'w') el.w = Math.max(2, n);
       else if (prop === 'h') el.h = Math.max(1, n);
       else if (prop === 'h') el.h = Math.max(1, n);
@@ -1767,25 +2048,96 @@
     updateMeta();
     updateMeta();
   }
   }
 
 
-  function exportCurrent() {
+  function downloadBlob(blob, filename) {
+    const a = document.createElement('a');
+    a.href = URL.createObjectURL(blob);
+    a.download = filename;
+    a.click();
+    setTimeout(function () { URL.revokeObjectURL(a.href); }, 1500);
+  }
+
+  function roundedRectSegments(x, y, w, h, r, seg) {
+    r = Math.max(0, Math.min(r, w / 2, h / 2));
+    seg = seg || 8;
+    const pts = [];
+    function arc(cx, cy, a0, a1) {
+      for (let i = 0; i <= seg; i += 1) {
+        const a = a0 + (a1 - a0) * i / seg;
+        pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]);
+      }
+    }
+    pts.push([x + r, y]);
+    pts.push([x + w - r, y]);
+    arc(x + w - r, y + r, -Math.PI / 2, 0);
+    pts.push([x + w, y + h - r]);
+    arc(x + w - r, y + h - r, 0, Math.PI / 2);
+    pts.push([x + r, y + h]);
+    arc(x + r, y + h - r, Math.PI / 2, Math.PI);
+    pts.push([x, y + r]);
+    arc(x + r, y + r, Math.PI, Math.PI * 1.5);
+    const segs = [];
+    for (let i = 0; i < pts.length; i += 1) {
+      const a = pts[i];
+      const b = pts[(i + 1) % pts.length];
+      if (Math.abs(a[0] - b[0]) < 1e-6 && Math.abs(a[1] - b[1]) < 1e-6) continue;
+      segs.push([a[0], a[1], b[0], b[1]]);
+    }
+    return segs;
+  }
+
+  function exportBagDxf() {
+    const p = product();
+    const s = size();
+    const pad = p.pad || { l: 12, r: 12, t: 34, b: 18 };
+    const bleed = 3;
+    const ox = pad.l + bleed;
+    const oy = pad.t + bleed;
+    let out = '0\nSECTION\n2\nENTITIES\n';
+    function line(layer, x1, y1, x2, y2) {
+      out += '0\nLINE\n8\n' + layer + '\n10\n' + (x1 + ox).toFixed(3) + '\n20\n' + (y1 + oy).toFixed(3) + '\n11\n' + (x2 + ox).toFixed(3) + '\n21\n' + (y2 + oy).toFixed(3) + '\n';
+    }
+    function add(layer, segs) { segs.forEach(function (g) { line(layer, g[0], g[1], g[2], g[3]); }); }
+    const w = s.w + pad.l + pad.r;
+    const h = s.h + pad.t + pad.b;
+    add('CUT', roundedRectSegments(-pad.l, -pad.t, w, h, 6));
+    add('BLEED', roundedRectSegments(-pad.l - bleed, -pad.t - bleed, w + bleed * 2, h + bleed * 2, 6 + bleed));
+    line('PRINT', 0, 0, s.w, 0);
+    line('PRINT', s.w, 0, s.w, s.h);
+    line('PRINT', s.w, s.h, 0, s.h);
+    line('PRINT', 0, s.h, 0, 0);
+    line('FOLD', 0, -pad.t, 0, s.h + pad.b);
+    line('FOLD', s.w, -pad.t, s.w, s.h + pad.b);
+    line('FOLD', -pad.l, 0, s.w + pad.r, 0);
+    line('FOLD', -pad.l, s.h, s.w + pad.r, s.h);
+    out += '0\nENDSEC\n0\nEOF\n';
+    downloadBlob(new Blob([out], { type: 'application/dxf' }), 'pouchlab-' + p.id + '-dieline.dxf');
+    toast('刀版 DXF 已导出 · CUT/FOLD/BLEED');
+  }
+
+  function exportCurrent(opts) {
+    opts = opts || {};
+    const svgWidth = opts.width || 1400;
+    const outWidth = opts.outWidth || 0;
     const p = renderProduct();
     const p = renderProduct();
     const s = size();
     const s = size();
     const side = mode === 'summary' ? summarySide : activeSide;
     const side = mode === 'summary' ? summarySide : activeSide;
-    const svg = R.bagSVG(p, side, sideData(side), { size: s, card: true, width: 1400, material: state.material, finish: state.finish });
+    const svg = R.bagSVG(p, side, sideData(side), { size: s, card: true, width: svgWidth, material: state.material, finish: state.finish });
     const blob = new Blob([svg], { type: 'image/svg+xml;charset=utf-8' });
     const blob = new Blob([svg], { type: 'image/svg+xml;charset=utf-8' });
     const url = URL.createObjectURL(blob);
     const url = URL.createObjectURL(blob);
     const img = new Image();
     const img = new Image();
     img.onload = function () {
     img.onload = function () {
-      const pad = 90;
-      const footer = 150;
+      const ratio = svgWidth / 1400;
+      const pad = Math.round(90 * ratio);
+      const footer = Math.round(150 * ratio);
+      const baseW = img.width + pad * 2;
+      const scale = outWidth ? outWidth / baseW : 1;
       const canvas = document.createElement('canvas');
       const canvas = document.createElement('canvas');
-      const scale = 1;
-      canvas.width = (img.width + pad * 2) * scale;
-      canvas.height = (img.height + pad + footer) * scale;
+      canvas.width = Math.round(baseW * scale);
+      canvas.height = Math.round((img.height + pad + footer) * scale);
       const ctx = canvas.getContext('2d');
       const ctx = canvas.getContext('2d');
       ctx.scale(scale, scale);
       ctx.scale(scale, scale);
       ctx.fillStyle = '#f6f2e9';
       ctx.fillStyle = '#f6f2e9';
-      ctx.fillRect(0, 0, canvas.width, canvas.height);
+      ctx.fillRect(0, 0, canvas.width / scale, canvas.height / scale);
       ctx.drawImage(img, pad, pad, img.width, img.height);
       ctx.drawImage(img, pad, pad, img.width, img.height);
       ctx.fillStyle = '#17140f';
       ctx.fillStyle = '#17140f';
       ctx.font = '700 24px "PingFang SC", "Helvetica Neue", sans-serif';
       ctx.font = '700 24px "PingFang SC", "Helvetica Neue", sans-serif';
@@ -1798,20 +2150,13 @@
       ctx.fillText('POUCHLAB DESIGN STUDIO · 300 DPI · ' + new Date().toLocaleDateString('zh-CN'), pad, img.height + pad + 100);
       ctx.fillText('POUCHLAB DESIGN STUDIO · 300 DPI · ' + new Date().toLocaleDateString('zh-CN'), pad, img.height + pad + 100);
       URL.revokeObjectURL(url);
       URL.revokeObjectURL(url);
       canvas.toBlob(function (b) {
       canvas.toBlob(function (b) {
-        const a = document.createElement('a');
-        a.href = URL.createObjectURL(b);
-        a.download = 'pouchlab-' + p.id + '-' + side + '.png';
-        a.click();
-        setTimeout(function () { URL.revokeObjectURL(a.href); }, 1500);
-        toast('效果图已下载');
+        downloadBlob(b, 'pouchlab-' + p.id + '-' + side + (opts.suffix || '') + '.png');
+        toast(opts.label ? opts.label + '已下载' : '效果图已下载');
       }, 'image/png');
       }, 'image/png');
     };
     };
     img.onerror = function () {
     img.onerror = function () {
       URL.revokeObjectURL(url);
       URL.revokeObjectURL(url);
-      const a = document.createElement('a');
-      a.href = URL.createObjectURL(blob);
-      a.download = 'pouchlab-' + p.id + '.svg';
-      a.click();
+      downloadBlob(blob, 'pouchlab-' + p.id + '-' + side + '.svg');
       toast('已下载 SVG 文件');
       toast('已下载 SVG 文件');
     };
     };
     img.src = url;
     img.src = url;
@@ -1969,8 +2314,9 @@
       const img = new Image();
       const img = new Image();
       img.onload = function () {
       img.onload = function () {
         const max = 1400;
         const max = 1400;
-        let w = img.width;
-        let h = img.height;
+        let w = img.naturalWidth || img.width || 1000;
+        let h = img.naturalHeight || img.height || 1000;
+        if (!w || !h) { w = 1000; h = 1000; }
         if (Math.max(w, h) > max) {
         if (Math.max(w, h) > max) {
           const k = max / Math.max(w, h);
           const k = max / Math.max(w, h);
           w = Math.round(w * k);
           w = Math.round(w * k);
@@ -2080,6 +2426,10 @@
     $('#zoomOut').addEventListener('click', function () { updateZoom(zoom / 1.18); });
     $('#zoomOut').addEventListener('click', function () { updateZoom(zoom / 1.18); });
     $('#zoomFit').addEventListener('click', function () { zoom = 1; renderCanvas(); });
     $('#zoomFit').addEventListener('click', function () { zoom = 1; renderCanvas(); });
     $('#downloadBtn').addEventListener('click', exportCurrent);
     $('#downloadBtn').addEventListener('click', exportCurrent);
+    const d4 = $('#download4kBtn');
+    if (d4) d4.addEventListener('click', function () { exportCurrent({ width: 3600, outWidth: 3840, suffix: '-4k', label: '4K 效果图' }); });
+    const ddxf = $('#downloadDxfBtn');
+    if (ddxf) ddxf.addEventListener('click', exportBagDxf);
     $('#toolPanelClose').addEventListener('click', function () {
     $('#toolPanelClose').addEventListener('click', function () {
       els.designView.classList.remove('panel-open');
       els.designView.classList.remove('panel-open');
       els.designView.classList.add('panel-collapsed');
       els.designView.classList.add('panel-collapsed');
@@ -2173,6 +2523,12 @@
       Array.from(e.dataTransfer.files).slice(0, 4).forEach(addUploadedFile);
       Array.from(e.dataTransfer.files).slice(0, 4).forEach(addUploadedFile);
     });
     });
 
 
+    els.propsClose.addEventListener('click', function () {
+      selectedId = null;
+      renderCanvas();
+      renderProps();
+    });
+
     els.propsBody.addEventListener('input', function (e) {
     els.propsBody.addEventListener('input', function (e) {
       const t = e.target;
       const t = e.target;
       if (t.hasAttribute('data-toggle-guides')) {
       if (t.hasAttribute('data-toggle-guides')) {
@@ -2193,7 +2549,6 @@
       else if (t.hasAttribute('data-num')) v = num(t.value, 0);
       else if (t.hasAttribute('data-num')) v = num(t.value, 0);
       else v = t.value;
       else v = t.value;
       if (t.dataset.scale) v = Number(v);
       if (t.dataset.scale) v = Number(v);
-      if (prop === 'opacity') v = v;
       updateSelected(prop, v);
       updateSelected(prop, v);
       const colorSpan = t.parentElement && t.parentElement.querySelector('span');
       const colorSpan = t.parentElement && t.parentElement.querySelector('span');
       if (t.type === 'color' && colorSpan) colorSpan.textContent = String(t.value).replace('#', '');
       if (t.type === 'color' && colorSpan) colorSpan.textContent = String(t.value).replace('#', '');
@@ -2280,6 +2635,10 @@
     });
     });
     $('#backToDesign').addEventListener('click', function () { setMode('design'); });
     $('#backToDesign').addEventListener('click', function () { setMode('design'); });
     $('#summaryDownload').addEventListener('click', exportCurrent);
     $('#summaryDownload').addEventListener('click', exportCurrent);
+    const s4 = $('#summaryDownload4k');
+    if (s4) s4.addEventListener('click', function () { exportCurrent({ width: 3600, outWidth: 3840, suffix: '-4k', label: '4K 效果图' }); });
+    const sdxf = $('#summaryDownloadDxf');
+    if (sdxf) sdxf.addEventListener('click', exportBagDxf);
     $('#summaryPreview3d').addEventListener('click', open3d);
     $('#summaryPreview3d').addEventListener('click', open3d);
 
 
     let orderSubmitting = false;
     let orderSubmitting = false;
@@ -2359,18 +2718,25 @@
       const btn = $('#submitOrder');
       const btn = $('#submitOrder');
       btn.disabled = true;
       btn.disabled = true;
       btn.textContent = '正在提交订单…';
       btn.textContent = '正在提交订单…';
+      let orderPayload = null;
       buildOrderPayload(data).then(function (payload) {
       buildOrderPayload(data).then(function (payload) {
+        orderPayload = payload;
         return PL.api.post('/orders', payload, { timeout: 60000 });
         return PL.api.post('/orders', payload, { timeout: 60000 });
       }).then(function (r) {
       }).then(function (r) {
         finishSubmit(r.orderNo, false);
         finishSubmit(r.orderNo, false);
       }, function (err) {
       }, function (err) {
         if (err && err.network) {
         if (err && err.network) {
-          // 离线回退:沿用旧的本地保存行为
+          // 离线回退:本地保存完整订单信息,联网后可在「我的订单」查看
           const n = 'PL-' + String(new Date().getFullYear()) + String(Date.now()).slice(-6);
           const n = 'PL-' + String(new Date().getFullYear()) + String(Date.now()).slice(-6);
           try {
           try {
             localStorage.setItem('pouchlab.order.' + n, JSON.stringify({
             localStorage.setItem('pouchlab.order.' + n, JSON.stringify({
               name: data.get('name'), phone: data.get('phone'), email: data.get('email'),
               name: data.get('name'), phone: data.get('phone'), email: data.get('email'),
-              note: data.get('note'), order: n, total: D.price(state).total, design: snapshot(), at: Date.now()
+              address: data.get('address') || '', note: data.get('note'),
+              order: n, total: D.price(state).total, qty: state.qty,
+              summary: orderPayload ? orderPayload.summary : '',
+              spec: orderPayload ? orderPayload.spec : null,
+              previews: orderPayload ? orderPayload.previews : {},
+              design: snapshot(), at: Date.now()
             }));
             }));
           } catch (e2) {}
           } catch (e2) {}
           finishSubmit(n, true);
           finishSubmit(n, true);
@@ -2674,13 +3040,13 @@
         if (handle === 'nw' || handle === 'sw') nx = orig.x + orig.w - nw;
         if (handle === 'nw' || handle === 'sw') nx = orig.x + orig.w - nw;
         if (handle === 'nw' || handle === 'ne') ny = orig.y + orig.h - nh;
         if (handle === 'nw' || handle === 'ne') ny = orig.y + orig.h - nh;
       }
       }
-      if (el.type === 'sticker' || el.type === 'badge') {
+      if (el.type === 'sticker' || el.type === 'badge' || el.type === 'qr' || el.type === 'asset') {
         nh = nw;
         nh = nw;
         if (handle === 'nw' || handle === 'ne') ny = orig.y + orig.h - nh;
         if (handle === 'nw' || handle === 'ne') ny = orig.y + orig.h - nh;
       }
       }
       if (el.type === 'shape' && el.shape === 'line') nh = Math.max(3, orig.h);
       if (el.type === 'shape' && el.shape === 'line') nh = Math.max(3, orig.h);
       el.w = nw;
       el.w = nw;
-      if (el.type !== 'badge') el.h = nh;
+      if (el.type !== 'badge' && el.type !== 'qr') el.h = nh;
       el.x = nx;
       el.x = nx;
       el.y = ny;
       el.y = ny;
       renderCanvas();
       renderCanvas();

+ 22 - 19
box.html

@@ -15,10 +15,12 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>3D云设计编辑器 — 袋研社 POUCHLAB</title>
   <title>3D云设计编辑器 — 袋研社 POUCHLAB</title>
   <meta name="description" content="在线 3D 纸盒设计:盒型库、模板、素材、文字、条码二维码、智能参数、动效预览与印刷下单。">
   <meta name="description" content="在线 3D 纸盒设计:盒型库、模板、素材、文字、条码二维码、智能参数、动效预览与印刷下单。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/box.css?v=1.8.10">
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/box.css?v=1.8.22">
+  <script src="assets/js/i18n-en.js?v=1.8.22"></script>
+  <script src="assets/js/i18n.js?v=1.8.22"></script>
 </head>
 </head>
 <body class="bx-body">
 <body class="bx-body">
   <header class="bx-topbar">
   <header class="bx-topbar">
@@ -73,6 +75,7 @@
       <button data-mode="3d">3D预览</button>
       <button data-mode="3d">3D预览</button>
     </div>
     </div>
     <div class="bx-top-actions">
     <div class="bx-top-actions">
+      <span data-lang-slot></span>
       <button class="btn-print" id="bxPrintBtn">
       <button class="btn-print" id="bxPrintBtn">
         <svg viewBox="0 0 24 24"><path d="M7 8V3h10v5M5 8h14a2 2 0 0 1 2 2v6h-4v5H7v-5H3v-6a2 2 0 0 1 2-2Z" fill="none" stroke="currentColor" stroke-width="1.7"/><path d="M7 16h10" stroke="currentColor" stroke-width="1.7"/></svg>
         <svg viewBox="0 0 24 24"><path d="M7 8V3h10v5M5 8h14a2 2 0 0 1 2 2v6h-4v5H7v-5H3v-6a2 2 0 0 1 2-2Z" fill="none" stroke="currentColor" stroke-width="1.7"/><path d="M7 16h10" stroke="currentColor" stroke-width="1.7"/></svg>
         印刷下单
         印刷下单
@@ -226,20 +229,20 @@
   <!-- 弹窗挂载点 -->
   <!-- 弹窗挂载点 -->
   <div id="bxModals"></div>
   <div id="bxModals"></div>
 
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/three.min.js?v=1.8.10"></script>
-  <script src="assets/js/data.js?v=1.8.10"></script>
-  <script src="assets/js/pantone.js?v=1.8.10"></script>
-  <script src="assets/js/render.js?v=1.8.14"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.10"></script>
-  <script src="assets/js/api.js?v=1.8.10"></script>
-  <script src="assets/js/auth.js?v=1.8.10"></script>
-  <script src="assets/js/qr.js?v=1.8.10"></script>
-  <script src="assets/js/boxlib.js?v=1.8.10"></script>
-  <script src="assets/js/box3d.js?v=1.8.10"></script>
-  <script src="assets/js/box.js?v=1.8.18"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/three.min.js?v=1.8.22"></script>
+  <script src="assets/js/data.js?v=1.8.22"></script>
+  <script src="assets/js/pantone.js?v=1.8.22"></script>
+  <script src="assets/js/render.js?v=1.8.22"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.22"></script>
+  <script src="assets/js/api.js?v=1.8.22"></script>
+  <script src="assets/js/auth.js?v=1.8.22"></script>
+  <script src="assets/js/qr.js?v=1.8.22"></script>
+  <script src="assets/js/boxlib.js?v=1.8.22"></script>
+  <script src="assets/js/box3d.js?v=1.8.22"></script>
+  <script src="assets/js/box.js?v=1.8.22"></script>
 </body>
 </body>
 </html>
 </html>

+ 1 - 1
deploy/Dockerfile

@@ -6,7 +6,7 @@ COPY server/requirements.txt /app/server/requirements.txt
 RUN pip install --no-cache-dir -r /app/server/requirements.txt
 RUN pip install --no-cache-dir -r /app/server/requirements.txt
 
 
 COPY server /app/server
 COPY server /app/server
-COPY index.html studio.html box.html orders.html admin.html /app/
+COPY index.html m.html studio.html box.html orders.html admin.html /app/
 COPY assets /app/assets
 COPY assets /app/assets
 
 
 ENV PL_SITE_DIR=/app \
 ENV PL_SITE_DIR=/app \

+ 1 - 1
deploy/k8s/pouchlab.yaml

@@ -33,7 +33,7 @@ spec:
         kubernetes.io/hostname: k8s-node1   # 数据 hostPath 固定节点(SQLite 单副本)
         kubernetes.io/hostname: k8s-node1   # 数据 hostPath 固定节点(SQLite 单副本)
       containers:
       containers:
         - name: pouchlab
         - name: pouchlab
-          image: k8s.device.wenhq.top:8583/docker_r/pouchlab:1.8.18
+          image: k8s.device.wenhq.top:8583/docker_r/pouchlab:1.8.22
           imagePullPolicy: IfNotPresent
           imagePullPolicy: IfNotPresent
           env:
           env:
             - name: PL_DB_HOST
             - name: PL_DB_HOST

+ 19 - 16
index.html

@@ -15,11 +15,13 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>袋研社 POUCHLAB — 包装袋在线设计工作室</title>
   <title>袋研社 POUCHLAB — 包装袋在线设计工作室</title>
   <meta name="description" content="在线设计你的包装袋:站立袋、平底袋、咖啡袋、牛皮纸袋、邮寄袋。100 个起订,3D 实时预览,刀版精准,小批量也能做出大品牌质感。">
   <meta name="description" content="在线设计你的包装袋:站立袋、平底袋、咖啡袋、牛皮纸袋、邮寄袋。100 个起订,3D 实时预览,刀版精准,小批量也能做出大品牌质感。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/landing.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/box.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.10">
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/landing.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/box.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.22">
+  <script src="assets/js/i18n-en.js?v=1.8.22"></script>
+  <script src="assets/js/i18n.js?v=1.8.22"></script>
 </head>
 </head>
 <body>
 <body>
   <header class="site-header">
   <header class="site-header">
@@ -44,6 +46,7 @@
         <a href="box.html">纸盒设计</a>
         <a href="box.html">纸盒设计</a>
       </nav>
       </nav>
       <div class="header-actions">
       <div class="header-actions">
+        <span data-lang-slot></span>
         <a class="header-link" href="orders.html">我的订单</a>
         <a class="header-link" href="orders.html">我的订单</a>
         <button class="header-link" id="loginTrigger" type="button">登录</button>
         <button class="header-link" id="loginTrigger" type="button">登录</button>
         <span data-ui="Button" data-props='{"type":"primary","size":"small","href":"studio.html"}' data-text="免费设计 →"></span>
         <span data-ui="Button" data-props='{"type":"primary","size":"small","href":"studio.html"}' data-text="免费设计 →"></span>
@@ -265,16 +268,16 @@
     </div>
     </div>
   </footer>
   </footer>
 
 
-  <script src="assets/vendor/react.production.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.10"></script>
-  <script src="assets/js/data.js?v=1.8.10"></script>
-  <script src="assets/js/render.js?v=1.8.14"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.10"></script>
-  <script src="assets/js/api.js?v=1.8.10"></script>
-  <script src="assets/js/auth.js?v=1.8.10"></script>
-  <script src="assets/js/agent-chat.js?v=1.8.10"></script>
-  <script src="assets/js/landing.js?v=1.8.10"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.22"></script>
+  <script src="assets/js/data.js?v=1.8.22"></script>
+  <script src="assets/js/render.js?v=1.8.22"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.22"></script>
+  <script src="assets/js/api.js?v=1.8.22"></script>
+  <script src="assets/js/auth.js?v=1.8.22"></script>
+  <script src="assets/js/agent-chat.js?v=1.8.22"></script>
+  <script src="assets/js/landing.js?v=1.8.22"></script>
 </body>
 </body>
 </html>
 </html>

+ 11 - 8
m.html

@@ -7,9 +7,11 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>AI 设计师 — 袋研社 POUCHLAB</title>
   <title>AI 设计师 — 袋研社 POUCHLAB</title>
   <meta name="description" content="手机端 AI 包装设计:对话式出稿、下单、查询订单物流。详细微调请到电脑网站。">
   <meta name="description" content="手机端 AI 包装设计:对话式出稿、下单、查询订单物流。详细微调请到电脑网站。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.7.0">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.7.0">
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.22">
   <link rel="stylesheet" href="assets/css/m.css?v=1.0.0">
   <link rel="stylesheet" href="assets/css/m.css?v=1.0.0">
+  <script src="assets/js/i18n-en.js?v=1.8.22"></script>
+  <script src="assets/js/i18n.js?v=1.8.22"></script>
 </head>
 </head>
 <body class="m-body">
 <body class="m-body">
   <header class="m-head">
   <header class="m-head">
@@ -25,6 +27,7 @@
     </a>
     </a>
     <span class="m-quota" id="mQuota"></span>
     <span class="m-quota" id="mQuota"></span>
     <button class="m-login" id="mLoginBtn">登录</button>
     <button class="m-login" id="mLoginBtn">登录</button>
+    <span data-lang-slot></span>
   </header>
   </header>
 
 
   <!-- 设计(AI 对话) -->
   <!-- 设计(AI 对话) -->
@@ -94,11 +97,11 @@
 
 
   <div class="m-toast" id="mToast" hidden></div>
   <div class="m-toast" id="mToast" hidden></div>
 
 
-  <script src="assets/vendor/dayjs.min.js?v=1.7.0"></script>
-  <script src="assets/js/data.js?v=1.7.0"></script>
-  <script src="assets/js/render.js?v=1.7.0"></script>
-  <script src="assets/js/api.js?v=1.7.0"></script>
-  <script src="assets/js/auth.js?v=1.7.0"></script>
-  <script src="assets/js/m.js?v=1.0.4"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.22"></script>
+  <script src="assets/js/data.js?v=1.8.22"></script>
+  <script src="assets/js/render.js?v=1.8.22"></script>
+  <script src="assets/js/api.js?v=1.8.22"></script>
+  <script src="assets/js/auth.js?v=1.8.22"></script>
+  <script src="assets/js/m.js?v=1.8.22"></script>
 </body>
 </body>
 </html>
 </html>

+ 18 - 12
orders.html

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

+ 1 - 1
server/agent_service.py

@@ -50,7 +50,7 @@ SYSTEM_PROMPT = """你是「袋研社 POUCHLAB」的 AI 包装设计师,通过
    两只并排礼盒内尺寸约 175×90×100;12oz 咖啡豆袋约 130×190;A5 书约 210×150×20;6 罐啤酒约 200×150×130;
    两只并排礼盒内尺寸约 175×90×100;12oz 咖啡豆袋约 130×190;A5 书约 210×150×20;6 罐啤酒约 200×150×130;
    蜡烛/咖啡/茶叶等主题设计应主动选用 candle/leaf 等贴合元素的 logo 模板)。
    蜡烛/咖啡/茶叶等主题设计应主动选用 candle/leaf 等贴合元素的 logo 模板)。
 3. generate_design 的 style 参数传客户对图案的原话描述(语言跟随客户)。
 3. generate_design 的 style 参数传客户对图案的原话描述(语言跟随客户)。
-4. 全部工具调用完成后,用中文简短总结:选了什么/尺寸/材质/设计亮点,并提示可点「去微调」进入编辑器继续调整或继续对话修改。
+4. 用客户使用的语言简短总结(客户说中文用中文,说英文用英文):选了什么/尺寸/材质/设计亮点,并提示可点「去微调」进入编辑器继续调整或继续对话修改。
 5. 客户后续要求调整时,再次调用对应工具(改尺寸/换材质/重新设计等),不要重新来一遍。禁止在回复里编造工具外的参数。"""
 5. 客户后续要求调整时,再次调用对应工具(改尺寸/换材质/重新设计等),不要重新来一遍。禁止在回复里编造工具外的参数。"""
 
 
 TOOLS_SPEC = [
 TOOLS_SPEC = [

+ 128 - 0
server/i18n.py

@@ -0,0 +1,128 @@
+# -*- coding: utf-8 -*-
+"""服务端多语言:按 Accept-Language 翻译 API 错误文案。
+
+前端 api.js 会随请求带上 Accept-Language: en / zh-CN。
+中文为源文案,英文通过整串精确匹配翻译;未收录的原文透传。
+"""
+import json
+import re
+
+def get_lang(request) -> str:
+    try:
+        header = (request.headers.get("accept-language") or "").lower()
+    except Exception:
+        return "zh"
+    # en 优先于 zh:仅当英文权重出现在中文之前才判为 en
+    first = None
+    for part in header.split(","):
+        tag = part.strip().split(";")[0]
+        if tag and tag != "*":
+            first = tag
+            break
+    if first and first.startswith("en"):
+        return "en"
+    return "zh"
+
+
+ERRORS_EN = {
+    "AI 排版次数已用完,请联系管理员增加额度": "AI layout quota exhausted — contact an admin to top up",
+    "AI 服务未配置(PL_AI_API_KEY)": "AI service not configured (PL_AI_API_KEY)",
+    "AI 服务未配置(后台 → AI 设置)": "AI service not configured (Admin → AI Settings)",
+    "AI 次数已用完,请联系管理员增加额度": "AI quota exhausted — contact an admin to top up",
+    "AI 生成失败,请换个说法重试": "AI generation failed — try rephrasing",
+    "Base URL 需以 http(s):// 开头": "Base URL must start with http(s)://",
+    "CAD 图纸生成失败": "CAD drawing generation failed",
+    "CAD 预览生成失败": "CAD preview generation failed",
+    "EPS 生成失败": "EPS generation failed",
+    "上一个设计任务还在进行中,稍等一下": "Previous design task is still running — hold on a moment",
+    "不能禁用自己": "You cannot disable yourself",
+    "会话 id 不合法": "Invalid session id",
+    "反馈不存在": "Feedback not found",
+    "发送太频繁,请稍后再试": "Sending too frequently — please try again later",
+    "密码至少 6 位": "Password must be at least 6 characters",
+    "工厂账号不存在": "Factory account not found",
+    "工厂账号专用接口": "Factory-account-only endpoint",
+    "已支付订单请联系客服处理": "Paid order — please contact support",
+    "当前状态不可取消": "Cannot cancel in the current status",
+    "支付状态不合法": "Invalid payment status",
+    "无权查看该订单": "You are not allowed to view this order",
+    "模型名过长": "Model name too long",
+    "状态不合法": "Invalid status",
+    "生产图纸生成失败": "Production drawing generation failed",
+    "用户不存在": "User not found",
+    "用户名已存在": "Username already exists",
+    "用户名或密码错误": "Incorrect username or password",
+    "用户名需 3-30 位字母/数字/下划线": "Username must be 3-30 letters, digits or underscores",
+    "登录已失效,请重新登录": "Session expired — please sign in again",
+    "矢量刀版生成失败": "Vector dieline generation failed",
+    "管理员未给你开放 AI 排版额度": "Admin has not granted you AI layout quota",
+    "管理员未给你开放 AI 额度": "Admin has not granted you AI quota",
+    "类型不合法": "Invalid type",
+    "订单不存在": "Order not found",
+    "订单不是待支付状态": "Order is not pending payment",
+    "订单已取消,不能发货": "Order cancelled — cannot ship",
+    "订单状态不允许支付": "Order status does not allow payment",
+    "订单状态不合法": "Invalid order status",
+    "订单类型不合法": "Invalid order type",
+    "订单金额不合法": "Invalid order amount",
+    "该订单尚未进入生产流程": "This order has not entered production yet",
+    "该订单没有刀版数据": "This order has no dieline data",
+    "该订单没有设计数据": "This order has no design data",
+    "请先登录": "Please sign in first",
+    "请填写反馈内容": "Please fill in the feedback",
+    "请填写回复内容": "Please fill in the reply",
+    "请填写快递公司和运单号": "Please enter the carrier and tracking number",
+    "请填写收货地址": "Please enter the shipping address",
+    "请填写联系人和手机号": "Please enter the contact name and phone",
+    "请填写邮件主题与内容": "Please enter the email subject and body",
+    "请描述你的排版需求": "Describe your layout needs",
+    "请输入正确的手机号": "Enter a valid phone number",
+    "请输入消息": "Please enter a message",
+    "账号不存在": "Account not found",
+    "账号已被禁用": "Account disabled",
+    "账号已被禁用,请联系客服": "Account disabled — please contact support",
+    "需要工作人员权限": "Staff permission required",
+    "需要管理员权限": "Admin permission required",
+    "预览图不存在": "Preview image not found",
+    "额度需在 0-100000 之间": "Quota must be between 0 and 100000",
+    "验证码错误或已过期": "Incorrect or expired verification code",
+}
+
+_HAS_CN = re.compile(r"[\u4e00-\u9fff]")
+
+
+def translate_detail(text):
+    """整串精确匹配;未命中且含中文时尝试去尾部动态括注后匹配。"""
+    if not isinstance(text, str) or not _HAS_CN.search(text):
+        return text
+    out = ERRORS_EN.get(text)
+    if out:
+        return out
+    base = re.sub(r"[((][^()()]*[))]\s*$", "", text).strip()
+    if base and base != text:
+        out = ERRORS_EN.get(base)
+        if out:
+            return out
+    return text
+
+
+def translate_json_body(body: bytes, lang: str) -> bytes:
+    """把 JSON 响应里的 detail/message 中文文案翻译为英文。"""
+    if lang != "en":
+        return body
+    try:
+        data = json.loads(body.decode("utf-8"))
+    except Exception:
+        return body
+    changed = False
+    if isinstance(data, dict):
+        for key in ("detail", "message", "msg", "error"):
+            v = data.get(key)
+            if isinstance(v, str):
+                t = translate_detail(v)
+                if t != v:
+                    data[key] = t
+                    changed = True
+    if not changed:
+        return body
+    return json.dumps(data, ensure_ascii=False).encode("utf-8")

+ 18 - 1
server/main.py

@@ -10,13 +10,14 @@
 """
 """
 import os
 import os
 
 
-from fastapi import FastAPI
+from fastapi import FastAPI, Response
 from fastapi.middleware.cors import CORSMiddleware
 from fastapi.middleware.cors import CORSMiddleware
 from fastapi.responses import PlainTextResponse
 from fastapi.responses import PlainTextResponse
 from fastapi.staticfiles import StaticFiles
 from fastapi.staticfiles import StaticFiles
 
 
 import cache
 import cache
 import db
 import db
+import i18n
 from routes_admin import router as admin_router
 from routes_admin import router as admin_router
 from routes_auth import router as auth_router
 from routes_auth import router as auth_router
 from routes_agent import router as agent_router
 from routes_agent import router as agent_router
@@ -45,6 +46,22 @@ async def no_store_html(request, call_next):
     return response
     return response
 
 
 
 
+@app.middleware("http")
+async def translate_api_errors(request, call_next):
+    """按 Accept-Language 把 JSON API 响应里的中文提示翻译成英文。"""
+    response = await call_next(request)
+    ctype = response.headers.get("content-type", "")
+    if "application/json" not in ctype or i18n.get_lang(request) != "en":
+        return response
+    body = b""
+    async for chunk in response.body_iterator:
+        body += chunk
+    body = i18n.translate_json_body(body, "en")
+    headers = dict(response.headers)
+    headers.pop("content-length", None)
+    return Response(content=body, status_code=response.status_code, headers=headers, media_type=ctype)
+
+
 app.include_router(auth_router)
 app.include_router(auth_router)
 app.include_router(orders_router)
 app.include_router(orders_router)
 app.include_router(admin_router)
 app.include_router(admin_router)

+ 29 - 19
studio.html

@@ -21,10 +21,12 @@
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
   <title>设计工作室 — 袋研社 POUCHLAB</title>
   <title>设计工作室 — 袋研社 POUCHLAB</title>
   <meta name="description" content="在线包装袋设计工作室:选择袋型、套用模板、上传 Logo、3D 预览并下单一站完成。">
   <meta name="description" content="在线包装袋设计工作室:选择袋型、套用模板、上传 Logo、3D 预览并下单一站完成。">
-  <link rel="stylesheet" href="assets/css/base.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/studio.css?v=1.4.14">
-  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.10">
-  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.10">
+  <link rel="stylesheet" href="assets/css/base.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/studio.css?v=1.4.15">
+  <link rel="stylesheet" href="assets/css/auth.css?v=1.8.22">
+  <link rel="stylesheet" href="assets/css/antd.css?v=1.8.22">
+  <script src="assets/js/i18n-en.js?v=1.8.22"></script>
+  <script src="assets/js/i18n.js?v=1.8.22"></script>
 </head>
 </head>
 <body class="studio-body">
 <body class="studio-body">
   <header class="studio-topbar">
   <header class="studio-topbar">
@@ -54,6 +56,7 @@
       <button class="step" data-step="summary"><i>3</i><span>订单</span></button>
       <button class="step" data-step="summary"><i>3</i><span>订单</span></button>
     </nav>
     </nav>
     <div class="studio-actions">
     <div class="studio-actions">
+      <span data-lang-slot></span>
       <a class="orders-link" href="orders.html" title="我的订单">我的订单</a>
       <a class="orders-link" href="orders.html" title="我的订单">我的订单</a>
       <span class="save-state" id="saveState"><i></i><span>已保存</span></span>
       <span class="save-state" id="saveState"><i></i><span>已保存</span></span>
       <div class="undo-group">
       <div class="undo-group">
@@ -179,6 +182,8 @@
           <svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><path d="M12 3v12M7 10l5 5 5-5"/><path d="M4 20h16"/></svg>
           <svg class="icon" viewBox="0 0 24 24" style="width:13px;height:13px"><path d="M12 3v12M7 10l5 5 5-5"/><path d="M4 20h16"/></svg>
           下载效果图
           下载效果图
         </button>
         </button>
+        <button id="download4kBtn">下载 4K</button>
+        <button id="downloadDxfBtn">导出 DXF</button>
       </div>
       </div>
     </section>
     </section>
 
 
@@ -186,6 +191,7 @@
       <div class="props-head">
       <div class="props-head">
         <h3>画布设置</h3>
         <h3>画布设置</h3>
         <span class="type-chip" id="propsChip">CANVAS</span>
         <span class="type-chip" id="propsChip">CANVAS</span>
+        <button class="props-close" id="propsClose" aria-label="关闭属性面板">×</button>
       </div>
       </div>
       <div class="props-body" id="propsBody"></div>
       <div class="props-body" id="propsBody"></div>
     </aside>
     </aside>
@@ -210,6 +216,8 @@
         <div class="summary-actions">
         <div class="summary-actions">
           <button id="backToDesign">← 继续编辑</button>
           <button id="backToDesign">← 继续编辑</button>
           <button id="summaryDownload">下载效果图</button>
           <button id="summaryDownload">下载效果图</button>
+          <button id="summaryDownload4k">下载 4K</button>
+          <button id="summaryDownloadDxf">导出 DXF</button>
           <button id="summaryPreview3d">查看 3D 预览</button>
           <button id="summaryPreview3d">查看 3D 预览</button>
         </div>
         </div>
       </div>
       </div>
@@ -293,20 +301,22 @@
 
 
   <div class="toast" id="toast"><span class="dot"></span><span id="toastText"></span></div>
   <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.10"></script>
-  <script src="assets/vendor/react-dom.production.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/dayjs.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/antd.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/three.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/fflate.min.js?v=1.8.10"></script>
-  <script src="assets/vendor/FBXLoader.js?v=1.8.10"></script>
-  <script src="assets/js/data.js?v=1.8.10"></script>
-  <script src="assets/js/pantone.js?v=1.8.10"></script>
-  <script src="assets/js/render.js?v=1.8.14"></script>
-  <script src="assets/js/antd-bridge.js?v=1.8.10"></script>
-  <script src="assets/js/api.js?v=1.8.10"></script>
-  <script src="assets/js/auth.js?v=1.8.10"></script>
-  <script src="assets/js/pouch3d.js?v=1.8.10"></script>
-  <script src="assets/js/studio.js?v=1.8.10"></script>
+  <script src="assets/vendor/react.production.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/react-dom.production.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/dayjs.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/antd.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/three.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/fflate.min.js?v=1.8.22"></script>
+  <script src="assets/vendor/FBXLoader.js?v=1.8.22"></script>
+  <script src="assets/js/data.js?v=1.8.22"></script>
+  <script src="assets/js/pantone.js?v=1.8.22"></script>
+  <script src="assets/js/qr.js?v=1.8.22"></script>
+  <script src="assets/js/boxlib.js?v=1.8.22"></script>
+  <script src="assets/js/render.js?v=1.8.22"></script>
+  <script src="assets/js/antd-bridge.js?v=1.8.22"></script>
+  <script src="assets/js/api.js?v=1.8.22"></script>
+  <script src="assets/js/auth.js?v=1.8.22"></script>
+  <script src="assets/js/pouch3d.js?v=1.8.22"></script>
+  <script src="assets/js/studio.js?v=1.8.22"></script>
 </body>
 </body>
 </html>
 </html>