dsh-design-studio 1.0.2 → 1.2.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
@@ -205,10 +205,13 @@ window.__ModuleLoader__.load({
205
205
  exportedHtml: '已导出 {name}({n} 屏,发给别人双击就能看)',
206
206
  exportedHtmlMiss: '已导出 {name}({n} 屏,{miss} 屏没读到)',
207
207
  htmlTooBig: '图片太多,演示包超过 150 MB,没导出。少放几屏再试',
208
+ htmlImgBig: '模拟数据(mock.json)里绑的图太大(单张最多 12 MB、加起来最多 60 MB),放不进演示,没导出。换小一点的图再试',
209
+ htmlMockBig: 'mock.json 太大(超过 1 MB),演示里的数据带不上,没导出。把里面的大段内容(比如图片的 base64)换成图片文件路径再试',
208
210
  htmlNoScreens: '一屏都没读到(文件被挪走或删了?),没导出',
209
211
  xoWarn: '有内容会被裁掉,先看一眼',
210
212
  xoChecking: '正在量页面…',
211
213
  xoClean: '没有会被裁掉的内容。',
214
+ xoStNoCheck: '上面只查了默认状态;另外 {n} 页(其他状态)没预检,内容更长的可能被截掉,拿不准就选「整页」。',
212
215
  xoOver: '{n} 个页面比画幅大,会被裁',
213
216
  xoLong: '{n} 个页面是长页,只会截首屏',
214
217
  xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
@@ -220,9 +223,10 @@ window.__ModuleLoader__.load({
220
223
  xoFail: '{n} 屏没量到,结果可能不全',
221
224
  xoAgain: '再查一次',
222
225
  xoGone: '设计换了,这次导出取消了',
226
+ xoStFail: '没取到各屏写了哪几个状态,这次没导出,再点一次导出试试',
223
227
  xoJobGone: '导出中断了(等太久或 DSH 重启过),请重新导出',
224
228
  styleMoved: '设计换了,这次调的样式没保存',
225
- xoCut: '一次最多导出 1000 屏,最后 {n} 屏没导出',
229
+ xoCut: '一次最多导出 1000 页,最后 {n} 页没导出',
226
230
  xoResize: '按内容改画幅({size})',
227
231
  xoFull: '取景改成整页',
228
232
  xoWhich: '导出哪些',
@@ -233,6 +237,8 @@ window.__ModuleLoader__.load({
233
237
  xoPick: '挑几屏…',
234
238
  xoPickN: '挑了 {n} 屏',
235
239
  xoPickNone: '至少挑一屏',
240
+ xoStates: '每个状态各出一张',
241
+ xoStatesN: '多 {n} 页',
236
242
  xoPre: '导出前检查',
237
243
  xoWho: '({list})',
238
244
  xoPages: '{n} 页',
@@ -269,6 +275,12 @@ window.__ModuleLoader__.load({
269
275
  checkLayout: '页面还没排好版,这次没量成,过一会儿再查一次',
270
276
  checkNote: '只量排版上的硬伤,好不好看你说了算',
271
277
  checkNoneTip: '量了 {s} 屏,没有量得出的排版硬伤',
278
+ dfHead: '部件各屏写得不一样 · 是提醒,不算问题',
279
+ dfItem: '{n} 屏里有 {v} 种写法',
280
+ dfMore: '还有 {n} 个部件也这样',
281
+ dfTip: '点一下:把「统一这个部件」放进输入框',
282
+ dfAsk: '〔部件不一致〕{sel} 在 {n} 屏里有 {v} 种写法:{diff}。请定一种写法(多数屏用的那种)挪进共用的 app.css,各屏删掉自己那份。',
283
+ dfNone: '没写',
272
284
  checkAsk: '〔设计体检〕发现 {n} 个问题:',
273
285
  checkTail: '请逐个修好:改源文件,只动有问题的地方;颜色、字号能改设计变量就改设计变量。',
274
286
  ckToolHead: '量了 {s} 屏,发现 {n} 个问题。逐个改源文件,只动有问题的地方;颜色、字号能改设计变量就改设计变量:',
@@ -291,6 +303,7 @@ window.__ModuleLoader__.load({
291
303
  ck_tight: '离固定栏太近',
292
304
  ck_jserr: '页面脚本报错',
293
305
  ck_missing: '文件没载出来',
306
+ ck_mockmiss: '模拟数据里没这个字段',
294
307
  ck_capsule: '被小程序胶囊挡住',
295
308
  ck_island: '被灵动岛挡住',
296
309
  ck_homebar: '伸进底部横条区',
@@ -321,6 +334,7 @@ window.__ModuleLoader__.load({
321
334
  cd_tight: '离{edgeName} {bar} 只有 {px}px(留 16px 以上)',
322
335
  cd_jserr: '{msg}{at}',
323
336
  cd_missing: '{what} {src} 载不出来(路径写错了,或者文件不在)',
337
+ cd_mockmiss: '用到了 {paths},mock.json 里没有(显示出来是空的)',
324
338
  cd_capsule: '伸进右上角胶囊 {px}px(胶囊是微信画的、盖不住:顶栏右边从 x={x} 起空着)',
325
339
  cd_island: '被灵动岛挡住 {px}px(灵动岛在 y 11–45:状态栏中间空着,内容放到状态栏下面)',
326
340
  cd_homebar: '{bar} 里的字或图标伸进底部横条区 {px}px(底部留 34px:栏加 padding-bottom: 34px,预览里 env(safe-area-inset-bottom) 是 0)',
@@ -722,6 +736,14 @@ window.__ModuleLoader__.load({
722
736
  pageSet: '页面设置',
723
737
  dPageSet: '类型、画幅、多尺寸、深色模式、刷新…',
724
738
  scrSearch: '搜屏名',
739
+ stMenuT: '「{name}」的状态',
740
+ stDefault: '默认',
741
+ stTip: '这一屏有 {n} 个状态',
742
+ dState: '同一个页面的几种样子(空的、有数据、已付款…)。点开换着看',
743
+ stSide: '并排看全部状态',
744
+ dStAll: '这一屏的每个状态并排摆在画布上',
745
+ stAllOn: '全部状态 · {name}',
746
+ stPickNote: '状态:{state}({label})——改这个状态时只动 [data-state="{state}"] 下的样式,别影响别的状态',
725
747
  scrNone: '没有对得上的屏',
726
748
  scrCount: '{n} / {m} 屏',
727
749
  scrKeyPick: '选',
@@ -1076,6 +1098,36 @@ window.__ModuleLoader__.load({
1076
1098
  anHelp: '模型读完设计,把规则、状态、流程写成一条条标注;点一条,页面上找到它。',
1077
1099
  hpLookSet: '点色块直接改颜色,所有屏一起变,点「保存」才写进文件;字体、形状点一项会放进对话,接着说怎么改。',
1078
1100
  histHelp: '模型每轮改完、你每次手调保存,都会自动存一版:能和现在并排比,也能退回去。',
1101
+ data: '数据',
1102
+ dData: '原型里点出来的数据:随时看、随手改、一键重置',
1103
+ dataHelp: '原型里点出来的变化都记在这,换页、刷新都还在。在这里改,页面马上跟着变;「存成初始数据」写回 mock.json,以后重置就回到这里。',
1104
+ dataWait: '正在读数据…',
1105
+ dataNoneT: '读不到数据',
1106
+ dataNone: '预览页面没开起来;关掉面板再开一次试试',
1107
+ dataBadT: 'mock.json 读不出来',
1108
+ dataFix: '让模型修好',
1109
+ dataFixText: 'mock.json 读不出来({err})。请修好它:要是一个 JSON 对象,原型里用到的字段都留着。',
1110
+ dataN: '改过 {n} 处(和 mock.json 比)',
1111
+ dataSame: '和 mock.json 一样',
1112
+ dataReset: '重置',
1113
+ dataResetTip: '所有屏一起回到 mock.json 里的初始数据',
1114
+ dataResetDone: '数据已重置',
1115
+ dataSave: '存成初始数据',
1116
+ dataSaveTip: '把现在的数据写回 mock.json,以后重置就回到这里',
1117
+ dataSaved: '已存成初始数据',
1118
+ dataNoMock: 'mock.json 不在了,没存',
1119
+ dataChanged: 'mock.json 刚被改过(模型或别的窗口),没存,免得把新的盖掉;面板会换成新的那份',
1120
+ dataBadFile: 'mock.json 读不出来,先让模型修好再存',
1121
+ dataBig: '数据太大存不下(最多 1 MB)',
1122
+ dataFail: '没改成:{msg}',
1123
+ dataNull: '空',
1124
+ dataItems: '{n} 条',
1125
+ dataKeys: '{n} 项',
1126
+ dataMore: '还有 {n} 条没列出来',
1127
+ dataAdd: '加一条',
1128
+ dataAddTip: '照最后一条复制一条',
1129
+ dataDel: '删掉这条',
1130
+ dataChg: '改过',
1079
1131
  styleHelp: '拖滑块时页面上先看效果,还没写进文件;满意了点「保存」,或点「让模型改」交给模型写进样式表。',
1080
1132
  hoHelp: '模型先写一份交接说明,再一屏一屏做;每屏做完自动和设计稿比一次,差多少写在「做完怎么验」里。',
1081
1133
  inPick: '选图片',
@@ -1378,10 +1430,13 @@ window.__ModuleLoader__.load({
1378
1430
  exportedHtml: 'Exported {name} ({n} screens; anyone can open it with a double-click)',
1379
1431
  exportedHtmlMiss: 'Exported {name} ({n} screens, {miss} could not be read)',
1380
1432
  htmlTooBig: 'Too many images: the demo would be over 150 MB, so nothing was exported. Try with fewer screens',
1433
+ htmlImgBig: 'An image referenced in the mock data (mock.json) is too big (12 MB each, 60 MB in total at most) to fit in the demo, so nothing was exported. Try a smaller image',
1434
+ htmlMockBig: 'mock.json is too big (over 1 MB) to carry its data into the demo, so nothing was exported. Replace large content (like base64 images) with image file paths and try again',
1381
1435
  htmlNoScreens: 'None of the screens could be read (moved or deleted?), so nothing was exported',
1382
1436
  xoWarn: 'Some content would be cut off. Have a look first',
1383
1437
  xoChecking: 'Measuring pages…',
1384
1438
  xoClean: 'Nothing will be cut off.',
1439
+ 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
1440
  xoOver: '{n} page(s) are larger than the canvas and will be cut off',
1386
1441
  xoLong: '{n} long page(s): only the first screen is captured',
1387
1442
  xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
@@ -1393,9 +1448,10 @@ window.__ModuleLoader__.load({
1393
1448
  xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
1394
1449
  xoAgain: 'Check again',
1395
1450
  xoGone: 'The design changed, so this export was cancelled',
1451
+ xoStFail: "Couldn't read which states each screen has, so nothing was exported. Try exporting again",
1396
1452
  xoJobGone: 'The export was interrupted (it waited too long or DSH restarted). Please export again',
1397
1453
  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',
1454
+ xoCut: 'At most 1000 pages per export; the last {n} were left out',
1399
1455
  xoResize: 'Fit canvas to content ({size})',
1400
1456
  xoFull: 'Switch to full page',
1401
1457
  xoWhich: 'Which screens',
@@ -1406,6 +1462,8 @@ window.__ModuleLoader__.load({
1406
1462
  xoPick: 'Pick some…',
1407
1463
  xoPickN: '{n} picked',
1408
1464
  xoPickNone: 'Pick at least one',
1465
+ xoStates: 'One page per state',
1466
+ xoStatesN: '+{n} pages',
1409
1467
  xoPre: 'Before exporting',
1410
1468
  xoWho: ' ({list})',
1411
1469
  xoPages: '{n} pages',
@@ -1442,6 +1500,12 @@ window.__ModuleLoader__.load({
1442
1500
  checkLayout: 'The page was not laid out yet, so it was not measured. Check again in a moment.',
1443
1501
  checkNote: 'Only measurable layout problems; whether it looks good is up to you',
1444
1502
  checkNoneTip: 'Measured {s} screens, no layout problems found',
1503
+ dfHead: 'Shared parts differ across screens · a heads-up, not a problem',
1504
+ dfItem: '{v} versions across {n} screens',
1505
+ dfMore: '{n} more parts like this',
1506
+ dfTip: 'Click to put “unify this part” in the message box',
1507
+ 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.',
1508
+ dfNone: 'unset',
1445
1509
  checkAsk: '[Design check] Found {n} problems:',
1446
1510
  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
1511
  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:',
@@ -1464,6 +1528,7 @@ window.__ModuleLoader__.load({
1464
1528
  ck_tight: 'Too close to a fixed bar',
1465
1529
  ck_jserr: 'Script error',
1466
1530
  ck_missing: 'File failed to load',
1531
+ ck_mockmiss: 'Not in the mock data',
1467
1532
  ck_capsule: 'Under the mini program capsule',
1468
1533
  ck_island: 'Under the Dynamic Island',
1469
1534
  ck_homebar: 'In the home indicator area',
@@ -1494,6 +1559,7 @@ window.__ModuleLoader__.load({
1494
1559
  cd_tight: 'only {px}px from the {edgeName} {bar} (leave 16px or more)',
1495
1560
  cd_jserr: '{msg}{at}',
1496
1561
  cd_missing: '{what} {src} did not load (wrong path, or the file is missing)',
1562
+ cd_mockmiss: 'Uses {paths}, which mock.json does not have (shows up empty)',
1497
1563
  cd_capsule: '{px}px under the top-right capsule (WeChat draws it on top; keep the top bar clear from x={x})',
1498
1564
  cd_island: '{px}px under the Dynamic Island (it sits at y 11–45: keep the middle of the status bar empty and start content below the status bar)',
1499
1565
  cd_homebar: 'text or icons in {bar} reach {px}px into the home indicator area (leave 34px: give the bar padding-bottom: 34px; env(safe-area-inset-bottom) is 0 in the preview)',
@@ -1894,6 +1960,14 @@ window.__ModuleLoader__.load({
1894
1960
  pageSet: 'Page setup',
1895
1961
  dPageSet: 'Type, canvas size, sizes, dark mode, reload…',
1896
1962
  scrSearch: 'Find a screen',
1963
+ stMenuT: 'States of "{name}"',
1964
+ stDefault: 'default',
1965
+ stTip: 'This screen has {n} states',
1966
+ dState: 'Different looks of the same page (empty, loaded, paid…). Click to switch',
1967
+ stSide: 'See all states side by side',
1968
+ dStAll: 'Lay every state of this screen side by side on the canvas',
1969
+ stAllOn: 'All states · {name}',
1970
+ 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
1971
  scrNone: 'No screen matches',
1898
1972
  scrCount: '{n} / {m}',
1899
1973
  scrKeyPick: 'move',
@@ -2247,6 +2321,36 @@ window.__ModuleLoader__.load({
2247
2321
  anHelp: 'The model reads the design and writes its rules, states and flows as notes. Click a note to find it on the page.',
2248
2322
  hpLookSet: 'Click a swatch to change a color; every screen follows, and Save writes it to the file. Click a font or shape item to add it to the chat and say how to change it.',
2249
2323
  histHelp: 'A version is saved after every model turn and every manual save: compare it with now side by side, or go back to it.',
2324
+ data: 'Data',
2325
+ dData: 'The data behind the clickable prototype: view it, edit it, reset it',
2326
+ dataHelp: 'Everything you click in the prototype is kept here and survives page changes and reloads. Edit it here and the pages follow at once; "Save as initial data" writes it back to mock.json, so Reset returns here from then on.',
2327
+ dataWait: 'Reading the data…',
2328
+ dataNoneT: 'Could not read the data',
2329
+ dataNone: 'The preview page did not open; close this panel and open it again',
2330
+ dataBadT: 'mock.json cannot be read',
2331
+ dataFix: 'Ask the model to fix it',
2332
+ dataFixText: 'mock.json cannot be read ({err}). Please fix it: it must be a JSON object, and keep every field the prototype uses.',
2333
+ dataN: '{n} changes (compared with mock.json)',
2334
+ dataSame: 'Same as mock.json',
2335
+ dataReset: 'Reset',
2336
+ dataResetTip: 'Every screen goes back to the initial data in mock.json',
2337
+ dataResetDone: 'Data reset',
2338
+ dataSave: 'Save as initial data',
2339
+ dataSaveTip: 'Write the current data back to mock.json; Reset returns here from then on',
2340
+ dataSaved: 'Saved as initial data',
2341
+ dataNoMock: 'mock.json is gone, so nothing was saved',
2342
+ dataChanged: 'mock.json was just changed (by the model or another window), so nothing was saved to avoid overwriting it; the panel will switch to the new data',
2343
+ dataBadFile: "mock.json can't be read; have the model fix it before saving",
2344
+ dataBig: 'The data is too big to save (1 MB at most)',
2345
+ dataFail: 'Not changed: {msg}',
2346
+ dataNull: 'empty',
2347
+ dataItems: '{n} items',
2348
+ dataKeys: '{n} fields',
2349
+ dataMore: '{n} more not listed',
2350
+ dataAdd: 'Add one',
2351
+ dataAddTip: 'Copy the last item',
2352
+ dataDel: 'Delete this item',
2353
+ dataChg: 'Changed',
2250
2354
  styleHelp: 'Dragging a slider previews the change on the page without touching the file. Click Save when you like it, or Ask the model to write it into the stylesheet.',
2251
2355
  hoHelp: 'The model writes a handoff note first, then builds one screen at a time; each finished screen is compared with the design, and the difference shows under “How it gets checked”.',
2252
2356
  inPick: 'Choose images',
@@ -3071,6 +3175,20 @@ window.__ModuleLoader__.load({
3071
3175
  .ddp-cell:hover .ddp-act,.ddp-cell.sel .ddp-act{display:flex}
3072
3176
  .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
3177
  .ddp-cell.sel .ddp-vt{background:rgba(77,107,254,.14);color:var(--dd-acc,${ACCENT})}
3178
+ /* 一页多状态(#30):屏名旁的「状态 ▾」。看的是默认状态时淡灰;换到别的状态带一点主色(提醒这屏现在不是默认的样子) */
3179
+ .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;
3180
+ 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}
3181
+ .ddp-stt:hover,.ddp-stt.on{background:rgba(127,127,127,.22);color:var(--dsw-alias-label-primary)}
3182
+ .ddp-stt.alt{background:rgba(77,107,254,.13);color:var(--dd-acc,${ACCENT})}
3183
+ .ddp-stt.alt:hover,.ddp-stt.alt.on{background:rgba(77,107,254,.22)}
3184
+ .ddp-stt>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3185
+ .ddp-stt svg{width:12px;height:12px;flex:none}
3186
+ .ddp-stt svg:last-child{width:10px;height:10px;opacity:.65}
3187
+ .ddp-stt:focus-visible{outline:2px solid var(--dd-acc,${ACCENT});outline-offset:1px}
3188
+ @container (max-width:104px){.ddp-stt>span{display:none}.ddp-stt{padding:0 4px}}
3189
+ /* 和「用这版」一样钉在最右、悬停不变大小:小按钮从它左边冒出来挤的是屏名,鼠标对着它时它不会跑开(不然点到冒出来的「导出」) */
3190
+ .ddp-lab>.ddp-stt{order:3;margin-left:auto}
3191
+ .ddp-cell:hover .ddp-lab>.ddp-stt,.ddp-cell.sel .ddp-lab>.ddp-stt{margin-left:0}
3074
3192
  .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
3193
  background:rgba(77,107,254,.12);color:var(--dd-acc,${ACCENT});font:inherit;font-size:11px;font-weight:500;cursor:pointer}
3076
3194
  .ddp-take:hover{background:rgba(77,107,254,.2)}
@@ -3378,6 +3496,18 @@ body[data-ds-dark-theme] .ddp{color-scheme:dark;
3378
3496
  /* 名字长时先缩项目名(最多缩到 5.5 字宽);换屏器上是「画布」或短屏名(≤6 字宽)时不缩,长屏名两边按比例缩 */
3379
3497
  @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
3498
  .ddp .dd-where.fix{flex-shrink:0}
3499
+ /* 单看时顶栏屏名后面的「状态 ▾」:和屏名那一块一样高、一样的底 */
3500
+ .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}
3501
+ .ddp .dd-bar>.ddp-stt:hover,.ddp .dd-bar>.ddp-stt.on{background:var(--dd-f2);color:var(--dsw-alias-label-primary)}
3502
+ .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)}
3503
+ .ddp .dd-bar>.ddp-stt svg{width:14px;height:14px}
3504
+ .ddp .dd-bar>.ddp-stt svg:last-child{width:11px;height:11px}
3505
+ @container (max-width:520px){.ddp .dd-bar>.ddp-stt>span{display:none}.ddp .dd-bar>.ddp-stt{padding:0 7px}}
3506
+ /* 状态菜单:浮在台面上,位置由打开它的那个「状态 ▾」定 */
3507
+ .ddp .ddp-menu.ddp-stmenu{position:absolute;right:auto;z-index:60;width:248px;max-width:calc(100% - 16px)}
3508
+ .ddp-stmenu .ls>button>em{flex:none;max-width:42%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3509
+ .ddp-stmenu .ls>button>.ck{width:15px;flex:none}
3510
+ .ddp-stmenu .ls>button.hi,.ddp-stmenu>button.hi{background:var(--dd-f2,rgba(127,127,127,.12))}
3381
3511
  /* 再窄(DSH 右侧栏最窄约 300):画布那格只留格子和 ▾;≤390 单看也只留格子和 ▾(屏名在菜单里);≤360 再去掉斜杠、间距收一点,「转成代码」不被切 */
3382
3512
  @container (max-width:400px){.ddp .dd-where.cv .ddp-addr .lb2{display:none}.ddp .dd-where.cv .ddp-addr{padding:0 8px}}
3383
3513
  @container (max-width:390px){.ddp .dd-where .ddp-addr .lb2{display:none}.ddp .dd-where .ddp-addr{padding:0 8px}}
@@ -3639,6 +3769,8 @@ body:not([data-ds-dark-theme]) .ddp .dd-seg::before{box-shadow:var(--dd-sh1)}
3639
3769
  .ddp .dd-pk .on i{background:var(--dd-au);box-shadow:none}
3640
3770
  .ddp .dd-pk i svg{width:10px;height:10px;stroke-width:3;animation:dd-pop .26s var(--dd-spring) backwards}
3641
3771
  .ddp .dd-pk span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3772
+ .ddp .dd-pk.dd-xst{max-height:none;overflow:visible;padding:8px 6px 0;margin-top:6px;border-top:1px solid var(--dd-line)}
3773
+ .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
3774
  .ddp .dd-xch{gap:6px;margin:0 0 16px}
3643
3775
  .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
3776
  .ddp .ddp-xo .dd-col>.dd-seg{margin-bottom:16px}
@@ -4184,6 +4316,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
4184
4316
  .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
4317
  .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
4318
  .ddp .dd-cks>.dd-ckerr svg{width:14px;height:14px;flex:none;margin-top:1px;color:var(--dd-warn)}
4319
+ /* 部件不一致(#30):问题下面单独一组,灰圆点「≠」,不算进问题数 */
4320
+ .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)}
4321
+ .ddp .dd-cks>.dd-ckgrp:first-child{margin-top:0;padding-top:2px;border-top:0}
4322
+ .ddp .dd-cks>.dd-ckgrp.more{margin:0 2px;padding:4px 12px;border-top:0}
4323
+ .ddp .dd-cks>.ok+.dd-ckgrp{margin-top:2px}
4324
+ .ddp .dd-ck .no.df{background:var(--dd-f2);color:var(--dd-t2);font-weight:600}
4325
+ .ddp .dd-ck.df .nm code{font:500 12px/18px ui-monospace,SFMono-Regular,Menlo,monospace}
4187
4326
  .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
4327
  @keyframes dd-ckin{from{opacity:0;transform:translateY(5px)}}
4189
4328
  /* 1.0 版本面板:一排卡片(缩略图 · 第几版 · 什么时候 · 谁改的和改了什么),左边是现在 */
@@ -4234,6 +4373,37 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
4234
4373
  .ddp .ddp-lktw .dd-seg>button{height:30px}
4235
4374
  .ddp .ddp-lktw .dd-chips{margin-top:0}
4236
4375
  /* 空着:一圈极光 + 标题 + 一句说明 + 一个按钮 */
4376
+ .ddp .dd-mkbr{position:absolute;width:0;height:0;border:0;visibility:hidden;pointer-events:none}
4377
+ /* 「数据」:一行一个字段,缩进看层级;改过的打个橙点 */
4378
+ .ddp .dd-sheet .dd-in>*>.bd.dd-mk{display:flex;flex-direction:column;gap:1px;padding:6px 8px 12px}
4379
+ .ddp .dd-mkr{display:flex;align-items:center;gap:8px;min-height:34px;padding:0 6px 0 calc(28px + var(--d,0) * 16px);border-radius:9px;animation:dd-ckin .3s var(--dd-out) backwards}
4380
+ .ddp .dd-mkr:hover{background:var(--dd-f1)}
4381
+ .ddp .dd-mkr>.k,.ddp .dd-mkr .fold>.k{flex:0 1 auto;min-width:0;max-width:46%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dd-t2);font:12px/18px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
4382
+ .ddp .dd-mkr>.v{flex:1 1 auto;min-width:0;display:flex;justify-content:flex-end;align-items:center}
4383
+ .ddp .dd-mkr .fold{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:6px;height:30px;margin-left:-20px;padding:0 4px;border:0;background:none;color:inherit;font:inherit;cursor:pointer;text-align:left}
4384
+ .ddp .dd-mkr .fold>svg{width:14px;height:14px;flex:none;color:var(--dd-t3);transition:transform .16s var(--dd-out)}
4385
+ .ddp .dd-mkr.op .fold>svg{transform:rotate(90deg)}
4386
+ .ddp .dd-mkr .fold>.k{max-width:none;color:var(--dd-t1);font-weight:600}
4387
+ .ddp .dd-mkr .ct{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dd-t3);font-size:11.5px}
4388
+ .ddp .dd-mkr input.tx{width:100%;max-width:280px;height:28px;padding:0 9px;border:0;border-radius:8px;background:var(--dd-f1);box-shadow:inset 0 0 0 1px var(--dd-line);color:var(--dd-t1);font:inherit;font-size:12.5px;text-align:right;text-overflow:ellipsis;transition:box-shadow .14s var(--dd-out),background .14s var(--dd-out)}
4389
+ .ddp .dd-mkr input.tx.num{max-width:120px;font-variant-numeric:tabular-nums}
4390
+ .ddp .dd-mkr input.tx:hover{box-shadow:inset 0 0 0 1px var(--dd-line2)}
4391
+ .ddp .dd-mkr input.tx:focus{outline:none;background:var(--dd-s1);box-shadow:inset 0 0 0 1.5px var(--dd-acc);text-align:left}
4392
+ .ddp .dd-mkr .sw{display:inline-flex;align-items:center;height:28px;padding:0 2px;border:0;background:none;cursor:pointer}
4393
+ .ddp .dd-mkr .nul{color:var(--dd-t4);font-style:italic;font-size:12px}
4394
+ .ddp .dd-mkr .chg{width:7px;height:7px;flex:none;border-radius:50%;background:var(--dd-c4);box-shadow:0 0 0 3px color-mix(in srgb,var(--dd-c4) 22%,transparent)}
4395
+ .ddp .dd-mkr>.del{width:24px;height:24px;flex:none;display:grid;place-items:center;padding:0;border:0;border-radius:7px;background:none;color:var(--dd-t3);cursor:pointer;opacity:0;transition:opacity .12s var(--dd-out)}
4396
+ .ddp .dd-mkr>.del svg{width:12px;height:12px}
4397
+ .ddp .dd-mkr:hover>.del,.ddp .dd-mkr>.del:focus-visible{opacity:1}
4398
+ .ddp .dd-mkr>.del:hover{background:var(--dd-err-bg);color:var(--dd-err)}
4399
+ .ddp .dd-mkr.more{color:var(--dd-t3);font-size:11.5px}
4400
+ .ddp .dd-mkr.add{min-height:30px}
4401
+ .ddp .dd-mkr.add .dd-bt{height:26px;padding:0 9px;font-size:12px}
4402
+ .ddp .dd-mkerr{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;margin:4px 2px 8px;padding:10px 10px 10px 12px;border-radius:var(--dd-r3);background:var(--dd-err-bg);color:var(--dd-err);font-size:12px;line-height:18px}
4403
+ .ddp .dd-mkerr>svg{width:15px;height:15px;flex:none}
4404
+ .ddp .dd-mkerr>span{flex:1 1 200px;min-width:0;overflow-wrap:anywhere}
4405
+ .ddp .dd-mkerr .dd-bt{height:30px;font-size:12.5px}
4406
+ @media (hover:none){.ddp .dd-mkr>.del{opacity:1}}
4237
4407
  .ddp .dd-emp{display:flex;flex-direction:column;align-items:center;gap:6px;padding:22px 16px 16px;color:var(--dd-t3);font-size:12px;line-height:18px;text-align:center;animation:dd-ckin .4s var(--dd-out) .08s backwards}
4238
4408
  .ddp .dd-emp>b{font-size:14px;font-weight:600;color:var(--dd-t1)}
4239
4409
  .ddp .dd-emp>span{max-width:440px;overflow-wrap:anywhere}
@@ -4499,6 +4669,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
4499
4669
  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
4670
  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
4671
  single: () => svg([h('rect', { key: 1, x: 5, y: 3.5, width: 14, height: 17, rx: 2.2 })]),
4672
+ // 一页多状态:一张卡片后面还叠着一张
4673
+ 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
4674
  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
4675
  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
4676
  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' })]),
@@ -4521,6 +4693,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
4521
4693
  image: () => svg([h('rect', { key: 1, x: 3.5, y: 4.5, width: 17, height: 15, rx: 2.2 }), h('circle', { key: 2, cx: 9, cy: 10, r: 1.7 }), h('path', { key: 3, d: 'M20 16l-4.5-4.5L7 19.5' })]),
4522
4694
  long: () => svg([h('rect', { key: 1, x: 6.5, y: 2.5, width: 11, height: 19, rx: 2 }), h('path', { key: 2, d: 'M9.5 7h5M9.5 10.5h5M9.5 14h3' })]),
4523
4695
  history: () => svg([h('path', { key: 1, d: 'M3.5 12a8.5 8.5 0 1 0 2.6-6.1' }), h('path', { key: 2, d: 'M3.5 4.5v4h4' }), h('path', { key: 3, d: 'M12 7.5V12l3 2' })]),
4696
+ data: () => svg([h('ellipse', { key: 1, cx: 12, cy: 6, rx: 7, ry: 3 }), h('path', { key: 2, d: 'M5 6v12c0 1.66 3.13 3 7 3s7-1.34 7-3V6' }), h('path', { key: 3, d: 'M5 12c0 1.66 3.13 3 7 3s7-1.34 7-3' })]),
4524
4697
  scan: () => svg([h('path', { key: 1, d: 'M4 8.5V6a2 2 0 0 1 2-2h2.5M15.5 4H18a2 2 0 0 1 2 2v2.5M20 15.5V18a2 2 0 0 1-2 2h-2.5M8.5 20H6a2 2 0 0 1-2-2v-2.5' }),
4525
4698
  h('rect', { key: 2, x: 9, y: 7.5, width: 6, height: 9, rx: 1.3 })]),
4526
4699
  sizes: () => svg([h('rect', { key: 1, x: 2.5, y: 5, width: 12, height: 9.5, rx: 1.4 }), h('path', { key: 2, d: 'M6.5 18h4' }),
@@ -6437,6 +6610,51 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
6437
6610
  return out
6438
6611
  }
6439
6612
 
6613
+ // ── 一页多状态(#30):<meta name="dsh-states" content="default:有数据, empty:空列表, paid:已付款">,<html data-state>,地址 ?state=paid ──
6614
+ const STATE_RE = /^[A-Za-z0-9_-]{1,32}$/ // 和 picker.js、serve.js 设状态那段一样
6615
+ const MAX_STATES = 8
6616
+ /** meta 内容 → [{ name, label }](第一个是默认状态;名字只认英文、数字、- _,后面可以跟「:中文名」);不到两个当没写 */
6617
+ function parseStates(raw) {
6618
+ const out = []
6619
+ for (const part of String(raw || '').split(/[,,;;\n]+/)) {
6620
+ const m = /^\s*([A-Za-z0-9_-]{1,32})\s*(?:[::=]\s*(.*?))?\s*$/.exec(part)
6621
+ if (!m || out.some((x) => x.name === m[1])) continue
6622
+ out.push({ name: m[1], label: String(m[2] || '').trim().slice(0, 24) || m[1] })
6623
+ if (out.length >= MAX_STATES) break
6624
+ }
6625
+ return out.length >= 2 ? out : []
6626
+ }
6627
+ /**
6628
+ * 单看时页面里点了换状态的链接(#30):顶栏记着的就是要的这个(在页面里去了别的页、又点链接回来,页面显示的不是顶栏那个状态),
6629
+ * 顶栏、地址都不会变 → 'reload' 重新载一遍这屏(不然点了没反应);不然 'pick' 交给顶栏换。def:要的是默认状态
6630
+ */
6631
+ /** 页面报上来的状态那段里有「#mock」那行:这页的状态跟着模拟数据走(不带状态 = 数据里那个,第一个状态要点名) */
6632
+ function followsMock(raw) {
6633
+ return /^#mock\n/.test(String(raw || ''))
6634
+ }
6635
+ function stateGoPlan(src, d) {
6636
+ let had = ''
6637
+ try { had = new URL(src).searchParams.get('state') || '' } catch { /* 地址不认识:当默认 */ }
6638
+ return (had ? had === d.state : d.def === true) ? 'reload' : 'pick'
6639
+ }
6640
+ /** 换状态的链接带的锚点:接着载的那一帧带上(3 秒内有效,只用一次) */
6641
+ function withHashNext(url, hn, now) {
6642
+ return hn && typeof hn.hash === 'string' && now - hn.at < 3000 ? String(url).replace(/#.*$/, '') + hn.hash : url
6643
+ }
6644
+ /** 地址的路径(解码过;认不出给 '') */
6645
+ function pathOfUrl(url) {
6646
+ try { const p = new URL(url).pathname; try { return decodeURIComponent(p) } catch { return p } } catch { return '' }
6647
+ }
6648
+ /** 屏的地址换成某个状态(默认状态 / 空 = 去掉 ?state=) */
6649
+ function withState(url, state) {
6650
+ try {
6651
+ const u = new URL(url)
6652
+ if (state && STATE_RE.test(state)) u.searchParams.set('state', state)
6653
+ else u.searchParams.delete('state')
6654
+ return u.href
6655
+ } catch { return url }
6656
+ }
6657
+
6440
6658
  /** 'WxH'(没有就按类型默认)→ [w, h] */
6441
6659
  function sizeOf(size, kind) {
6442
6660
  const m = /^(\d{2,5})x(\d{2,5})$/.exec(String(size || ''))
@@ -6481,6 +6699,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
6481
6699
  const LAB = 34 // 每屏上面标题占的高度(屏幕像素,不跟着缩放)
6482
6700
  const GAP = 18 // 两屏之间最少隔开的屏幕像素
6483
6701
  const clampZ = (z) => Math.max(ZMIN, Math.min(ZMAX, z))
6702
+ const MAX_DOC_PAGES = 1000 // PDF / PPT 最多几页(和服务端 MAX_PAGES 一样)
6484
6703
  const LIVE_MAX = 24 // 同时跑几个 iframe。超过这么多屏,画布只挂镜头附近的(选中的那屏总在),导出时分批挂
6485
6704
  /** 该挂着的几屏:离镜头中心最近的 max 屏,选中的那屏排最前。cx、cy 是镜头中心在画布上的坐标 */
6486
6705
  function nearestLive(ids, pos, dw, dh, cx, cy, selId, max, prev) {
@@ -7185,7 +7404,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7185
7404
  /** 这一屏(预览服务器上的地址)打包后的取法。fresh:要求服务端别复用缓存、重新打包 */
7186
7405
  function bundleOf(href, sid, fresh) {
7187
7406
  let p
7188
- try { p = new URL(href).pathname } catch { return '' }
7407
+ let state = ''
7408
+ try { const u = new URL(href); p = u.pathname; state = u.searchParams.get('state') || '' } catch { return '' }
7189
7409
  try { p = decodeURIComponent(p) } catch { /* 原样 */ }
7190
7410
  p = p.replace(/^\/+/, '')
7191
7411
  let v = ''
@@ -7193,6 +7413,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7193
7413
  if (m) { v = m[1]; p = m[2] }
7194
7414
  if (!p || p.endsWith('/')) p += 'index.html'
7195
7415
  const q = { session: sid, key: p, v, parent: location.origin }
7416
+ if (state && STATE_RE.test(state)) q.state = state // 一页多状态(#30):打包时就把 <html data-state> 设好
7196
7417
  if (fresh) q.fresh = '1'
7197
7418
  return `${API}bundle?${new URLSearchParams(q)}`
7198
7419
  }
@@ -7442,6 +7663,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7442
7663
  }
7443
7664
  let url = P.current.src
7444
7665
  try { if (seed && seed.href && new URL(seed.href).origin === origin) url = seed.href } catch { /* 用原地址 */ }
7666
+ // 换状态的链接带了锚点(见 stateGo):这一帧带上,页面载好自己滚过去
7667
+ if (!seed) url = withHashNext(url, L.hashNext, Date.now())
7668
+ L.hashNext = null
7445
7669
  setFrames((fs) => [...fs, { id, src: url, dir: L.dir }])
7446
7670
  }
7447
7671
 
@@ -7511,6 +7735,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7511
7735
  L.tops.clear()
7512
7736
  L.gen++
7513
7737
  L.at = ''
7738
+ L.trail = []
7514
7739
  L.deps = null
7515
7740
  L.fails = 0
7516
7741
  L.floor = L.next
@@ -7589,11 +7814,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7589
7814
  L.seeds.delete(id)
7590
7815
  L.seedOf.delete(id)
7591
7816
  // 改动通知由右侧栏转告(见下面「本机预览」),页面别自己开 SSE;做出来的页面(ownEvents)不在设计目录里,让它自己听
7592
- postTo(id, { type: 'init', seed, relay: !P.current.ownEvents })
7817
+ // stateNav:这一帧本该显示哪一页(路径);页面里点了同一页换状态的链接才交给右侧栏(#30)
7818
+ postTo(id, { type: 'init', seed, relay: !P.current.ownEvents, stateNav: P.current.onStateGo ? pathOfUrl(P.current.src) : '' })
7593
7819
  break
7594
7820
  }
7595
7821
  case 'ready': {
7596
7822
  L.readied.add(id)
7823
+ // 这一帧写了哪几个状态(#30,远程看同一页换状态时认)
7824
+ if (!L.stBy) L.stBy = new Map()
7825
+ L.stBy.set(id, typeof d.states === 'string' ? parseStates(d.states.slice(0, 400)).map((x) => x.name) : [])
7826
+ if (L.stBy.size > 20) L.stBy.delete(L.stBy.keys().next().value)
7597
7827
  L.title = d.title || ''
7598
7828
  let fail = null
7599
7829
  if (d.err) {
@@ -7613,8 +7843,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7613
7843
  if (p.annotGo && list.some((x) => x.id === p.annotGo.current)) { postTo(id, { type: 'annotFocus', id: p.annotGo.current }); p.annotGo.current = '' }
7614
7844
  }
7615
7845
  }
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)
7846
+ // 写了哪几个状态(#30):在这一帧里点链接去了别的页(单看时可以)就不记——不然顶栏的状态菜单拿着别的页的状态,切了载的却是这屏
7847
+ const away = !!d.href && !!p.src && pathOfUrl(d.href) !== pathOfUrl(p.src)
7848
+ 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) })
7849
+ if (p.onHref && d.href) p.onHref(d.href, typeof d.states === 'string' ? d.states.slice(0, 400) : '')
7618
7850
  if (isCur) {
7619
7851
  postTo(id, { type: 'reveal' })
7620
7852
  postTo(id, { type: 'zoom', z: p.zoom || 1 })
@@ -7686,10 +7918,34 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
7686
7918
  case 'picked':
7687
7919
  if (isCur && p.picking && p.onPicked) p.onPicked(d.payload)
7688
7920
  break
7921
+ case 'stateGo': { // 单看时点了同一页换状态的链接(#30)
7922
+ // clear:状态跟着模拟数据走的页里点了不带状态的链接 → 去掉点名的状态(回到跟着数据)
7923
+ if (!isCur || !p.onStateGo || typeof d.state !== 'string' || !(STATE_RE.test(d.state) || (d.state === '' && d.clear === true))) break
7924
+ // 链接带的锚点(?state=paid#receipt):换好状态的那一帧载的时候带上(只认这一下,过会儿就不算了)
7925
+ L.hashNext = typeof d.hash === 'string' && /^#[^\s#]{1,200}$/.test(d.hash) ? { hash: d.hash, at: Date.now() } : null
7926
+ if (stateGoPlan(p.src, d) === 'reload') { L.at = ''; load(null, true) } else p.onStateGo(d.state)
7927
+ break
7928
+ }
7689
7929
  case 'nav':
7690
7930
  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 自己跳过去一样)
7931
+ 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 : '')
7932
+ else if (remOf(p)) {
7933
+ // 远程看:页面里点了跳页,这一框换成那一页(和本机预览时 iframe 自己跳过去一样)。
7934
+ // 带状态(#30)的连状态一起;data-back 按这一框走过的路退一步,没得退才去它写的地方
7935
+ // data-back 和本机预览一样去它写的地方(按走过的路退只在试用里有)
7936
+ if (!d.path) break
7937
+ const s = typeof d.state === 'string' && STATE_RE.test(d.state) ? d.state : ''
7938
+ // 单看时还在原来那页里、换这页写了的状态(#30):和本机预览一样交给顶栏换(状态标签跟着变);不带状态 = 回默认。
7939
+ // 去了别的页、老页面(没写状态)的链接照常换页
7940
+ const dec = (L.stBy && L.stBy.get(id)) || []
7941
+ if (p.onStateGo && d.back !== true && !L.at && d.path === pathOfUrl(p.src) && dec.length && (!s || dec.includes(s))) {
7942
+ if (stateGoPlan(p.src, { state: s, def: !s }) === 'reload') load(null, true)
7943
+ else p.onStateGo(s)
7944
+ break
7945
+ }
7946
+ L.at = origin + d.path + (s ? '?state=' + s : '')
7947
+ load(null)
7948
+ }
7693
7949
  break
7694
7950
  case 'edited':
7695
7951
  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 +9042,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
8786
9042
  * 体检面板(1.0):头上「5 屏 · 4 个问题」,问题排成卡片(宽了两列):圆点序号(红 = 严重、黄 = 一般,和页面上的记号一一对上,按屏各自编号),
8787
9043
  * 第一行 什么问题 · 哪段字,第二行 哪一屏 · 量出来多少;底栏 一句说明 | 再查一次 · 让模型改
8788
9044
  */
8789
- function CheckPanel({ t, head, ck, nameOf = (x) => x, onFocus, onFix, onAgain, onClose }) {
9045
+ /** 部件不一致的一条差在哪:padding 16px / 14px · border-radius 12px / 10px(who:每种写法后面带上哪几屏) */
9046
+ function driftDiff(t, it, who) {
9047
+ const scr = (keys) => keys.slice(0, 3).map((k) => String(k).replace(/\.html?$/i, '')).join(who === true ? '、' : ', ') + (keys.length > 3 ? ` +${keys.length - 3}` : '')
9048
+ return (it.props || []).map((p) => `${p.prop} ${(p.values || []).map((x) => (x.v || t('dfNone')) + (who ? `(${scr(x.keys || [])})` : '')).join(' / ')}`).join(who ? ';' : ' · ')
9049
+ }
9050
+
9051
+ function CheckPanel({ t, head, ck, nameOf = (x) => x, onFocus, onFix, onAgain, onDrift, onClose }) {
8790
9052
  const list = ck.list || []
8791
9053
  const n = list.reduce((m, x) => m + x.issues.length, 0)
8792
9054
  const multi = list.length > 1
@@ -8804,12 +9066,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
8804
9066
  })
8805
9067
  }
8806
9068
  const clean = !ck.running && !n && !list.some((sc) => sc.error)
9069
+ // 部件各屏写得不一样(#30):单独一组,不算进问题数;点一条把「统一它」放进输入框
9070
+ const df = !ck.running && ck.drift && ck.drift.items.length ? ck.drift : null
9071
+ const dfRows = df ? [
9072
+ h('div', { key: 'df:h', className: 'dd-ckgrp' }, t('dfHead')),
9073
+ ...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) },
9074
+ h('i', { className: 'no df' }, '≠'),
9075
+ h('span', { className: 'tx' },
9076
+ h('span', { className: 'nm' }, h('code', null, it.sel), ' · ' + t('dfItem', { n: it.screens, v: it.variants })),
9077
+ h('span', { className: 'vl' }, driftDiff(t, it, false))))),
9078
+ df.more ? h('div', { key: 'df:m', className: 'dd-ckgrp more' }, t('dfMore', { n: df.more })) : null,
9079
+ ] : []
8807
9080
  return h('div', { className: 'ddp-tokens ddp-check', onPointerDown: (e) => e.stopPropagation() },
8808
9081
  head,
8809
9082
  h('div', { className: 'bd dd-cks' + (clean ? ' clean' : '') },
8810
9083
  ...rows,
8811
9084
  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),
9085
+ 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,
9086
+ ...dfRows),
8813
9087
  h('footer', { className: 'dd-sf' },
8814
9088
  h('span', { className: 'note' }),
8815
9089
  h('button', { className: 'dd-bt ghost', onClick: onAgain, disabled: ck.running }, h(I.refresh), t('checkAgain')),
@@ -10031,6 +10305,44 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
10031
10305
  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
10306
  }
10033
10307
 
10308
+ /**
10309
+ * 一页多状态(#30)的状态菜单:画布上屏名旁、单看时顶栏的「状态 ▾」点出来。浮在台面上(屏名那一行会裁掉超出的部分),
10310
+ * 位置 at 是相对台面的。点外面、按 Esc 收起;↑↓ 回车也能选
10311
+ */
10312
+ function StateMenu({ t, at, name, list, cur, onPick, onAll, allOn, onClose }) {
10313
+ const ref = useRef(null)
10314
+ const [hi, setHi] = useState(() => Math.max(0, list.findIndex((x) => x.name === cur)))
10315
+ const closeR = useRef(onClose)
10316
+ closeR.current = onClose
10317
+ useEffect(() => {
10318
+ const off = (e) => { if (ref.current && !ref.current.contains(e.target) && !(e.target.closest && e.target.closest('.ddp-stt'))) closeR.current() }
10319
+ // 捕获阶段先收:别让同一下 Esc 再把单看退回画布、退出试用
10320
+ const esc = (e) => { if (isEsc(e)) { e.preventDefault(); e.stopPropagation(); closeR.current(true) } }
10321
+ document.addEventListener('pointerdown', off, true)
10322
+ window.addEventListener('keydown', esc, true)
10323
+ try { if (ref.current) ref.current.focus({ preventScroll: true }) } catch { /* 拿不到焦点也能点 */ }
10324
+ return () => {
10325
+ document.removeEventListener('pointerdown', off, true)
10326
+ window.removeEventListener('keydown', esc, true)
10327
+ }
10328
+ }, [])
10329
+ const pick = (x) => { onPick(x.name); onClose(true) }
10330
+ const key = (e) => {
10331
+ if (e.key === 'ArrowDown') { e.preventDefault(); setHi((i) => Math.min(list.length - (onAll ? 0 : 1), i + 1)) }
10332
+ else if (e.key === 'ArrowUp') { e.preventDefault(); setHi((i) => Math.max(0, i - 1)) }
10333
+ else if (e.key === 'Enter') { e.preventDefault(); if (hi < list.length) pick(list[hi]); else if (onAll) { onAll(); onClose(true) } }
10334
+ }
10335
+ 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 },
10336
+ h('div', { className: 'hd' }, t('stMenuT', { name })),
10337
+ h('div', { className: 'ls' },
10338
+ ...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) },
10339
+ h('span', null, x.label),
10340
+ h('em', null, i === 0 ? (x.label === x.name ? t('stDefault') : x.name + ' · ' + t('stDefault')) : x.label === x.name ? '' : x.name),
10341
+ x.name === cur ? h(I.check) : h('i', { className: 'ck', 'aria-hidden': true })))),
10342
+ onAll ? h('div', { className: 'sp' }) : null,
10343
+ 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)
10344
+ }
10345
+
10034
10346
  // 左上屏名 ▾:换屏(画布 / 某一屏)、多尺寸、类型、打开别的页面——「在看什么、怎么看」都在这一个菜单里
10035
10347
  /** 屏名菜单里的「画幅」一行(#23):显示现在多大,点「自定义…」填宽×高,改过的能恢复默认 */
10036
10348
  function SizeRow({ t, size, custom, onSize, done }) {
@@ -10191,7 +10503,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
10191
10503
  // 几百屏的设计(#29):只列前 12 个名字
10192
10504
  return t('pubScreens', { n: list.length, names: list.slice(0, 12).join(t('sep')) + (list.length > 12 ? t('pubMoreNames') : '') })
10193
10505
  })()
10194
- const errText = (r) => (r.error === 'tooBig' ? t('pubTooBig') : r.error === 'noScreens' ? t('pubNoScreens') : t('pubFail', { msg: r.message || r.error || '' }))
10506
+ const errText = (r) => (r.error === 'tooBig' ? t('pubTooBig') : r.error === 'imgTooBig' ? t('htmlImgBig') : r.error === 'mockTooBig' ? t('htmlMockBig') : r.error === 'noScreens' ? t('pubNoScreens') : t('pubFail', { msg: r.message || r.error || '' }))
10195
10507
  // 接口拒了(点生成的那一刻换了设计、或者现在看的不是本地文件):别说成「没连上 Cloudflare」
10196
10508
  const errMsg = (m) => (m === 'designChanged' || m === 'not-file' ? t('pubGone') : t('pubFail', { msg: m }))
10197
10509
  const ended = (r) => (r.ended === 'expired' ? t('pubEndExpired') : r.ended === 'dropped' ? t('pubEndDropped') : r.ended === 'moved' ? t('pubEndMoved') : '')
@@ -10226,7 +10538,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
10226
10538
  h('button', { type: 'button', className: 'dd-bt pri', onClick: () => onCopy(res.url) }, h(I.copy), t('phoneCopy')),
10227
10539
  h('button', { type: 'button', className: 'dd-bt danger', onClick: stop }, h(I.stopSq), t('pubStop'))),
10228
10540
  res.state === 'reconnecting' ? h('p', { className: 'fine warn' }, t('pubReconnectingFine')) : null,
10229
- res.broken ? h('p', { className: 'fine warn' }, t('pubBroken', { why: res.broken === 'tooBig' ? t('pubTooBig') : res.broken === 'noScreens' ? t('pubNoScreens') : res.broken })) : null,
10541
+ res.broken ? h('p', { className: 'fine warn' }, t('pubBroken', { why: res.broken === 'tooBig' ? t('pubTooBig') : res.broken === 'imgTooBig' ? t('htmlImgBig') : res.broken === 'mockTooBig' ? t('htmlMockBig') : res.broken === 'noScreens' ? t('pubNoScreens') : res.broken })) : null,
10230
10542
  res.screens && res.screens.length ? h('p', { className: 'fine' }, t('pubShared', { n: res.screens.length, names: res.screens.join(t('sep')) })) : null),
10231
10543
  notes(['pubHow', 'pubLive', 'pubWarn']))
10232
10544
  } else if (res.dl && !res.dl.done && !res.tool) {
@@ -10345,6 +10657,120 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
10345
10657
  : h('div', { className: 'bd' }, emptyBox(I.history, t('histEmptyT'), t('histEmpty'))))
10346
10658
  }
10347
10659
 
10660
+ /**
10661
+ * 「数据」(#30 模拟数据):设计目录里有 mock.json 才有。面板里藏一个预览地址上的小页(/__dsh_design__/mock.html)当桥:
10662
+ * 它和各屏读写同一份数据(同一个地址的 localStorage),这里改了各屏马上跟着变,各屏点出来的变化也马上显示在这
10663
+ */
10664
+ const MOCK_SHOW = 200 // 一层最多列多少
10665
+ const mkSame = (a, b) => { try { return JSON.stringify(a) === JSON.stringify(b) } catch { return false } }
10666
+ const mkAt = (o, keys) => { let v = o; for (const k of keys) { if (v == null || typeof v !== 'object') return undefined; v = v[k] } return v }
10667
+ /** 叶子上不一样的有几处(和 mock.json 比) */
10668
+ function mkDiff(a, b) {
10669
+ if (mkSame(a, b)) return 0
10670
+ if (!a || !b || typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) !== Array.isArray(b)) return 1
10671
+ let n = 0
10672
+ for (const k of new Set([...Object.keys(a), ...Object.keys(b)])) n += mkDiff(a[k], b[k])
10673
+ return n
10674
+ }
10675
+ /** 列表里一条(对象)收着时旁边写什么:头一个文字 / 数字字段 */
10676
+ const mkPeek = (v) => { for (const x of Object.values(v || {})) if (typeof x === 'string' ? x.trim() : typeof x === 'number') return String(x).slice(0, 40); return '' }
10677
+ function DataPanel({ t, head, origin, fp, err, write, onFix, onSave, onSay }) {
10678
+ const fr = useRef(null)
10679
+ const [snap, setSnap] = useState(null) // 桥报上来的:{ data, initial, err }
10680
+ const [dead, setDead] = useState(false)
10681
+ const [fold, setFold] = useState(() => new Map()) // 路径 → 开 / 收(点过的才记)
10682
+ const got = useRef(false)
10683
+ useEffect(() => {
10684
+ got.current = false
10685
+ setSnap(null)
10686
+ setDead(false)
10687
+ const on = (e) => {
10688
+ const d = e.data
10689
+ if (!fr.current || e.source !== fr.current.contentWindow || e.origin !== origin || !d || d.ddpMock !== 1) return
10690
+ if (d.type === 'data') {
10691
+ got.current = true
10692
+ setDead(false)
10693
+ setSnap({ data: d.data && typeof d.data === 'object' ? d.data : {}, initial: d.initial && typeof d.initial === 'object' ? d.initial : {}, err: String(d.err || ''), fp: String(d.fp || '') })
10694
+ } else if (d.type === 'fail') onSay(t('dataFail', { msg: String(d.msg || '') }))
10695
+ }
10696
+ addEventListener('message', on)
10697
+ const tm = setTimeout(() => { if (!got.current) setDead(true) }, 8000)
10698
+ return () => { removeEventListener('message', on); clearTimeout(tm) }
10699
+ }, [origin, fp])
10700
+ const send = (m) => { const w = fr.current && fr.current.contentWindow; if (w) try { w.postMessage({ ddpMock: 1, ...m }, origin) } catch { /* 桥不在了 */ } }
10701
+ const setAt = (keys, value) => send({ type: 'set', keys, value })
10702
+ const bridge = h('iframe', { key: 'br:' + fp, ref: fr, className: 'dd-mkbr', src: `${origin}/__dsh_design__/mock.html?fp=${encodeURIComponent(fp || '')}`, title: 'mock', 'aria-hidden': true, tabIndex: -1, onLoad: () => send({ type: 'get' }) })
10703
+ const bad = (snap && snap.err) || err
10704
+ const errBox = bad ? h('div', { className: 'dd-mkerr', key: 'err' }, h(I.warn), h('span', null, h('b', null, t('dataBadT')), ' · ', bad), h('button', { className: 'dd-bt', onClick: () => onFix(bad) }, h(I.sparkle), t('dataFix'))) : null
10705
+ const n = snap ? mkDiff(snap.data, snap.initial) : 0
10706
+ const foot = h('footer', { className: 'dd-sf' },
10707
+ h('span', { className: 'note' }, snap ? (n ? t('dataN', { n }) : t('dataSame')) : ''),
10708
+ h('button', { className: 'dd-bt ghost', disabled: !n, ...tipA(t('dataReset'), t('dataResetTip')), onClick: () => { send({ type: 'reset' }); onSay(t('dataResetDone')) } }, h(I.refresh), t('dataReset')),
10709
+ h('button', { className: 'dd-bt pri go', disabled: !n || !write.ok || !!bad, ...tipA(t('dataSave'), bad ? t('dataBadFile') : write.ok ? t('dataSaveTip') : write.tip), onClick: () => snap && !bad && onSave(snap.data, snap.fp) }, t('dataSave')))
10710
+ const box = (body) => h('div', { className: 'ddp-tokens ddp-data', onPointerDown: (e) => e.stopPropagation() }, head, body, foot, bridge)
10711
+ if (!snap) {
10712
+ return box(h('div', { className: 'bd', key: 'w' }, errBox, dead
10713
+ ? emptyBox(I.data, t('dataNoneT'), t('dataNone'))
10714
+ : h('div', { className: 'dd-ckwait' }, h('i', { className: 'dd-spin' }), h('span', null, t('dataWait')))))
10715
+ }
10716
+ // 开着还是收着:点过的照点的;没点过的,最上一层开着,别的小的(不在列表里)开着
10717
+ const isOpen = (path, d, size, inArr) => (fold.has(path) ? fold.get(path) : d === 0 || (!inArr && d <= 2 && size <= 6))
10718
+ const toggle = (path, on) => setFold((m) => new Map(m).set(path, on))
10719
+ const editor = (keys, v) => {
10720
+ const nm = keys.join('.')
10721
+ if (typeof v === 'boolean') return h('button', { className: 'sw', role: 'switch', 'aria-checked': v, 'aria-label': nm, onClick: () => setAt(keys, !v) }, swOf(v))
10722
+ if (v === null) return h('span', { className: 'nul' }, t('dataNull'))
10723
+ const num = typeof v === 'number'
10724
+ const back = (el) => { el.value = String(v) }
10725
+ return h('input', {
10726
+ key: 'in:' + JSON.stringify(v),
10727
+ className: 'tx' + (num ? ' num' : ''),
10728
+ defaultValue: String(v),
10729
+ inputMode: num ? 'decimal' : undefined,
10730
+ spellCheck: false,
10731
+ 'aria-label': nm,
10732
+ onKeyDown: (e) => {
10733
+ if (e.nativeEvent.isComposing || e.keyCode === 229) return
10734
+ if (e.key === 'Enter') e.currentTarget.blur()
10735
+ else if (isEsc(e)) { e.stopPropagation(); back(e.currentTarget); e.currentTarget.blur() }
10736
+ },
10737
+ onBlur: (e) => {
10738
+ const s = e.currentTarget.value
10739
+ if (s === String(v)) return
10740
+ if (!num) return setAt(keys, s)
10741
+ const x = Number(s.trim())
10742
+ if (!s.trim() || !Number.isFinite(x)) return back(e.currentTarget)
10743
+ setAt(keys, x)
10744
+ },
10745
+ })
10746
+ }
10747
+ const rows = []
10748
+ const walk = (keys, label, v, d, inArr) => {
10749
+ const path = keys.join('\u0001')
10750
+ const chg = !mkSame(v, mkAt(snap.initial, keys))
10751
+ const dot = chg ? h('i', { className: 'chg', title: t('dataChg'), 'aria-label': t('dataChg') }) : null
10752
+ const del = inArr ? h('button', { className: 'del', ...tipA(t('dataDel')), onClick: () => { const up = keys.slice(0, -1); const a = mkAt(snap.data, up); if (Array.isArray(a)) setAt(up, a.filter((_, i) => String(i) !== keys[keys.length - 1])) } }, h(I.close)) : null
10753
+ const style = { '--d': d }
10754
+ if (v && typeof v === 'object') {
10755
+ const arr = Array.isArray(v)
10756
+ const ks = arr ? v.map((_, i) => String(i)) : Object.keys(v)
10757
+ const op = isOpen(path, d, ks.length, inArr)
10758
+ const peek = inArr && !arr && !op ? mkPeek(v) : ''
10759
+ rows.push(h('div', { key: path, className: 'dd-mkr grp' + (op ? ' op' : ''), style },
10760
+ h('button', { className: 'fold', 'aria-expanded': op, onClick: () => toggle(path, !op) }, h(I.chev), h('span', { className: 'k' }, label), dot, h('span', { className: 'ct' }, peek || t(arr ? 'dataItems' : 'dataKeys', { n: ks.length }))),
10761
+ del))
10762
+ if (!op) return
10763
+ for (const k of ks.slice(0, MOCK_SHOW)) walk([...keys, k], arr ? '#' + (Number(k) + 1) : k, v[k], d + 1, arr)
10764
+ if (ks.length > MOCK_SHOW) rows.push(h('div', { key: path + '\u0002more', className: 'dd-mkr more', style: { '--d': d + 1 } }, t('dataMore', { n: ks.length - MOCK_SHOW })))
10765
+ if (arr && v.length) rows.push(h('div', { key: path + '\u0002add', className: 'dd-mkr add', style: { '--d': d + 1 } }, h('button', { className: 'dd-bt ghost', ...tipA(t('dataAdd'), t('dataAddTip')), onClick: () => setAt(keys, [...v, JSON.parse(JSON.stringify(v[v.length - 1]))]) }, h(I.plus), t('dataAdd'))))
10766
+ return
10767
+ }
10768
+ rows.push(h('div', { key: path, className: 'dd-mkr', style }, h('span', { className: 'k', title: keys.join('.') }, label), dot, h('span', { className: 'v' }, editor(keys, v)), del))
10769
+ }
10770
+ for (const k of Object.keys(snap.data)) walk([k], k, snap.data[k], 0, false)
10771
+ return box(h('div', { className: 'bd dd-mk', key: 'tree' }, errBox, ...rows))
10772
+ }
10773
+
10348
10774
  /**
10349
10775
  * 画布:几屏排成网格,能拖、能缩放(触控板双指滑 = 平移,捏合 / ⌘ 滚轮 = 缩放)。
10350
10776
  * 平时每屏上盖一层「挡板」:点一下选中,双击只看这一屏;选取时拿掉挡板,直接在页面里点。
@@ -11013,7 +11439,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11013
11439
  return c
11014
11440
  }
11015
11441
 
11016
- function ExportPanel({ t, head, fmt = 'pdf', imgModes = [], onImg, kind, size, opts, setOpts, screens, items = [], curKey = '', canvas, rev, measure, onResize, onExport, onClose }) {
11442
+ function ExportPanel({ t, head, fmt = 'pdf', imgModes = [], onImg, kind, size, opts, setOpts, screens, items = [], stCount = null, curKey = '', canvas, rev, measure, onResize, onExport, onClose }) {
11017
11443
  const [im, setIm] = useState('')
11018
11444
  const imCur = imgModes.some((x) => x[0] === im) ? im : (imgModes[0] || [''])[0]
11019
11445
  const [list, setList] = useState(null)
@@ -11032,7 +11458,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11032
11458
  measure(tok).then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
11033
11459
  }, first ? 0 : 900)
11034
11460
  return () => { off = true; tok.off = true; clearTimeout(timer) }
11035
- }, [size.join('x'), screens, rev, again])
11461
+ }, [size.join('x'), screens, rev, again, opts.states ? 1 : 0])
11036
11462
  // 导出哪些:全部 / 只导当前这屏 / 挑几屏(挑的屏改名、删了就不算)
11037
11463
  const cur = items.find((x) => x.key === curKey) || items[0]
11038
11464
  const has = new Set(items.map((x) => x.key))
@@ -11040,7 +11466,11 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11040
11466
  const scope = opts.scope === 'cur' && cur ? 'cur' : opts.scope === 'pick' ? 'pick' : 'all'
11041
11467
  const keys = scope === 'cur' ? [cur.key] : scope === 'pick' ? items.map((x) => x.key).filter((k) => picked.includes(k)) : null
11042
11468
  const want = keys ? new Set(keys) : null
11043
- const count = keys ? keys.length : items.length
11469
+ // 每个状态各出一张(#30):写了状态的屏一个状态一页
11470
+ const stOf = (k) => (stCount && stCount[k] > 1 ? stCount[k] : 1)
11471
+ const anyStates = items.some((x) => stOf(x.key) > 1)
11472
+ const extra = anyStates ? (keys || items.map((x) => x.key)).reduce((m, k) => m + stOf(k) - 1, 0) : 0
11473
+ const count = (keys ? keys.length : items.length) + (opts.states ? extra : 0)
11044
11474
  // 量到的结果和 items 一一对应:只看这次要导的那些
11045
11475
  const mine = list ? list.map((m, i) => [m, items[i]]).filter(([, x]) => !want || (x && want.has(x.key))) : null
11046
11476
  // 和真导出同一套取景:PDF 页签里网页、邮件没选怎么截时放整页长图(不会裁),只有 PPT 截首屏
@@ -11075,7 +11505,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11075
11505
  }
11076
11506
  const ppt = fmt === 'pptx'
11077
11507
  const cols = opts.cols === 2 ? 2 : 1
11078
- const pages = Math.ceil(count / cols)
11508
+ const pages = Math.ceil(Math.min(count, MAX_DOC_PAGES) / cols)
11079
11509
  const long = opts.fit === 'page' || (!opts.fit && !ppt && (kind === 'web' || kind === 'email'))
11080
11510
  // 底栏一句话:格式 · 几页 · 多大 · 每页是图片
11081
11511
  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 +11523,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11093
11523
  h('div', { className: 'dd-col' },
11094
11524
  h('h6', null, t('xoWhich')),
11095
11525
  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) }) : ''),
11526
+ radio('all', t('xoAll', { n: items.length }), scope === 'all' ? t(canvas ? 'xoAllSub' : 'xoAllSub1', { n: items.length, m: pages }) : ''),
11097
11527
  items.length > 1 && cur ? radio('cur', t('xoCur', { name: cur.label })) : null,
11098
11528
  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)),
11529
+ 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),
11530
+ 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 }) },
11531
+ 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
11532
  h('div', { className: 'dd-col' },
11101
11533
  h('h6', null, t('xoLayout')),
11102
11534
  chips('layout', t('xoLayout'), [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
@@ -11117,6 +11549,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11117
11549
  rep && rep.ai ? h('p', { className: 'sm' }, t('xoAi', { n: rep.ai })) : null,
11118
11550
  rep && rep.fail ? h('p', { className: 'sm' }, t('xoFail', { n: rep.fail })) : null,
11119
11551
  rep && !cut && !rep.dead && !rep.fail ? h('p', null, h(I.check), t('xoClean')) : null,
11552
+ rep && opts.states && extra ? h('p', { className: 'sm' }, t('xoStNoCheck', { n: extra })) : null,
11120
11553
  rep ? h('div', { className: 'act' },
11121
11554
  rep.over && canFit ? h('button', { type: 'button', className: 'dd-xbt', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', ' × ') })) : null,
11122
11555
  (rep.long || rep.moved) && opts.fit !== 'page' ? h('button', { type: 'button', className: 'dd-xbt', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
@@ -11784,7 +12217,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11784
12217
  // 拖背景 / 挡板 = 平移;没拖动就算点了一下
11785
12218
  const onPointerDown = (e) => {
11786
12219
  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
12220
+ if (e.target.closest && e.target.closest('.ddp-zoom, .ddp-act, .ddp-take, .ddp-stt, .ddp-fail button')) return
11788
12221
  const keyEl = e.target.closest ? e.target.closest('[data-key]') : null
11789
12222
  const d = { x: e.clientX, y: e.clientY, cam: camRef.current, moved: false, key: keyEl ? keyEl.getAttribute('data-key') : '' }
11790
12223
  const move = (ev) => {
@@ -11859,7 +12292,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11859
12292
  },
11860
12293
  done ? h('i', { key: 'au', className: 'dd-au out', 'aria-hidden': true }, h('b')) : null,
11861
12294
  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),
12295
+ 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
12296
  cull && !(live && live.has(sc.id || sc.key)) ? props.sleep(sc, z) : props.render(sc, z, i),
11864
12297
  picking ? null : h('div', { className: 'ddp-shield', 'data-key': sc.key, title: items ? '' : t('openScreen'), style: { borderRadius: fr.r } })))
11865
12298
  })
@@ -11922,8 +12355,29 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11922
12355
  return list.map((x) => by.get(x.key) || x)
11923
12356
  }
11924
12357
 
12358
+ /**
12359
+ * 导出「每个状态各出一张」(#30):写了状态的屏按状态展开成几页(xs = 状态名)。默认状态那页 key 不变(别的屏跳过来落在它上面),
12360
+ * 其余几页 key 带 ?state=(原型里跳到某个状态的链接落在那页,见 doc 路由)
12361
+ */
12362
+ function byStates(list, statesFor) {
12363
+ const out = []
12364
+ for (const sc of list) {
12365
+ const ss = sc.v ? [] : statesFor(sc.key) || []
12366
+ if (ss.length < 2) { out.push(sc); continue }
12367
+ // 第一个状态也写明(状态跟着模拟数据走的屏,不写就是数据里那个状态,会和后面某张重复)
12368
+ ss.forEach((s, i) => out.push({ ...sc, url: withState(sc.url, s.name), xs: s.name, xsLabel: s.label, xsFirst: i === 0 }))
12369
+ }
12370
+ return out
12371
+ }
12372
+ /** 某个状态那页的标题:「订单 · 梅林练」→「订单(已付款) · 梅林练」(屏名后面带上状态,产品名还在原处,拼大标题照样认得出) */
12373
+ function stateTitle(title, label) {
12374
+ const tag = /^[\x20-\x7e]*$/.test(label) ? ` (${label})` : `(${label})`
12375
+ const m = /\s*[·||—]\s*|\s+[-–]\s+/.exec(title)
12376
+ return m ? title.slice(0, m.index) + tag + title.slice(m.index) : title + tag
12377
+ }
12378
+
11925
12379
  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
12380
+ 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
12381
  const sayErr = (m, a) => say(m, a, true) // 没成的事:红色消息条,不自己走
11928
12382
  // 导出用的全部屏(#29):屏多过上限时右侧栏只显示最新的 60 屏,收起来的那些接在前面;没收起来就是显示的这些
11929
12383
  let every = x.every || shown
@@ -11986,16 +12440,27 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
11986
12440
  ghostQueue.current = job.catch(() => {})
11987
12441
  return job
11988
12442
  }
11989
- const measureAll = async (map, tok) => {
12443
+ const measureAll = async (map, tok, pool = every) => {
11990
12444
  const stamp = designSeq.current
11991
12445
  const list = []
11992
- for (const [i, sc] of every.entries()) {
12446
+ for (const [i, sc] of pool.entries()) {
11993
12447
  if (designSeq.current !== stamp || (tok && tok.off)) break // 设计换了 / 选项面板这一遍作废:别再等旧的屏
11994
- if (every.length > LIVE_MAX) say(t('xoCheckingN', { i: i + 1, n: every.length }))
12448
+ if (pool.length > LIVE_MAX) say(t('xoCheckingN', { i: i + 1, n: pool.length }))
11995
12449
  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
12450
  }
11997
12451
  return list
11998
12452
  }
12453
+ // 「每个状态各出一张」(#30):默认那页按默认状态截(画布上这屏选着别的状态也一样,见 byStates)。
12454
+ // 选项面板的预检也量默认状态,和导出对得上(xs 让它在背后另挂一个,不拿画布上正显示别的状态的那个)
12455
+ const toDefault = (sc) => {
12456
+ if (!sc.state || sc.v || !statesFor) return sc
12457
+ const ss = statesFor(sc.key) || []
12458
+ return ss.length >= 2 ? { ...sc, url: withState(sc.url, ss[0].name), state: '', xs: ss[0].name, xsLabel: ss[0].label, xsFirst: true } : sc
12459
+ }
12460
+ const precheck = (tok, def) => {
12461
+ const pool = def ? every.map(toDefault) : every
12462
+ return withFrames((map) => (tok && tok.off ? [] : measureAll(map, tok, pool)), undefined, pool)
12463
+ }
11999
12464
 
12000
12465
  // 图片 / 整套展示图 / PDF / PPT(菜单里的「选项」「打包」「分享」在面板里分流,见 doExport)
12001
12466
  const exportShots = async (mode, key, opts) => {
@@ -12017,7 +12482,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12017
12482
  if (gone()) { sayErr(t('xoGone')); return }
12018
12483
  // 面板里挑了「只导这屏 / 挑几屏」:只截这些(顺序照右侧栏)
12019
12484
  const want = opts && Array.isArray(opts.keys) ? new Set(opts.keys) : null
12020
- const list = want ? every.filter((sc) => want.has(ik(sc))) : every
12485
+ const base = want ? every.filter((sc) => want.has(ik(sc))) : every
12486
+ // 「每个状态各出一张」:写了状态的屏按状态展开(超过页数上限的不导,提示里说)。
12487
+ // 本地文件的设计这时再问一次服务端各屏写了哪几个状态(面板刚打开、刚换了设计时手上的可能还没回来,别按「没写」少导几页);问不到就不导
12488
+ let stFor = statesFor
12489
+ if (opts && opts.states && !ver && x.loadStates) {
12490
+ try { const map = await x.loadStates(); stFor = (key) => map[key] || [] } catch (e) { console.warn('[dsh-design-studio] 取状态失败', e); sayErr(t('xoStFail')); return }
12491
+ if (gone()) { sayErr(t('xoGone')); return }
12492
+ }
12493
+ let list = opts && opts.states && !ver && stFor ? byStates(base, stFor) : base
12494
+ if (list.length > base.length && list.length > MAX_DOC_PAGES) { cutN += list.length - MAX_DOC_PAGES; list = list.slice(0, MAX_DOC_PAGES) }
12021
12495
  if (!list.length) throw new Error('no screens')
12022
12496
  await withFrames(async (map) => {
12023
12497
  // 从菜单直接点:先量一遍,有内容会被裁就先给看清单(同样的结果只拦一次)
@@ -12051,7 +12525,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12051
12525
  const r = await captureOf(sc, long, map, maxH, aiShot)
12052
12526
  const cut = maxH && r.h > maxH
12053
12527
  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) })) })
12528
+ // 按状态展开的页:标题带上状态名;跳到某个状态的链接(?state=)落在那个状态那页,没展开就落在那屏
12529
+ 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
12530
  titles.push(title)
12056
12531
  n++
12057
12532
  } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
@@ -12161,11 +12636,11 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12161
12636
  } catch (e) {
12162
12637
  const m = String((e && e.message) || '')
12163
12638
  if (m === 'designChanged' || m === 'not-file') sayErr(t('xoGone'))
12164
- else if (m === 'tooBig' || m === 'noScreens') sayErr(t(m === 'tooBig' ? 'htmlTooBig' : 'htmlNoScreens'))
12639
+ else if (m === 'tooBig' || m === 'noScreens' || m === 'imgTooBig' || m === 'mockTooBig') sayErr(t(m === 'tooBig' ? 'htmlTooBig' : m === 'imgTooBig' ? 'htmlImgBig' : m === 'mockTooBig' ? 'htmlMockBig' : 'htmlNoScreens'))
12165
12640
  else sayErr(t('exportFail', { msg: m }), { label: t('retry'), run: () => exportHtml() })
12166
12641
  }
12167
12642
  }
12168
- return { withFrames, measureAll, exportShots, exportHtml, htmlBody, loadEvery }
12643
+ return { withFrames, measureAll, precheck, exportShots, exportHtml, htmlBody, loadEvery }
12169
12644
  }
