dsh-design-studio 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -209,6 +209,7 @@ window.__ModuleLoader__.load({
209
209
  xoWarn: '有内容会被裁掉,先看一眼',
210
210
  xoChecking: '正在量页面…',
211
211
  xoClean: '没有会被裁掉的内容。',
212
+ xoStNoCheck: '上面只查了默认状态;另外 {n} 页(其他状态)没预检,内容更长的可能被截掉,拿不准就选「整页」。',
212
213
  xoOver: '{n} 个页面比画幅大,会被裁',
213
214
  xoLong: '{n} 个页面是长页,只会截首屏',
214
215
  xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
@@ -220,9 +221,10 @@ window.__ModuleLoader__.load({
220
221
  xoFail: '{n} 屏没量到,结果可能不全',
221
222
  xoAgain: '再查一次',
222
223
  xoGone: '设计换了,这次导出取消了',
224
+ xoStFail: '没取到各屏写了哪几个状态,这次没导出,再点一次导出试试',
223
225
  xoJobGone: '导出中断了(等太久或 DSH 重启过),请重新导出',
224
226
  styleMoved: '设计换了,这次调的样式没保存',
225
- xoCut: '一次最多导出 1000 屏,最后 {n} 屏没导出',
227
+ xoCut: '一次最多导出 1000 页,最后 {n} 页没导出',
226
228
  xoResize: '按内容改画幅({size})',
227
229
  xoFull: '取景改成整页',
228
230
  xoWhich: '导出哪些',
@@ -233,6 +235,8 @@ window.__ModuleLoader__.load({
233
235
  xoPick: '挑几屏…',
234
236
  xoPickN: '挑了 {n} 屏',
235
237
  xoPickNone: '至少挑一屏',
238
+ xoStates: '每个状态各出一张',
239
+ xoStatesN: '多 {n} 页',
236
240
  xoPre: '导出前检查',
237
241
  xoWho: '({list})',
238
242
  xoPages: '{n} 页',
@@ -269,6 +273,12 @@ window.__ModuleLoader__.load({
269
273
  checkLayout: '页面还没排好版,这次没量成,过一会儿再查一次',
270
274
  checkNote: '只量排版上的硬伤,好不好看你说了算',
271
275
  checkNoneTip: '量了 {s} 屏,没有量得出的排版硬伤',
276
+ dfHead: '部件各屏写得不一样 · 是提醒,不算问题',
277
+ dfItem: '{n} 屏里有 {v} 种写法',
278
+ dfMore: '还有 {n} 个部件也这样',
279
+ dfTip: '点一下:把「统一这个部件」放进输入框',
280
+ dfAsk: '〔部件不一致〕{sel} 在 {n} 屏里有 {v} 种写法:{diff}。请定一种写法(多数屏用的那种)挪进共用的 app.css,各屏删掉自己那份。',
281
+ dfNone: '没写',
272
282
  checkAsk: '〔设计体检〕发现 {n} 个问题:',
273
283
  checkTail: '请逐个修好:改源文件,只动有问题的地方;颜色、字号能改设计变量就改设计变量。',
274
284
  ckToolHead: '量了 {s} 屏,发现 {n} 个问题。逐个改源文件,只动有问题的地方;颜色、字号能改设计变量就改设计变量:',
@@ -722,6 +732,14 @@ window.__ModuleLoader__.load({
722
732
  pageSet: '页面设置',
723
733
  dPageSet: '类型、画幅、多尺寸、深色模式、刷新…',
724
734
  scrSearch: '搜屏名',
735
+ stMenuT: '「{name}」的状态',
736
+ stDefault: '默认',
737
+ stTip: '这一屏有 {n} 个状态',
738
+ dState: '同一个页面的几种样子(空的、有数据、已付款…)。点开换着看',
739
+ stSide: '并排看全部状态',
740
+ dStAll: '这一屏的每个状态并排摆在画布上',
741
+ stAllOn: '全部状态 · {name}',
742
+ stPickNote: '状态:{state}({label})——改这个状态时只动 [data-state="{state}"] 下的样式,别影响别的状态',
725
743
  scrNone: '没有对得上的屏',
726
744
  scrCount: '{n} / {m} 屏',
727
745
  scrKeyPick: '选',
@@ -1382,6 +1400,7 @@ window.__ModuleLoader__.load({
1382
1400
  xoWarn: 'Some content would be cut off. Have a look first',
1383
1401
  xoChecking: 'Measuring pages…',
1384
1402
  xoClean: 'Nothing will be cut off.',
1403
+ xoStNoCheck: 'Only the default states were checked above; the other {n} pages (other states) were not, and longer content there may be cut off. If unsure, choose “Full page”.',
1385
1404
  xoOver: '{n} page(s) are larger than the canvas and will be cut off',
1386
1405
  xoLong: '{n} long page(s): only the first screen is captured',
1387
1406
  xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
@@ -1393,9 +1412,10 @@ window.__ModuleLoader__.load({
1393
1412
  xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
1394
1413
  xoAgain: 'Check again',
1395
1414
  xoGone: 'The design changed, so this export was cancelled',
1415
+ xoStFail: "Couldn't read which states each screen has, so nothing was exported. Try exporting again",
1396
1416
  xoJobGone: 'The export was interrupted (it waited too long or DSH restarted). Please export again',
1397
1417
  styleMoved: 'The design changed, so these style tweaks were not saved',
1398
- xoCut: 'At most 1000 screens per export; the last {n} were left out',
1418
+ xoCut: 'At most 1000 pages per export; the last {n} were left out',
1399
1419
  xoResize: 'Fit canvas to content ({size})',
1400
1420
  xoFull: 'Switch to full page',
1401
1421
  xoWhich: 'Which screens',
@@ -1406,6 +1426,8 @@ window.__ModuleLoader__.load({
1406
1426
  xoPick: 'Pick some…',
1407
1427
  xoPickN: '{n} picked',
1408
1428
  xoPickNone: 'Pick at least one',
1429
+ xoStates: 'One page per state',
1430
+ xoStatesN: '+{n} pages',
1409
1431
  xoPre: 'Before exporting',
1410
1432
  xoWho: ' ({list})',
1411
1433
  xoPages: '{n} pages',
@@ -1442,6 +1464,12 @@ window.__ModuleLoader__.load({
1442
1464
  checkLayout: 'The page was not laid out yet, so it was not measured. Check again in a moment.',
1443
1465
  checkNote: 'Only measurable layout problems; whether it looks good is up to you',
1444
1466
  checkNoneTip: 'Measured {s} screens, no layout problems found',
1467
+ dfHead: 'Shared parts differ across screens · a heads-up, not a problem',
1468
+ dfItem: '{v} versions across {n} screens',
1469
+ dfMore: '{n} more parts like this',
1470
+ dfTip: 'Click to put “unify this part” in the message box',
1471
+ dfAsk: '[Part drift] {sel} has {v} versions across {n} screens: {diff}. Pick one (the one most screens use), move it into the shared app.css and delete each screen’s own copy.',
1472
+ dfNone: 'unset',
1445
1473
  checkAsk: '[Design check] Found {n} problems:',
1446
1474
  checkTail: 'Please fix each one in the source files, touching only what is listed; for colors and type sizes, change the design tokens where possible.',
1447
1475
  ckToolHead: 'Measured {s} screens and found {n} problems. Fix each one in the source files, touching only what is listed; for colors and type sizes, change the design tokens where possible:',
@@ -1894,6 +1922,14 @@ window.__ModuleLoader__.load({
1894
1922
  pageSet: 'Page setup',
1895
1923
  dPageSet: 'Type, canvas size, sizes, dark mode, reload…',
1896
1924
  scrSearch: 'Find a screen',
1925
+ stMenuT: 'States of "{name}"',
1926
+ stDefault: 'default',
1927
+ stTip: 'This screen has {n} states',
1928
+ dState: 'Different looks of the same page (empty, loaded, paid…). Click to switch',
1929
+ stSide: 'See all states side by side',
1930
+ dStAll: 'Lay every state of this screen side by side on the canvas',
1931
+ stAllOn: 'All states · {name}',
1932
+ stPickNote: 'State: {state} ({label}) — when changing this state, only touch the styles under [data-state="{state}"] so the other states stay as they are',
1897
1933
  scrNone: 'No screen matches',
1898
1934
  scrCount: '{n} / {m}',
1899
1935
  scrKeyPick: 'move',
@@ -3071,6 +3107,20 @@ window.__ModuleLoader__.load({
3071
3107
  .ddp-cell:hover .ddp-act,.ddp-cell.sel .ddp-act{display:flex}
3072
3108
  .ddp-vt{flex:none;display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 4px;border-radius:5px;background:rgba(127,127,127,.14);color:var(--dsw-alias-label-secondary);font-size:11px;font-weight:600}
3073
3109
  .ddp-cell.sel .ddp-vt{background:rgba(77,107,254,.14);color:var(--dd-acc,${ACCENT})}
3110
+ /* 一页多状态(#30):屏名旁的「状态 ▾」。看的是默认状态时淡灰;换到别的状态带一点主色(提醒这屏现在不是默认的样子) */
3111
+ .ddp-stt{flex:none;display:inline-flex;align-items:center;gap:3px;height:20px;max-width:10em;padding:0 4px 0 6px;border:0;border-radius:10px;corner-shape:round;
3112
+ background:rgba(127,127,127,.13);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;font-weight:500;line-height:20px;cursor:pointer;transition:background .15s,color .15s}
3113
+ .ddp-stt:hover,.ddp-stt.on{background:rgba(127,127,127,.22);color:var(--dsw-alias-label-primary)}
3114
+ .ddp-stt.alt{background:rgba(77,107,254,.13);color:var(--dd-acc,${ACCENT})}
3115
+ .ddp-stt.alt:hover,.ddp-stt.alt.on{background:rgba(77,107,254,.22)}
3116
+ .ddp-stt>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3117
+ .ddp-stt svg{width:12px;height:12px;flex:none}
3118
+ .ddp-stt svg:last-child{width:10px;height:10px;opacity:.65}
3119
+ .ddp-stt:focus-visible{outline:2px solid var(--dd-acc,${ACCENT});outline-offset:1px}
3120
+ @container (max-width:104px){.ddp-stt>span{display:none}.ddp-stt{padding:0 4px}}
3121
+ /* 和「用这版」一样钉在最右、悬停不变大小:小按钮从它左边冒出来挤的是屏名,鼠标对着它时它不会跑开(不然点到冒出来的「导出」) */
3122
+ .ddp-lab>.ddp-stt{order:3;margin-left:auto}
3123
+ .ddp-cell:hover .ddp-lab>.ddp-stt,.ddp-cell.sel .ddp-lab>.ddp-stt{margin-left:0}
3074
3124
  .ddp-take{order:3;margin-left:auto;flex:none;display:inline-flex;align-items:center;gap:3px;height:20px;padding:0 8px 0 6px;border:0;border-radius:10px;
3075
3125
  background:rgba(77,107,254,.12);color:var(--dd-acc,${ACCENT});font:inherit;font-size:11px;font-weight:500;cursor:pointer}
3076
3126
  .ddp-take:hover{background:rgba(77,107,254,.2)}
@@ -3378,6 +3428,18 @@ body[data-ds-dark-theme] .ddp{color-scheme:dark;
3378
3428
  /* 名字长时先缩项目名(最多缩到 5.5 字宽);换屏器上是「画布」或短屏名(≤6 字宽)时不缩,长屏名两边按比例缩 */
3379
3429
  @supports (min-width:calc-size(max-content,size)){.ddp .dd-proj{min-width:calc-size(max-content,min(size,5.5em))}@container (max-width:360px){.ddp .dd-proj{min-width:calc-size(max-content,min(size,3.5em))}}}
3380
3430
  .ddp .dd-where.fix{flex-shrink:0}
3431
+ /* 单看时顶栏屏名后面的「状态 ▾」:和屏名那一块一样高、一样的底 */
3432
+ .ddp .dd-bar>.ddp-stt{height:32px;max-width:150px;margin-left:6px;padding:0 8px 0 9px;border-radius:var(--dd-r2);background:var(--dd-f1);box-shadow:inset 0 0 0 1px var(--dd-line);color:var(--dd-t2,var(--dsw-alias-label-secondary));font-size:12.5px;line-height:32px}
3433
+ .ddp .dd-bar>.ddp-stt:hover,.ddp .dd-bar>.ddp-stt.on{background:var(--dd-f2);color:var(--dsw-alias-label-primary)}
3434
+ .ddp .dd-bar>.ddp-stt.alt{color:var(--dd-acc,${ACCENT});box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dd-acc,${ACCENT}) 35%,transparent)}
3435
+ .ddp .dd-bar>.ddp-stt svg{width:14px;height:14px}
3436
+ .ddp .dd-bar>.ddp-stt svg:last-child{width:11px;height:11px}
3437
+ @container (max-width:520px){.ddp .dd-bar>.ddp-stt>span{display:none}.ddp .dd-bar>.ddp-stt{padding:0 7px}}
3438
+ /* 状态菜单:浮在台面上,位置由打开它的那个「状态 ▾」定 */
3439
+ .ddp .ddp-menu.ddp-stmenu{position:absolute;right:auto;z-index:60;width:248px;max-width:calc(100% - 16px)}
3440
+ .ddp-stmenu .ls>button>em{flex:none;max-width:42%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3441
+ .ddp-stmenu .ls>button>.ck{width:15px;flex:none}
3442
+ .ddp-stmenu .ls>button.hi,.ddp-stmenu>button.hi{background:var(--dd-f2,rgba(127,127,127,.12))}
3381
3443
  /* 再窄(DSH 右侧栏最窄约 300):画布那格只留格子和 ▾;≤390 单看也只留格子和 ▾(屏名在菜单里);≤360 再去掉斜杠、间距收一点,「转成代码」不被切 */
3382
3444
  @container (max-width:400px){.ddp .dd-where.cv .ddp-addr .lb2{display:none}.ddp .dd-where.cv .ddp-addr{padding:0 8px}}
3383
3445
  @container (max-width:390px){.ddp .dd-where .ddp-addr .lb2{display:none}.ddp .dd-where .ddp-addr{padding:0 8px}}
@@ -3639,6 +3701,8 @@ body:not([data-ds-dark-theme]) .ddp .dd-seg::before{box-shadow:var(--dd-sh1)}
3639
3701
  .ddp .dd-pk .on i{background:var(--dd-au);box-shadow:none}
3640
3702
  .ddp .dd-pk i svg{width:10px;height:10px;stroke-width:3;animation:dd-pop .26s var(--dd-spring) backwards}
3641
3703
  .ddp .dd-pk span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3704
+ .ddp .dd-pk.dd-xst{max-height:none;overflow:visible;padding:8px 6px 0;margin-top:6px;border-top:1px solid var(--dd-line)}
3705
+ .ddp .dd-xst em{margin-left:auto;padding-left:8px;flex:none;font-style:normal;font-size:11.5px;color:var(--dd-t3);font-variant-numeric:tabular-nums}
3642
3706
  .ddp .dd-xch{gap:6px;margin:0 0 16px}
3643
3707
  .ddp .dd-xch .dd-chip{height:28px;padding:0 11px;border-radius:9px;font-size:12.5px;transition:background-color .16s var(--dd-out),box-shadow .16s var(--dd-out),color .16s}
3644
3708
  .ddp .ddp-xo .dd-col>.dd-seg{margin-bottom:16px}
@@ -4184,6 +4248,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
4184
4248
  .ddp .dd-cks>.dd-ckwait{grid-column:1/-1;display:flex;align-items:center;justify-content:center;gap:8px;padding:22px 12px;color:var(--dd-t3);font-size:12px}
4185
4249
  .ddp .dd-cks>.dd-ckerr{grid-column:1/-1;display:flex;align-items:flex-start;gap:8px;padding:9px 12px;color:var(--dd-t2);font-size:12px;line-height:17px}
4186
4250
  .ddp .dd-cks>.dd-ckerr svg{width:14px;height:14px;flex:none;margin-top:1px;color:var(--dd-warn)}
4251
+ /* 部件不一致(#30):问题下面单独一组,灰圆点「≠」,不算进问题数 */
4252
+ .ddp .dd-cks>.dd-ckgrp{grid-column:1/-1;margin:10px 2px 2px;padding:10px 10px 2px;border-top:1px solid var(--dd-line);font-size:11.5px;line-height:16px;color:var(--dd-t3)}
4253
+ .ddp .dd-cks>.dd-ckgrp:first-child{margin-top:0;padding-top:2px;border-top:0}
4254
+ .ddp .dd-cks>.dd-ckgrp.more{margin:0 2px;padding:4px 12px;border-top:0}
4255
+ .ddp .dd-cks>.ok+.dd-ckgrp{margin-top:2px}
4256
+ .ddp .dd-ck .no.df{background:var(--dd-f2);color:var(--dd-t2);font-weight:600}
4257
+ .ddp .dd-ck.df .nm code{font:500 12px/18px ui-monospace,SFMono-Regular,Menlo,monospace}
4187
4258
  .ddp .dd-spin{width:14px;height:14px;flex:none;border-radius:50%;corner-shape:round;border:2px solid var(--dd-f3);border-top-color:var(--dd-c2);animation:dd-spin .9s linear infinite}
4188
4259
  @keyframes dd-ckin{from{opacity:0;transform:translateY(5px)}}
4189
4260
  /* 1.0 版本面板:一排卡片(缩略图 · 第几版 · 什么时候 · 谁改的和改了什么),左边是现在 */
@@ -4499,6 +4570,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
4499
4570
  canvas: () => svg([h('rect', { key: 1, x: 3.5, y: 3.5, width: 7, height: 7, rx: 1.6 }), h('rect', { key: 2, x: 13.5, y: 3.5, width: 7, height: 7, rx: 1.6 }),
4500
4571
  h('rect', { key: 3, x: 3.5, y: 13.5, width: 7, height: 7, rx: 1.6 }), h('rect', { key: 4, x: 13.5, y: 13.5, width: 7, height: 7, rx: 1.6 })]),
4501
4572
  single: () => svg([h('rect', { key: 1, x: 5, y: 3.5, width: 14, height: 17, rx: 2.2 })]),
4573
+ // 一页多状态:一张卡片后面还叠着一张
4574
+ states: () => svg([h('path', { key: 1, d: 'M12 3.5 3.5 8 12 12.5 20.5 8z' }), h('path', { key: 2, d: 'M3.5 12 12 16.5 20.5 12' }), h('path', { key: 3, d: 'M3.5 16 12 20.5 20.5 16' })]),
4502
4575
  globe: () => svg([h('circle', { key: 1, cx: 12, cy: 12, r: 8.5 }), h('path', { key: 2, d: 'M3.5 12h17M12 3.5c2.4 2.3 3.6 5.1 3.6 8.5s-1.2 6.2-3.6 8.5c-2.4-2.3-3.6-5.1-3.6-8.5s1.2-6.2 3.6-8.5z' })]),
4503
4576
  link: () => svg([h('path', { key: 1, d: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1.2 1.2' }), h('path', { key: 2, d: 'M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1.2-1.2' })]),
4504
4577
  web: () => svg([h('rect', { key: 1, x: 3, y: 4.5, width: 18, height: 15, rx: 2.2 }), h('path', { key: 2, d: 'M3 9h18' }), h('path', { key: 3, d: 'M6 6.8h.01M8.5 6.8h.01' })]),
@@ -6437,6 +6510,47 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
6437
6510
  return out
6438
6511
  }
6439
6512
 
6513
+ // ── 一页多状态(#30):<meta name="dsh-states" content="default:有数据, empty:空列表, paid:已付款">,<html data-state>,地址 ?state=paid ──
6514
+ const STATE_RE = /^[A-Za-z0-9_-]{1,32}$/ // 和 picker.js、serve.js 设状态那段一样
6515
+ const MAX_STATES = 8
6516
+ /** meta 内容 → [{ name, label }](第一个是默认状态;名字只认英文、数字、- _,后面可以跟「:中文名」);不到两个当没写 */
6517
+ function parseStates(raw) {
6518
+ const out = []
6519
+ for (const part of String(raw || '').split(/[,,;;\n]+/)) {
6520
+ const m = /^\s*([A-Za-z0-9_-]{1,32})\s*(?:[::=]\s*(.*?))?\s*$/.exec(part)
6521
+ if (!m || out.some((x) => x.name === m[1])) continue
6522
+ out.push({ name: m[1], label: String(m[2] || '').trim().slice(0, 24) || m[1] })
6523
+ if (out.length >= MAX_STATES) break
6524
+ }
6525
+ return out.length >= 2 ? out : []
6526
+ }
6527
+ /**
6528
+ * 单看时页面里点了换状态的链接(#30):顶栏记着的就是要的这个(在页面里去了别的页、又点链接回来,页面显示的不是顶栏那个状态),
6529
+ * 顶栏、地址都不会变 → 'reload' 重新载一遍这屏(不然点了没反应);不然 'pick' 交给顶栏换。def:要的是默认状态
6530
+ */
6531
+ function stateGoPlan(src, d) {
6532
+ let had = ''
6533
+ try { had = new URL(src).searchParams.get('state') || '' } catch { /* 地址不认识:当默认 */ }
6534
+ return (had ? had === d.state : d.def === true) ? 'reload' : 'pick'
6535
+ }
6536
+ /** 换状态的链接带的锚点:接着载的那一帧带上(3 秒内有效,只用一次) */
6537
+ function withHashNext(url, hn, now) {
6538
+ return hn && typeof hn.hash === 'string' && now - hn.at < 3000 ? String(url).replace(/#.*$/, '') + hn.hash : url
6539
+ }
6540
+ /** 地址的路径(解码过;认不出给 '') */
6541
+ function pathOfUrl(url) {
6542
+ try { const p = new URL(url).pathname; try { return decodeURIComponent(p) } catch { return p } } catch { return '' }
6543
+ }
6544
+ /** 屏的地址换成某个状态(默认状态 / 空 = 去掉 ?state=) */
6545
+ function withState(url, state) {
6546
+ try {
6547
+ const u = new URL(url)
6548
+ if (state && STATE_RE.test(state)) u.searchParams.set('state', state)
6549
+ else u.searchParams.delete('state')
6550
+ return u.href
6551
+ } catch { return url }
6552
+ }
6553
+
6440
6554
  /** 'WxH'(没有就按类型默认)→ [w, h] */
6441
6555
  function sizeOf(size, kind) {
6442
6556
  const m = /^(\d{2,5})x(\d{2,5})$/.exec(String(size || ''))
@@ -6481,6 +6595,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
6481
6595
  const LAB = 34 // 每屏上面标题占的高度(屏幕像素,不跟着缩放)
6482
6596
  const GAP = 18 // 两屏之间最少隔开的屏幕像素
6483
6597
  const clampZ = (z) => Math.max(ZMIN, Math.min(ZMAX, z))
6598
+ const MAX_DOC_PAGES = 1000 // PDF / PPT 最多几页(和服务端 MAX_PAGES 一样)
6484
6599
  const LIVE_MAX = 24 // 同时跑几个 iframe。超过这么多屏,画布只挂镜头附近的(选中的那屏总在),导出时分批挂
6485
6600
  /** 该挂着的几屏:离镜头中心最近的 max 屏,选中的那屏排最前。cx、cy 是镜头中心在画布上的坐标 */
6486
6601
  function nearestLive(ids, pos, dw, dh, cx, cy, selId, max, prev) {
@@ -7185,7 +7300,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7185
7300
  /** 这一屏(预览服务器上的地址)打包后的取法。fresh:要求服务端别复用缓存、重新打包 */
7186
7301
  function bundleOf(href, sid, fresh) {
7187
7302
  let p
7188
- try { p = new URL(href).pathname } catch { return '' }
7303
+ let state = ''
7304
+ try { const u = new URL(href); p = u.pathname; state = u.searchParams.get('state') || '' } catch { return '' }
7189
7305
  try { p = decodeURIComponent(p) } catch { /* 原样 */ }
7190
7306
  p = p.replace(/^\/+/, '')
7191
7307
  let v = ''
@@ -7193,6 +7309,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7193
7309
  if (m) { v = m[1]; p = m[2] }
7194
7310
  if (!p || p.endsWith('/')) p += 'index.html'
7195
7311
  const q = { session: sid, key: p, v, parent: location.origin }
7312
+ if (state && STATE_RE.test(state)) q.state = state // 一页多状态(#30):打包时就把 <html data-state> 设好
7196
7313
  if (fresh) q.fresh = '1'
7197
7314
  return `${API}bundle?${new URLSearchParams(q)}`
7198
7315
  }
@@ -7442,6 +7559,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7442
7559
  }
7443
7560
  let url = P.current.src
7444
7561
  try { if (seed && seed.href && new URL(seed.href).origin === origin) url = seed.href } catch { /* 用原地址 */ }
7562
+ // 换状态的链接带了锚点(见 stateGo):这一帧带上,页面载好自己滚过去
7563
+ if (!seed) url = withHashNext(url, L.hashNext, Date.now())
7564
+ L.hashNext = null
7445
7565
  setFrames((fs) => [...fs, { id, src: url, dir: L.dir }])
7446
7566
  }
7447
7567
 
@@ -7511,6 +7631,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7511
7631
  L.tops.clear()
7512
7632
  L.gen++
7513
7633
  L.at = ''
7634
+ L.trail = []
7514
7635
  L.deps = null
7515
7636
  L.fails = 0
7516
7637
  L.floor = L.next
@@ -7589,11 +7710,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7589
7710
  L.seeds.delete(id)
7590
7711
  L.seedOf.delete(id)
7591
7712
  // 改动通知由右侧栏转告(见下面「本机预览」),页面别自己开 SSE;做出来的页面(ownEvents)不在设计目录里,让它自己听
7592
- postTo(id, { type: 'init', seed, relay: !P.current.ownEvents })
7713
+ // stateNav:这一帧本该显示哪一页(路径);页面里点了同一页换状态的链接才交给右侧栏(#30)
7714
+ postTo(id, { type: 'init', seed, relay: !P.current.ownEvents, stateNav: P.current.onStateGo ? pathOfUrl(P.current.src) : '' })
7593
7715
  break
7594
7716
  }
7595
7717
  case 'ready': {
7596
7718
  L.readied.add(id)
7719
+ // 这一帧写了哪几个状态(#30,远程看同一页换状态时认)
7720
+ if (!L.stBy) L.stBy = new Map()
7721
+ L.stBy.set(id, typeof d.states === 'string' ? parseStates(d.states.slice(0, 400)).map((x) => x.name) : [])
7722
+ if (L.stBy.size > 20) L.stBy.delete(L.stBy.keys().next().value)
7597
7723
  L.title = d.title || ''
7598
7724
  let fail = null
7599
7725
  if (d.err) {
@@ -7613,8 +7739,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7613
7739
  if (p.annotGo && list.some((x) => x.id === p.annotGo.current)) { postTo(id, { type: 'annotFocus', id: p.annotGo.current }); p.annotGo.current = '' }
7614
7740
  }
7615
7741
  }
7616
- if (p.onMeta) p.onMeta(d.meta || '', fail ? '' : d.title || '', Array.isArray(d.tokens) ? d.tokens : [], !!d.dark, Array.isArray(d.links) ? d.links : [], d.natural, fail ? fail.err : '')
7617
- if (p.onHref && d.href) p.onHref(d.href)
7742
+ // 写了哪几个状态(#30):在这一帧里点链接去了别的页(单看时可以)就不记——不然顶栏的状态菜单拿着别的页的状态,切了载的却是这屏
7743
+ const away = !!d.href && !!p.src && pathOfUrl(d.href) !== pathOfUrl(p.src)
7744
+ if (p.onMeta) p.onMeta(d.meta || '', fail ? '' : d.title || '', Array.isArray(d.tokens) ? d.tokens : [], !!d.dark, Array.isArray(d.links) ? d.links : [], d.natural, fail ? fail.err : '', away ? undefined : { states: fail || typeof d.states !== 'string' ? '' : d.states.slice(0, 400) })
7745
+ if (p.onHref && d.href) p.onHref(d.href, typeof d.states === 'string' ? d.states.slice(0, 400) : '')
7618
7746
  if (isCur) {
7619
7747
  postTo(id, { type: 'reveal' })
7620
7748
  postTo(id, { type: 'zoom', z: p.zoom || 1 })
@@ -7686,10 +7814,33 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7686
7814
  case 'picked':
7687
7815
  if (isCur && p.picking && p.onPicked) p.onPicked(d.payload)
7688
7816
  break
7817
+ case 'stateGo': { // 单看时点了同一页换状态的链接(#30)
7818
+ if (!isCur || !p.onStateGo || typeof d.state !== 'string' || !STATE_RE.test(d.state)) break
7819
+ // 链接带的锚点(?state=paid#receipt):换好状态的那一帧载的时候带上(只认这一下,过会儿就不算了)
7820
+ L.hashNext = typeof d.hash === 'string' && /^#[^\s#]{1,200}$/.test(d.hash) ? { hash: d.hash, at: Date.now() } : null
7821
+ if (stateGoPlan(p.src, d) === 'reload') { L.at = ''; load(null, true) } else p.onStateGo(d.state)
7822
+ break
7823
+ }
7689
7824
  case 'nav':
7690
7825
  if (!isCur || typeof d.path !== 'string') break
7691
- if (p.onNav) p.onNav(d.path)
7692
- else if (remOf(p)) { L.at = origin + d.path; load(null) } // 远程看:页面里点了跳页,这一框换成那一页(和本机预览时 iframe 自己跳过去一样)
7826
+ if (p.onNav) p.onNav(d.path, typeof d.state === 'string' && STATE_RE.test(d.state) ? d.state : '', d.back === true, typeof d.hash === 'string' && /^#[^\s#]{1,200}$/.test(d.hash) ? d.hash : '')
7827
+ else if (remOf(p)) {
7828
+ // 远程看:页面里点了跳页,这一框换成那一页(和本机预览时 iframe 自己跳过去一样)。
7829
+ // 带状态(#30)的连状态一起;data-back 按这一框走过的路退一步,没得退才去它写的地方
7830
+ // data-back 和本机预览一样去它写的地方(按走过的路退只在试用里有)
7831
+ if (!d.path) break
7832
+ const s = typeof d.state === 'string' && STATE_RE.test(d.state) ? d.state : ''
7833
+ // 单看时还在原来那页里、换这页写了的状态(#30):和本机预览一样交给顶栏换(状态标签跟着变);不带状态 = 回默认。
7834
+ // 去了别的页、老页面(没写状态)的链接照常换页
7835
+ const dec = (L.stBy && L.stBy.get(id)) || []
7836
+ if (p.onStateGo && d.back !== true && !L.at && d.path === pathOfUrl(p.src) && dec.length && (!s || dec.includes(s))) {
7837
+ if (stateGoPlan(p.src, { state: s, def: !s }) === 'reload') load(null, true)
7838
+ else p.onStateGo(s)
7839
+ break
7840
+ }
7841
+ L.at = origin + d.path + (s ? '?state=' + s : '')
7842
+ load(null)
7843
+ }
7693
7844
  break
7694
7845
  case 'edited':
7695
7846
  if (isCur && (p.textEdit || Date.now() - editOffAt.current < EDIT_GRACE_MS) && p.onEdited && typeof d.before === 'string' && typeof d.after === 'string') p.onEdited(d)
@@ -8786,7 +8937,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
8786
8937
  * 体检面板(1.0):头上「5 屏 · 4 个问题」,问题排成卡片(宽了两列):圆点序号(红 = 严重、黄 = 一般,和页面上的记号一一对上,按屏各自编号),
8787
8938
  * 第一行 什么问题 · 哪段字,第二行 哪一屏 · 量出来多少;底栏 一句说明 | 再查一次 · 让模型改
8788
8939
  */
8789
- function CheckPanel({ t, head, ck, nameOf = (x) => x, onFocus, onFix, onAgain, onClose }) {
8940
+ /** 部件不一致的一条差在哪:padding 16px / 14px · border-radius 12px / 10px(who:每种写法后面带上哪几屏) */
8941
+ function driftDiff(t, it, who) {
8942
+ const scr = (keys) => keys.slice(0, 3).map((k) => String(k).replace(/\.html?$/i, '')).join(who === true ? '、' : ', ') + (keys.length > 3 ? ` +${keys.length - 3}` : '')
8943
+ return (it.props || []).map((p) => `${p.prop} ${(p.values || []).map((x) => (x.v || t('dfNone')) + (who ? `(${scr(x.keys || [])})` : '')).join(' / ')}`).join(who ? ';' : ' · ')
8944
+ }
8945
+
8946
+ function CheckPanel({ t, head, ck, nameOf = (x) => x, onFocus, onFix, onAgain, onDrift, onClose }) {
8790
8947
  const list = ck.list || []
8791
8948
  const n = list.reduce((m, x) => m + x.issues.length, 0)
8792
8949
  const multi = list.length > 1
@@ -8804,12 +8961,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
8804
8961
  })
8805
8962
  }
8806
8963
  const clean = !ck.running && !n && !list.some((sc) => sc.error)
8964
+ // 部件各屏写得不一样(#30):单独一组,不算进问题数;点一条把「统一它」放进输入框
8965
+ const df = !ck.running && ck.drift && ck.drift.items.length ? ck.drift : null
8966
+ const dfRows = df ? [
8967
+ h('div', { key: 'df:h', className: 'dd-ckgrp' }, t('dfHead')),
8968
+ ...df.items.map((it, i) => h('button', { key: 'df:' + it.sel, className: 'ddp-ck dd-ck df', style: { '--i': Math.min(rows.length + i + 1, 12) }, ...tipA(it.sel, t('dfTip')), onClick: () => onDrift && onDrift(it) },
8969
+ h('i', { className: 'no df' }, '≠'),
8970
+ h('span', { className: 'tx' },
8971
+ h('span', { className: 'nm' }, h('code', null, it.sel), ' · ' + t('dfItem', { n: it.screens, v: it.variants })),
8972
+ h('span', { className: 'vl' }, driftDiff(t, it, false))))),
8973
+ df.more ? h('div', { key: 'df:m', className: 'dd-ckgrp more' }, t('dfMore', { n: df.more })) : null,
8974
+ ] : []
8807
8975
  return h('div', { className: 'ddp-tokens ddp-check', onPointerDown: (e) => e.stopPropagation() },
8808
8976
  head,
8809
8977
  h('div', { className: 'bd dd-cks' + (clean ? ' clean' : '') },
8810
8978
  ...rows,
8811
8979
  ck.running && !rows.length ? h('div', { className: 'dd-ckwait' }, h('i', { className: 'dd-spin' }), h('span', null, t('checking'))) : null,
8812
- clean ? h('div', { className: 'ok' }, h('i', { className: 'ring' }, h(I.shield)), h('b', null, t('checkNone')), h('span', null, t('checkNoneTip', { s: list.length }))) : null),
8980
+ clean ? h('div', { className: 'ok' }, h('i', { className: 'ring' }, h(I.shield)), h('b', null, t('checkNone')), h('span', null, t('checkNoneTip', { s: list.length }))) : null,
8981
+ ...dfRows),
8813
8982
  h('footer', { className: 'dd-sf' },
8814
8983
  h('span', { className: 'note' }),
8815
8984
  h('button', { className: 'dd-bt ghost', onClick: onAgain, disabled: ck.running }, h(I.refresh), t('checkAgain')),
@@ -10031,6 +10200,44 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
10031
10200
  h('div', { className: 'dd-smf', 'aria-hidden': true }, h('kbd', null, '↑↓'), h('span', null, t('scrKeyPick')), h('kbd', null, '↵'), h('span', null, t('scrKeyOpen')))) : null))
10032
10201
  }
10033
10202
 
10203
+ /**
10204
+ * 一页多状态(#30)的状态菜单:画布上屏名旁、单看时顶栏的「状态 ▾」点出来。浮在台面上(屏名那一行会裁掉超出的部分),
10205
+ * 位置 at 是相对台面的。点外面、按 Esc 收起;↑↓ 回车也能选
10206
+ */
10207
+ function StateMenu({ t, at, name, list, cur, onPick, onAll, allOn, onClose }) {
10208
+ const ref = useRef(null)
10209
+ const [hi, setHi] = useState(() => Math.max(0, list.findIndex((x) => x.name === cur)))
10210
+ const closeR = useRef(onClose)
10211
+ closeR.current = onClose
10212
+ useEffect(() => {
10213
+ const off = (e) => { if (ref.current && !ref.current.contains(e.target) && !(e.target.closest && e.target.closest('.ddp-stt'))) closeR.current() }
10214
+ // 捕获阶段先收:别让同一下 Esc 再把单看退回画布、退出试用
10215
+ const esc = (e) => { if (isEsc(e)) { e.preventDefault(); e.stopPropagation(); closeR.current(true) } }
10216
+ document.addEventListener('pointerdown', off, true)
10217
+ window.addEventListener('keydown', esc, true)
10218
+ try { if (ref.current) ref.current.focus({ preventScroll: true }) } catch { /* 拿不到焦点也能点 */ }
10219
+ return () => {
10220
+ document.removeEventListener('pointerdown', off, true)
10221
+ window.removeEventListener('keydown', esc, true)
10222
+ }
10223
+ }, [])
10224
+ const pick = (x) => { onPick(x.name); onClose(true) }
10225
+ const key = (e) => {
10226
+ if (e.key === 'ArrowDown') { e.preventDefault(); setHi((i) => Math.min(list.length - (onAll ? 0 : 1), i + 1)) }
10227
+ else if (e.key === 'ArrowUp') { e.preventDefault(); setHi((i) => Math.max(0, i - 1)) }
10228
+ else if (e.key === 'Enter') { e.preventDefault(); if (hi < list.length) pick(list[hi]); else if (onAll) { onAll(); onClose(true) } }
10229
+ }
10230
+ return h('div', { ref, className: 'ddp-menu dd-sm ddp-stmenu', role: 'menu', 'aria-label': t('stMenuT', { name }), tabIndex: -1, style: { left: at.x, top: at.y }, onKeyDown: key },
10231
+ h('div', { className: 'hd' }, t('stMenuT', { name })),
10232
+ h('div', { className: 'ls' },
10233
+ ...list.map((x, i) => h('button', { key: x.name, tabIndex: -1, role: 'menuitemradio', 'aria-checked': x.name === cur, className: (x.name === cur ? 'sel' : '') + (i === hi ? ' hi' : ''), onMouseEnter: () => setHi(i), onClick: () => pick(x) },
10234
+ h('span', null, x.label),
10235
+ h('em', null, i === 0 ? (x.label === x.name ? t('stDefault') : x.name + ' · ' + t('stDefault')) : x.label === x.name ? '' : x.name),
10236
+ x.name === cur ? h(I.check) : h('i', { className: 'ck', 'aria-hidden': true })))),
10237
+ onAll ? h('div', { className: 'sp' }) : null,
10238
+ onAll ? h('button', { className: (allOn ? 'sel' : '') + (list.length === hi ? ' hi' : ''), role: 'menuitemcheckbox', 'aria-checked': !!allOn, title: t('dStAll'), onMouseEnter: () => setHi(list.length), onClick: () => { onAll(); onClose(true) } }, h(I.sideBy), h('span', null, t('stSide')), allOn ? h(I.check) : null) : null)
10239
+ }
10240
+
10034
10241
  // 左上屏名 ▾:换屏(画布 / 某一屏)、多尺寸、类型、打开别的页面——「在看什么、怎么看」都在这一个菜单里
10035
10242
  /** 屏名菜单里的「画幅」一行(#23):显示现在多大,点「自定义…」填宽×高,改过的能恢复默认 */
10036
10243
  function SizeRow({ t, size, custom, onSize, done }) {
@@ -11013,7 +11220,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11013
11220
  return c
11014
11221
  }
11015
11222
 
11016
- function ExportPanel({ t, head, fmt = 'pdf', imgModes = [], onImg, kind, size, opts, setOpts, screens, items = [], curKey = '', canvas, rev, measure, onResize, onExport, onClose }) {
11223
+ function ExportPanel({ t, head, fmt = 'pdf', imgModes = [], onImg, kind, size, opts, setOpts, screens, items = [], stCount = null, curKey = '', canvas, rev, measure, onResize, onExport, onClose }) {
11017
11224
  const [im, setIm] = useState('')
11018
11225
  const imCur = imgModes.some((x) => x[0] === im) ? im : (imgModes[0] || [''])[0]
11019
11226
  const [list, setList] = useState(null)
@@ -11032,7 +11239,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11032
11239
  measure(tok).then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
11033
11240
  }, first ? 0 : 900)
11034
11241
  return () => { off = true; tok.off = true; clearTimeout(timer) }
11035
- }, [size.join('x'), screens, rev, again])
11242
+ }, [size.join('x'), screens, rev, again, opts.states ? 1 : 0])
11036
11243
  // 导出哪些:全部 / 只导当前这屏 / 挑几屏(挑的屏改名、删了就不算)
11037
11244
  const cur = items.find((x) => x.key === curKey) || items[0]
11038
11245
  const has = new Set(items.map((x) => x.key))
@@ -11040,7 +11247,11 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11040
11247
  const scope = opts.scope === 'cur' && cur ? 'cur' : opts.scope === 'pick' ? 'pick' : 'all'
11041
11248
  const keys = scope === 'cur' ? [cur.key] : scope === 'pick' ? items.map((x) => x.key).filter((k) => picked.includes(k)) : null
11042
11249
  const want = keys ? new Set(keys) : null
11043
- const count = keys ? keys.length : items.length
11250
+ // 每个状态各出一张(#30):写了状态的屏一个状态一页
11251
+ const stOf = (k) => (stCount && stCount[k] > 1 ? stCount[k] : 1)
11252
+ const anyStates = items.some((x) => stOf(x.key) > 1)
11253
+ const extra = anyStates ? (keys || items.map((x) => x.key)).reduce((m, k) => m + stOf(k) - 1, 0) : 0
11254
+ const count = (keys ? keys.length : items.length) + (opts.states ? extra : 0)
11044
11255
  // 量到的结果和 items 一一对应:只看这次要导的那些
11045
11256
  const mine = list ? list.map((m, i) => [m, items[i]]).filter(([, x]) => !want || (x && want.has(x.key))) : null
11046
11257
  // 和真导出同一套取景:PDF 页签里网页、邮件没选怎么截时放整页长图(不会裁),只有 PPT 截首屏
@@ -11075,7 +11286,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11075
11286
  }
11076
11287
  const ppt = fmt === 'pptx'
11077
11288
  const cols = opts.cols === 2 ? 2 : 1
11078
- const pages = Math.ceil(count / cols)
11289
+ const pages = Math.ceil(Math.min(count, MAX_DOC_PAGES) / cols)
11079
11290
  const long = opts.fit === 'page' || (!opts.fit && !ppt && (kind === 'web' || kind === 'email'))
11080
11291
  // 底栏一句话:格式 · 几页 · 多大 · 每页是图片
11081
11292
  const sz = opts.layout === 'custom' ? (layoutOk(opts.custom) ? opts.custom.trim().replace(/\s*[x×*]\s*/, ' × ') : '') : opts.layout === 'a3' ? t('xoA3') : opts.layout !== 'auto' ? opts.layout
@@ -11093,10 +11304,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11093
11304
  h('div', { className: 'dd-col' },
11094
11305
  h('h6', null, t('xoWhich')),
11095
11306
  h('div', { className: 'dd-rcs', role: 'radiogroup', 'aria-label': t('xoWhich') },
11096
- radio('all', t('xoAll', { n: items.length }), scope === 'all' ? t(canvas ? 'xoAllSub' : 'xoAllSub1', { n: items.length, m: Math.ceil(items.length / cols) }) : ''),
11307
+ radio('all', t('xoAll', { n: items.length }), scope === 'all' ? t(canvas ? 'xoAllSub' : 'xoAllSub1', { n: items.length, m: pages }) : ''),
11097
11308
  items.length > 1 && cur ? radio('cur', t('xoCur', { name: cur.label })) : null,
11098
11309
  items.length > 1 ? radio('pick', scope === 'pick' ? t('xoPickN', { n: picked.length }) : t('xoPick'), scope === 'pick' && !picked.length ? t('xoPickNone') : '',
11099
- scope === 'pick' ? h('div', { className: 'dd-pk' }, ...items.map((x) => h('button', { key: x.key, type: 'button', role: 'checkbox', 'aria-checked': picked.includes(x.key), className: picked.includes(x.key) ? 'on' : '', title: x.label, onClick: () => toggle(x.key) }, h('i', null, picked.includes(x.key) ? h(I.check) : null), h('span', null, x.label)))) : null) : null)),
11310
+ scope === 'pick' ? h('div', { className: 'dd-pk' }, ...items.map((x) => h('button', { key: x.key, type: 'button', role: 'checkbox', 'aria-checked': picked.includes(x.key), className: picked.includes(x.key) ? 'on' : '', title: x.label, onClick: () => toggle(x.key) }, h('i', null, picked.includes(x.key) ? h(I.check) : null), h('span', null, x.label)))) : null) : null),
11311
+ anyStates ? h('div', { className: 'dd-pk dd-xst' }, h('button', { type: 'button', role: 'checkbox', 'aria-checked': !!opts.states, className: opts.states ? 'on' : '', onClick: () => setOpts({ ...opts, states: !opts.states }) },
11312
+ h('i', null, opts.states ? h(I.check) : null), h('span', null, t('xoStates')), extra ? h('em', null, t('xoStatesN', { n: extra })) : null)) : null),
11100
11313
  h('div', { className: 'dd-col' },
11101
11314
  h('h6', null, t('xoLayout')),
11102
11315
  chips('layout', t('xoLayout'), [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
@@ -11117,6 +11330,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11117
11330
  rep && rep.ai ? h('p', { className: 'sm' }, t('xoAi', { n: rep.ai })) : null,
11118
11331
  rep && rep.fail ? h('p', { className: 'sm' }, t('xoFail', { n: rep.fail })) : null,
11119
11332
  rep && !cut && !rep.dead && !rep.fail ? h('p', null, h(I.check), t('xoClean')) : null,
11333
+ rep && opts.states && extra ? h('p', { className: 'sm' }, t('xoStNoCheck', { n: extra })) : null,
11120
11334
  rep ? h('div', { className: 'act' },
11121
11335
  rep.over && canFit ? h('button', { type: 'button', className: 'dd-xbt', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', ' × ') })) : null,
11122
11336
  (rep.long || rep.moved) && opts.fit !== 'page' ? h('button', { type: 'button', className: 'dd-xbt', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
@@ -11784,7 +11998,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11784
11998
  // 拖背景 / 挡板 = 平移;没拖动就算点了一下
11785
11999
  const onPointerDown = (e) => {
11786
12000
  if (e.button !== 0 || !camRef.current) return
11787
- if (e.target.closest && e.target.closest('.ddp-zoom, .ddp-act, .ddp-take, .ddp-fail button')) return
12001
+ if (e.target.closest && e.target.closest('.ddp-zoom, .ddp-act, .ddp-take, .ddp-stt, .ddp-fail button')) return
11788
12002
  const keyEl = e.target.closest ? e.target.closest('[data-key]') : null
11789
12003
  const d = { x: e.clientX, y: e.clientY, cam: camRef.current, moved: false, key: keyEl ? keyEl.getAttribute('data-key') : '' }
11790
12004
  const move = (ev) => {
@@ -11859,7 +12073,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11859
12073
  },
11860
12074
  done ? h('i', { key: 'au', className: 'dd-au out', 'aria-hidden': true }, h('b')) : null,
11861
12075
  done ? h('i', { key: 'gl', className: 'dd-glow out', 'aria-hidden': true }, h('b')) : null,
11862
- lab(sc.key, [props.tag ? props.tag(sc) : null, h('span', { key: 's' }, labelOf(sc)), !picking && props.badge ? props.badge(sc) : null, !picking && props.actions ? h('span', { key: 'a', className: 'ddp-act' }, ...props.actions(sc)) : null], cw),
12076
+ lab(sc.key, [props.tag ? props.tag(sc) : null, h('span', { key: 's' }, labelOf(sc)), !picking && props.stateChip ? props.stateChip(sc) : null, !picking && props.badge ? props.badge(sc) : null, !picking && props.actions ? h('span', { key: 'a', className: 'ddp-act' }, ...props.actions(sc)) : null], cw),
11863
12077
  cull && !(live && live.has(sc.id || sc.key)) ? props.sleep(sc, z) : props.render(sc, z, i),
11864
12078
  picking ? null : h('div', { className: 'ddp-shield', 'data-key': sc.key, title: items ? '' : t('openScreen'), style: { borderRadius: fr.r } })))
11865
12079
  })
@@ -11922,8 +12136,28 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11922
12136
  return list.map((x) => by.get(x.key) || x)
11923
12137
  }
11924
12138
 
12139
+ /**
12140
+ * 导出「每个状态各出一张」(#30):写了状态的屏按状态展开成几页(xs = 状态名)。默认状态那页 key 不变(别的屏跳过来落在它上面),
12141
+ * 其余几页 key 带 ?state=(原型里跳到某个状态的链接落在那页,见 doc 路由)
12142
+ */
12143
+ function byStates(list, statesFor) {
12144
+ const out = []
12145
+ for (const sc of list) {
12146
+ const ss = sc.v ? [] : statesFor(sc.key) || []
12147
+ if (ss.length < 2) { out.push(sc); continue }
12148
+ ss.forEach((s, i) => out.push({ ...sc, url: withState(sc.url, i ? s.name : ''), xs: s.name, xsLabel: s.label, xsFirst: i === 0 }))
12149
+ }
12150
+ return out
12151
+ }
12152
+ /** 某个状态那页的标题:「订单 · 梅林练」→「订单(已付款) · 梅林练」(屏名后面带上状态,产品名还在原处,拼大标题照样认得出) */
12153
+ function stateTitle(title, label) {
12154
+ const tag = /^[\x20-\x7e]*$/.test(label) ? ` (${label})` : `(${label})`
12155
+ const m = /\s*[·||—]\s*|\s+[-–]\s+/.exec(title)
12156
+ return m ? title.slice(0, m.index) + tag + title.slice(m.index) : title + tag
12157
+ }
12158
+
11925
12159
  function makeExporter(x) {
11926
- const { sid, st, kind, size, dark, meta, tokens, t, say, canvas, focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, onWarn, apiOf, targetKey, tops, tweak, webFit } = x
12160
+ const { sid, st, kind, size, dark, meta, tokens, t, say, canvas, focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, onWarn, apiOf, targetKey, tops, tweak, webFit, statesFor } = x
11927
12161
  const sayErr = (m, a) => say(m, a, true) // 没成的事:红色消息条,不自己走
11928
12162
  // 导出用的全部屏(#29):屏多过上限时右侧栏只显示最新的 60 屏,收起来的那些接在前面;没收起来就是显示的这些
11929
12163
  let every = x.every || shown
@@ -11986,16 +12220,27 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11986
12220
  ghostQueue.current = job.catch(() => {})
11987
12221
  return job
11988
12222
  }
11989
- const measureAll = async (map, tok) => {
12223
+ const measureAll = async (map, tok, pool = every) => {
11990
12224
  const stamp = designSeq.current
11991
12225
  const list = []
11992
- for (const [i, sc] of every.entries()) {
12226
+ for (const [i, sc] of pool.entries()) {
11993
12227
  if (designSeq.current !== stamp || (tok && tok.off)) break // 设计换了 / 选项面板这一遍作废:别再等旧的屏
11994
- if (every.length > LIVE_MAX) say(t('xoCheckingN', { i: i + 1, n: every.length }))
12228
+ if (pool.length > LIVE_MAX) say(t('xoCheckingN', { i: i + 1, n: pool.length }))
11995
12229
  try { const api = await apiOf(sc, map); list.push(await api.measure()) } catch (e) { console.warn('[dsh-design-studio] 量页面失败', sc.key, e); list.push({ failed: true }) }
11996
12230
  }
11997
12231
  return list
11998
12232
  }
12233
+ // 「每个状态各出一张」(#30):默认那页按默认状态截(画布上这屏选着别的状态也一样,见 byStates)。
12234
+ // 选项面板的预检也量默认状态,和导出对得上(xs 让它在背后另挂一个,不拿画布上正显示别的状态的那个)
12235
+ const toDefault = (sc) => {
12236
+ if (!sc.state || sc.v || !statesFor) return sc
12237
+ const ss = statesFor(sc.key) || []
12238
+ return ss.length >= 2 ? { ...sc, url: withState(sc.url, ''), state: '', xs: ss[0].name, xsLabel: ss[0].label, xsFirst: true } : sc
12239
+ }
12240
+ const precheck = (tok, def) => {
12241
+ const pool = def ? every.map(toDefault) : every
12242
+ return withFrames((map) => (tok && tok.off ? [] : measureAll(map, tok, pool)), undefined, pool)
12243
+ }
11999
12244
 
12000
12245
  // 图片 / 整套展示图 / PDF / PPT(菜单里的「选项」「打包」「分享」在面板里分流,见 doExport)
12001
12246
  const exportShots = async (mode, key, opts) => {
@@ -12017,7 +12262,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12017
12262
  if (gone()) { sayErr(t('xoGone')); return }
12018
12263
  // 面板里挑了「只导这屏 / 挑几屏」:只截这些(顺序照右侧栏)
12019
12264
  const want = opts && Array.isArray(opts.keys) ? new Set(opts.keys) : null
12020
- const list = want ? every.filter((sc) => want.has(ik(sc))) : every
12265
+ const base = want ? every.filter((sc) => want.has(ik(sc))) : every
12266
+ // 「每个状态各出一张」:写了状态的屏按状态展开(超过页数上限的不导,提示里说)。
12267
+ // 本地文件的设计这时再问一次服务端各屏写了哪几个状态(面板刚打开、刚换了设计时手上的可能还没回来,别按「没写」少导几页);问不到就不导
12268
+ let stFor = statesFor
12269
+ if (opts && opts.states && !ver && x.loadStates) {
12270
+ try { const map = await x.loadStates(); stFor = (key) => map[key] || [] } catch (e) { console.warn('[dsh-design-studio] 取状态失败', e); sayErr(t('xoStFail')); return }
12271
+ if (gone()) { sayErr(t('xoGone')); return }
12272
+ }
12273
+ let list = opts && opts.states && !ver && stFor ? byStates(base, stFor) : base
12274
+ if (list.length > base.length && list.length > MAX_DOC_PAGES) { cutN += list.length - MAX_DOC_PAGES; list = list.slice(0, MAX_DOC_PAGES) }
12021
12275
  if (!list.length) throw new Error('no screens')
12022
12276
  await withFrames(async (map) => {
12023
12277
  // 从菜单直接点:先量一遍,有内容会被裁就先给看清单(同样的结果只拦一次)
@@ -12051,7 +12305,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12051
12305
  const r = await captureOf(sc, long, map, maxH, aiShot)
12052
12306
  const cut = maxH && r.h > maxH
12053
12307
  const title = exportTitle(sc, r)
12054
- batch.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title, key: sc.key, links: r.links.map((l) => ({ x: l.x, y: l.y, w: l.w, h: l.h, key: keyOfPath(l.path, fileTarget) })) })
12308
+ // 按状态展开的页:标题带上状态名;跳到某个状态的链接(?state=)落在那个状态那页,没展开就落在那屏
12309
+ batch.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title: sc.xs ? stateTitle(title, sc.xsLabel) : title, key: sc.xs && !sc.xsFirst ? `${sc.key}?state=${sc.xs}` : sc.key, links: r.links.map((l) => ({ x: l.x, y: l.y, w: l.w, h: l.h, key: keyOfPath(l.path, fileTarget) + (l.state ? '?state=' + l.state : '') })) })
12055
12310
  titles.push(title)
12056
12311
  n++
12057
12312
  } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
@@ -12165,7 +12420,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12165
12420
  else sayErr(t('exportFail', { msg: m }), { label: t('retry'), run: () => exportHtml() })
12166
12421
  }
12167
12422
  }
12168
- return { withFrames, measureAll, exportShots, exportHtml, htmlBody, loadEvery }
12423
+ return { withFrames, measureAll, precheck, exportShots, exportHtml, htmlBody, loadEvery }
12169
12424
  }
12170
12425
 
12171
12426
  // ── 画笔标注(从预览面板里拆出来的):台面上看得到的几屏截图拼好、叠上画的,存进 refs/ 交给模型,或者复制
@@ -12358,7 +12613,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12358
12613
  // ── 设计体检(从预览面板里拆出来的):画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里
12359
12614
  // x:这一次画面的值和几个 ref;onOpen:开体检面板时收掉别的面板。自动量、check_design 回话的 effect 留在面板里
12360
12615
  function makeCheck(x) {
12361
- const { kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, onOpen, insert, say, t } = x
12616
+ const { sid, fileTarget, kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, onOpen, insert, say, t } = x
12362
12617
  const sayErr = (m, a) => say(m, a, true) // 没成的事:红色消息条,不自己走
12363
12618
  const closeCheck = () => {
12364
12619
  ckGen.current++
@@ -12384,13 +12639,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12384
12639
  setCk({ running: true, list: [] })
12385
12640
  const g = ++ckGen.current
12386
12641
  ckOpen.current = true
12642
+ // 共用部件各屏写得不一样(#30):服务端读文件比,和量页面一起跑;问不到就不显示这一组
12643
+ const dr = fileTarget && sid ? post('drift', { session: sid }).catch(() => null) : Promise.resolve(null)
12387
12644
  const out = await measure(checkList(), false)
12645
+ const d = await dr
12388
12646
  if (g !== ckGen.current) { // 量的时候面板关了 / 又量了一轮:这份结果作废;面板关着的话,这一轮画上的标记也清掉
12389
12647
  if (!ckOpen.current) for (const sc of out) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
12390
12648
  return out
12391
12649
  }
12392
12650
  if (canvas && shown.length > LIVE_MAX) say(t('checkPartial', { n: out.length }))
12393
- setCk({ running: false, list: out })
12651
+ setCk({ running: false, list: out, drift: d && Array.isArray(d.items) && d.items.length ? d : null })
12394
12652
  setCkCount(total(out))
12395
12653
  // 有问题的第一屏被面板挡着、在画布外面:挪过来
12396
12654
  const first = out.find((x) => x.issues.length)
@@ -12411,7 +12669,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12411
12669
  insert(formatCheck(t, ck.list, stRef.current), 'insertedSend')
12412
12670
  closeCheck()
12413
12671
  }
12414
- return { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues }
12672
+ // 部件不一致的一条:放进输入框(不发),用户看了再发
12673
+ const askDrift = (it) => insert(t('dfAsk', { sel: it.sel, n: it.screens, v: it.variants, diff: driftDiff(t, it, true) }), 'inserted')
12674
+ return { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues, askDrift }
12415
12675
  }
12416
12676
 
12417
12677
  // ── 调样式(从预览面板里拆出来的):点一个元素,面板里拖滑块先在页面上看效果;写回文件 = 并进它在源码里的 style 属性
@@ -12558,44 +12818,65 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12558
12818
  return { implLoad, implRecompare }
12559
12819
  }
12560
12820
 
12821
+ /**
12822
+ * 试用(演示)里走过的路:stack 是 [{ key 哪一屏, state 哪个状态(#30,'' = 页面默认的)}],最多记 30 步。
12823
+ * 点到的正好是上一步那屏(同一状态)就当返回(反向过场);写了 data-back 的按走过的路退一步,没得退才去它的 href
12824
+ */
12561
12825
  function makeDemoNav(x) {
12562
- const { setDemo, demoSeq, fileTarget } = x
12563
- const demoGo = (path) => demoTo(keyOfPath(path, fileTarget))
12564
- const demoTo = (key) => {
12565
- setDemo((d) => {
12566
- if (!d) return d
12567
- const top = d.stack[d.stack.length - 1]
12568
- if (key === top) return d
12569
- const back = d.stack.length > 1 && d.stack[d.stack.length - 2] === key
12570
- const stack = back ? d.stack.slice(0, -1) : [...d.stack, key].slice(-30)
12571
- const last = d.layers[d.layers.length - 1]
12572
- return { stack, layers: [last, { id: ++demoSeq.current, key, dir: back ? -1 : 1, shown: false }] }
12573
- })
12826
+ const { setDemo, demoSeq, fileTarget, defOf = () => '' } = x
12827
+ // 默认状态写不写都是同一屏(order.html 和 order.html?state=default):不然两种写法回默认,返回的路不一样
12828
+ const norm = (a, def = defOf(a.key)) => (a.state && a.state !== def ? a.state : '')
12829
+ const same = (a, b) => !!a && !!b && a.key === b.key && norm(a) === norm(b)
12830
+ const pop = (d, hash = '') => {
12831
+ const stack = d.stack.slice(0, -1)
12832
+ const to = stack[stack.length - 1]
12833
+ const last = d.layers[d.layers.length - 1]
12834
+ return { stack, layers: [last, { id: ++demoSeq.current, key: to.key, state: to.state || '', dir: -1, shown: false, ...(hash ? { hash } : null) }] }
12574
12835
  }
12575
- const demoRestart = () => setDemo((d) => {
12576
- if (!d || d.stack.length < 2) return d
12836
+ // hash:链接里的锚点(换到那一屏 / 那个状态后滚过去),只放在这一层的地址上,不算进走过的路
12837
+ const go = (d, at, hash = '') => {
12838
+ if (same(at, d.stack[d.stack.length - 1])) return d
12839
+ if (d.stack.length > 1 && same(at, d.stack[d.stack.length - 2])) return pop(d, hash) // 点回上一步(?state=default#receipt):锚点照带
12577
12840
  const last = d.layers[d.layers.length - 1]
12578
- return { stack: [d.stack[0]], layers: [last, { id: ++demoSeq.current, key: d.stack[0], dir: -1, shown: false }] }
12579
- })
12580
- const demoBack = () => setDemo((d) => {
12841
+ return { stack: [...d.stack, at].slice(-30), layers: [last, { id: ++demoSeq.current, key: at.key, state: at.state, dir: 1, shown: false, ...(hash ? { hash } : null) }] }
12842
+ }
12843
+ const demoGo = (path, state, back, hash = '') => {
12844
+ const at = path ? { key: keyOfPath(path, fileTarget), state: state || '' } : null
12845
+ setDemo((d) => (!d ? d : back && d.stack.length > 1 ? pop(d) : at ? go(d, at, /^#[^\s#]{1,200}$/.test(hash || '') ? hash : '') : d))
12846
+ }
12847
+ const demoTo = (key, state = '') => setDemo((d) => (d ? go(d, { key, state: state || '' }) : d))
12848
+ const demoRestart = () => setDemo((d) => {
12581
12849
  if (!d || d.stack.length < 2) return d
12582
- const stack = d.stack.slice(0, -1)
12583
12850
  const last = d.layers[d.layers.length - 1]
12584
- return { stack, layers: [last, { id: ++demoSeq.current, key: stack[stack.length - 1], dir: -1, shown: false }] }
12851
+ const first = d.stack[0]
12852
+ return { stack: [first], layers: [last, { id: ++demoSeq.current, key: first.key, state: first.state || '', dir: -1, shown: false }] }
12585
12853
  })
12854
+ const demoBack = () => setDemo((d) => (d && d.stack.length > 1 ? pop(d) : d))
12586
12855
  const demoShown = (id) => {
12587
12856
  setDemo((d) => (d ? { ...d, layers: d.layers.map((l) => (l.id === id ? { ...l, shown: true } : l)) } : d))
12588
12857
  setTimeout(() => setDemo((d) => (d && d.layers.length > 1 && d.layers[d.layers.length - 1].id === id ? { ...d, layers: [d.layers[d.layers.length - 1]] } : d)), 480)
12589
12858
  }
12590
- // 页面自己用脚本跳了(没走我们拦下的链接):只改记下的是哪一屏,不重载
12591
- const demoHref = (id, href) => {
12859
+ // 页面自己用脚本跳了(没走我们拦下的链接):只改记下的是哪一屏,不重载。
12860
+ // raw:这页 <meta name="dsh-states"> 写的(页面报上来的)。没写这个状态的(老页面自己拿 ?state= 当参数)当没带状态,
12861
+ // 不然记下来、地址一变又重载一遍,页面自己带的别的参数也丢了
12862
+ const demoHref = (id, href, raw) => {
12592
12863
  let key = ''
12593
- try { key = keyOfPath(decodeURIComponent(new URL(href).pathname), fileTarget) } catch { return }
12864
+ let state = ''
12865
+ const dec = parseStates(raw).map((x) => x.name)
12866
+ let given = ''
12867
+ try {
12868
+ const u = new URL(href)
12869
+ key = keyOfPath(decodeURIComponent(u.pathname), fileTarget)
12870
+ given = u.searchParams.get('state') || ''
12871
+ state = STATE_RE.test(given) && dec.includes(given) && given !== dec[0] ? given : ''
12872
+ } catch { return }
12594
12873
  setDemo((d) => {
12595
12874
  if (!d) return d
12596
12875
  const last = d.layers[d.layers.length - 1]
12597
- if (last.id !== id || last.key === key) return d
12598
- return { stack: [...d.stack.slice(0, -1), key], layers: d.layers.map((l) => (l.id === id ? { ...l, key } : l)) }
12876
+ // 还是这一层载的那个地址(跨页链接带的 ?state= 那页没写,地址里照样有):没跳,别改记下的、别再载一遍
12877
+ // 没写状态的页(老页面自己拿 ?state= 当参数)自己换了参数:也不算换屏,别动这一层(一动地址就变、重载,参数丢了)
12878
+ if (last.id !== id || (last.key === key && (!dec.length || (last.state || '') === given || norm(last, dec[0] || defOf(key)) === state))) return d
12879
+ return { stack: [...d.stack.slice(0, -1), { key, state }], layers: d.layers.map((l) => (l.id === id ? { ...l, key, state, hash: l.key === key ? l.hash : '' } : l)) }
12599
12880
  })
12600
12881
  }
12601
12882
  return { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref }
@@ -12625,6 +12906,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12625
12906
  const [info, setInfo] = useState({}) // 目录|屏 → { meta, title }(页面报上来的)
12626
12907
  const [tops, setTops] = useState({}) // 屏 → 顶栏右边是不是深色(小程序胶囊画白的)
12627
12908
  const setTop = (k, dk) => setTops((cur) => (cur[k] === dk ? cur : { ...cur, [k]: dk }))
12909
+ const [stSel, setStSel] = useState({}) // 目录|屏 → 选着看的状态(#30 一页多状态;默认状态不记)
12910
+ const [stMenu, setStMenu] = useState(null) // 状态菜单开在哪:{ key, x, y }
12628
12911
  const [sel, setSel] = useState('')
12629
12912
  const [panel, setPanel] = useState(false)
12630
12913
  const [lookTab, setLookTab] = useState('set') // 外观面板开在哪一页:set 整套 / tw 滑块 / style 换风格 / brand 品牌
@@ -12669,6 +12952,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12669
12952
  const [phone, setPhone] = useState(false) // 手机上看的面板
12670
12953
  const [pubP, setPubP] = useState(false) // 公网链接的面板
12671
12954
  const [multi, setMulti] = useState(false) // 多尺寸并排
12955
+ const [stAll, setStAll] = useState('') // 一页多状态(#30):把哪一屏的每个状态并排摆出来
12672
12956
  const ckGen = useRef(0) // 每量一次、每关一次面板 +1:量完发现不是最新的一次就不算数
12673
12957
  const ckOpen = useRef(false) // 面板开着(或正在量):过期的一次结果回来时别清掉新一轮的标记
12674
12958
  const [ck, setCk] = useState(null) // 设计体检:null = 面板关着;{ running, list: [{ key, label, url, issues, error }] }
@@ -12742,6 +13026,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12742
13026
  const [loadTick, setLoadTick] = useState(0) // 导出面板开着时页面又载入了一次:重新量
12743
13027
  const warned = useRef('') // 预检提醒过的结果:同样的结果只拦一次
12744
13028
  const [xo, setXo] = useState({ layout: 'auto', custom: '', fit: '', fitH: '', cols: 1 }) // 导出选项
13029
+ const [xStates, setXStates] = useState(null) // { target, map: { key: [{ name, label }] } }:导出面板开着时问服务端各屏写了哪几个状态(收起来的屏也算)
12745
13030
  const cmpRef = useRef(null)
12746
13031
  const [box, setBox] = useState({ w: 0, h: 0 })
12747
13032
  // 灵动条各形态量出来的真宽度(按语言、形态记):估的宽度只在没量过时用,英文字长也不会和两边的小块撞
@@ -12791,7 +13076,18 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12791
13076
  const tg = st && st.target
12792
13077
  const site = tg ? (tg.kind === 'file' ? 'file:' + String(tg.file || '').replace(/[\\/][^\\/]*$/, '') : 'proxy:' + tg.port) : origin
12793
13078
  const busy = !!(st && st.turn)
12794
- const screens = (st && st.screens) || []
13079
+ // 一页多状态(#30):这屏写了哪几个状态(页面报上来的)、现在看哪个;选了不是默认的那屏,地址带上 ?state=
13080
+ const statesOf = (key) => parseStates((info[site + '|' + key] || {}).states)
13081
+ const stateFor = (key) => {
13082
+ const s = stSel[site + '|' + key]
13083
+ return s && statesOf(key).some((x, i) => i > 0 && x.name === s) ? s : ''
13084
+ }
13085
+ const pickState = (key, name) => {
13086
+ const list = statesOf(key)
13087
+ const v = list.length && name !== list[0].name ? name : ''
13088
+ setStSel((m) => ((m[site + '|' + key] || '') === v ? m : { ...m, [site + '|' + key]: v }))
13089
+ }
13090
+ const screens = ((st && st.screens) || []).map((sc) => { const s = stateFor(sc.key); return s ? { ...sc, url: withState(sc.url, s), state: s } : sc })
12795
13091
 
12796
13092
  // 哪几屏是「刚生成的」:第一次看到它时模型正在干活 → 第一次显示时播生成动画(播过就不再播)
12797
13093
  // 这一轮开始时已有的屏记下来:这轮里出了新的一屏,就在画布末尾留个「生成中…」等下一屏;
@@ -12853,7 +13149,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12853
13149
  }, [busy])
12854
13150
 
12855
13151
  const infoOf = (key) => info[site + '|' + key] || null
12856
- const ik = (sc) => (sc.v ? 'v' + sc.v + '|' : '') + sc.key // 旧版本的屏单独记标题
13152
+ const ik = (sc) => (sc.v ? 'v' + sc.v + '|' : '') + sc.key + (sc.xs ? '?state=' + sc.xs : '') // 旧版本的屏单独记标题;导出时按状态展开的那几页(xs)各挂各的
12857
13153
  const focus = (st && st.focus) || ''
12858
13154
  const main = infoOf(focus) || (screens[0] && infoOf(screens[0].key)) || {}
12859
13155
  const meta = parseMeta(main.meta || (st && st.draft && st.draft.meta) || (playR.current.end ? '' : playR.current.meta) || '') // 第一屏还在放草稿(真的没摆出来):按草稿开头写的类型
@@ -13094,12 +13390,20 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13094
13390
  // 手机上看:现在这一屏在预览服务器上的路径;手机开着时,电脑上换屏手机跟着跳
13095
13391
  const phoneOn = !!(st && st.phone && st.phone.on)
13096
13392
  const demoKey = demo ? demo.layers[demo.layers.length - 1].key : ''
13393
+ // 试用里这屏是哪个状态(#30):写在灵动条的屏名后面
13394
+ const demoStateLabel = () => {
13395
+ const top = demo ? demo.layers[demo.layers.length - 1] : null
13396
+ const list = top && top.state ? statesOf(top.key) : []
13397
+ const x = list.find((y) => y.name === top.state)
13398
+ return x && x !== list[0] ? ' · ' + x.label : ''
13399
+ }
13097
13400
  const urlOfKey = (key) => {
13098
13401
  const sc = screens.find((x) => x.key === key)
13099
- if (sc) return sc.url
13402
+ if (sc) return sc.state ? withState(sc.url, '') : sc.url // 画布上给这屏选了状态:试用里没写状态的链接还是落在默认状态
13100
13403
  return fileTarget ? `${origin}/${key.split('/').map(encodeURIComponent).join('/')}` : origin + key
13101
13404
  }
13102
- const curScreen = demo ? { key: demoKey, url: urlOfKey(demoKey) } : screens.find((x) => x.key === (canvas ? sel || focus : focus)) || screens[0]
13405
+ const demoState = demo ? demo.layers[demo.layers.length - 1].state || '' : ''
13406
+ const curScreen = demo ? { key: demoKey, url: demoState ? withState(urlOfKey(demoKey), demoState) : urlOfKey(demoKey) } : screens.find((x) => x.key === (canvas ? sel || focus : focus)) || screens[0]
13103
13407
  let curPath = '/'
13104
13408
  try { if (curScreen) { const u = new URL(curScreen.url); curPath = u.pathname + u.search } } catch { /* 地址不对 */ }
13105
13409
  const lastFollow = useRef('')
@@ -13187,7 +13491,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13187
13491
  showFlash(t('born', { name: title || labelOf(sc) }))
13188
13492
  }
13189
13493
 
13190
- const remember = (key, m, title, toks, dk, links, nat, err = '') => {
13494
+ const remember = (key, m, title, toks, dk, links, nat, err = '', ext) => {
13191
13495
  if (pane === 'export') setLoadTick((n) => n + 1)
13192
13496
  const k = site + '|' + key
13193
13497
  const sk = snapSite + '|' + key
@@ -13195,8 +13499,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13195
13499
  const sig = JSON.stringify([toks || [], links || []])
13196
13500
  setInfo((cur) => {
13197
13501
  const natural = nat === 0 ? null : nat || (cur[k] && cur[k].natural) || null // 画幅放大后页面正好撑满、报空:还按上回量的;0 是这页不再是一整块:清掉
13198
- return cur[k] && cur[k].meta === m && cur[k].title === title && cur[k].sig === sig && cur[k].dark === dk && String(cur[k].natural) === String(natural) && (cur[k].err || '') === err ? cur
13199
- : { ...cur, [k]: { meta: m, title, tokens: toks || [], links: links || [], sig, dark: dk, natural, err } }
13502
+ const states = ext ? ext.states || '' : (cur[k] && cur[k].states) || '' // 写了哪几个状态(#30):对比那几处不报,留着上回的
13503
+ return cur[k] && cur[k].meta === m && cur[k].title === title && cur[k].sig === sig && cur[k].dark === dk && String(cur[k].natural) === String(natural) && (cur[k].err || '') === err && (cur[k].states || '') === states ? cur
13504
+ : { ...cur, [k]: { meta: m, title, tokens: toks || [], links: links || [], sig, dark: dk, natural, err, states } }
13200
13505
  })
13201
13506
  }
13202
13507
 
@@ -13416,12 +13721,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13416
13721
  setPicking(false)
13417
13722
  setPanel(false)
13418
13723
  setHist(false)
13419
- setDemo({ stack: [key], layers: [{ id: ++demoSeq.current, key, dir: 0, shown: false }] })
13724
+ const state = stateFor(key) // 从这屏现在看着的状态开始
13725
+ setDemo({ stack: [{ key, state }], layers: [{ id: ++demoSeq.current, key, state, dir: 0, shown: false }] })
13420
13726
  const inf = infoOf(key)
13421
13727
  if (inf && !(inf.links || []).length) say(t('demoNone'))
13422
13728
  }
13423
13729
  // 演示里跳屏、返回、从头来(makeDemoNav)
13424
- const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget })
13730
+ const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget, defOf: (key) => { const ss = statesOf(key); return ss.length ? ss[0].name : '' } })
13425
13731
  const { implLoad, implRecompare } = makeImpl({ sid, setImpl, setImplRun, say, t })
13426
13732
  // 和做出来的比:在比哪一屏(看旧版本时不比)、那屏记着的地址和上次的分数
13427
13733
  const implSc = impl && !ver ? screens.find((x) => x.key === impl.key) || null : null
@@ -13591,11 +13897,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13591
13897
  onEditing: setTxOn,
13592
13898
  lang: t('lang'),
13593
13899
  onNote: (n) => note(n, sc),
13594
- onMeta: (m, title, toks, dk, links, nat, err) => remember(ik(sc), m, title, toks, dk, links, nat, err),
13900
+ onMeta: (m, title, toks, dk, links, nat, err, ext) => remember(ik(sc), m, title, toks, dk, links, nat, err, ext),
13595
13901
  onLinks: (links) => rememberLinks(ik(sc), links),
13596
13902
  onFix: (f) => insert(t(f.err === 'down' ? 'scrFailAskDown' : 'scrFailAsk', { file: f.file || labelOf(sc) }), 'insertedSend'),
13597
13903
  onTop: (dk) => setTop(ik(sc), dk),
13598
13904
  onBuilt: (title) => onBuilt(sc, title),
13905
+ onStateGo: sc.v || canvas ? undefined : (s) => pickState(sc.key, s),
13599
13906
  }))
13600
13907
 
13601
13908
  // 画布上屏太多、离镜头远的:先不挂 iframe,放一张后台截的缩略图(issue #17),截不到就是「挪近就加载」。
@@ -13606,7 +13913,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13606
13913
  const sleepScreen = (sc, z, quiet) => h(Device, { kind, w: size[0], h: size[1], fill: false, label: labelOf(sc), top: tops[ik(sc)], os: meta.os },
13607
13914
  h('div', { className: 'ddp-scr' + (dark ? ' dk' : '') },
13608
13915
  quiet ? null : h('div', { className: 'ddp-away', style: { fontSize: 13 / Math.max(0.25, z || 1) } }, t('canvasAsleep')),
13609
- snapQ && !sc.v ? h(Snap, { key: snapId + '&key=' + sc.key, src: `${API}scrthumb?${snapQ}&key=${encodeURIComponent(sc.key)}`, blind: /^off/.test((st && st.watch) || ''), onTitle: (title) => snapTitled(sc.key, title) }) : null))
13916
+ snapQ && !sc.v ? h(Snap, { key: snapId + '&key=' + sc.key + (sc.state ? '&state=' + sc.state : ''), src: `${API}scrthumb?${snapQ}&key=${encodeURIComponent(sc.key)}${sc.state ? '&state=' + encodeURIComponent(sc.state) : ''}`, blind: /^off/.test((st && st.watch) || ''), onTitle: (title) => snapTitled(sc.key, title) }) : null))
13610
13917
 
13611
13918
  // 那一屏的接口(截图、体检、业务标注都用);刚载入的等它就绪
13612
13919
  const apiOf = async (sc, map = apis.current) => {
@@ -13643,10 +13950,18 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13643
13950
  return () => clearTimeout(tm)
13644
13951
  }, [hidRev])
13645
13952
  const every = hidSig && hid.sig === hidSig ? everyOf(shown, hid.list) : shown
13646
- const { withFrames, measureAll, exportShots, exportHtml, htmlBody, loadEvery } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, every, loadHidden, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, tops, tweak, webFit,
13953
+ // 导出用:某屏写了哪几个状态(本地文件问服务端的;别的用页面报上来的)
13954
+ const statesForX = (key) => (fileTarget ? (xStates && xStates.target === targetKey && xStates.map[key]) || [] : statesOf(key))
13955
+ const { withFrames, measureAll, precheck, exportShots, exportHtml, htmlBody, loadEvery } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, every, loadHidden, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, tops, tweak, webFit, statesFor: statesForX, loadStates: fileTarget ? () => post('states', { session: sid }).then((d) => (d && d.map && typeof d.map === 'object' ? d.map : {})) : null,
13647
13956
  onWarn: (mode) => { setXFmt(mode === 'pptx' ? 'pptx' : 'pdf'); if (pane !== 'export') openPane('export') } })
13648
13957
  // 换了设计:导出面板里挑的屏不算了,回到「全部」
13649
13958
  useEffect(() => { setXo((o) => (o.scope && o.scope !== 'all' ? { ...o, scope: 'all', pick: [] } : o)) }, [targetKey])
13959
+ useEffect(() => {
13960
+ if (pane !== 'export' || !fileTarget || ver) return
13961
+ let off = false
13962
+ post('states', { session: sid }).then((d) => { if (!off) setXStates({ target: targetKey, map: (d && d.map) || {}, at: Date.now() }) }, () => {})
13963
+ return () => { off = true }
13964
+ }, [pane, targetKey, st ? st.rev : 0, !!ver])
13650
13965
  const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
13651
13966
  if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
13652
13967
  // 公网链接(#27)开着:右侧栏换了屏、画幅、深浅色、调节值,对方下次打开就按新的(看旧版本时不动)
@@ -13710,6 +14025,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13710
14025
  return g ? (g.letter || 'a').toUpperCase() : ''
13711
14026
  }
13712
14027
  const tagOf = (sc) => { const L = takeTag(sc); return L ? h('b', { key: 'g', className: 'ddp-vt', title: t('takeN', { l: L }) }, L) : null }
14028
+ // 一页多状态(#30):写了几个状态的屏,屏名旁一个「状态 ▾」小胶囊(默认状态也显示:一眼看出这屏有几种样子),点开换着看
14029
+ const openStMenu = (key, el) => {
14030
+ if (stMenu && stMenu.key === key) { setStMenu(null); return }
14031
+ const stage = stageRef.current
14032
+ if (!stage || !el) return
14033
+ const r = el.getBoundingClientRect()
14034
+ const R = stage.getBoundingClientRect()
14035
+ setStMenu({ key, x: Math.round(Math.max(8, Math.min(r.left - R.left, R.width - 256))), y: Math.round(Math.min(r.bottom - R.top + 6, Math.max(8, R.height - 300))) })
14036
+ }
14037
+ const stateChip = (sc) => {
14038
+ if (!sc || sc.v) return null
14039
+ const list = statesOf(sc.key)
14040
+ if (!list.length) return null
14041
+ const x = list.find((y) => y.name === (sc.state || '')) || list[0]
14042
+ const on = !!(stMenu && stMenu.key === sc.key)
14043
+ return h('button', { key: 'st', type: 'button', className: 'ddp-stt' + (on ? ' on' : '') + (x === list[0] ? '' : ' alt'), 'aria-haspopup': 'menu', 'aria-expanded': on,
14044
+ ...tipA(t('stTip', { n: list.length }), t('dState')), onClick: (e) => openStMenu(sc.key, e.currentTarget) }, h(I.states), h('span', null, x.label), h(I.caret))
14045
+ }
13713
14046
  // 几个方向并排时每屏标题旁都挂着「用这版」,不用先点中那一屏才看得到
13714
14047
  const badge = (sc) => (infoOf(ik(sc)) || {}).err ? h('em', { key: 'f', className: 'ddp-failtag' }, t('scrFailChip'))
13715
14048
  : !sc.v && takesOf(shown.map((x) => x.key), sc.key)
@@ -13755,13 +14088,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13755
14088
  return base.some(([, , x]) => x[0] === sz[0] && x[1] === sz[1]) ? base : [...base, ['szCustom', kind, sz]]
13756
14089
  })()
13757
14090
  const inMulti = multi && !!sizeSet && !ver
14091
+ // 一页多状态(#30):这一屏的每个状态并排看(和多尺寸一样是画布上的一种看法)
14092
+ const inStAll = !!stAll && !ver && !demo && !inMulti && !implSc && statesOf(stAll).length > 0
14093
+ const inSide = inMulti || inStAll
13758
14094
  // 单页看手机 / 平板时,选择、改字的提示条放在设备上方,给它让出一条(不然压住设备顶边)
13759
- const hintTop = (picking || textEdit) && !canvas && !inMulti && !ver && !demo && (kind !== 'web' || webFit) // 网页按画幅缩放时也和设备一样让出一条(#20)
13760
- const flows = canvas && !inMulti && !picking && !textEdit ? flowsOf(shown, (sc) => (infoOf(ik(sc)) || {}).links, fileTarget) : []
14095
+ const hintTop = (picking || textEdit) && !canvas && !inSide && !ver && !demo && (kind !== 'web' || webFit) // 网页按画幅缩放时也和设备一样让出一条(#20)
14096
+ const flows = canvas && !inSide && !picking && !textEdit ? flowsOf(shown, (sc) => (infoOf(ik(sc)) || {}).links, fileTarget) : []
13761
14097
 
13762
14098
  // ── 设计体检:画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里 ──
13763
14099
  // 设计体检:量、开面板、定位、交给模型(makeCheck)
13764
- const { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues } = makeCheck({ kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, insert, say, t,
14100
+ const { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues, askDrift } = makeCheck({ sid, fileTarget, kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, insert, say, t,
13765
14101
  onOpen: () => { setPanel(false); setHist(false); setPhone(false); setPubP(false); setAn(false); setStyleEdit(false) } }) // 1.0:一次只开一个面板(调样式抽屉也算)
13766
14102
  // 打开一套设计、模型又干完一轮(turns 变了):面板开着就再查一次(改没改好一眼看到);关着就悄悄量一下,问题数标在按钮上。
13767
14103
  // 模型干着活时不量;等一会儿再量:刚写完的屏还在刷新、播生成动画
@@ -13803,7 +14139,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13803
14139
  }, 1500)
13804
14140
  return () => clearTimeout(timer)
13805
14141
  }, [ckReq])
13806
- const checkOff = !url || !!ver || !!demo || inMulti || !!implSc
14142
+ const checkOff = !url || !!ver || !!demo || inSide || !!implSc
13807
14143
  // ── 业务标注(插件页的试验开关开着才有 st.annotations 这个键):面板和体检、版本共用右边那个位置;点选、改字、调样式、画笔时编号收起,退出后回来 ──
13808
14144
  useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
13809
14145
  const toggleAn = () => {
@@ -13836,10 +14172,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13836
14172
  const k = Math.max(1, f.offsetWidth) / Math.max(1, r.width)
13837
14173
  api.annotHit((x - r.left) * k, (y - r.top) * k)
13838
14174
  }
13839
- const styleOff = !url || !!ver || !!demo || inMulti || busy || !!implSc
14175
+ const styleOff = !url || !!ver || !!demo || inSide || busy || !!implSc
13840
14176
 
13841
14177
  // ── 画笔标注:画完把台面上看得到的几屏各截一张,按位置摆好,叠上画的东西,存进 refs/,路径放进输入框让模型用 read_image 看(不动剪贴板) ──
13842
- const markOff = !url || !!ver || !!demo || inMulti || !!implSc
14178
+ const markOff = !url || !!ver || !!demo || inSide || !!implSc
13843
14179
  const toggleMark = () => {
13844
14180
  markRun.current++
13845
14181
  if (mark) { setMark(false); return }
@@ -13932,7 +14268,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13932
14268
  const reload = () => setReloadSeq((x) => x + 1)
13933
14269
 
13934
14270
  // 按钮鼠标停一下出说明卡(HoverTip):名字 + 一句用途;窄了(样式表里)先截屏名,再收字
13935
- const curKey = implSc ? implSc.key : demo && demo.stack.length ? demo.stack[demo.stack.length - 1] : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
14271
+ const curKey = implSc ? implSc.key : demo && demo.stack.length ? demo.stack[demo.stack.length - 1].key : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
13936
14272
  const curSc = screens.find((x) => x.key === curKey)
13937
14273
  const stLabel = (st && st.label) || ''
13938
14274
  const scrLabel = canvas && screens.length > 1 && !implSc
@@ -13942,6 +14278,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13942
14278
  const pickScreen = (key) => {
13943
14279
  if (implSc) { implOpen(key); return } // 在和做出来的比:换成比这一屏
13944
14280
  setMulti(false)
14281
+ setStAll('')
13945
14282
  if (demo) setDemo(null)
13946
14283
  setSel(key)
13947
14284
  if (canvas || key !== focus || dr) openByUser(key)
@@ -13950,8 +14287,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13950
14287
  const exSc = implSc || shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
13951
14288
  const exName = exSc ? dropBrand(shortOf(exSc)) + (takeTag(exSc) ? ' · ' + takeTag(exSc) : '') : ''
13952
14289
  const libOpen = () => { setLibFocus(''); if (lib) setLib(''); else libDefaultThen((k) => setLib((c) => c || k)) }
13953
- const onCanvas = canvas && !inMulti && !demo && homeAt !== 'on' && !(ver && cmp) && !implSc
13954
- const toCanvas = () => { homeAway(); setMulti(false); setCmp(false); implClose(); if (demo) setDemo(null); change({ view: 'canvas' }) }
14290
+ const onCanvas = canvas && !inSide && !demo && homeAt !== 'on' && !(ver && cmp) && !implSc
14291
+ const toCanvas = () => { homeAway(); setMulti(false); setStAll(''); setCmp(false); implClose(); if (demo) setDemo(null); change({ view: 'canvas' }) }
13955
14292
  // 面板(1.0)开的是哪一张:同一时间只开一个
13956
14293
  const packOther = !!packDir && !(fileTarget && st && st.target && packDir === st.target.root)
13957
14294
  const shareTab = phone ? 'phone' : pubP ? 'pub' : pane === 'pack' && !packOther ? 'demo' : pane === 'share' && !packOther ? 'submit' : ''
@@ -13962,7 +14299,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13962
14299
  const toggleShare = () => (sheet === 'share' ? closeShare() : pubOn && fileTarget ? togglePub() : togglePhone())
13963
14300
  // 换屏器:画布时写「画布 5 屏」,单看时写「详情 3 / 5」
13964
14301
  const curIdx = screens.findIndex((x) => x.key === curKey)
13965
- const swLabel = onCanvas || curIdx < 0 ? t('canvasShort') : dropBrand(shortOf(screens[curIdx])) + (takeTag(screens[curIdx]) ? ' · ' + takeTag(screens[curIdx]) : '')
14302
+ const swLabel = inStAll ? t('stAllOn', { name: dropBrand(labelOf(screens.find((x) => x.key === stAll) || { key: stAll, label: stAll.replace(/\.html?$/i, '') })) }) : onCanvas || curIdx < 0 ? t('canvasShort') : dropBrand(shortOf(screens[curIdx])) + (takeTag(screens[curIdx]) ? ' · ' + takeTag(screens[curIdx]) : '')
13966
14303
  const swPos = onCanvas || curIdx < 0 ? (screens.length > 1 ? t('nScr', { n: screens.length }) : '') : screens.length > 1 ? `${curIdx + 1} / ${screens.length}` : ''
13967
14304
  // 1.0 骨架:标题栏(标志 = 首页 | 项目名 ▾ / ⊞ 屏名 ▾ | 分享 导出 转成代码)+ 底部灵动条(说一句 | 选择 改字 调样式 画笔 | 试用 外观 体检)
13968
14305
  // 两边小块:左 版本、右 缩放(画布自己带)。模型在干活时灵动条变成状态胶囊;画笔标注时让给标注自己的底栏
@@ -14037,6 +14374,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14037
14374
  thumb: snapQ ? (k) => `${API}scrthumb?${snapQ}&key=${encodeURIComponent(k)}` : null,
14038
14375
  ratio: size[1] / size[0],
14039
14376
  }),
14377
+ // 单看写了几个状态的屏:屏名后面接着「状态 ▾」(画布上每屏的屏名旁各有一个)
14378
+ !onCanvas && !demo && !implSc && !ver && !mark && curKey ? stateChip({ key: curKey, state: stateFor(curKey) }) : null,
14040
14379
  h('span', { className: 'dd-sp' }),
14041
14380
  h('button', { className: 'ddp-btn' + (sheet === 'share' ? ' sel' : '') + (pubOn || phoneOn ? ' has' : ''), ...tipA(t('shareT'), pubOn || phoneOn ? t('phoneOnTip') : t('dShare')), 'aria-pressed': sheet === 'share', disabled: !url, onClick: toggleShare }, h(I.share), h('span', { className: 'lb' }, t('shareT'))),
14042
14381
  h('button', { className: 'ddp-btn' + (sheet === 'export' ? ' sel' : ''), ...tipA(t('exportT'), t('dExport')), 'aria-pressed': sheet === 'export', disabled: !url, onClick: () => openPane('export') }, h(I.download), h('span', { className: 'lb' }, t('exportT'))),
@@ -14069,7 +14408,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14069
14408
  h('button', { className: 'dd-bt pri', ...tipA(t('restore'), t('dRestore')), onClick: doRestore }, t('restore')),
14070
14409
  h('button', { className: 'dd-x', ...tipA(t('backNow'), '', 'Esc'), 'aria-label': t('backNow'), onClick: () => { setVer(null); setCmp(false) } }, h(I.close)))
14071
14410
  : demo ? h('div', { key: 'dock-demo', className: 'ddp-isl ddp-dock dd-isl dd-mode nocmd' + (capShow || mark ? ' away' : ''), role: 'toolbar', 'aria-label': t('demoOn') },
14072
- h('span', { className: 'dd-mt' }, h(I.play), h('b', null, t('demoOn')), h('em', null, dropBrand((infoOf(demoKey) || {}).title || demoKey.replace(/\.html?$/i, '')))),
14411
+ h('span', { className: 'dd-mt' }, h(I.play), h('b', null, t('demoOn')), h('em', null, dropBrand((infoOf(demoKey) || {}).title || demoKey.replace(/\.html?$/i, '')) + demoStateLabel())),
14073
14412
  h('span', { className: 'dd-vs' }),
14074
14413
  h('button', { className: 'dd-bt ghost', ...tipA(t('demoBack'), demo.stack.length < 2 ? t('demoHow') : ''), disabled: demo.stack.length < 2, onClick: demoBack }, h(I.back), t('demoBack')),
14075
14414
  h('button', { className: 'dd-bt ghost', ...tipA(t('demoRestart')), disabled: demo.stack.length < 2, onClick: demoRestart }, h(I.refresh), t('demoRestart')),
@@ -14394,7 +14733,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14394
14733
  const anL = (anFile && anFile.list) || []
14395
14734
  const sub = an ? (anL.length ? t('anUpdated', { n: anL.length, time: hhmm(anFile.mtime) }) : '') : ck ? (ck.running ? t('checking') : t(ckN ? 'checkSum' : 'checkSumOk', { s: (ck.list || []).length, n: ckN })) : ''
14396
14735
  const head = hd({ icon: I.shield, title: t('check'), help: an ? t('anHelp') : t('checkNote'), sub, tabs, tab: an ? 'an' : 'ck', onTab: (k) => { if (k === 'an' && !an) toggleAn(); else if (k === 'ck' && !ck) runCheck() } })
14397
- if (ck) return h(CheckPanel, { t, head, ck, nameOf: dropBrand, onFocus: focusIssue, onFix: fixIssues, onAgain: runCheck, onClose: closeCheck })
14736
+ if (ck) return h(CheckPanel, { t, head, ck, nameOf: dropBrand, onFocus: focusIssue, onFix: fixIssues, onAgain: runCheck, onDrift: askDrift, onClose: closeCheck })
14398
14737
  return h(AnnotPanel, {
14399
14738
  t,
14400
14739
  head,
@@ -14462,7 +14801,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14462
14801
  if (sheet === 'zip') return h(ZipIssues, { t, head: hd({ icon: I.box, title: t('zipNotOpened') }), issues: zipIssues, onClose: () => { setPane(''); setZipIssues(null) } })
14463
14802
  if (sheet === 'export') {
14464
14803
  const imgModes = exportItems(t, kind, shown.length, exName).filter(([m]) => m !== 'pdf' && m !== 'pptx' && m !== 'opts')
14465
- return h(ExportPanel, { t, head: hd({ icon: I.download, title: t('exportT'), help: xFmt === 'img' ? t('xImgNote') : '', tabs: [['img', t('xImg'), I.image], ['pdf', 'PDF', I.pdf], ['pptx', 'PPT', I.deck]], tab: xFmt, onTab: setXFmt }), fmt: xFmt, imgModes, onImg: (m) => doExport(m), kind, size, opts: xo, setOpts: setXo, screens: every.map(ik).join('|'), items: ((sp) => every.map((sc, i) => ({ key: ik(sc), label: (sp.brand && sp.labels[i]) || dropBrand(labelOf(sc)) })))(splitTitles(every.map(labelOf))), curKey: ((k) => ((every.find((sc) => sc.key === k) || shown[0]) ? ik(every.find((sc) => sc.key === k) || shown[0]) : ''))(implSc ? implSc.key : canvas ? sel || focus : focus), canvas: canvas && !implSc, rev: `${st ? st.rev : 0}|${reloadSeq}|${loadTick}`, measure: async (tok) => { await loadEvery(); return tok && tok.off ? [] : withFrames((map) => (tok && tok.off ? [] : measureAll(map, tok))) }, onResize: (s) => change({ size: s }), onExport: (format, keys) => doExport(format, undefined, { ...xo, keys }), onClose: () => setPane('') })
14804
+ return h(ExportPanel, { t, head: hd({ icon: I.download, title: t('exportT'), help: xFmt === 'img' ? t('xImgNote') : '', tabs: [['img', t('xImg'), I.image], ['pdf', 'PDF', I.pdf], ['pptx', 'PPT', I.deck]], tab: xFmt, onTab: setXFmt }), fmt: xFmt, imgModes, onImg: (m) => doExport(m), kind, size, opts: xo, setOpts: setXo, screens: every.map(ik).join('|'), items: ((sp) => every.map((sc, i) => ({ key: ik(sc), label: (sp.brand && sp.labels[i]) || dropBrand(labelOf(sc)) })))(splitTitles(every.map(labelOf))), stCount: ver ? null : Object.fromEntries(every.map((sc) => [ik(sc), statesForX(sc.key).length])), curKey: ((k) => ((every.find((sc) => sc.key === k) || shown[0]) ? ik(every.find((sc) => sc.key === k) || shown[0]) : ''))(implSc ? implSc.key : canvas ? sel || focus : focus), canvas: canvas && !implSc, rev: `${st ? st.rev : 0}|${reloadSeq}|${loadTick}|${xo.states && fileTarget ? (xStates && xStates.target === targetKey ? xStates.at : '-') : ''}`, measure: async (tok) => { await loadEvery(); return tok && tok.off ? [] : precheck(tok, !!xo.states && !ver) }, onResize: (s) => change({ size: s }), onExport: (format, keys) => doExport(format, undefined, { ...xo, keys }), onClose: () => setPane('') })
14466
14805
  }
14467
14806
  if (sheet === 'code') {
14468
14807
  const hoSteps = h('ol', { className: 'dd-steps', 'aria-label': t('hoSteps'), title: t('hoTip') }, ...['hoS1', 'hoS2', 'hoS3'].map((k, i) => h('li', { key: k, className: i < hoStep ? 'done' : i === hoStep ? 'on' : '', 'aria-current': i === hoStep ? 'step' : undefined }, h('i', null, i < hoStep ? h(I.check) : String(i + 1)), h('span', null, t(k)))))
@@ -14674,7 +15013,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14674
15013
  const rightOn = !!sheet && wideP // 右边开着一张面板(只有宽过 1000 才是右边一张)
14675
15014
  const rightW = 340 // 面板宽 320 + 离边 10 + 留白 10
14676
15015
  const ah = Math.max(0, box.h - TOP_R - BOT_R - dRes)
14677
- const cvBody = !demo && (inMulti || (canvas && !(ver && cmp) && !implSc))
15016
+ const cvBody = !demo && (inSide || (canvas && !(ver && cmp) && !implSc))
14678
15017
  let body
14679
15018
  navR.current = null
14680
15019
  let busyGap = false
@@ -14693,7 +15032,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14693
15032
  h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
14694
15033
  h(Device, { kind, w: size[0], h: size[1], fill, label, top: tops[l.key], os: meta.os },
14695
15034
  h(Screen, { t, remote, onPageDrag: pageDrag,
14696
- src: urlOfKey(l.key),
15035
+ src: (l.state ? withState(urlOfKey(l.key), l.state) : urlOfKey(l.key)) + (l.hash || ''),
14697
15036
  label,
14698
15037
  busy: false,
14699
15038
  born: false,
@@ -14704,13 +15043,53 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14704
15043
  zoom: z,
14705
15044
  reloadSeq,
14706
15045
  onNav: isTop ? demoGo : undefined,
14707
- onHref: isTop ? (href) => demoHref(l.id, href) : undefined,
15046
+ onHref: isTop ? (href, raw) => demoHref(l.id, href, raw) : undefined,
14708
15047
  onShown: () => demoShown(l.id),
14709
- onMeta: (m, title, toks, dk, links, nat) => remember(l.key, m, title, toks, dk, links, nat),
15048
+ onMeta: (m, title, toks, dk, links, nat, err, ext) => remember(l.key, m, title, toks, dk, links, nat, '', ext),
14710
15049
  onLinks: (links) => rememberLinks(l.key, links),
14711
15050
  onTop: (dk) => setTop(l.key, dk),
14712
15051
  })))))
14713
15052
  }))