12170
12645
 
12171
12646
  // ── 画笔标注(从预览面板里拆出来的):台面上看得到的几屏截图拼好、叠上画的,存进 refs/ 交给模型,或者复制
@@ -12358,7 +12833,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12358
12833
  // ── 设计体检(从预览面板里拆出来的):画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里
12359
12834
  // x:这一次画面的值和几个 ref;onOpen:开体检面板时收掉别的面板。自动量、check_design 回话的 effect 留在面板里
12360
12835
  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
12836
+ 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
12837
  const sayErr = (m, a) => say(m, a, true) // 没成的事:红色消息条,不自己走
12363
12838
  const closeCheck = () => {
12364
12839
  ckGen.current++
@@ -12384,13 +12859,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12384
12859
  setCk({ running: true, list: [] })
12385
12860
  const g = ++ckGen.current
12386
12861
  ckOpen.current = true
12862
+ // 共用部件各屏写得不一样(#30):服务端读文件比,和量页面一起跑;问不到就不显示这一组
12863
+ const dr = fileTarget && sid ? post('drift', { session: sid }).catch(() => null) : Promise.resolve(null)
12387
12864
  const out = await measure(checkList(), false)
12865
+ const d = await dr
12388
12866
  if (g !== ckGen.current) { // 量的时候面板关了 / 又量了一轮:这份结果作废;面板关着的话,这一轮画上的标记也清掉
12389
12867
  if (!ckOpen.current) for (const sc of out) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
12390
12868
  return out
12391
12869
  }
12392
12870
  if (canvas && shown.length > LIVE_MAX) say(t('checkPartial', { n: out.length }))
12393
- setCk({ running: false, list: out })
12871
+ setCk({ running: false, list: out, drift: d && Array.isArray(d.items) && d.items.length ? d : null })
12394
12872
  setCkCount(total(out))
12395
12873
  // 有问题的第一屏被面板挡着、在画布外面:挪过来
12396
12874
  const first = out.find((x) => x.issues.length)
@@ -12411,7 +12889,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12411
12889
  insert(formatCheck(t, ck.list, stRef.current), 'insertedSend')
12412
12890
  closeCheck()
12413
12891
  }
12414
- return { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues }
12892
+ // 部件不一致的一条:放进输入框(不发),用户看了再发
12893
+ const askDrift = (it) => insert(t('dfAsk', { sel: it.sel, n: it.screens, v: it.variants, diff: driftDiff(t, it, true) }), 'inserted')
12894
+ return { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues, askDrift }
12415
12895
  }
12416
12896
 
12417
12897
  // ── 调样式(从预览面板里拆出来的):点一个元素,面板里拖滑块先在页面上看效果;写回文件 = 并进它在源码里的 style 属性
@@ -12558,44 +13038,65 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12558
13038
  return { implLoad, implRecompare }
12559
13039
  }
12560
13040
 
13041
+ /**
13042
+ * 试用(演示)里走过的路:stack 是 [{ key 哪一屏, state 哪个状态(#30,'' = 页面默认的)}],最多记 30 步。
13043
+ * 点到的正好是上一步那屏(同一状态)就当返回(反向过场);写了 data-back 的按走过的路退一步,没得退才去它的 href
13044
+ */
12561
13045
  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
- })
13046
+ const { setDemo, demoSeq, fileTarget, defOf = () => '' } = x
13047
+ // 默认状态写不写都是同一屏(order.html 和 order.html?state=default):不然两种写法回默认,返回的路不一样
13048
+ const norm = (a, def = defOf(a.key)) => (a.state && a.state !== def ? a.state : '')
13049
+ const same = (a, b) => !!a && !!b && a.key === b.key && norm(a) === norm(b)
13050
+ const pop = (d, hash = '') => {
13051
+ const stack = d.stack.slice(0, -1)
13052
+ const to = stack[stack.length - 1]
13053
+ const last = d.layers[d.layers.length - 1]
13054
+ return { stack, layers: [last, { id: ++demoSeq.current, key: to.key, state: to.state || '', dir: -1, shown: false, ...(hash ? { hash } : null) }] }
12574
13055
  }