15053
+ } else if (inStAll) {
15054
+ // 一页多状态(#30):这一屏的每个状态并排(第一个是默认);点选、改字照常,发给模型时说明是哪个状态
15055
+ const base = screens.find((x) => x.key === stAll) || { key: stAll, url: urlOfKey(stAll), label: stAll.replace(/\.html?$/i, '') }
15056
+ const list = statesOf(stAll)
15057
+ const fake = list.map((x, i) => ({ key: 'st' + i, id: 'st:' + x.name + '|' + base.key, url: withState(base.url, i ? x.name : ''), label: x.label }))
15058
+ body = h(Canvas, {
15059
+ key: 'stall',
15060
+ t,
15061
+ top: TOP_R,
15062
+ bottom: BOT_R + dRes,
15063
+ screens: fake,
15064
+ kind,
15065
+ size,
15066
+ ghost: false,
15067
+ picking: picking || textEdit,
15068
+ sel: '',
15069
+ labelOf: (sc) => sc.label,
15070
+ render: (sc, z, i) => h(Device, { kind, w: size[0], h: size[1], label: labelOf(base), top: tops[ik(base) + '|st' + i], os: meta.os },
15071
+ h(Screen, { t, remote, onPageDrag: pageDrag,
15072
+ src: fake[i].url,
15073
+ label: labelOf(base),
15074
+ busy,
15075
+ born: false,
15076
+ picking,
15077
+ textEdit,
15078
+ dark,
15079
+ tweak,
15080
+ quietPick: true,
15081
+ zoom: z,
15082
+ reloadSeq,
15083
+ onPicked: (payload) => deliver(payload, t('stPickNote', { state: list[i].name, label: list[i].label }) + '\n'),
15084
+ onCancelled: () => setPicking(false),
15085
+ onEdited: (d) => onEdited(base, d),
15086
+ onEditDone: () => setTextEdit(false),
15087
+ onEditing: setTxOn,
15088
+ lang: t('lang'),
15089
+ onNote: (n) => note(n, base),
15090
+ onTop: (dk) => setTop(ik(base) + '|st' + i, dk),
15091
+ })),
15092
+ })
14714
15093
  } else if (inMulti) {
14715
15094
  // 多尺寸:现在这一屏,按几档宽度并排
14716
15095
  const base = curScreen || { key: focus, url, label: st.label }
@@ -14812,6 +15191,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14812
15191
  actions,
14813
15192
  badge,
14814
15193
  tag: tagOf,
15194
+ stateChip,
14815
15195
  kind,
14816
15196
  size,
14817
15197
  ghost,
@@ -14842,7 +15222,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14842
15222
  // 画笔标注开着:网页按开标注时的大小定住(侧栏拉窄了就整体缩小,不重排),画的才对得上
14843
15223
  const lock = fill && mark && markSize ? markSize : sideLock
14844
15224
  const z = sideLock ? Math.max(0.05, Math.min(1, (box.w - aside - 32) / sideLock.w)) : lock ? Math.max(0.05, Math.min(1, box.w / lock.w, ah / lock.h)) : fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - (hintTop || busyGap ? 46 : 0)) / dh))