12575
- const demoRestart = () => setDemo((d) => {
12576
- if (!d || d.stack.length < 2) return d
13056
+ // hash:链接里的锚点(换到那一屏 / 那个状态后滚过去),只放在这一层的地址上,不算进走过的路
13057
+ const go = (d, at, hash = '') => {
13058
+ if (same(at, d.stack[d.stack.length - 1])) return d
13059
+ if (d.stack.length > 1 && same(at, d.stack[d.stack.length - 2])) return pop(d, hash) // 点回上一步(?state=default#receipt):锚点照带
12577
13060
  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) => {
13061
+ 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) }] }
13062
+ }
13063
+ const demoGo = (path, state, back, hash = '') => {
13064
+ const at = path ? { key: keyOfPath(path, fileTarget), state: state || '' } : null
13065
+ setDemo((d) => (!d ? d : back && d.stack.length > 1 ? pop(d) : at ? go(d, at, /^#[^\s#]{1,200}$/.test(hash || '') ? hash : '') : d))
13066
+ }
13067
+ const demoTo = (key, state = '') => setDemo((d) => (d ? go(d, { key, state: state || '' }) : d))
13068
+ const demoRestart = () => setDemo((d) => {
12581
13069
  if (!d || d.stack.length < 2) return d
12582
- const stack = d.stack.slice(0, -1)
12583
13070
  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 }] }
13071
+ const first = d.stack[0]
13072
+ return { stack: [first], layers: [last, { id: ++demoSeq.current, key: first.key, state: first.state || '', dir: -1, shown: false }] }
12585
13073
  })
13074
+ const demoBack = () => setDemo((d) => (d && d.stack.length > 1 ? pop(d) : d))
12586
13075
  const demoShown = (id) => {
12587
13076
  setDemo((d) => (d ? { ...d, layers: d.layers.map((l) => (l.id === id ? { ...l, shown: true } : l)) } : d))
12588
13077
  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
13078
  }
12590
- // 页面自己用脚本跳了(没走我们拦下的链接):只改记下的是哪一屏,不重载
12591
- const demoHref = (id, href) => {
13079
+ // 页面自己用脚本跳了(没走我们拦下的链接):只改记下的是哪一屏,不重载。
13080
+ // raw:这页 <meta name="dsh-states"> 写的(页面报上来的)。没写这个状态的(老页面自己拿 ?state= 当参数)当没带状态,
13081
+ // 不然记下来、地址一变又重载一遍,页面自己带的别的参数也丢了
13082
+ const demoHref = (id, href, raw) => {
12592
13083
  let key = ''
12593
- try { key = keyOfPath(decodeURIComponent(new URL(href).pathname), fileTarget) } catch { return }
13084
+ let state = ''
13085
+ const dec = parseStates(raw).map((x) => x.name)
13086
+ let given = ''
13087
+ try {
13088
+ const u = new URL(href)
13089
+ key = keyOfPath(decodeURIComponent(u.pathname), fileTarget)
13090
+ given = u.searchParams.get('state') || ''
13091
+ state = STATE_RE.test(given) && dec.includes(given) && (given !== dec[0] || followsMock(raw)) ? given : ''
13092
+ } catch { return }
12594
13093
  setDemo((d) => {
12595
13094
  if (!d) return d
12596
13095
  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)) }
13096
+ // 还是这一层载的那个地址(跨页链接带的 ?state= 那页没写,地址里照样有):没跳,别改记下的、别再载一遍
13097
+ // 没写状态的页(老页面自己拿 ?state= 当参数)自己换了参数:也不算换屏,别动这一层(一动地址就变、重载,参数丢了)
13098
+ if (last.id !== id || (last.key === key && (!dec.length || (last.state || '') === given || norm(last, followsMock(raw) ? '' : dec[0] || defOf(key)) === state))) return d
13099
+ 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
13100
  })