14845
- const one = ver ? shown.find((x) => x.key === focus) || shown[0] || { key: focus, url, label: st.label } : { key: focus, url, label: st.label }
15225
+ const one = ver ? shown.find((x) => x.key === focus) || shown[0] || { key: focus, url, label: st.label } : { key: focus, url: stateFor(focus) ? withState(url, stateFor(focus)) : url, label: st.label }
14846
15226
  // 单屏时模型在写新的一屏:先看着它写(没在选、改字、调样式、标注的时候),写完换过去
14847
15227
  const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !peekR.current
14848
15228
  if (watch) singleDraftR.current = dr.key || '*' // 还不知道是哪屏:名字到了再说
@@ -14879,7 +15259,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14879
15259
  let chip = null
14880
15260
  const sideOpen = rightOn // 右边开着面板:提示放在左边那块的中间
14881
15261
  const side = sideOpen ? ' side' : ''
14882
- const hintText = picking ? t(canvas || inMulti ? 'pickAny' : 'pickOne') : textEdit ? t(canvas || inMulti ? 'textAny' : 'textOne') : styleEdit && !sty ? t(canvas ? 'styleAny' : 'styleOne') : ''
15262
+ const hintText = picking ? t(canvas || inSide ? 'pickAny' : 'pickOne') : textEdit ? t(canvas || inSide ? 'textAny' : 'textOne') : styleEdit && !sty ? t(canvas ? 'styleAny' : 'styleOne') : ''
14883
15263
  if (flash) chip = h('div', { className: 'ddp-chip ok' + side, key: 'ok' }, h(I.check), h('span', null, flash))