12600
13101
  }
12601
13102
  return { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref }
@@ -12625,6 +13126,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12625
13126
  const [info, setInfo] = useState({}) // 目录|屏 → { meta, title }(页面报上来的)
12626
13127
  const [tops, setTops] = useState({}) // 屏 → 顶栏右边是不是深色(小程序胶囊画白的)
12627
13128
  const setTop = (k, dk) => setTops((cur) => (cur[k] === dk ? cur : { ...cur, [k]: dk }))
13129
+ const [stSel, setStSel] = useState({}) // 目录|屏 → 选着看的状态(#30 一页多状态;默认状态不记)
13130
+ const [stMenu, setStMenu] = useState(null) // 状态菜单开在哪:{ key, x, y }
12628
13131
  const [sel, setSel] = useState('')
12629
13132
  const [panel, setPanel] = useState(false)
12630
13133
  const [lookTab, setLookTab] = useState('set') // 外观面板开在哪一页:set 整套 / tw 滑块 / style 换风格 / brand 品牌
@@ -12669,6 +13172,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12669
13172
  const [phone, setPhone] = useState(false) // 手机上看的面板
12670
13173
  const [pubP, setPubP] = useState(false) // 公网链接的面板
12671
13174
  const [multi, setMulti] = useState(false) // 多尺寸并排
13175
+ const [stAll, setStAll] = useState('') // 一页多状态(#30):把哪一屏的每个状态并排摆出来
12672
13176
  const ckGen = useRef(0) // 每量一次、每关一次面板 +1:量完发现不是最新的一次就不算数
12673
13177
  const ckOpen = useRef(false) // 面板开着(或正在量):过期的一次结果回来时别清掉新一轮的标记
12674
13178
  const [ck, setCk] = useState(null) // 设计体检:null = 面板关着;{ running, list: [{ key, label, url, issues, error }] }
@@ -12742,6 +13246,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12742
13246
  const [loadTick, setLoadTick] = useState(0) // 导出面板开着时页面又载入了一次:重新量
12743
13247
  const warned = useRef('') // 预检提醒过的结果:同样的结果只拦一次
12744
13248
  const [xo, setXo] = useState({ layout: 'auto', custom: '', fit: '', fitH: '', cols: 1 }) // 导出选项
13249
+ const [xStates, setXStates] = useState(null) // { target, map: { key: [{ name, label }] } }:导出面板开着时问服务端各屏写了哪几个状态(收起来的屏也算)
12745
13250
  const cmpRef = useRef(null)
12746
13251
  const [box, setBox] = useState({ w: 0, h: 0 })
12747
13252
  // 灵动条各形态量出来的真宽度(按语言、形态记):估的宽度只在没量过时用,英文字长也不会和两边的小块撞
@@ -12791,7 +13296,19 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12791
13296
  const tg = st && st.target
12792
13297
  const site = tg ? (tg.kind === 'file' ? 'file:' + String(tg.file || '').replace(/[\\/][^\\/]*$/, '') : 'proxy:' + tg.port) : origin
12793
13298
  const busy = !!(st && st.turn)
12794
- const screens = (st && st.screens) || []
13299
+ // 一页多状态(#30):这屏写了哪几个状态(页面报上来的)、现在看哪个;点名选了的(第一个也算)地址带上 ?state=——
13300
+ // 状态跟着模拟数据走的页,不带就是数据里那个,选「第一个」不带就切不回去
13301
+ const statesOf = (key) => parseStates((info[site + '|' + key] || {}).states)
13302
+ const stateFor = (key) => {
13303
+ const s = stSel[site + '|' + key]
13304
+ return s && statesOf(key).some((x) => x.name === s) ? s : ''
13305
+ }
13306
+ const pickState = (key, name) => {
13307
+ const list = statesOf(key)
13308
+ const v = list.some((x) => x.name === name) ? name : ''
13309
+ setStSel((m) => ((m[site + '|' + key] || '') === v ? m : { ...m, [site + '|' + key]: v }))
13310
+ }
13311
+ const screens = ((st && st.screens) || []).map((sc) => { const s = stateFor(sc.key); return s ? { ...sc, url: withState(sc.url, s), state: s } : sc })
12795
13312
 
12796
13313
  // 哪几屏是「刚生成的」:第一次看到它时模型正在干活 → 第一次显示时播生成动画(播过就不再播)
12797
13314
  // 这一轮开始时已有的屏记下来:这轮里出了新的一屏,就在画布末尾留个「生成中…」等下一屏;
@@ -12853,7 +13370,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
12853
13370
  }, [busy])
12854
13371
 
12855
13372
  const infoOf = (key) => info[site + '|' + key] || null
12856
- const ik = (sc) => (sc.v ? 'v' + sc.v + '|' : '') + sc.key // 旧版本的屏单独记标题
13373
+ const ik = (sc) => (sc.v ? 'v' + sc.v + '|' : '') + sc.key + (sc.xs ? '?state=' + sc.xs : '') // 旧版本的屏单独记标题;导出时按状态展开的那几页(xs)各挂各的
12857
13374
  const focus = (st && st.focus) || ''
12858
13375
  const main = infoOf(focus) || (screens[0] && infoOf(screens[0].key)) || {}
12859
13376
  const meta = parseMeta(main.meta || (st && st.draft && st.draft.meta) || (playR.current.end ? '' : playR.current.meta) || '') // 第一屏还在放草稿(真的没摆出来):按草稿开头写的类型
@@ -13094,12 +13611,20 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13094
13611
  // 手机上看:现在这一屏在预览服务器上的路径;手机开着时,电脑上换屏手机跟着跳
13095
13612
  const phoneOn = !!(st && st.phone && st.phone.on)
13096
13613
  const demoKey = demo ? demo.layers[demo.layers.length - 1].key : ''
13614
+ // 试用里这屏是哪个状态(#30):写在灵动条的屏名后面
13615
+ const demoStateLabel = () => {
13616
+ const top = demo ? demo.layers[demo.layers.length - 1] : null
13617
+ const list = top && top.state ? statesOf(top.key) : []
13618
+ const x = list.find((y) => y.name === top.state)
13619
+ return x && x !== list[0] ? ' · ' + x.label : ''
13620
+ }
13097
13621
  const urlOfKey = (key) => {
13098
13622
  const sc = screens.find((x) => x.key === key)
13099
- if (sc) return sc.url
13623
+ if (sc) return sc.state ? withState(sc.url, '') : sc.url // 画布上给这屏选了状态:试用里没写状态的链接还是落在默认状态
13100
13624
  return fileTarget ? `${origin}/${key.split('/').map(encodeURIComponent).join('/')}` : origin + key
13101
13625
  }
13102
- const curScreen = demo ? { key: demoKey, url: urlOfKey(demoKey) } : screens.find((x) => x.key === (canvas ? sel || focus : focus)) || screens[0]
13626
+ const demoState = demo ? demo.layers[demo.layers.length - 1].state || '' : ''
13627
+ 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
13628
  let curPath = '/'
13104
13629
  try { if (curScreen) { const u = new URL(curScreen.url); curPath = u.pathname + u.search } } catch { /* 地址不对 */ }
13105
13630
  const lastFollow = useRef('')
@@ -13187,7 +13712,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13187
13712
  showFlash(t('born', { name: title || labelOf(sc) }))
13188
13713
  }
13189
13714
 
13190
- const remember = (key, m, title, toks, dk, links, nat, err = '') => {
13715
+ const remember = (key, m, title, toks, dk, links, nat, err = '', ext) => {
13191
13716
  if (pane === 'export') setLoadTick((n) => n + 1)
13192
13717
  const k = site + '|' + key
13193
13718
  const sk = snapSite + '|' + key
@@ -13195,8 +13720,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13195
13720
  const sig = JSON.stringify([toks || [], links || []])
13196
13721
  setInfo((cur) => {
13197
13722
  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 } }
13723
+ const states = ext ? ext.states || '' : (cur[k] && cur[k].states) || '' // 写了哪几个状态(#30):对比那几处不报,留着上回的
13724
+ 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
13725
+ : { ...cur, [k]: { meta: m, title, tokens: toks || [], links: links || [], sig, dark: dk, natural, err, states } }
13200
13726
  })
13201
13727
  }
13202
13728
 
@@ -13416,12 +13942,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13416
13942
  setPicking(false)
13417
13943
  setPanel(false)
13418
13944
  setHist(false)
13419
- setDemo({ stack: [key], layers: [{ id: ++demoSeq.current, key, dir: 0, shown: false }] })
13945
+ const state = stateFor(key) // 从这屏现在看着的状态开始
13946
+ setDemo({ stack: [{ key, state }], layers: [{ id: ++demoSeq.current, key, state, dir: 0, shown: false }] })
13420
13947
  const inf = infoOf(key)
13421
13948
  if (inf && !(inf.links || []).length) say(t('demoNone'))
13422
13949
  }
13423
13950
  // 演示里跳屏、返回、从头来(makeDemoNav)
13424
- const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget })
13951
+ const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget, defOf: (key) => { const ss = statesOf(key); return ss.length && !followsMock((info[site + '|' + key] || {}).states) ? ss[0].name : '' } })
13425
13952
  const { implLoad, implRecompare } = makeImpl({ sid, setImpl, setImplRun, say, t })
13426
13953
  // 和做出来的比:在比哪一屏(看旧版本时不比)、那屏记着的地址和上次的分数
13427
13954
  const implSc = impl && !ver ? screens.find((x) => x.key === impl.key) || null : null
@@ -13591,11 +14118,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13591
14118
  onEditing: setTxOn,
13592
14119
  lang: t('lang'),
13593
14120
  onNote: (n) => note(n, sc),
13594
- onMeta: (m, title, toks, dk, links, nat, err) => remember(ik(sc), m, title, toks, dk, links, nat, err),
14121
+ onMeta: (m, title, toks, dk, links, nat, err, ext) => remember(ik(sc), m, title, toks, dk, links, nat, err, ext),
13595
14122
  onLinks: (links) => rememberLinks(ik(sc), links),
13596
14123
  onFix: (f) => insert(t(f.err === 'down' ? 'scrFailAskDown' : 'scrFailAsk', { file: f.file || labelOf(sc) }), 'insertedSend'),
13597
14124
  onTop: (dk) => setTop(ik(sc), dk),
13598
14125
  onBuilt: (title) => onBuilt(sc, title),
14126
+ onStateGo: sc.v || canvas ? undefined : (s) => pickState(sc.key, s),
13599
14127
  }))
13600
14128
 
13601
14129
  // 画布上屏太多、离镜头远的:先不挂 iframe,放一张后台截的缩略图(issue #17),截不到就是「挪近就加载」。
@@ -13606,7 +14134,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13606
14134
  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
14135
  h('div', { className: 'ddp-scr' + (dark ? ' dk' : '') },
13608
14136
  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))
14137
+ 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
14138
 
13611
14139
  // 那一屏的接口(截图、体检、业务标注都用);刚载入的等它就绪
13612
14140
  const apiOf = async (sc, map = apis.current) => {
@@ -13643,10 +14171,18 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13643
14171
  return () => clearTimeout(tm)
13644
14172
  }, [hidRev])
13645
14173
  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,
14174
+ // 导出用:某屏写了哪几个状态(本地文件问服务端的;别的用页面报上来的)
14175
+ const statesForX = (key) => (fileTarget ? (xStates && xStates.target === targetKey && xStates.map[key]) || [] : statesOf(key))
14176
+ 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
14177
  onWarn: (mode) => { setXFmt(mode === 'pptx' ? 'pptx' : 'pdf'); if (pane !== 'export') openPane('export') } })
13648
14178
  // 换了设计:导出面板里挑的屏不算了,回到「全部」
13649
14179
  useEffect(() => { setXo((o) => (o.scope && o.scope !== 'all' ? { ...o, scope: 'all', pick: [] } : o)) }, [targetKey])
14180
+ useEffect(() => {
14181
+ if (pane !== 'export' || !fileTarget || ver) return
14182
+ let off = false
14183
+ post('states', { session: sid }).then((d) => { if (!off) setXStates({ target: targetKey, map: (d && d.map) || {}, at: Date.now() }) }, () => {})
14184
+ return () => { off = true }
14185
+ }, [pane, targetKey, st ? st.rev : 0, !!ver])
13650
14186
  const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
13651
14187
  if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
13652
14188
  // 公网链接(#27)开着:右侧栏换了屏、画幅、深浅色、调节值,对方下次打开就按新的(看旧版本时不动)
@@ -13710,6 +14246,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13710
14246
  return g ? (g.letter || 'a').toUpperCase() : ''
13711
14247
  }
13712
14248
  const tagOf = (sc) => { const L = takeTag(sc); return L ? h('b', { key: 'g', className: 'ddp-vt', title: t('takeN', { l: L }) }, L) : null }
14249
+ // 一页多状态(#30):写了几个状态的屏,屏名旁一个「状态 ▾」小胶囊(默认状态也显示:一眼看出这屏有几种样子),点开换着看
14250
+ const openStMenu = (key, el) => {
14251
+ if (stMenu && stMenu.key === key) { setStMenu(null); return }
14252
+ const stage = stageRef.current
14253
+ if (!stage || !el) return
14254
+ const r = el.getBoundingClientRect()
14255
+ const R = stage.getBoundingClientRect()
14256
+ 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))) })
14257
+ }
14258
+ const stateChip = (sc) => {
14259
+ if (!sc || sc.v) return null
14260
+ const list = statesOf(sc.key)
14261
+ if (!list.length) return null
14262
+ const x = list.find((y) => y.name === (sc.state || '')) || list[0]
14263
+ const on = !!(stMenu && stMenu.key === sc.key)
14264
+ return h('button', { key: 'st', type: 'button', className: 'ddp-stt' + (on ? ' on' : '') + (x === list[0] ? '' : ' alt'), 'aria-haspopup': 'menu', 'aria-expanded': on,
14265
+ ...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))
14266
+ }
13713
14267
  // 几个方向并排时每屏标题旁都挂着「用这版」,不用先点中那一屏才看得到
13714
14268
  const badge = (sc) => (infoOf(ik(sc)) || {}).err ? h('em', { key: 'f', className: 'ddp-failtag' }, t('scrFailChip'))
13715
14269
  : !sc.v && takesOf(shown.map((x) => x.key), sc.key)
@@ -13755,13 +14309,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13755
14309
  return base.some(([, , x]) => x[0] === sz[0] && x[1] === sz[1]) ? base : [...base, ['szCustom', kind, sz]]
13756
14310
  })()
13757
14311
  const inMulti = multi && !!sizeSet && !ver
14312
+ // 一页多状态(#30):这一屏的每个状态并排看(和多尺寸一样是画布上的一种看法)
14313
+ const inStAll = !!stAll && !ver && !demo && !inMulti && !implSc && statesOf(stAll).length > 0
14314
+ const inSide = inMulti || inStAll
13758
14315
  // 单页看手机 / 平板时,选择、改字的提示条放在设备上方,给它让出一条(不然压住设备顶边)
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) : []
14316
+ const hintTop = (picking || textEdit) && !canvas && !inSide && !ver && !demo && (kind !== 'web' || webFit) // 网页按画幅缩放时也和设备一样让出一条(#20)
14317
+ const flows = canvas && !inSide && !picking && !textEdit ? flowsOf(shown, (sc) => (infoOf(ik(sc)) || {}).links, fileTarget) : []
13761
14318
 
13762
14319
  // ── 设计体检:画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里 ──
13763
14320
  // 设计体检:量、开面板、定位、交给模型(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,
14321
+ 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
14322
  onOpen: () => { setPanel(false); setHist(false); setPhone(false); setPubP(false); setAn(false); setStyleEdit(false) } }) // 1.0:一次只开一个面板(调样式抽屉也算)
13766
14323
  // 打开一套设计、模型又干完一轮(turns 变了):面板开着就再查一次(改没改好一眼看到);关着就悄悄量一下,问题数标在按钮上。
13767
14324
  // 模型干着活时不量;等一会儿再量:刚写完的屏还在刷新、播生成动画
@@ -13803,7 +14360,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13803
14360
  }, 1500)
13804
14361
  return () => clearTimeout(timer)
13805
14362
  }, [ckReq])
13806
- const checkOff = !url || !!ver || !!demo || inMulti || !!implSc
14363
+ const checkOff = !url || !!ver || !!demo || inSide || !!implSc
13807
14364
  // ── 业务标注(插件页的试验开关开着才有 st.annotations 这个键):面板和体检、版本共用右边那个位置;点选、改字、调样式、画笔时编号收起,退出后回来 ──
13808
14365
  useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
13809
14366
  const toggleAn = () => {
@@ -13836,10 +14393,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13836
14393
  const k = Math.max(1, f.offsetWidth) / Math.max(1, r.width)
13837
14394
  api.annotHit((x - r.left) * k, (y - r.top) * k)
13838
14395
  }
13839
- const styleOff = !url || !!ver || !!demo || inMulti || busy || !!implSc
14396
+ const styleOff = !url || !!ver || !!demo || inSide || busy || !!implSc
13840
14397
 
13841
14398
  // ── 画笔标注:画完把台面上看得到的几屏各截一张,按位置摆好,叠上画的东西,存进 refs/,路径放进输入框让模型用 read_image 看(不动剪贴板) ──
13842
- const markOff = !url || !!ver || !!demo || inMulti || !!implSc
14399
+ const markOff = !url || !!ver || !!demo || inSide || !!implSc
13843
14400
  const toggleMark = () => {
13844
14401
  markRun.current++
13845
14402
  if (mark) { setMark(false); return }
@@ -13882,6 +14439,19 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13882
14439
  // 右边同一时间只开一个面板:别的开了,这几个关掉;开这几个时别的关掉
13883
14440
  const oldOpen = !!(panel || hist || phone || pubP || ck || styleEdit)
13884
14441
  useEffect(() => { if (oldOpen) setPane('') }, [oldOpen])
14442
+ // 「数据」(模拟数据):本地文件的设计、目录里有 mock.json 才有;从别的设备打开的 DSH 够不着电脑上的预览地址,不给;
14443
+ // 看旧版本时不给(旧版本的屏用的是自己那份数据,面板改的是现在的)
14444
+ const mockOn = !!(fileTarget && st && st.mock && url && !away(url) && !ver)
14445
+ useEffect(() => { if (pane === 'data' && !mockOn) setPane('') }, [pane, mockOn])
14446
+ const saveMockData = async (data, fp) => {
14447
+ try {
14448
+ const r = await post('mocksave', { session: sid, root: st && st.target ? st.target.root : '', data, fp: fp || '' })
14449
+ if (!r.ok) return say(r.reason === 'busy' ? t('styleBusyTip') : r.reason === 'moved' ? t('twMoved') : r.reason === 'big' ? t('dataBig') : r.reason === 'no-mock' ? t('dataNoMock') : r.reason === 'changed' ? t('dataChanged') : r.reason === 'bad-file' ? t('dataBadFile') : t('twNoWrite'))
14450
+ showFlash(t('dataSaved'))
14451
+ } catch (e) {
14452
+ sayErr(t('failed', { msg: e.message }))
14453
+ }
14454
+ }
13885
14455
  const openPane = (p) => {
13886
14456
  const next = pane === p ? '' : p
13887
14457
  if (next) { setPanel(false); setHist(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
@@ -13932,7 +14502,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13932
14502
  const reload = () => setReloadSeq((x) => x + 1)
13933
14503
 
13934
14504
  // 按钮鼠标停一下出说明卡(HoverTip):名字 + 一句用途;窄了(样式表里)先截屏名,再收字
13935
- const curKey = implSc ? implSc.key : demo && demo.stack.length ? demo.stack[demo.stack.length - 1] : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
14505
+ const curKey = implSc ? implSc.key : demo && demo.stack.length ? demo.stack[demo.stack.length - 1].key : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
13936
14506
  const curSc = screens.find((x) => x.key === curKey)
13937
14507
  const stLabel = (st && st.label) || ''
13938
14508
  const scrLabel = canvas && screens.length > 1 && !implSc
@@ -13942,6 +14512,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13942
14512
  const pickScreen = (key) => {
13943
14513
  if (implSc) { implOpen(key); return } // 在和做出来的比:换成比这一屏
13944
14514
  setMulti(false)
14515
+ setStAll('')
13945
14516
  if (demo) setDemo(null)
13946
14517
  setSel(key)
13947
14518
  if (canvas || key !== focus || dr) openByUser(key)
@@ -13950,26 +14521,26 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
13950
14521
  const exSc = implSc || shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
13951
14522
  const exName = exSc ? dropBrand(shortOf(exSc)) + (takeTag(exSc) ? ' · ' + takeTag(exSc) : '') : ''
13952
14523
  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' }) }
14524
+ const onCanvas = canvas && !inSide && !demo && homeAt !== 'on' && !(ver && cmp) && !implSc
14525
+ const toCanvas = () => { homeAway(); setMulti(false); setStAll(''); setCmp(false); implClose(); if (demo) setDemo(null); change({ view: 'canvas' }) }
13955
14526
  // 面板(1.0)开的是哪一张:同一时间只开一个
13956
14527
  const packOther = !!packDir && !(fileTarget && st && st.target && packDir === st.target.root)
13957
14528
  const shareTab = phone ? 'phone' : pubP ? 'pub' : pane === 'pack' && !packOther ? 'demo' : pane === 'share' && !packOther ? 'submit' : ''
13958
14529
  const sheet = styleEdit ? 'style' : panel ? 'look' : ck || anUp ? 'check' : hist ? 'ver' : shareTab ? 'share'
13959
- : pane === 'export' ? 'export' : pane === 'handoff' ? 'code' : pane === 'pack' ? 'pack' : pane === 'share' ? 'submit' : pane === 'zip' && zipIssues ? 'zip' : ''
14530
+ : pane === 'export' ? 'export' : pane === 'handoff' ? 'code' : pane === 'pack' ? 'pack' : pane === 'share' ? 'submit' : pane === 'zip' && zipIssues ? 'zip' : pane === 'data' && mockOn ? 'data' : ''
13960
14531
  const closeShare = () => { setPhone(false); setPubP(false); if (pane === 'pack' || pane === 'share') setPane('') }
13961
14532
  // 标题栏「分享」:开着手机看 / 公网链接时直接到那一页
13962
14533
  const toggleShare = () => (sheet === 'share' ? closeShare() : pubOn && fileTarget ? togglePub() : togglePhone())
13963
14534
  // 换屏器:画布时写「画布 5 屏」,单看时写「详情 3 / 5」
13964
14535
  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]) : '')
14536
+ 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
14537
  const swPos = onCanvas || curIdx < 0 ? (screens.length > 1 ? t('nScr', { n: screens.length }) : '') : screens.length > 1 ? `${curIdx + 1} / ${screens.length}` : ''
13967
14538
  // 1.0 骨架:标题栏(标志 = 首页 | 项目名 ▾ / ⊞ 屏名 ▾ | 分享 导出 转成代码)+ 底部灵动条(说一句 | 选择 改字 调样式 画笔 | 试用 外观 体检)
13968
14539
  // 两边小块:左 版本、右 缩放(画布自己带)。模型在干活时灵动条变成状态胶囊;画笔标注时让给标注自己的底栏
13969
14540
  const tool = (cls, on, desc, off, run, Icon, label, extra, k) => h('button', { className: 'ddp-tool' + (cls ? ' ' + cls : '') + (on ? ' on' : ''), ...tipA(label, desc, on ? 'Esc' : k || ''), 'aria-pressed': !!on, disabled: !!off, onClick: run }, h(Icon), h('span', null, label), extra || null)
13970
14541
  const badgeOf = (n) => (n ? h('span', { className: 'bdg' }, n > 99 ? '99+' : String(n)) : null)
13971
14542
  // 灵动条放得下多少:全宽 → 藏快捷键 → 「说一句」收成图标 → 工具也只剩图标(两边小块挪到上面一行)
13972
- const nTools = 7
14543
+ const nTools = mockOn ? 8 : 7
13973
14544
  const islW = (cmd, tw) => 12 + cmd + 4 + nTools * tw + 11
13974
14545
  const dwKey = (m) => t('askSay') + '|' + m + (busy && capAway ? '|run' : '')
13975
14546
  const dwOf = (m, est) => dockW.current[dwKey(m)] || est
@@ -14037,6 +14608,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14037
14608
  thumb: snapQ ? (k) => `${API}scrthumb?${snapQ}&key=${encodeURIComponent(k)}` : null,
14038
14609
  ratio: size[1] / size[0],
14039
14610
  }),