14884
15264
 
14885
15265
  return root(
@@ -14904,6 +15284,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14904
15284
  h('img', { src: implShot, alt: t('implShotT'), onError: () => { setImplShot(''); say(t('implShotGone')) } }),
14905
15285
  h('span', null, t('implShotHow'))) : null,
14906
15286
  chip,
15287
+ stMenu && statesOf(stMenu.key).length
15288
+ ? h(StateMenu, { key: 'stm:' + stMenu.key, t, at: stMenu, name: dropBrand(labelOf(screens.find((x) => x.key === stMenu.key) || { key: stMenu.key, label: stMenu.key.replace(/\.html?$/i, '') })),
15289
+ list: statesOf(stMenu.key), cur: stateFor(stMenu.key) || statesOf(stMenu.key)[0].name,
15290
+ onPick: (n) => { pickState(stMenu.key, n); if (stAll === stMenu.key) setStAll('') },
15291
+ allOn: stAll === stMenu.key, onAll: () => { const k = stMenu.key; setMulti(false); setStAll((c) => (c === k ? '' : k)) },
15292
+ onClose: () => setStMenu(null) })
15293
+ : null,
14907
15294
  msgEl(false),
14908
15295
  ...islands,
14909
15296
  palScrim(),
@@ -15065,7 +15452,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
15065
15452
  // 注意:这里是客户端**服务名**(短的),不是包名