14611
+ // 单看写了几个状态的屏:屏名后面接着「状态 ▾」(画布上每屏的屏名旁各有一个)
14612
+ !onCanvas && !demo && !implSc && !ver && !mark && curKey ? stateChip({ key: curKey, state: stateFor(curKey) }) : null,
14040
14613
  h('span', { className: 'dd-sp' }),
14041
14614
  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
14615
  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 +14642,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14069
14642
  h('button', { className: 'dd-bt pri', ...tipA(t('restore'), t('dRestore')), onClick: doRestore }, t('restore')),
14070
14643
  h('button', { className: 'dd-x', ...tipA(t('backNow'), '', 'Esc'), 'aria-label': t('backNow'), onClick: () => { setVer(null); setCmp(false) } }, h(I.close)))
14071
14644
  : 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, '')))),
14645
+ 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
14646
  h('span', { className: 'dd-vs' }),
14074
14647
  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
14648
  h('button', { className: 'dd-bt ghost', ...tipA(t('demoRestart')), disabled: demo.stack.length < 2, onClick: demoRestart }, h(I.refresh), t('demoRestart')),
@@ -14085,6 +14658,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14085
14658
  tool('', mark, t('dMark'), markOff, toggleMark, I.pen, t('markShort'), null, 'P'),
14086
14659
  h('span', { className: 'dd-vs' }),
14087
14660
  tool('dm', !!demo, t('dPlay'), !url || !!ver, toggleDemo, I.play, t('demoShort'), null, 'R'),
14661
+ mockOn ? tool('', pane === 'data', t('dData'), false, () => openPane('data'), I.data, t('data')) : null,
14088
14662
  tool('', !!panel, t('dLook'), false, () => (panel ? setPanel(false) : openLook()), I.palette, t('look'), null, 'L'),
14089
14663
  tool('', !!ck || anUp, ckCount && !ck ? t('dCheckN', { n: ckCount }) : t('dCheck'), checkOff, () => (ck ? closeCheck() : anUp ? toggleAn() : runCheck()), I.shield, t('checkShort'), !ck && !anUp && !checkOff ? badgeOf(ckCount) : null, 'C')),
14090
14664
  implSc ? null : h('button', { key: 'ver', className: 'ddp-isl dd-mini' + (verIco ? ' ico' : '') + (hist ? ' on' : ''), ...tipA(t('history'), t('dHistory')), 'aria-pressed': hist, disabled: !fileTarget, onClick: toggleHist }, h(I.history), h('span', null, t('history'))),
@@ -14394,7 +14968,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14394
14968
  const anL = (anFile && anFile.list) || []
14395
14969
  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
14970
  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 })
14971
+ if (ck) return h(CheckPanel, { t, head, ck, nameOf: dropBrand, onFocus: focusIssue, onFix: fixIssues, onAgain: runCheck, onDrift: askDrift, onClose: closeCheck })
14398
14972
  return h(AnnotPanel, {
14399
14973
  t,
14400
14974
  head,
@@ -14459,10 +15033,23 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14459
15033
  }
14460
15034
  if (sheet === 'submit') return h(SharePanel, { t, head: hd({ icon: I.share, title: t('subT') }), sid, root: sheetRoot, brand: '', onFix: fixPack, onSay: say, onClose: () => setPane('') })
14461
15035
  if (sheet === 'pack') return h(PackPanel, { t, head: hd({ icon: I.box, title: t('pkTitle'), help: t('pkTip') }), sid, root: sheetRoot, onFix: fixPack, onSay: say, onClose: () => setPane('') })
15036
+ if (sheet === 'data') {
15037
+ return h(DataPanel, {
15038
+ t,
15039
+ head: hd({ icon: I.data, title: t('data'), help: t('dataHelp'), sub: 'mock.json' }),
15040
+ origin,
15041
+ fp: st.mock.fp,
15042
+ err: st.mock.err,
15043
+ write: busy ? { ok: false, tip: t('styleBusyTip') } : { ok: true },
15044
+ onFix: (err) => insert(t('dataFixText', { err }) + '\n', 'insertedSend'),
15045
+ onSave: saveMockData,
15046
+ onSay: say,
15047
+ })
15048
+ }
14462
15049
  if (sheet === 'zip') return h(ZipIssues, { t, head: hd({ icon: I.box, title: t('zipNotOpened') }), issues: zipIssues, onClose: () => { setPane(''); setZipIssues(null) } })
14463
15050
  if (sheet === 'export') {
14464
15051
  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('') })
15052
+ 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
15053
  }
14467
15054
  if (sheet === 'code') {
14468
15055
  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)))))
@@ -14471,7 +15058,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14471
15058
  }
14472
15059
  return null
14473
15060
  }
14474
- const SHEET_T = { style: 'style', look: 'look', check: 'check', ver: 'history', share: 'shareT', submit: 'subT', pack: 'pkTitle', zip: 'zipNotOpened', export: 'exportT', code: 'handoff' }
15061
+ const SHEET_T = { style: 'style', look: 'look', check: 'check', ver: 'history', share: 'shareT', submit: 'subT', pack: 'pkTitle', zip: 'zipNotOpened', export: 'exportT', code: 'handoff', data: 'data' }
14475
15062
  // 壳一直在(换面板时只换里面,淡出淡入);关的时候整张落下 / 滑走
14476
15063
  const sheetEl = (home) => h(Presence, { key: 'sheet', on: !!sheet, ms: 300 }, sheet ? h('div', {
14477
15064
  className: 'dd-sheet' + (box.w > 1000 ? ' wide' : '') + (home ? ' home' : ''),
@@ -14517,6 +15104,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14517
15104
  add('mark', I.pen, t('markShort'), toggleMark, { key: 'P', on: mark, off: markOff, kw: kwOf('markShort') })
14518
15105
  add('demo', I.play, t('demoShort'), () => { if (implSc) implClose(); toggleDemo() }, { key: 'R', on: !!demo, off: noUrl || !!ver, top: true, kw: kwOf('demoShort') })
14519
15106
  add('look', I.palette, t('look'), () => (panel ? setPanel(false) : openLook()), { key: 'L', on: !!panel, top: true, kw: kwOf('look', 'lookSet') })
15107
+ if (mockOn) add('data', I.data, t('data'), () => openPane('data'), { on: pane === 'data', kw: kwOf('data', 'dataReset') + ' mock json' })
14520
15108
  add('look-style', I.palette, t('look') + ' · ' + t('lookStyle'), () => openLook('style'), { kw: kwOf('lookStyle') })
14521
15109
  add('look-brand', I.palette, t('look') + ' · ' + t('lookBrand'), () => openLook('brand'), { kw: kwOf('lookBrand') })
14522
15110
  add('check', I.shield, t('checkShort'), () => (ck ? closeCheck() : runCheck()), { key: 'C', on: !!ck, off: checkOff, top: true, note: ckCount && !ck ? String(ckCount) : '', kw: kwOf('checkShort') })
@@ -14674,7 +15262,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14674
15262
  const rightOn = !!sheet && wideP // 右边开着一张面板(只有宽过 1000 才是右边一张)
14675
15263
  const rightW = 340 // 面板宽 320 + 离边 10 + 留白 10
14676
15264
  const ah = Math.max(0, box.h - TOP_R - BOT_R - dRes)
14677
- const cvBody = !demo && (inMulti || (canvas && !(ver && cmp) && !implSc))
15265
+ const cvBody = !demo && (inSide || (canvas && !(ver && cmp) && !implSc))
14678
15266
  let body
14679
15267
  navR.current = null
14680
15268
  let busyGap = false
@@ -14693,7 +15281,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14693
15281
  h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
14694
15282
  h(Device, { kind, w: size[0], h: size[1], fill, label, top: tops[l.key], os: meta.os },
14695
15283
  h(Screen, { t, remote, onPageDrag: pageDrag,
14696
- src: urlOfKey(l.key),
15284
+ src: (l.state ? withState(urlOfKey(l.key), l.state) : urlOfKey(l.key)) + (l.hash || ''),
14697
15285
  label,
14698
15286
  busy: false,
14699
15287
  born: false,
@@ -14704,13 +15292,53 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14704
15292
  zoom: z,
14705
15293
  reloadSeq,
14706
15294
  onNav: isTop ? demoGo : undefined,
14707
- onHref: isTop ? (href) => demoHref(l.id, href) : undefined,
15295
+ onHref: isTop ? (href, raw) => demoHref(l.id, href, raw) : undefined,
14708
15296
  onShown: () => demoShown(l.id),
14709
- onMeta: (m, title, toks, dk, links, nat) => remember(l.key, m, title, toks, dk, links, nat),
15297
+ onMeta: (m, title, toks, dk, links, nat, err, ext) => remember(l.key, m, title, toks, dk, links, nat, '', ext),
14710
15298
  onLinks: (links) => rememberLinks(l.key, links),
14711
15299
  onTop: (dk) => setTop(l.key, dk),
14712
15300
  })))))
14713
15301
  }))
15302
+ } else if (inStAll) {
15303
+ // 一页多状态(#30):这一屏的每个状态并排(第一个是默认);点选、改字照常,发给模型时说明是哪个状态
15304
+ const base = screens.find((x) => x.key === stAll) || { key: stAll, url: urlOfKey(stAll), label: stAll.replace(/\.html?$/i, '') }
15305
+ const list = statesOf(stAll)
15306
+ const fake = list.map((x, i) => ({ key: 'st' + i, id: 'st:' + x.name + '|' + base.key, url: withState(base.url, x.name), label: x.label }))
15307
+ body = h(Canvas, {
15308
+ key: 'stall',
15309
+ t,
15310
+ top: TOP_R,
15311
+ bottom: BOT_R + dRes,
15312
+ screens: fake,
15313
+ kind,
15314
+ size,
15315
+ ghost: false,
15316
+ picking: picking || textEdit,
15317
+ sel: '',
15318
+ labelOf: (sc) => sc.label,
15319
+ 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 },
15320
+ h(Screen, { t, remote, onPageDrag: pageDrag,
15321
+ src: fake[i].url,
15322
+ label: labelOf(base),
15323
+ busy,
15324
+ born: false,
15325
+ picking,
15326
+ textEdit,
15327
+ dark,
15328
+ tweak,
15329
+ quietPick: true,
15330
+ zoom: z,
15331
+ reloadSeq,
15332
+ onPicked: (payload) => deliver(payload, t('stPickNote', { state: list[i].name, label: list[i].label }) + '\n'),
15333
+ onCancelled: () => setPicking(false),
15334
+ onEdited: (d) => onEdited(base, d),
15335
+ onEditDone: () => setTextEdit(false),
15336
+ onEditing: setTxOn,
15337
+ lang: t('lang'),
15338
+ onNote: (n) => note(n, base),
15339
+ onTop: (dk) => setTop(ik(base) + '|st' + i, dk),
15340
+ })),
15341
+ })
14714
15342
  } else if (inMulti) {
14715
15343
  // 多尺寸:现在这一屏,按几档宽度并排
14716
15344
  const base = curScreen || { key: focus, url, label: st.label }
@@ -14812,6 +15440,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14812
15440
  actions,
14813
15441
  badge,
14814
15442
  tag: tagOf,
15443
+ stateChip,
14815
15444
  kind,
14816
15445
  size,
14817
15446
  ghost,
@@ -14842,7 +15471,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14842
15471
  // 画笔标注开着:网页按开标注时的大小定住(侧栏拉窄了就整体缩小,不重排),画的才对得上
14843
15472
  const lock = fill && mark && markSize ? markSize : sideLock
14844
15473
  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 }
15474
+ 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
15475
  // 单屏时模型在写新的一屏:先看着它写(没在选、改字、调样式、标注的时候),写完换过去
14847
15476
  const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !peekR.current
14848
15477
  if (watch) singleDraftR.current = dr.key || '*' // 还不知道是哪屏:名字到了再说
@@ -14879,7 +15508,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14879
15508
  let chip = null
14880
15509
  const sideOpen = rightOn // 右边开着面板:提示放在左边那块的中间
14881
15510
  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') : ''
15511
+ const hintText = picking ? t(canvas || inSide ? 'pickAny' : 'pickOne') : textEdit ? t(canvas || inSide ? 'textAny' : 'textOne') : styleEdit && !sty ? t(canvas ? 'styleAny' : 'styleOne') : ''
14883
15512
  if (flash) chip = h('div', { className: 'ddp-chip ok' + side, key: 'ok' }, h(I.check), h('span', null, flash))
14884
15513
 
14885
15514
  return root(
@@ -14904,6 +15533,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
14904
15533
  h('img', { src: implShot, alt: t('implShotT'), onError: () => { setImplShot(''); say(t('implShotGone')) } }),
14905
15534
  h('span', null, t('implShotHow'))) : null,
14906
15535
  chip,
15536
+ stMenu && statesOf(stMenu.key).length
15537
+ ? 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, '') })),
15538
+ list: statesOf(stMenu.key), cur: stateFor(stMenu.key) || statesOf(stMenu.key)[0].name,
15539
+ onPick: (n) => { pickState(stMenu.key, n); if (stAll === stMenu.key) setStAll('') },
15540
+ allOn: stAll === stMenu.key, onAll: () => { const k = stMenu.key; setMulti(false); setStAll((c) => (c === k ? '' : k)) },
15541
+ onClose: () => setStMenu(null) })
15542
+ : null,
14907
15543
  msgEl(false),
14908
15544
  ...islands,
14909
15545
  palScrim(),
@@ -15065,7 +15701,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
15065
15701
  // 注意:这里是客户端**服务名**(短的),不是包名
15066
15702
  exports.inject = INJECT
15067
15703
  // 测试用
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 }
15704
+ 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
15705
  return module.exports
15070
15706
  },
15071
15707
  })