15066
15453
  exports.inject = INJECT
15067
15454
  // 测试用
15068
- exports._test = { STYLE, makeDemoNav, implLayout, implAwayUrl, KIND_LIST, KIND_KEY, KIND_SIZE, META_ALIAS, FIXED, SHOW_COLS, FRAME, ASK_EX, ASK_KINDS, KIND_ICON: I, pollGap, webFitOf, precheckOf, fitCanvas, layoutOk, fitHOk, autoSize, pulseStep, MarketDetail, dragKind, droppedOf, pickInfo, pickLabel, pickRanges, pickRule, chipOf, chipRanges, makeT, ZH, EN, formatCheck, formatTweaks, markHit, markPath, STYLES, formatStyle, accentUse, autoStyle, recStyles, styleLook, padInsert, pageOf, pxOf, styleChanges, formatStyleAsk, everyOf, shareOn, takesOf, formatCheckTool, poller, frameOf, paletteOf, formatRef, layoutRow, keyOfPath, flowsOf, flowLines, flowMarks, formatPick, whereOf, parseMeta, sizeOf, layoutGrid, fitCam, nearestLive, LIVE_MAX, tokenKind, formatToken, splitTitles, pickColors, hhmm, formatTpl, formatPrep, styleFromTokens, myStyleOf, isZipFile, hoStepOf }
15455
+ exports._test = { STYLE, makeDemoNav, implLayout, implAwayUrl, KIND_LIST, KIND_KEY, KIND_SIZE, META_ALIAS, FIXED, SHOW_COLS, FRAME, ASK_EX, ASK_KINDS, KIND_ICON: I, pollGap, webFitOf, precheckOf, fitCanvas, layoutOk, fitHOk, autoSize, pulseStep, MarketDetail, dragKind, droppedOf, pickInfo, pickLabel, pickRanges, pickRule, chipOf, chipRanges, makeT, ZH, EN, formatCheck, formatTweaks, markHit, markPath, STYLES, formatStyle, accentUse, autoStyle, recStyles, styleLook, padInsert, pageOf, pxOf, styleChanges, formatStyleAsk, everyOf, shareOn, takesOf, formatCheckTool, poller, frameOf, paletteOf, formatRef, layoutRow, keyOfPath, flowsOf, flowLines, parseStates, withState, byStates, stateTitle, stateGoPlan, withHashNext, flowMarks, formatPick, whereOf, parseMeta, sizeOf, layoutGrid, fitCam, nearestLive, LIVE_MAX, tokenKind, formatToken, splitTitles, pickColors, hhmm, formatTpl, formatPrep, styleFromTokens, myStyleOf, isZipFile, hoStepOf }
15069
15456
  return module.exports
15070
15457
  },
15071
15458
  })