dsh-design-studio 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -0
- package/README.md +1 -0
- package/lib/canvthumb.js +5 -3
- package/lib/client.js +565 -102
- package/lib/core.js +10 -2
- package/lib/drift.js +222 -0
- package/lib/handoff.js +24 -0
- package/lib/htmlpack.js +97 -28
- package/lib/index.js +119 -16
- package/lib/look.js +26 -7
- package/lib/picker.js +160 -17
- package/lib/serve.js +18 -5
- package/lib/states.js +138 -0
- package/lib/styles.js +7 -1
- package/package.json +1 -1
- package/skills/ui-design/SKILL.md +4 -2
package/lib/client.js
CHANGED
|
@@ -209,6 +209,7 @@ window.__ModuleLoader__.load({
|
|
|
209
209
|
xoWarn: '有内容会被裁掉,先看一眼',
|
|
210
210
|
xoChecking: '正在量页面…',
|
|
211
211
|
xoClean: '没有会被裁掉的内容。',
|
|
212
|
+
xoStNoCheck: '上面只查了默认状态;另外 {n} 页(其他状态)没预检,内容更长的可能被截掉,拿不准就选「整页」。',
|
|
212
213
|
xoOver: '{n} 个页面比画幅大,会被裁',
|
|
213
214
|
xoLong: '{n} 个页面是长页,只会截首屏',
|
|
214
215
|
xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
|
|
@@ -220,9 +221,10 @@ window.__ModuleLoader__.load({
|
|
|
220
221
|
xoFail: '{n} 屏没量到,结果可能不全',
|
|
221
222
|
xoAgain: '再查一次',
|
|
222
223
|
xoGone: '设计换了,这次导出取消了',
|
|
224
|
+
xoStFail: '没取到各屏写了哪几个状态,这次没导出,再点一次导出试试',
|
|
223
225
|
xoJobGone: '导出中断了(等太久或 DSH 重启过),请重新导出',
|
|
224
226
|
styleMoved: '设计换了,这次调的样式没保存',
|
|
225
|
-
xoCut: '一次最多导出 1000
|
|
227
|
+
xoCut: '一次最多导出 1000 页,最后 {n} 页没导出',
|
|
226
228
|
xoResize: '按内容改画幅({size})',
|
|
227
229
|
xoFull: '取景改成整页',
|
|
228
230
|
xoWhich: '导出哪些',
|
|
@@ -233,6 +235,8 @@ window.__ModuleLoader__.load({
|
|
|
233
235
|
xoPick: '挑几屏…',
|
|
234
236
|
xoPickN: '挑了 {n} 屏',
|
|
235
237
|
xoPickNone: '至少挑一屏',
|
|
238
|
+
xoStates: '每个状态各出一张',
|
|
239
|
+
xoStatesN: '多 {n} 页',
|
|
236
240
|
xoPre: '导出前检查',
|
|
237
241
|
xoWho: '({list})',
|
|
238
242
|
xoPages: '{n} 页',
|
|
@@ -269,6 +273,12 @@ window.__ModuleLoader__.load({
|
|
|
269
273
|
checkLayout: '页面还没排好版,这次没量成,过一会儿再查一次',
|
|
270
274
|
checkNote: '只量排版上的硬伤,好不好看你说了算',
|
|
271
275
|
checkNoneTip: '量了 {s} 屏,没有量得出的排版硬伤',
|
|
276
|
+
dfHead: '部件各屏写得不一样 · 是提醒,不算问题',
|
|
277
|
+
dfItem: '{n} 屏里有 {v} 种写法',
|
|
278
|
+
dfMore: '还有 {n} 个部件也这样',
|
|
279
|
+
dfTip: '点一下:把「统一这个部件」放进输入框',
|
|
280
|
+
dfAsk: '〔部件不一致〕{sel} 在 {n} 屏里有 {v} 种写法:{diff}。请定一种写法(多数屏用的那种)挪进共用的 app.css,各屏删掉自己那份。',
|
|
281
|
+
dfNone: '没写',
|
|
272
282
|
checkAsk: '〔设计体检〕发现 {n} 个问题:',
|
|
273
283
|
checkTail: '请逐个修好:改源文件,只动有问题的地方;颜色、字号能改设计变量就改设计变量。',
|
|
274
284
|
ckToolHead: '量了 {s} 屏,发现 {n} 个问题。逐个改源文件,只动有问题的地方;颜色、字号能改设计变量就改设计变量:',
|
|
@@ -722,6 +732,14 @@ window.__ModuleLoader__.load({
|
|
|
722
732
|
pageSet: '页面设置',
|
|
723
733
|
dPageSet: '类型、画幅、多尺寸、深色模式、刷新…',
|
|
724
734
|
scrSearch: '搜屏名',
|
|
735
|
+
stMenuT: '「{name}」的状态',
|
|
736
|
+
stDefault: '默认',
|
|
737
|
+
stTip: '这一屏有 {n} 个状态',
|
|
738
|
+
dState: '同一个页面的几种样子(空的、有数据、已付款…)。点开换着看',
|
|
739
|
+
stSide: '并排看全部状态',
|
|
740
|
+
dStAll: '这一屏的每个状态并排摆在画布上',
|
|
741
|
+
stAllOn: '全部状态 · {name}',
|
|
742
|
+
stPickNote: '状态:{state}({label})——改这个状态时只动 [data-state="{state}"] 下的样式,别影响别的状态',
|
|
725
743
|
scrNone: '没有对得上的屏',
|
|
726
744
|
scrCount: '{n} / {m} 屏',
|
|
727
745
|
scrKeyPick: '选',
|
|
@@ -1382,6 +1400,7 @@ window.__ModuleLoader__.load({
|
|
|
1382
1400
|
xoWarn: 'Some content would be cut off. Have a look first',
|
|
1383
1401
|
xoChecking: 'Measuring pages…',
|
|
1384
1402
|
xoClean: 'Nothing will be cut off.',
|
|
1403
|
+
xoStNoCheck: 'Only the default states were checked above; the other {n} pages (other states) were not, and longer content there may be cut off. If unsure, choose “Full page”.',
|
|
1385
1404
|
xoOver: '{n} page(s) are larger than the canvas and will be cut off',
|
|
1386
1405
|
xoLong: '{n} long page(s): only the first screen is captured',
|
|
1387
1406
|
xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
|
|
@@ -1393,9 +1412,10 @@ window.__ModuleLoader__.load({
|
|
|
1393
1412
|
xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
|
|
1394
1413
|
xoAgain: 'Check again',
|
|
1395
1414
|
xoGone: 'The design changed, so this export was cancelled',
|
|
1415
|
+
xoStFail: "Couldn't read which states each screen has, so nothing was exported. Try exporting again",
|
|
1396
1416
|
xoJobGone: 'The export was interrupted (it waited too long or DSH restarted). Please export again',
|
|
1397
1417
|
styleMoved: 'The design changed, so these style tweaks were not saved',
|
|
1398
|
-
xoCut: 'At most 1000
|
|
1418
|
+
xoCut: 'At most 1000 pages per export; the last {n} were left out',
|
|
1399
1419
|
xoResize: 'Fit canvas to content ({size})',
|
|
1400
1420
|
xoFull: 'Switch to full page',
|
|
1401
1421
|
xoWhich: 'Which screens',
|
|
@@ -1406,6 +1426,8 @@ window.__ModuleLoader__.load({
|
|
|
1406
1426
|
xoPick: 'Pick some…',
|
|
1407
1427
|
xoPickN: '{n} picked',
|
|
1408
1428
|
xoPickNone: 'Pick at least one',
|
|
1429
|
+
xoStates: 'One page per state',
|
|
1430
|
+
xoStatesN: '+{n} pages',
|
|
1409
1431
|
xoPre: 'Before exporting',
|
|
1410
1432
|
xoWho: ' ({list})',
|
|
1411
1433
|
xoPages: '{n} pages',
|
|
@@ -1442,6 +1464,12 @@ window.__ModuleLoader__.load({
|
|
|
1442
1464
|
checkLayout: 'The page was not laid out yet, so it was not measured. Check again in a moment.',
|
|
1443
1465
|
checkNote: 'Only measurable layout problems; whether it looks good is up to you',
|
|
1444
1466
|
checkNoneTip: 'Measured {s} screens, no layout problems found',
|
|
1467
|
+
dfHead: 'Shared parts differ across screens · a heads-up, not a problem',
|
|
1468
|
+
dfItem: '{v} versions across {n} screens',
|
|
1469
|
+
dfMore: '{n} more parts like this',
|
|
1470
|
+
dfTip: 'Click to put “unify this part” in the message box',
|
|
1471
|
+
dfAsk: '[Part drift] {sel} has {v} versions across {n} screens: {diff}. Pick one (the one most screens use), move it into the shared app.css and delete each screen’s own copy.',
|
|
1472
|
+
dfNone: 'unset',
|
|
1445
1473
|
checkAsk: '[Design check] Found {n} problems:',
|
|
1446
1474
|
checkTail: 'Please fix each one in the source files, touching only what is listed; for colors and type sizes, change the design tokens where possible.',
|
|
1447
1475
|
ckToolHead: 'Measured {s} screens and found {n} problems. Fix each one in the source files, touching only what is listed; for colors and type sizes, change the design tokens where possible:',
|
|
@@ -1894,6 +1922,14 @@ window.__ModuleLoader__.load({
|
|
|
1894
1922
|
pageSet: 'Page setup',
|
|
1895
1923
|
dPageSet: 'Type, canvas size, sizes, dark mode, reload…',
|
|
1896
1924
|
scrSearch: 'Find a screen',
|
|
1925
|
+
stMenuT: 'States of "{name}"',
|
|
1926
|
+
stDefault: 'default',
|
|
1927
|
+
stTip: 'This screen has {n} states',
|
|
1928
|
+
dState: 'Different looks of the same page (empty, loaded, paid…). Click to switch',
|
|
1929
|
+
stSide: 'See all states side by side',
|
|
1930
|
+
dStAll: 'Lay every state of this screen side by side on the canvas',
|
|
1931
|
+
stAllOn: 'All states · {name}',
|
|
1932
|
+
stPickNote: 'State: {state} ({label}) — when changing this state, only touch the styles under [data-state="{state}"] so the other states stay as they are',
|
|
1897
1933
|
scrNone: 'No screen matches',
|
|
1898
1934
|
scrCount: '{n} / {m}',
|
|
1899
1935
|
scrKeyPick: 'move',
|
|
@@ -2533,6 +2569,7 @@ window.__ModuleLoader__.load({
|
|
|
2533
2569
|
.ddp-frame{position:absolute;left:0;top:0;width:100%;height:100%;border:0;background:#fff;opacity:0;z-index:0;pointer-events:none}
|
|
2534
2570
|
.ddp-frame.old{opacity:1;z-index:1}
|
|
2535
2571
|
.ddp-frame.cur{opacity:1;z-index:2;pointer-events:auto;transition:opacity .32s ease}
|
|
2572
|
+
.ddp-frame.cur.held{pointer-events:none}
|
|
2536
2573
|
.ddp-dev{position:relative;background:#fff;box-shadow:0 0 0 .5px rgba(0,0,0,.14),0 18px 48px rgba(0,0,0,.2)}
|
|
2537
2574
|
.ddp-dev.fill{position:absolute;inset:0;box-shadow:none;border-radius:0}
|
|
2538
2575
|
.ddp-dev.k-app,.ddp-dev.k-miniprogram,.ddp-dev.k-tablet{background:#0e0e12;box-shadow:inset 0 0 0 1.5px #2b2b33,0 0 0 1px rgba(0,0,0,.45),0 24px 60px rgba(0,0,0,.3)}
|
|
@@ -3070,6 +3107,20 @@ window.__ModuleLoader__.load({
|
|
|
3070
3107
|
.ddp-cell:hover .ddp-act,.ddp-cell.sel .ddp-act{display:flex}
|
|
3071
3108
|
.ddp-vt{flex:none;display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 4px;border-radius:5px;background:rgba(127,127,127,.14);color:var(--dsw-alias-label-secondary);font-size:11px;font-weight:600}
|
|
3072
3109
|
.ddp-cell.sel .ddp-vt{background:rgba(77,107,254,.14);color:var(--dd-acc,${ACCENT})}
|
|
3110
|
+
/* 一页多状态(#30):屏名旁的「状态 ▾」。看的是默认状态时淡灰;换到别的状态带一点主色(提醒这屏现在不是默认的样子) */
|
|
3111
|
+
.ddp-stt{flex:none;display:inline-flex;align-items:center;gap:3px;height:20px;max-width:10em;padding:0 4px 0 6px;border:0;border-radius:10px;corner-shape:round;
|
|
3112
|
+
background:rgba(127,127,127,.13);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;font-weight:500;line-height:20px;cursor:pointer;transition:background .15s,color .15s}
|
|
3113
|
+
.ddp-stt:hover,.ddp-stt.on{background:rgba(127,127,127,.22);color:var(--dsw-alias-label-primary)}
|
|
3114
|
+
.ddp-stt.alt{background:rgba(77,107,254,.13);color:var(--dd-acc,${ACCENT})}
|
|
3115
|
+
.ddp-stt.alt:hover,.ddp-stt.alt.on{background:rgba(77,107,254,.22)}
|
|
3116
|
+
.ddp-stt>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
3117
|
+
.ddp-stt svg{width:12px;height:12px;flex:none}
|
|
3118
|
+
.ddp-stt svg:last-child{width:10px;height:10px;opacity:.65}
|
|
3119
|
+
.ddp-stt:focus-visible{outline:2px solid var(--dd-acc,${ACCENT});outline-offset:1px}
|
|
3120
|
+
@container (max-width:104px){.ddp-stt>span{display:none}.ddp-stt{padding:0 4px}}
|
|
3121
|
+
/* 和「用这版」一样钉在最右、悬停不变大小:小按钮从它左边冒出来挤的是屏名,鼠标对着它时它不会跑开(不然点到冒出来的「导出」) */
|
|
3122
|
+
.ddp-lab>.ddp-stt{order:3;margin-left:auto}
|
|
3123
|
+
.ddp-cell:hover .ddp-lab>.ddp-stt,.ddp-cell.sel .ddp-lab>.ddp-stt{margin-left:0}
|
|
3073
3124
|
.ddp-take{order:3;margin-left:auto;flex:none;display:inline-flex;align-items:center;gap:3px;height:20px;padding:0 8px 0 6px;border:0;border-radius:10px;
|
|
3074
3125
|
background:rgba(77,107,254,.12);color:var(--dd-acc,${ACCENT});font:inherit;font-size:11px;font-weight:500;cursor:pointer}
|
|
3075
3126
|
.ddp-take:hover{background:rgba(77,107,254,.2)}
|
|
@@ -3377,6 +3428,18 @@ body[data-ds-dark-theme] .ddp{color-scheme:dark;
|
|
|
3377
3428
|
/* 名字长时先缩项目名(最多缩到 5.5 字宽);换屏器上是「画布」或短屏名(≤6 字宽)时不缩,长屏名两边按比例缩 */
|
|
3378
3429
|
@supports (min-width:calc-size(max-content,size)){.ddp .dd-proj{min-width:calc-size(max-content,min(size,5.5em))}@container (max-width:360px){.ddp .dd-proj{min-width:calc-size(max-content,min(size,3.5em))}}}
|
|
3379
3430
|
.ddp .dd-where.fix{flex-shrink:0}
|
|
3431
|
+
/* 单看时顶栏屏名后面的「状态 ▾」:和屏名那一块一样高、一样的底 */
|
|
3432
|
+
.ddp .dd-bar>.ddp-stt{height:32px;max-width:150px;margin-left:6px;padding:0 8px 0 9px;border-radius:var(--dd-r2);background:var(--dd-f1);box-shadow:inset 0 0 0 1px var(--dd-line);color:var(--dd-t2,var(--dsw-alias-label-secondary));font-size:12.5px;line-height:32px}
|
|
3433
|
+
.ddp .dd-bar>.ddp-stt:hover,.ddp .dd-bar>.ddp-stt.on{background:var(--dd-f2);color:var(--dsw-alias-label-primary)}
|
|
3434
|
+
.ddp .dd-bar>.ddp-stt.alt{color:var(--dd-acc,${ACCENT});box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dd-acc,${ACCENT}) 35%,transparent)}
|
|
3435
|
+
.ddp .dd-bar>.ddp-stt svg{width:14px;height:14px}
|
|
3436
|
+
.ddp .dd-bar>.ddp-stt svg:last-child{width:11px;height:11px}
|
|
3437
|
+
@container (max-width:520px){.ddp .dd-bar>.ddp-stt>span{display:none}.ddp .dd-bar>.ddp-stt{padding:0 7px}}
|
|
3438
|
+
/* 状态菜单:浮在台面上,位置由打开它的那个「状态 ▾」定 */
|
|
3439
|
+
.ddp .ddp-menu.ddp-stmenu{position:absolute;right:auto;z-index:60;width:248px;max-width:calc(100% - 16px)}
|
|
3440
|
+
.ddp-stmenu .ls>button>em{flex:none;max-width:42%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
3441
|
+
.ddp-stmenu .ls>button>.ck{width:15px;flex:none}
|
|
3442
|
+
.ddp-stmenu .ls>button.hi,.ddp-stmenu>button.hi{background:var(--dd-f2,rgba(127,127,127,.12))}
|
|
3380
3443
|
/* 再窄(DSH 右侧栏最窄约 300):画布那格只留格子和 ▾;≤390 单看也只留格子和 ▾(屏名在菜单里);≤360 再去掉斜杠、间距收一点,「转成代码」不被切 */
|
|
3381
3444
|
@container (max-width:400px){.ddp .dd-where.cv .ddp-addr .lb2{display:none}.ddp .dd-where.cv .ddp-addr{padding:0 8px}}
|
|
3382
3445
|
@container (max-width:390px){.ddp .dd-where .ddp-addr .lb2{display:none}.ddp .dd-where .ddp-addr{padding:0 8px}}
|
|
@@ -3638,6 +3701,8 @@ body:not([data-ds-dark-theme]) .ddp .dd-seg::before{box-shadow:var(--dd-sh1)}
|
|
|
3638
3701
|
.ddp .dd-pk .on i{background:var(--dd-au);box-shadow:none}
|
|
3639
3702
|
.ddp .dd-pk i svg{width:10px;height:10px;stroke-width:3;animation:dd-pop .26s var(--dd-spring) backwards}
|
|
3640
3703
|
.ddp .dd-pk span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
3704
|
+
.ddp .dd-pk.dd-xst{max-height:none;overflow:visible;padding:8px 6px 0;margin-top:6px;border-top:1px solid var(--dd-line)}
|
|
3705
|
+
.ddp .dd-xst em{margin-left:auto;padding-left:8px;flex:none;font-style:normal;font-size:11.5px;color:var(--dd-t3);font-variant-numeric:tabular-nums}
|
|
3641
3706
|
.ddp .dd-xch{gap:6px;margin:0 0 16px}
|
|
3642
3707
|
.ddp .dd-xch .dd-chip{height:28px;padding:0 11px;border-radius:9px;font-size:12.5px;transition:background-color .16s var(--dd-out),box-shadow .16s var(--dd-out),color .16s}
|
|
3643
3708
|
.ddp .ddp-xo .dd-col>.dd-seg{margin-bottom:16px}
|
|
@@ -4183,6 +4248,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
4183
4248
|
.ddp .dd-cks>.dd-ckwait{grid-column:1/-1;display:flex;align-items:center;justify-content:center;gap:8px;padding:22px 12px;color:var(--dd-t3);font-size:12px}
|
|
4184
4249
|
.ddp .dd-cks>.dd-ckerr{grid-column:1/-1;display:flex;align-items:flex-start;gap:8px;padding:9px 12px;color:var(--dd-t2);font-size:12px;line-height:17px}
|
|
4185
4250
|
.ddp .dd-cks>.dd-ckerr svg{width:14px;height:14px;flex:none;margin-top:1px;color:var(--dd-warn)}
|
|
4251
|
+
/* 部件不一致(#30):问题下面单独一组,灰圆点「≠」,不算进问题数 */
|
|
4252
|
+
.ddp .dd-cks>.dd-ckgrp{grid-column:1/-1;margin:10px 2px 2px;padding:10px 10px 2px;border-top:1px solid var(--dd-line);font-size:11.5px;line-height:16px;color:var(--dd-t3)}
|
|
4253
|
+
.ddp .dd-cks>.dd-ckgrp:first-child{margin-top:0;padding-top:2px;border-top:0}
|
|
4254
|
+
.ddp .dd-cks>.dd-ckgrp.more{margin:0 2px;padding:4px 12px;border-top:0}
|
|
4255
|
+
.ddp .dd-cks>.ok+.dd-ckgrp{margin-top:2px}
|
|
4256
|
+
.ddp .dd-ck .no.df{background:var(--dd-f2);color:var(--dd-t2);font-weight:600}
|
|
4257
|
+
.ddp .dd-ck.df .nm code{font:500 12px/18px ui-monospace,SFMono-Regular,Menlo,monospace}
|
|
4186
4258
|
.ddp .dd-spin{width:14px;height:14px;flex:none;border-radius:50%;corner-shape:round;border:2px solid var(--dd-f3);border-top-color:var(--dd-c2);animation:dd-spin .9s linear infinite}
|
|
4187
4259
|
@keyframes dd-ckin{from{opacity:0;transform:translateY(5px)}}
|
|
4188
4260
|
/* 1.0 版本面板:一排卡片(缩略图 · 第几版 · 什么时候 · 谁改的和改了什么),左边是现在 */
|
|
@@ -4498,6 +4570,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
4498
4570
|
canvas: () => svg([h('rect', { key: 1, x: 3.5, y: 3.5, width: 7, height: 7, rx: 1.6 }), h('rect', { key: 2, x: 13.5, y: 3.5, width: 7, height: 7, rx: 1.6 }),
|
|
4499
4571
|
h('rect', { key: 3, x: 3.5, y: 13.5, width: 7, height: 7, rx: 1.6 }), h('rect', { key: 4, x: 13.5, y: 13.5, width: 7, height: 7, rx: 1.6 })]),
|
|
4500
4572
|
single: () => svg([h('rect', { key: 1, x: 5, y: 3.5, width: 14, height: 17, rx: 2.2 })]),
|
|
4573
|
+
// 一页多状态:一张卡片后面还叠着一张
|
|
4574
|
+
states: () => svg([h('path', { key: 1, d: 'M12 3.5 3.5 8 12 12.5 20.5 8z' }), h('path', { key: 2, d: 'M3.5 12 12 16.5 20.5 12' }), h('path', { key: 3, d: 'M3.5 16 12 20.5 20.5 16' })]),
|
|
4501
4575
|
globe: () => svg([h('circle', { key: 1, cx: 12, cy: 12, r: 8.5 }), h('path', { key: 2, d: 'M3.5 12h17M12 3.5c2.4 2.3 3.6 5.1 3.6 8.5s-1.2 6.2-3.6 8.5c-2.4-2.3-3.6-5.1-3.6-8.5s1.2-6.2 3.6-8.5z' })]),
|
|
4502
4576
|
link: () => svg([h('path', { key: 1, d: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1.2 1.2' }), h('path', { key: 2, d: 'M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1.2-1.2' })]),
|
|
4503
4577
|
web: () => svg([h('rect', { key: 1, x: 3, y: 4.5, width: 18, height: 15, rx: 2.2 }), h('path', { key: 2, d: 'M3 9h18' }), h('path', { key: 3, d: 'M6 6.8h.01M8.5 6.8h.01' })]),
|
|
@@ -5515,6 +5589,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
5515
5589
|
/** 首页「风格:自动」时按题材替模型挑一张风格卡(模型自己定时,消费类 App 总落回米色暖调)。
|
|
5516
5590
|
* 用户话里已经说了风格 → 不挑(null),照他的话来;没认出题材 → 按类型给一张不是米色的 */
|
|
5517
5591
|
const AUTO_STYLE = [
|
|
5592
|
+
// 用户说的是「什么感觉」(可爱、简约、复古……):先按感觉挑,再按题材(「可爱的习惯打卡 App」别因为没认出题材落到随机的运动风);同一小句里感觉词前面有「不 / 别 / 没 / 无 / 非」(特别、告别、不一样、非常这类除外)、not / n't / no 就不算,落回题材
|
|
5593
|
+
['cute', /(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(可爱|卡通|童趣|软萌|萌萌|治愈系|治愈风|治愈感)|(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(?<!(?:\b(?:not|no|without|avoid|never|nothing|less)\b|n['’]t\b)(?:(?!\bbut\b)[^,.;:!?\n]){0,40})\b(cute|kawaii|adorable)\b/i],
|
|
5594
|
+
['minimal', /(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(简约|极简|简洁)|(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(?<!(?:\b(?:not|no|without|avoid|never|nothing|less)\b|n['’]t\b)(?:(?!\bbut\b)[^,.;:!?\n]){0,40})\b(minimal|minimalist|minimalistic)\b/i],
|
|
5595
|
+
['fresh', /(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})清新/],
|
|
5596
|
+
['playful', /(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(活泼|俏皮)|(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(?<!(?:\b(?:not|no|without|avoid|never|nothing|less)\b|n['’]t\b)(?:(?!\bbut\b)[^,.;:!?\n]){0,40})\b(playful)\b/i],
|
|
5597
|
+
['retro', /(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(复古|怀旧)|(?<!(?:(?<![特告区分识派])别(?!致)|不(?![一同错仅但只光失])|没|勿|无(?!论)|非(?!常)|避免|拒绝|讨厌|去掉)[^,。,.;;!!??\n但而]{0,30})(?<!(?:\b(?:not|no|without|avoid|never|nothing|less)\b|n['’]t\b)(?:(?!\bbut\b)[^,.;:!?\n]){0,40})\b(retro)\b/i],
|
|
5518
5598
|
['sport', /跑步|健身|运动|赛事|马拉松|骑行|瑜伽|球馆|\b(runners?|running|fitness|gym|workouts?|sports?|marathons?|cycling|athletes?)\b/i],
|
|
5519
5599
|
['cyber', /电音|夜店|电竞|游戏|音乐节|livehouse|酒吧|\b(game|gaming|esports?|nightclub|club|rave|festival)\b/i],
|
|
5520
5600
|
['sale', /促销|大促|双十一|双11|618|秒杀|优惠|团购|外卖|\b(sale|deals?|coupons?|promo|black friday)\b/i],
|
|
@@ -5530,7 +5610,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
5530
5610
|
['swiss', /设计工作室|建筑|展览|美术馆|画廊|作品集|\b(agency|studio|architecture|exhibition|gallery|museum|portfolio)\b/i],
|
|
5531
5611
|
]
|
|
5532
5612
|
const AUTO_BY_KIND = { slides: 'swiss', web: 'minimal', desktop: 'tech', email: 'minimal', poster: 'playful', tablet: 'minimal', diagram: 'tech' }
|
|
5533
|
-
const AUTO_SPREAD = ['minimal', 'editorial', 'playful', 'fresh', 'tech', 'glass', 'dark'
|
|
5613
|
+
const AUTO_SPREAD = ['minimal', 'editorial', 'playful', 'fresh', 'tech', 'glass', 'dark']
|
|
5534
5614
|
// 「北欧风」「清新风:首页…」「中国风的界面」算说了风格;先去掉「通风」「台风」「新风系统」「风控」「风景」这类不是风格的词
|
|
5535
5615
|
const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
|
|
5536
5616
|
const SAID_STYLE = /风格|配色|色调|主色|色系|[红橙黄绿青蓝紫粉黑白灰棕金银米]色|蓝白|黑白|黑金|红白|绿白|深色|浅色|暗色|亮色|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel|dark|light)\b/i
|
|
@@ -6077,6 +6157,19 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
6077
6157
|
}
|
|
6078
6158
|
|
|
6079
6159
|
/** 一串页面标题 → 共同的品牌名 + 每屏自己的名字(「登录 · 八克咖啡」「首页 · 八克咖啡」→ 八克咖啡 / 登录、首页) */
|
|
6160
|
+
// 转成代码的步骤条走到第几步(0 选怎么转 / 1 模型在做 / 2 逐屏比)。拿不准就停在第 1 步,和 1.0.1 一样:
|
|
6161
|
+
// 这套设计的交接包真写好了(handoff_design 成功,后台按设计目录记 st.ho)、那一轮还在跑 →「模型在做」;
|
|
6162
|
+
// 交接那轮正常做完、现在还在的屏有交接以后的比对记录 →「逐屏比」(比对记录和交接都是后台的钟)。
|
|
6163
|
+
// 模型在问用户问题、交接那轮被停 / 出错 / 没说怎么结束的、还没收到那轮怎么结束的、没交接过(DSH 重启过也算)、换了设计目录,都回第 1 步
|
|
6164
|
+
function hoStepOf({ st, root, impl, keys, busy }) {
|
|
6165
|
+
if (!st || st.asking) return 0
|
|
6166
|
+
const ho = st.ho && st.ho.root === root ? st.ho : null
|
|
6167
|
+
if (!ho) return 0
|
|
6168
|
+
if (ho.end == null) return busy ? 1 : 0
|
|
6169
|
+
if (ho.end !== 'completed') return 0 // 老版 DSH 没给结束原因(done)、交接包写好时那轮已经停了:分不清做完还是被停,回第 1 步
|
|
6170
|
+
const at = Number(ho.at) || 0
|
|
6171
|
+
return Object.keys(impl || {}).some((k) => { const r = impl[k]; return r && typeof r.pct === 'number' && (keys || []).includes(k) && (Number(r.when) || 0) > at }) ? 2 : 0
|
|
6172
|
+
}
|
|
6080
6173
|
function splitTitles(titles) {
|
|
6081
6174
|
const SEP = /\s*[·||—]\s*|\s+[-–]\s+/
|
|
6082
6175
|
const parts = titles.map((x) => String(x || '').split(SEP).map((s) => s.trim()).filter(Boolean))
|
|
@@ -6417,6 +6510,47 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
6417
6510
|
return out
|
|
6418
6511
|
}
|
|
6419
6512
|
|
|
6513
|
+
// ── 一页多状态(#30):<meta name="dsh-states" content="default:有数据, empty:空列表, paid:已付款">,<html data-state>,地址 ?state=paid ──
|
|
6514
|
+
const STATE_RE = /^[A-Za-z0-9_-]{1,32}$/ // 和 picker.js、serve.js 设状态那段一样
|
|
6515
|
+
const MAX_STATES = 8
|
|
6516
|
+
/** meta 内容 → [{ name, label }](第一个是默认状态;名字只认英文、数字、- _,后面可以跟「:中文名」);不到两个当没写 */
|
|
6517
|
+
function parseStates(raw) {
|
|
6518
|
+
const out = []
|
|
6519
|
+
for (const part of String(raw || '').split(/[,,;;\n]+/)) {
|
|
6520
|
+
const m = /^\s*([A-Za-z0-9_-]{1,32})\s*(?:[::=]\s*(.*?))?\s*$/.exec(part)
|
|
6521
|
+
if (!m || out.some((x) => x.name === m[1])) continue
|
|
6522
|
+
out.push({ name: m[1], label: String(m[2] || '').trim().slice(0, 24) || m[1] })
|
|
6523
|
+
if (out.length >= MAX_STATES) break
|
|
6524
|
+
}
|
|
6525
|
+
return out.length >= 2 ? out : []
|
|
6526
|
+
}
|
|
6527
|
+
/**
|
|
6528
|
+
* 单看时页面里点了换状态的链接(#30):顶栏记着的就是要的这个(在页面里去了别的页、又点链接回来,页面显示的不是顶栏那个状态),
|
|
6529
|
+
* 顶栏、地址都不会变 → 'reload' 重新载一遍这屏(不然点了没反应);不然 'pick' 交给顶栏换。def:要的是默认状态
|
|
6530
|
+
*/
|
|
6531
|
+
function stateGoPlan(src, d) {
|
|
6532
|
+
let had = ''
|
|
6533
|
+
try { had = new URL(src).searchParams.get('state') || '' } catch { /* 地址不认识:当默认 */ }
|
|
6534
|
+
return (had ? had === d.state : d.def === true) ? 'reload' : 'pick'
|
|
6535
|
+
}
|
|
6536
|
+
/** 换状态的链接带的锚点:接着载的那一帧带上(3 秒内有效,只用一次) */
|
|
6537
|
+
function withHashNext(url, hn, now) {
|
|
6538
|
+
return hn && typeof hn.hash === 'string' && now - hn.at < 3000 ? String(url).replace(/#.*$/, '') + hn.hash : url
|
|
6539
|
+
}
|
|
6540
|
+
/** 地址的路径(解码过;认不出给 '') */
|
|
6541
|
+
function pathOfUrl(url) {
|
|
6542
|
+
try { const p = new URL(url).pathname; try { return decodeURIComponent(p) } catch { return p } } catch { return '' }
|
|
6543
|
+
}
|
|
6544
|
+
/** 屏的地址换成某个状态(默认状态 / 空 = 去掉 ?state=) */
|
|
6545
|
+
function withState(url, state) {
|
|
6546
|
+
try {
|
|
6547
|
+
const u = new URL(url)
|
|
6548
|
+
if (state && STATE_RE.test(state)) u.searchParams.set('state', state)
|
|
6549
|
+
else u.searchParams.delete('state')
|
|
6550
|
+
return u.href
|
|
6551
|
+
} catch { return url }
|
|
6552
|
+
}
|
|
6553
|
+
|
|
6420
6554
|
/** 'WxH'(没有就按类型默认)→ [w, h] */
|
|
6421
6555
|
function sizeOf(size, kind) {
|
|
6422
6556
|
const m = /^(\d{2,5})x(\d{2,5})$/.exec(String(size || ''))
|
|
@@ -6461,6 +6595,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
6461
6595
|
const LAB = 34 // 每屏上面标题占的高度(屏幕像素,不跟着缩放)
|
|
6462
6596
|
const GAP = 18 // 两屏之间最少隔开的屏幕像素
|
|
6463
6597
|
const clampZ = (z) => Math.max(ZMIN, Math.min(ZMAX, z))
|
|
6598
|
+
const MAX_DOC_PAGES = 1000 // PDF / PPT 最多几页(和服务端 MAX_PAGES 一样)
|
|
6464
6599
|
const LIVE_MAX = 24 // 同时跑几个 iframe。超过这么多屏,画布只挂镜头附近的(选中的那屏总在),导出时分批挂
|
|
6465
6600
|
/** 该挂着的几屏:离镜头中心最近的 max 屏,选中的那屏排最前。cx、cy 是镜头中心在画布上的坐标 */
|
|
6466
6601
|
function nearestLive(ids, pos, dw, dh, cx, cy, selId, max, prev) {
|
|
@@ -7165,7 +7300,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7165
7300
|
/** 这一屏(预览服务器上的地址)打包后的取法。fresh:要求服务端别复用缓存、重新打包 */
|
|
7166
7301
|
function bundleOf(href, sid, fresh) {
|
|
7167
7302
|
let p
|
|
7168
|
-
|
|
7303
|
+
let state = ''
|
|
7304
|
+
try { const u = new URL(href); p = u.pathname; state = u.searchParams.get('state') || '' } catch { return '' }
|
|
7169
7305
|
try { p = decodeURIComponent(p) } catch { /* 原样 */ }
|
|
7170
7306
|
p = p.replace(/^\/+/, '')
|
|
7171
7307
|
let v = ''
|
|
@@ -7173,6 +7309,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7173
7309
|
if (m) { v = m[1]; p = m[2] }
|
|
7174
7310
|
if (!p || p.endsWith('/')) p += 'index.html'
|
|
7175
7311
|
const q = { session: sid, key: p, v, parent: location.origin }
|
|
7312
|
+
if (state && STATE_RE.test(state)) q.state = state // 一页多状态(#30):打包时就把 <html data-state> 设好
|
|
7176
7313
|
if (fresh) q.fresh = '1'
|
|
7177
7314
|
return `${API}bundle?${new URLSearchParams(q)}`
|
|
7178
7315
|
}
|
|
@@ -7422,6 +7559,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7422
7559
|
}
|
|
7423
7560
|
let url = P.current.src
|
|
7424
7561
|
try { if (seed && seed.href && new URL(seed.href).origin === origin) url = seed.href } catch { /* 用原地址 */ }
|
|
7562
|
+
// 换状态的链接带了锚点(见 stateGo):这一帧带上,页面载好自己滚过去
|
|
7563
|
+
if (!seed) url = withHashNext(url, L.hashNext, Date.now())
|
|
7564
|
+
L.hashNext = null
|
|
7425
7565
|
setFrames((fs) => [...fs, { id, src: url, dir: L.dir }])
|
|
7426
7566
|
}
|
|
7427
7567
|
|
|
@@ -7473,9 +7613,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7473
7613
|
}
|
|
7474
7614
|
}
|
|
7475
7615
|
|
|
7476
|
-
//
|
|
7616
|
+
// 换了页面:从头来。正在显示的那帧先留在底下(单看翻屏别先闪一下空白占位),新的一帧好了滑进来盖上、再撤掉它;
|
|
7617
|
+
// 它发来的消息一律不认(L.floor 之前的帧)。新的一帧迟迟没好(开发服务器连不上等)就撤掉它、露出占位,别让旧页冒充新页
|
|
7618
|
+
const remWas = useRef(!!rem)
|
|
7619
|
+
const [held, setHeld] = useState(0) // 留着垫底的那帧:只看,不能点、不能改(点了也不算数)
|
|
7477
7620
|
useEffect(() => {
|
|
7478
7621
|
const L = life.current
|
|
7622
|
+
const keep = src && cur && !errs[cur] && remWas.current === !!rem ? cur : 0
|
|
7623
|
+
remWas.current = !!rem
|
|
7624
|
+
setHeld(keep)
|
|
7625
|
+
if (keep) { try { const w = wins.current.get(keep); if (w && document.activeElement === w) w.blur() } catch { /* 拿不出来也只是多打几个字 */ } }
|
|
7479
7626
|
L.dir = P.current.flip || 0 // 单屏翻屏(‹ › ← →):新的一屏从这一侧滑进来
|
|
7480
7627
|
L.loading = 0
|
|
7481
7628
|
L.again = false
|
|
@@ -7484,17 +7631,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7484
7631
|
L.tops.clear()
|
|
7485
7632
|
L.gen++
|
|
7486
7633
|
L.at = ''
|
|
7634
|
+
L.trail = []
|
|
7487
7635
|
L.deps = null
|
|
7488
7636
|
L.fails = 0
|
|
7637
|
+
L.floor = L.next
|
|
7489
7638
|
curRef.current = 0
|
|
7490
|
-
|
|
7491
|
-
setFrames(
|
|
7639
|
+
clearTimeout(L.keepT)
|
|
7640
|
+
if (keep) setFrames((fs) => fs.filter((f) => f.id === keep))
|
|
7641
|
+
else {
|
|
7642
|
+
setCur(0)
|
|
7643
|
+
setFrames([])
|
|
7644
|
+
}
|
|
7492
7645
|
setFailed(false)
|
|
7493
7646
|
L.stale = 0
|
|
7494
7647
|
clearTimeout(L.first)
|
|
7495
7648
|
clearTimeout(L.snapTimer) // 上一页等着的刷新、重试别落到这一页
|
|
7496
7649
|
clearTimeout(L.retry)
|
|
7497
7650
|
const g = L.gen
|
|
7651
|
+
if (keep) L.keepT = setTimeout(() => { if (L.gen === g && !curRef.current) { setCur(0); setFrames((fs) => fs.filter((f) => f.id !== keep)) } }, 1500)
|
|
7498
7652
|
if (src) L.first = setTimeout(() => { if (L.gen === g) load(null) }, 0)
|
|
7499
7653
|
}, [src, !!rem])
|
|
7500
7654
|
|
|
@@ -7505,6 +7659,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7505
7659
|
clearTimeout(L.snapTimer)
|
|
7506
7660
|
clearTimeout(L.first)
|
|
7507
7661
|
clearTimeout(L.retry)
|
|
7662
|
+
clearTimeout(L.keepT)
|
|
7508
7663
|
}, [])
|
|
7509
7664
|
|
|
7510
7665
|
// 远程看:「哪些算别人做的」变了(别的会话退回了旧版、装了设计)——文件没动,但这一屏可能从此要加硬规矩,重取一次
|
|
@@ -7544,8 +7699,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7544
7699
|
let id = 0
|
|
7545
7700
|
for (const [k, f] of wins.current) if (f && f.contentWindow === e.source) { id = k; break }
|
|
7546
7701
|
const d = e.data
|
|
7547
|
-
if (!id || !d || d.dshDesign !== 1) return
|
|
7548
7702
|
const L = life.current
|
|
7703
|
+
if (!id || !d || d.dshDesign !== 1 || id < (L.floor || 0)) return // 换页时留着垫底的上一页:它说什么都不算
|
|
7549
7704
|
const p = P.current
|
|
7550
7705
|
const isCur = id === curRef.current
|
|
7551
7706
|
switch (d.type) {
|
|
@@ -7555,11 +7710,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7555
7710
|
L.seeds.delete(id)
|
|
7556
7711
|
L.seedOf.delete(id)
|
|
7557
7712
|
// 改动通知由右侧栏转告(见下面「本机预览」),页面别自己开 SSE;做出来的页面(ownEvents)不在设计目录里,让它自己听
|
|
7558
|
-
|
|
7713
|
+
// stateNav:这一帧本该显示哪一页(路径);页面里点了同一页换状态的链接才交给右侧栏(#30)
|
|
7714
|
+
postTo(id, { type: 'init', seed, relay: !P.current.ownEvents, stateNav: P.current.onStateGo ? pathOfUrl(P.current.src) : '' })
|
|
7559
7715
|
break
|
|
7560
7716
|
}
|
|
7561
7717
|
case 'ready': {
|
|
7562
7718
|
L.readied.add(id)
|
|
7719
|
+
// 这一帧写了哪几个状态(#30,远程看同一页换状态时认)
|
|
7720
|
+
if (!L.stBy) L.stBy = new Map()
|
|
7721
|
+
L.stBy.set(id, typeof d.states === 'string' ? parseStates(d.states.slice(0, 400)).map((x) => x.name) : [])
|
|
7722
|
+
if (L.stBy.size > 20) L.stBy.delete(L.stBy.keys().next().value)
|
|
7563
7723
|
L.title = d.title || ''
|
|
7564
7724
|
let fail = null
|
|
7565
7725
|
if (d.err) {
|
|
@@ -7579,8 +7739,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7579
7739
|
if (p.annotGo && list.some((x) => x.id === p.annotGo.current)) { postTo(id, { type: 'annotFocus', id: p.annotGo.current }); p.annotGo.current = '' }
|
|
7580
7740
|
}
|
|
7581
7741
|
}
|
|
7582
|
-
|
|
7583
|
-
|
|
7742
|
+
// 写了哪几个状态(#30):在这一帧里点链接去了别的页(单看时可以)就不记——不然顶栏的状态菜单拿着别的页的状态,切了载的却是这屏
|
|
7743
|
+
const away = !!d.href && !!p.src && pathOfUrl(d.href) !== pathOfUrl(p.src)
|
|
7744
|
+
if (p.onMeta) p.onMeta(d.meta || '', fail ? '' : d.title || '', Array.isArray(d.tokens) ? d.tokens : [], !!d.dark, Array.isArray(d.links) ? d.links : [], d.natural, fail ? fail.err : '', away ? undefined : { states: fail || typeof d.states !== 'string' ? '' : d.states.slice(0, 400) })
|
|
7745
|
+
if (p.onHref && d.href) p.onHref(d.href, typeof d.states === 'string' ? d.states.slice(0, 400) : '')
|
|
7584
7746
|
if (isCur) {
|
|
7585
7747
|
postTo(id, { type: 'reveal' })
|
|
7586
7748
|
postTo(id, { type: 'zoom', z: p.zoom || 1 })
|
|
@@ -7652,10 +7814,33 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7652
7814
|
case 'picked':
|
|
7653
7815
|
if (isCur && p.picking && p.onPicked) p.onPicked(d.payload)
|
|
7654
7816
|
break
|
|
7817
|
+
case 'stateGo': { // 单看时点了同一页换状态的链接(#30)
|
|
7818
|
+
if (!isCur || !p.onStateGo || typeof d.state !== 'string' || !STATE_RE.test(d.state)) break
|
|
7819
|
+
// 链接带的锚点(?state=paid#receipt):换好状态的那一帧载的时候带上(只认这一下,过会儿就不算了)
|
|
7820
|
+
L.hashNext = typeof d.hash === 'string' && /^#[^\s#]{1,200}$/.test(d.hash) ? { hash: d.hash, at: Date.now() } : null
|
|
7821
|
+
if (stateGoPlan(p.src, d) === 'reload') { L.at = ''; load(null, true) } else p.onStateGo(d.state)
|
|
7822
|
+
break
|
|
7823
|
+
}
|
|
7655
7824
|
case 'nav':
|
|
7656
7825
|
if (!isCur || typeof d.path !== 'string') break
|
|
7657
|
-
if (p.onNav) p.onNav(d.path)
|
|
7658
|
-
else if (remOf(p)) {
|
|
7826
|
+
if (p.onNav) p.onNav(d.path, typeof d.state === 'string' && STATE_RE.test(d.state) ? d.state : '', d.back === true, typeof d.hash === 'string' && /^#[^\s#]{1,200}$/.test(d.hash) ? d.hash : '')
|
|
7827
|
+
else if (remOf(p)) {
|
|
7828
|
+
// 远程看:页面里点了跳页,这一框换成那一页(和本机预览时 iframe 自己跳过去一样)。
|
|
7829
|
+
// 带状态(#30)的连状态一起;data-back 按这一框走过的路退一步,没得退才去它写的地方
|
|
7830
|
+
// data-back 和本机预览一样去它写的地方(按走过的路退只在试用里有)
|
|
7831
|
+
if (!d.path) break
|
|
7832
|
+
const s = typeof d.state === 'string' && STATE_RE.test(d.state) ? d.state : ''
|
|
7833
|
+
// 单看时还在原来那页里、换这页写了的状态(#30):和本机预览一样交给顶栏换(状态标签跟着变);不带状态 = 回默认。
|
|
7834
|
+
// 去了别的页、老页面(没写状态)的链接照常换页
|
|
7835
|
+
const dec = (L.stBy && L.stBy.get(id)) || []
|
|
7836
|
+
if (p.onStateGo && d.back !== true && !L.at && d.path === pathOfUrl(p.src) && dec.length && (!s || dec.includes(s))) {
|
|
7837
|
+
if (stateGoPlan(p.src, { state: s, def: !s }) === 'reload') load(null, true)
|
|
7838
|
+
else p.onStateGo(s)
|
|
7839
|
+
break
|
|
7840
|
+
}
|
|
7841
|
+
L.at = origin + d.path + (s ? '?state=' + s : '')
|
|
7842
|
+
load(null)
|
|
7843
|
+
}
|
|
7659
7844
|
break
|
|
7660
7845
|
case 'edited':
|
|
7661
7846
|
if (isCur && (p.textEdit || Date.now() - editOffAt.current < EDIT_GRACE_MS) && p.onEdited && typeof d.before === 'string' && typeof d.after === 'string') p.onEdited(d)
|
|
@@ -7798,12 +7983,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
7798
7983
|
return h('iframe', {
|
|
7799
7984
|
key: f.id,
|
|
7800
7985
|
ref: (el) => { if (el) wins.current.set(f.id, el); else wins.current.delete(f.id) },
|
|
7801
|
-
className: 'ddp-frame' + (f.id === cur ? ' cur' + (f.dir ? (f.dir > 0 ? ' fin-r' : ' fin-l') : '') : f.id < cur ? ' old' : ''),
|
|
7986
|
+
className: 'ddp-frame' + (f.id === cur ? ' cur' + (f.dir ? (f.dir > 0 ? ' fin-r' : ' fin-l') : '') + (f.id === held ? ' held' : '') : f.id < cur ? ' old' : ''),
|
|
7802
7987
|
...(typeof f.doc === 'string' ? { srcDoc: f.doc, sandbox: strict ? 'allow-scripts' : 'allow-scripts allow-forms', referrerPolicy: 'no-referrer' }
|
|
7803
7988
|
: strict ? { src: f.src, sandbox: 'allow-scripts allow-same-origin', referrerPolicy: 'no-referrer' } : { src: f.src }),
|
|
7804
7989
|
title: props.label || '',
|
|
7805
|
-
tabIndex: f.id === cur ? 0 : -1,
|
|
7806
|
-
'aria-hidden': f.id === cur ? undefined : true,
|
|
7990
|
+
tabIndex: f.id === cur && f.id !== held ? 0 : -1,
|
|
7991
|
+
'aria-hidden': f.id === cur && f.id !== held ? undefined : true,
|
|
7807
7992
|
allow: strict ? 'fullscreen' : 'clipboard-read; clipboard-write; fullscreen',
|
|
7808
7993
|
onLoad: () => onFrameLoad(f.id),
|
|
7809
7994
|
})
|
|
@@ -8752,7 +8937,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
8752
8937
|
* 体检面板(1.0):头上「5 屏 · 4 个问题」,问题排成卡片(宽了两列):圆点序号(红 = 严重、黄 = 一般,和页面上的记号一一对上,按屏各自编号),
|
|
8753
8938
|
* 第一行 什么问题 · 哪段字,第二行 哪一屏 · 量出来多少;底栏 一句说明 | 再查一次 · 让模型改
|
|
8754
8939
|
*/
|
|
8755
|
-
|
|
8940
|
+
/** 部件不一致的一条差在哪:padding 16px / 14px · border-radius 12px / 10px(who:每种写法后面带上哪几屏) */
|
|
8941
|
+
function driftDiff(t, it, who) {
|
|
8942
|
+
const scr = (keys) => keys.slice(0, 3).map((k) => String(k).replace(/\.html?$/i, '')).join(who === true ? '、' : ', ') + (keys.length > 3 ? ` +${keys.length - 3}` : '')
|
|
8943
|
+
return (it.props || []).map((p) => `${p.prop} ${(p.values || []).map((x) => (x.v || t('dfNone')) + (who ? `(${scr(x.keys || [])})` : '')).join(' / ')}`).join(who ? ';' : ' · ')
|
|
8944
|
+
}
|
|
8945
|
+
|
|
8946
|
+
function CheckPanel({ t, head, ck, nameOf = (x) => x, onFocus, onFix, onAgain, onDrift, onClose }) {
|
|
8756
8947
|
const list = ck.list || []
|
|
8757
8948
|
const n = list.reduce((m, x) => m + x.issues.length, 0)
|
|
8758
8949
|
const multi = list.length > 1
|
|
@@ -8770,12 +8961,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
8770
8961
|
})
|
|
8771
8962
|
}
|
|
8772
8963
|
const clean = !ck.running && !n && !list.some((sc) => sc.error)
|
|
8964
|
+
// 部件各屏写得不一样(#30):单独一组,不算进问题数;点一条把「统一它」放进输入框
|
|
8965
|
+
const df = !ck.running && ck.drift && ck.drift.items.length ? ck.drift : null
|
|
8966
|
+
const dfRows = df ? [
|
|
8967
|
+
h('div', { key: 'df:h', className: 'dd-ckgrp' }, t('dfHead')),
|
|
8968
|
+
...df.items.map((it, i) => h('button', { key: 'df:' + it.sel, className: 'ddp-ck dd-ck df', style: { '--i': Math.min(rows.length + i + 1, 12) }, ...tipA(it.sel, t('dfTip')), onClick: () => onDrift && onDrift(it) },
|
|
8969
|
+
h('i', { className: 'no df' }, '≠'),
|
|
8970
|
+
h('span', { className: 'tx' },
|
|
8971
|
+
h('span', { className: 'nm' }, h('code', null, it.sel), ' · ' + t('dfItem', { n: it.screens, v: it.variants })),
|
|
8972
|
+
h('span', { className: 'vl' }, driftDiff(t, it, false))))),
|
|
8973
|
+
df.more ? h('div', { key: 'df:m', className: 'dd-ckgrp more' }, t('dfMore', { n: df.more })) : null,
|
|
8974
|
+
] : []
|
|
8773
8975
|
return h('div', { className: 'ddp-tokens ddp-check', onPointerDown: (e) => e.stopPropagation() },
|
|
8774
8976
|
head,
|
|
8775
8977
|
h('div', { className: 'bd dd-cks' + (clean ? ' clean' : '') },
|
|
8776
8978
|
...rows,
|
|
8777
8979
|
ck.running && !rows.length ? h('div', { className: 'dd-ckwait' }, h('i', { className: 'dd-spin' }), h('span', null, t('checking'))) : null,
|
|
8778
|
-
clean ? h('div', { className: 'ok' }, h('i', { className: 'ring' }, h(I.shield)), h('b', null, t('checkNone')), h('span', null, t('checkNoneTip', { s: list.length }))) : null
|
|
8980
|
+
clean ? h('div', { className: 'ok' }, h('i', { className: 'ring' }, h(I.shield)), h('b', null, t('checkNone')), h('span', null, t('checkNoneTip', { s: list.length }))) : null,
|
|
8981
|
+
...dfRows),
|
|
8779
8982
|
h('footer', { className: 'dd-sf' },
|
|
8780
8983
|
h('span', { className: 'note' }),
|
|
8781
8984
|
h('button', { className: 'dd-bt ghost', onClick: onAgain, disabled: ck.running }, h(I.refresh), t('checkAgain')),
|
|
@@ -9336,15 +9539,19 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
9336
9539
|
const list = info.kind === 'miniprogram' ? [...FW_MINI, ...FW_LIST] : FW_LIST
|
|
9337
9540
|
const name = (k) => (k === 'html' ? t('hoHtml') : k === 'uniapp' ? t('hoUni') : k === 'weapp' ? t('hoWeapp') : FW_LABEL[k])
|
|
9338
9541
|
// [键, 交给模型的名字, 卡片上的名字, 小标签]
|
|
9339
|
-
|
|
9340
|
-
|
|
9542
|
+
// 选的文件夹本身就是 React + Vite 这类认得出的项目:列表里同名那项和「和项目一样」是一回事,只留后者(选过同名那项就算选了它)
|
|
9543
|
+
// 手改了路径(还没认过)就不去重:用户点的框架照原样发
|
|
9544
|
+
const dupK = same && dest.trim() === info.dest ? list.find((k) => name(k) === sameLabel) || '' : ''
|
|
9545
|
+
const opts = [...(same ? [['same', t('hoSame', { label: sameLabel }), sameLabel, t('hoSameTag')]] : []), ...list.filter((k) => k !== dupK).map((k) => [k, name(k), name(k), ''])]
|
|
9546
|
+
const fwOn = dupK && fw === dupK ? 'same' : fw
|
|
9547
|
+
const pick = opts.find(([k]) => k === fwOn)
|
|
9341
9548
|
const label = pick ? pick[1] : ''
|
|
9342
9549
|
const count = screens.length
|
|
9343
9550
|
const curSc = cur ? screens.find((x) => x.key === cur) : null
|
|
9344
9551
|
const only = one && count > 1 && curSc ? curSc.key : ''
|
|
9345
|
-
const rc = ([k, , l, tag]) => h('div', { key: k, className: 'dd-rc' + (
|
|
9346
|
-
h('button', { type: 'button', role: 'radio', 'aria-checked':
|
|
9347
|
-
h('i', { className: 'rd' },
|
|
9552
|
+
const rc = ([k, , l, tag]) => h('div', { key: k, className: 'dd-rc' + (fwOn === k ? ' on' : '') },
|
|
9553
|
+
h('button', { type: 'button', role: 'radio', 'aria-checked': fwOn === k, className: 'opt' + (fwOn === k ? ' on' : ''), title: l, onClick: () => { live.current.hand = true; setFw(k) } },
|
|
9554
|
+
h('i', { className: 'rd' }, fwOn === k ? h(I.check) : null),
|
|
9348
9555
|
h('span', null, h('b', null, l), tag ? h('em', { className: 'tag' }, tag) : null)))
|
|
9349
9556
|
// 做完怎么验:每屏一行,记着和做出来的比过就写差多少;点一行直接去比
|
|
9350
9557
|
const row = (x, i) => {
|
|
@@ -9380,7 +9587,25 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
9380
9587
|
h('footer', { className: 'dd-sf' },
|
|
9381
9588
|
h('span', { className: 'note' }, [pick ? pick[2] : '', only ? t('hoOneName', { name: curSc.label }) : t('hoAll', { n: count || 1 })].filter(Boolean).join(' · ')),
|
|
9382
9589
|
implBt,
|
|
9383
|
-
h('button', { className: 'dd-bt pri', disabled: !
|
|
9590
|
+
h('button', { className: 'dd-bt pri', disabled: !fwOn || !dest.trim() || checking === 'busy', onClick: () => onGo({ fw: fwOn, label, dest: dest.trim(), only, wx: fwOn === 'weapp' ? true : fwOn !== 'same' ? false : dest.trim() === info.dest ? p.framework === 'weapp' : null }) }, h(I.sparkle), h('span', null, t('hoGo')))))
|
|
9591
|
+
}
|
|
9592
|
+
|
|
9593
|
+
// 认出来的产品名记在本机(目录 → 名字,最多 60 个);记不住就只在这次打开里有效
|
|
9594
|
+
const BRAND_LS = 'ddp-brands'
|
|
9595
|
+
function loadBrands() {
|
|
9596
|
+
try { const o = JSON.parse(localStorage.getItem(BRAND_LS) || '{}'); return o && typeof o === 'object' && !Array.isArray(o) ? o : {} } catch { return {} }
|
|
9597
|
+
}
|
|
9598
|
+
function saveBrand(site, brand) {
|
|
9599
|
+
if (!String(site).startsWith('file:')) return // 开发服务器(端口)过几天可能跑的是别的项目:只在这次打开里记
|
|
9600
|
+
try {
|
|
9601
|
+
const o = loadBrands()
|
|
9602
|
+
if (o[site] === (brand || undefined)) return
|
|
9603
|
+
delete o[site]
|
|
9604
|
+
if (brand) o[site] = brand
|
|
9605
|
+
const ks = Object.keys(o)
|
|
9606
|
+
for (const k of ks.slice(0, Math.max(0, ks.length - 60))) delete o[k]
|
|
9607
|
+
localStorage.setItem(BRAND_LS, JSON.stringify(o))
|
|
9608
|
+
} catch { /* 记不住就这次有效 */ }
|
|
9384
9609
|
}
|
|
9385
9610
|
|
|
9386
9611
|
/** 按的是 Esc、而且不是在输入法组字里取消选字(那一下归输入法,别关菜单 / 面板) */
|
|
@@ -9975,6 +10200,44 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
9975
10200
|
h('div', { className: 'dd-smf', 'aria-hidden': true }, h('kbd', null, '↑↓'), h('span', null, t('scrKeyPick')), h('kbd', null, '↵'), h('span', null, t('scrKeyOpen')))) : null))
|
|
9976
10201
|
}
|
|
9977
10202
|
|
|
10203
|
+
/**
|
|
10204
|
+
* 一页多状态(#30)的状态菜单:画布上屏名旁、单看时顶栏的「状态 ▾」点出来。浮在台面上(屏名那一行会裁掉超出的部分),
|
|
10205
|
+
* 位置 at 是相对台面的。点外面、按 Esc 收起;↑↓ 回车也能选
|
|
10206
|
+
*/
|
|
10207
|
+
function StateMenu({ t, at, name, list, cur, onPick, onAll, allOn, onClose }) {
|
|
10208
|
+
const ref = useRef(null)
|
|
10209
|
+
const [hi, setHi] = useState(() => Math.max(0, list.findIndex((x) => x.name === cur)))
|
|
10210
|
+
const closeR = useRef(onClose)
|
|
10211
|
+
closeR.current = onClose
|
|
10212
|
+
useEffect(() => {
|
|
10213
|
+
const off = (e) => { if (ref.current && !ref.current.contains(e.target) && !(e.target.closest && e.target.closest('.ddp-stt'))) closeR.current() }
|
|
10214
|
+
// 捕获阶段先收:别让同一下 Esc 再把单看退回画布、退出试用
|
|
10215
|
+
const esc = (e) => { if (isEsc(e)) { e.preventDefault(); e.stopPropagation(); closeR.current(true) } }
|
|
10216
|
+
document.addEventListener('pointerdown', off, true)
|
|
10217
|
+
window.addEventListener('keydown', esc, true)
|
|
10218
|
+
try { if (ref.current) ref.current.focus({ preventScroll: true }) } catch { /* 拿不到焦点也能点 */ }
|
|
10219
|
+
return () => {
|
|
10220
|
+
document.removeEventListener('pointerdown', off, true)
|
|
10221
|
+
window.removeEventListener('keydown', esc, true)
|
|
10222
|
+
}
|
|
10223
|
+
}, [])
|
|
10224
|
+
const pick = (x) => { onPick(x.name); onClose(true) }
|
|
10225
|
+
const key = (e) => {
|
|
10226
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); setHi((i) => Math.min(list.length - (onAll ? 0 : 1), i + 1)) }
|
|
10227
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); setHi((i) => Math.max(0, i - 1)) }
|
|
10228
|
+
else if (e.key === 'Enter') { e.preventDefault(); if (hi < list.length) pick(list[hi]); else if (onAll) { onAll(); onClose(true) } }
|
|
10229
|
+
}
|
|
10230
|
+
return h('div', { ref, className: 'ddp-menu dd-sm ddp-stmenu', role: 'menu', 'aria-label': t('stMenuT', { name }), tabIndex: -1, style: { left: at.x, top: at.y }, onKeyDown: key },
|
|
10231
|
+
h('div', { className: 'hd' }, t('stMenuT', { name })),
|
|
10232
|
+
h('div', { className: 'ls' },
|
|
10233
|
+
...list.map((x, i) => h('button', { key: x.name, tabIndex: -1, role: 'menuitemradio', 'aria-checked': x.name === cur, className: (x.name === cur ? 'sel' : '') + (i === hi ? ' hi' : ''), onMouseEnter: () => setHi(i), onClick: () => pick(x) },
|
|
10234
|
+
h('span', null, x.label),
|
|
10235
|
+
h('em', null, i === 0 ? (x.label === x.name ? t('stDefault') : x.name + ' · ' + t('stDefault')) : x.label === x.name ? '' : x.name),
|
|
10236
|
+
x.name === cur ? h(I.check) : h('i', { className: 'ck', 'aria-hidden': true })))),
|
|
10237
|
+
onAll ? h('div', { className: 'sp' }) : null,
|
|
10238
|
+
onAll ? h('button', { className: (allOn ? 'sel' : '') + (list.length === hi ? ' hi' : ''), role: 'menuitemcheckbox', 'aria-checked': !!allOn, title: t('dStAll'), onMouseEnter: () => setHi(list.length), onClick: () => { onAll(); onClose(true) } }, h(I.sideBy), h('span', null, t('stSide')), allOn ? h(I.check) : null) : null)
|
|
10239
|
+
}
|
|
10240
|
+
|
|
9978
10241
|
// 左上屏名 ▾:换屏(画布 / 某一屏)、多尺寸、类型、打开别的页面——「在看什么、怎么看」都在这一个菜单里
|
|
9979
10242
|
/** 屏名菜单里的「画幅」一行(#23):显示现在多大,点「自定义…」填宽×高,改过的能恢复默认 */
|
|
9980
10243
|
function SizeRow({ t, size, custom, onSize, done }) {
|
|
@@ -10957,7 +11220,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
10957
11220
|
return c
|
|
10958
11221
|
}
|
|
10959
11222
|
|
|
10960
|
-
function ExportPanel({ t, head, fmt = 'pdf', imgModes = [], onImg, kind, size, opts, setOpts, screens, items = [], curKey = '', canvas, rev, measure, onResize, onExport, onClose }) {
|
|
11223
|
+
function ExportPanel({ t, head, fmt = 'pdf', imgModes = [], onImg, kind, size, opts, setOpts, screens, items = [], stCount = null, curKey = '', canvas, rev, measure, onResize, onExport, onClose }) {
|
|
10961
11224
|
const [im, setIm] = useState('')
|
|
10962
11225
|
const imCur = imgModes.some((x) => x[0] === im) ? im : (imgModes[0] || [''])[0]
|
|
10963
11226
|
const [list, setList] = useState(null)
|
|
@@ -10976,7 +11239,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
10976
11239
|
measure(tok).then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
|
|
10977
11240
|
}, first ? 0 : 900)
|
|
10978
11241
|
return () => { off = true; tok.off = true; clearTimeout(timer) }
|
|
10979
|
-
}, [size.join('x'), screens, rev, again])
|
|
11242
|
+
}, [size.join('x'), screens, rev, again, opts.states ? 1 : 0])
|
|
10980
11243
|
// 导出哪些:全部 / 只导当前这屏 / 挑几屏(挑的屏改名、删了就不算)
|
|
10981
11244
|
const cur = items.find((x) => x.key === curKey) || items[0]
|
|
10982
11245
|
const has = new Set(items.map((x) => x.key))
|
|
@@ -10984,7 +11247,11 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
10984
11247
|
const scope = opts.scope === 'cur' && cur ? 'cur' : opts.scope === 'pick' ? 'pick' : 'all'
|
|
10985
11248
|
const keys = scope === 'cur' ? [cur.key] : scope === 'pick' ? items.map((x) => x.key).filter((k) => picked.includes(k)) : null
|
|
10986
11249
|
const want = keys ? new Set(keys) : null
|
|
10987
|
-
|
|
11250
|
+
// 每个状态各出一张(#30):写了状态的屏一个状态一页
|
|
11251
|
+
const stOf = (k) => (stCount && stCount[k] > 1 ? stCount[k] : 1)
|
|
11252
|
+
const anyStates = items.some((x) => stOf(x.key) > 1)
|
|
11253
|
+
const extra = anyStates ? (keys || items.map((x) => x.key)).reduce((m, k) => m + stOf(k) - 1, 0) : 0
|
|
11254
|
+
const count = (keys ? keys.length : items.length) + (opts.states ? extra : 0)
|
|
10988
11255
|
// 量到的结果和 items 一一对应:只看这次要导的那些
|
|
10989
11256
|
const mine = list ? list.map((m, i) => [m, items[i]]).filter(([, x]) => !want || (x && want.has(x.key))) : null
|
|
10990
11257
|
// 和真导出同一套取景:PDF 页签里网页、邮件没选怎么截时放整页长图(不会裁),只有 PPT 截首屏
|
|
@@ -11019,7 +11286,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11019
11286
|
}
|
|
11020
11287
|
const ppt = fmt === 'pptx'
|
|
11021
11288
|
const cols = opts.cols === 2 ? 2 : 1
|
|
11022
|
-
const pages = Math.ceil(count / cols)
|
|
11289
|
+
const pages = Math.ceil(Math.min(count, MAX_DOC_PAGES) / cols)
|
|
11023
11290
|
const long = opts.fit === 'page' || (!opts.fit && !ppt && (kind === 'web' || kind === 'email'))
|
|
11024
11291
|
// 底栏一句话:格式 · 几页 · 多大 · 每页是图片
|
|
11025
11292
|
const sz = opts.layout === 'custom' ? (layoutOk(opts.custom) ? opts.custom.trim().replace(/\s*[x×*]\s*/, ' × ') : '') : opts.layout === 'a3' ? t('xoA3') : opts.layout !== 'auto' ? opts.layout
|
|
@@ -11037,10 +11304,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11037
11304
|
h('div', { className: 'dd-col' },
|
|
11038
11305
|
h('h6', null, t('xoWhich')),
|
|
11039
11306
|
h('div', { className: 'dd-rcs', role: 'radiogroup', 'aria-label': t('xoWhich') },
|
|
11040
|
-
radio('all', t('xoAll', { n: items.length }), scope === 'all' ? t(canvas ? 'xoAllSub' : 'xoAllSub1', { n: items.length, m:
|
|
11307
|
+
radio('all', t('xoAll', { n: items.length }), scope === 'all' ? t(canvas ? 'xoAllSub' : 'xoAllSub1', { n: items.length, m: pages }) : ''),
|
|
11041
11308
|
items.length > 1 && cur ? radio('cur', t('xoCur', { name: cur.label })) : null,
|
|
11042
11309
|
items.length > 1 ? radio('pick', scope === 'pick' ? t('xoPickN', { n: picked.length }) : t('xoPick'), scope === 'pick' && !picked.length ? t('xoPickNone') : '',
|
|
11043
|
-
scope === 'pick' ? h('div', { className: 'dd-pk' }, ...items.map((x) => h('button', { key: x.key, type: 'button', role: 'checkbox', 'aria-checked': picked.includes(x.key), className: picked.includes(x.key) ? 'on' : '', title: x.label, onClick: () => toggle(x.key) }, h('i', null, picked.includes(x.key) ? h(I.check) : null), h('span', null, x.label)))) : null) : null)
|
|
11310
|
+
scope === 'pick' ? h('div', { className: 'dd-pk' }, ...items.map((x) => h('button', { key: x.key, type: 'button', role: 'checkbox', 'aria-checked': picked.includes(x.key), className: picked.includes(x.key) ? 'on' : '', title: x.label, onClick: () => toggle(x.key) }, h('i', null, picked.includes(x.key) ? h(I.check) : null), h('span', null, x.label)))) : null) : null),
|
|
11311
|
+
anyStates ? h('div', { className: 'dd-pk dd-xst' }, h('button', { type: 'button', role: 'checkbox', 'aria-checked': !!opts.states, className: opts.states ? 'on' : '', onClick: () => setOpts({ ...opts, states: !opts.states }) },
|
|
11312
|
+
h('i', null, opts.states ? h(I.check) : null), h('span', null, t('xoStates')), extra ? h('em', null, t('xoStatesN', { n: extra })) : null)) : null),
|
|
11044
11313
|
h('div', { className: 'dd-col' },
|
|
11045
11314
|
h('h6', null, t('xoLayout')),
|
|
11046
11315
|
chips('layout', t('xoLayout'), [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
|
|
@@ -11061,6 +11330,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11061
11330
|
rep && rep.ai ? h('p', { className: 'sm' }, t('xoAi', { n: rep.ai })) : null,
|
|
11062
11331
|
rep && rep.fail ? h('p', { className: 'sm' }, t('xoFail', { n: rep.fail })) : null,
|
|
11063
11332
|
rep && !cut && !rep.dead && !rep.fail ? h('p', null, h(I.check), t('xoClean')) : null,
|
|
11333
|
+
rep && opts.states && extra ? h('p', { className: 'sm' }, t('xoStNoCheck', { n: extra })) : null,
|
|
11064
11334
|
rep ? h('div', { className: 'act' },
|
|
11065
11335
|
rep.over && canFit ? h('button', { type: 'button', className: 'dd-xbt', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', ' × ') })) : null,
|
|
11066
11336
|
(rep.long || rep.moved) && opts.fit !== 'page' ? h('button', { type: 'button', className: 'dd-xbt', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
|
|
@@ -11728,7 +11998,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11728
11998
|
// 拖背景 / 挡板 = 平移;没拖动就算点了一下
|
|
11729
11999
|
const onPointerDown = (e) => {
|
|
11730
12000
|
if (e.button !== 0 || !camRef.current) return
|
|
11731
|
-
if (e.target.closest && e.target.closest('.ddp-zoom, .ddp-act, .ddp-take, .ddp-fail button')) return
|
|
12001
|
+
if (e.target.closest && e.target.closest('.ddp-zoom, .ddp-act, .ddp-take, .ddp-stt, .ddp-fail button')) return
|
|
11732
12002
|
const keyEl = e.target.closest ? e.target.closest('[data-key]') : null
|
|
11733
12003
|
const d = { x: e.clientX, y: e.clientY, cam: camRef.current, moved: false, key: keyEl ? keyEl.getAttribute('data-key') : '' }
|
|
11734
12004
|
const move = (ev) => {
|
|
@@ -11803,7 +12073,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11803
12073
|
},
|
|
11804
12074
|
done ? h('i', { key: 'au', className: 'dd-au out', 'aria-hidden': true }, h('b')) : null,
|
|
11805
12075
|
done ? h('i', { key: 'gl', className: 'dd-glow out', 'aria-hidden': true }, h('b')) : null,
|
|
11806
|
-
lab(sc.key, [props.tag ? props.tag(sc) : null, h('span', { key: 's' }, labelOf(sc)), !picking && props.badge ? props.badge(sc) : null, !picking && props.actions ? h('span', { key: 'a', className: 'ddp-act' }, ...props.actions(sc)) : null], cw),
|
|
12076
|
+
lab(sc.key, [props.tag ? props.tag(sc) : null, h('span', { key: 's' }, labelOf(sc)), !picking && props.stateChip ? props.stateChip(sc) : null, !picking && props.badge ? props.badge(sc) : null, !picking && props.actions ? h('span', { key: 'a', className: 'ddp-act' }, ...props.actions(sc)) : null], cw),
|
|
11807
12077
|
cull && !(live && live.has(sc.id || sc.key)) ? props.sleep(sc, z) : props.render(sc, z, i),
|
|
11808
12078
|
picking ? null : h('div', { className: 'ddp-shield', 'data-key': sc.key, title: items ? '' : t('openScreen'), style: { borderRadius: fr.r } })))
|
|
11809
12079
|
})
|
|
@@ -11866,8 +12136,28 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11866
12136
|
return list.map((x) => by.get(x.key) || x)
|
|
11867
12137
|
}
|
|
11868
12138
|
|
|
12139
|
+
/**
|
|
12140
|
+
* 导出「每个状态各出一张」(#30):写了状态的屏按状态展开成几页(xs = 状态名)。默认状态那页 key 不变(别的屏跳过来落在它上面),
|
|
12141
|
+
* 其余几页 key 带 ?state=(原型里跳到某个状态的链接落在那页,见 doc 路由)
|
|
12142
|
+
*/
|
|
12143
|
+
function byStates(list, statesFor) {
|
|
12144
|
+
const out = []
|
|
12145
|
+
for (const sc of list) {
|
|
12146
|
+
const ss = sc.v ? [] : statesFor(sc.key) || []
|
|
12147
|
+
if (ss.length < 2) { out.push(sc); continue }
|
|
12148
|
+
ss.forEach((s, i) => out.push({ ...sc, url: withState(sc.url, i ? s.name : ''), xs: s.name, xsLabel: s.label, xsFirst: i === 0 }))
|
|
12149
|
+
}
|
|
12150
|
+
return out
|
|
12151
|
+
}
|
|
12152
|
+
/** 某个状态那页的标题:「订单 · 梅林练」→「订单(已付款) · 梅林练」(屏名后面带上状态,产品名还在原处,拼大标题照样认得出) */
|
|
12153
|
+
function stateTitle(title, label) {
|
|
12154
|
+
const tag = /^[\x20-\x7e]*$/.test(label) ? ` (${label})` : `(${label})`
|
|
12155
|
+
const m = /\s*[·||—]\s*|\s+[-–]\s+/.exec(title)
|
|
12156
|
+
return m ? title.slice(0, m.index) + tag + title.slice(m.index) : title + tag
|
|
12157
|
+
}
|
|
12158
|
+
|
|
11869
12159
|
function makeExporter(x) {
|
|
11870
|
-
const { sid, st, kind, size, dark, meta, tokens, t, say, canvas, focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, onWarn, apiOf, targetKey, tops, tweak, webFit } = x
|
|
12160
|
+
const { sid, st, kind, size, dark, meta, tokens, t, say, canvas, focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, onWarn, apiOf, targetKey, tops, tweak, webFit, statesFor } = x
|
|
11871
12161
|
const sayErr = (m, a) => say(m, a, true) // 没成的事:红色消息条,不自己走
|
|
11872
12162
|
// 导出用的全部屏(#29):屏多过上限时右侧栏只显示最新的 60 屏,收起来的那些接在前面;没收起来就是显示的这些
|
|
11873
12163
|
let every = x.every || shown
|
|
@@ -11930,16 +12220,27 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11930
12220
|
ghostQueue.current = job.catch(() => {})
|
|
11931
12221
|
return job
|
|
11932
12222
|
}
|
|
11933
|
-
const measureAll = async (map, tok) => {
|
|
12223
|
+
const measureAll = async (map, tok, pool = every) => {
|
|
11934
12224
|
const stamp = designSeq.current
|
|
11935
12225
|
const list = []
|
|
11936
|
-
for (const [i, sc] of
|
|
12226
|
+
for (const [i, sc] of pool.entries()) {
|
|
11937
12227
|
if (designSeq.current !== stamp || (tok && tok.off)) break // 设计换了 / 选项面板这一遍作废:别再等旧的屏
|
|
11938
|
-
if (
|
|
12228
|
+
if (pool.length > LIVE_MAX) say(t('xoCheckingN', { i: i + 1, n: pool.length }))
|
|
11939
12229
|
try { const api = await apiOf(sc, map); list.push(await api.measure()) } catch (e) { console.warn('[dsh-design-studio] 量页面失败', sc.key, e); list.push({ failed: true }) }
|
|
11940
12230
|
}
|
|
11941
12231
|
return list
|
|
11942
12232
|
}
|
|
12233
|
+
// 「每个状态各出一张」(#30):默认那页按默认状态截(画布上这屏选着别的状态也一样,见 byStates)。
|
|
12234
|
+
// 选项面板的预检也量默认状态,和导出对得上(xs 让它在背后另挂一个,不拿画布上正显示别的状态的那个)
|
|
12235
|
+
const toDefault = (sc) => {
|
|
12236
|
+
if (!sc.state || sc.v || !statesFor) return sc
|
|
12237
|
+
const ss = statesFor(sc.key) || []
|
|
12238
|
+
return ss.length >= 2 ? { ...sc, url: withState(sc.url, ''), state: '', xs: ss[0].name, xsLabel: ss[0].label, xsFirst: true } : sc
|
|
12239
|
+
}
|
|
12240
|
+
const precheck = (tok, def) => {
|
|
12241
|
+
const pool = def ? every.map(toDefault) : every
|
|
12242
|
+
return withFrames((map) => (tok && tok.off ? [] : measureAll(map, tok, pool)), undefined, pool)
|
|
12243
|
+
}
|
|
11943
12244
|
|
|
11944
12245
|
// 图片 / 整套展示图 / PDF / PPT(菜单里的「选项」「打包」「分享」在面板里分流,见 doExport)
|
|
11945
12246
|
const exportShots = async (mode, key, opts) => {
|
|
@@ -11961,7 +12262,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11961
12262
|
if (gone()) { sayErr(t('xoGone')); return }
|
|
11962
12263
|
// 面板里挑了「只导这屏 / 挑几屏」:只截这些(顺序照右侧栏)
|
|
11963
12264
|
const want = opts && Array.isArray(opts.keys) ? new Set(opts.keys) : null
|
|
11964
|
-
const
|
|
12265
|
+
const base = want ? every.filter((sc) => want.has(ik(sc))) : every
|
|
12266
|
+
// 「每个状态各出一张」:写了状态的屏按状态展开(超过页数上限的不导,提示里说)。
|
|
12267
|
+
// 本地文件的设计这时再问一次服务端各屏写了哪几个状态(面板刚打开、刚换了设计时手上的可能还没回来,别按「没写」少导几页);问不到就不导
|
|
12268
|
+
let stFor = statesFor
|
|
12269
|
+
if (opts && opts.states && !ver && x.loadStates) {
|
|
12270
|
+
try { const map = await x.loadStates(); stFor = (key) => map[key] || [] } catch (e) { console.warn('[dsh-design-studio] 取状态失败', e); sayErr(t('xoStFail')); return }
|
|
12271
|
+
if (gone()) { sayErr(t('xoGone')); return }
|
|
12272
|
+
}
|
|
12273
|
+
let list = opts && opts.states && !ver && stFor ? byStates(base, stFor) : base
|
|
12274
|
+
if (list.length > base.length && list.length > MAX_DOC_PAGES) { cutN += list.length - MAX_DOC_PAGES; list = list.slice(0, MAX_DOC_PAGES) }
|
|
11965
12275
|
if (!list.length) throw new Error('no screens')
|
|
11966
12276
|
await withFrames(async (map) => {
|
|
11967
12277
|
// 从菜单直接点:先量一遍,有内容会被裁就先给看清单(同样的结果只拦一次)
|
|
@@ -11995,7 +12305,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
11995
12305
|
const r = await captureOf(sc, long, map, maxH, aiShot)
|
|
11996
12306
|
const cut = maxH && r.h > maxH
|
|
11997
12307
|
const title = exportTitle(sc, r)
|
|
11998
|
-
|
|
12308
|
+
// 按状态展开的页:标题带上状态名;跳到某个状态的链接(?state=)落在那个状态那页,没展开就落在那屏
|
|
12309
|
+
batch.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title: sc.xs ? stateTitle(title, sc.xsLabel) : title, key: sc.xs && !sc.xsFirst ? `${sc.key}?state=${sc.xs}` : sc.key, links: r.links.map((l) => ({ x: l.x, y: l.y, w: l.w, h: l.h, key: keyOfPath(l.path, fileTarget) + (l.state ? '?state=' + l.state : '') })) })
|
|
11999
12310
|
titles.push(title)
|
|
12000
12311
|
n++
|
|
12001
12312
|
} catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
|
|
@@ -12109,7 +12420,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12109
12420
|
else sayErr(t('exportFail', { msg: m }), { label: t('retry'), run: () => exportHtml() })
|
|
12110
12421
|
}
|
|
12111
12422
|
}
|
|
12112
|
-
return { withFrames, measureAll, exportShots, exportHtml, htmlBody, loadEvery }
|
|
12423
|
+
return { withFrames, measureAll, precheck, exportShots, exportHtml, htmlBody, loadEvery }
|
|
12113
12424
|
}
|
|
12114
12425
|
|
|
12115
12426
|
// ── 画笔标注(从预览面板里拆出来的):台面上看得到的几屏截图拼好、叠上画的,存进 refs/ 交给模型,或者复制
|
|
@@ -12302,7 +12613,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12302
12613
|
// ── 设计体检(从预览面板里拆出来的):画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里
|
|
12303
12614
|
// x:这一次画面的值和几个 ref;onOpen:开体检面板时收掉别的面板。自动量、check_design 回话的 effect 留在面板里
|
|
12304
12615
|
function makeCheck(x) {
|
|
12305
|
-
const { kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, onOpen, insert, say, t } = x
|
|
12616
|
+
const { sid, fileTarget, kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, onOpen, insert, say, t } = x
|
|
12306
12617
|
const sayErr = (m, a) => say(m, a, true) // 没成的事:红色消息条,不自己走
|
|
12307
12618
|
const closeCheck = () => {
|
|
12308
12619
|
ckGen.current++
|
|
@@ -12328,13 +12639,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12328
12639
|
setCk({ running: true, list: [] })
|
|
12329
12640
|
const g = ++ckGen.current
|
|
12330
12641
|
ckOpen.current = true
|
|
12642
|
+
// 共用部件各屏写得不一样(#30):服务端读文件比,和量页面一起跑;问不到就不显示这一组
|
|
12643
|
+
const dr = fileTarget && sid ? post('drift', { session: sid }).catch(() => null) : Promise.resolve(null)
|
|
12331
12644
|
const out = await measure(checkList(), false)
|
|
12645
|
+
const d = await dr
|
|
12332
12646
|
if (g !== ckGen.current) { // 量的时候面板关了 / 又量了一轮:这份结果作废;面板关着的话,这一轮画上的标记也清掉
|
|
12333
12647
|
if (!ckOpen.current) for (const sc of out) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
|
|
12334
12648
|
return out
|
|
12335
12649
|
}
|
|
12336
12650
|
if (canvas && shown.length > LIVE_MAX) say(t('checkPartial', { n: out.length }))
|
|
12337
|
-
setCk({ running: false, list: out })
|
|
12651
|
+
setCk({ running: false, list: out, drift: d && Array.isArray(d.items) && d.items.length ? d : null })
|
|
12338
12652
|
setCkCount(total(out))
|
|
12339
12653
|
// 有问题的第一屏被面板挡着、在画布外面:挪过来
|
|
12340
12654
|
const first = out.find((x) => x.issues.length)
|
|
@@ -12355,7 +12669,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12355
12669
|
insert(formatCheck(t, ck.list, stRef.current), 'insertedSend')
|
|
12356
12670
|
closeCheck()
|
|
12357
12671
|
}
|
|
12358
|
-
|
|
12672
|
+
// 部件不一致的一条:放进输入框(不发),用户看了再发
|
|
12673
|
+
const askDrift = (it) => insert(t('dfAsk', { sel: it.sel, n: it.screens, v: it.variants, diff: driftDiff(t, it, true) }), 'inserted')
|
|
12674
|
+
return { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues, askDrift }
|
|
12359
12675
|
}
|
|
12360
12676
|
|
|
12361
12677
|
// ── 调样式(从预览面板里拆出来的):点一个元素,面板里拖滑块先在页面上看效果;写回文件 = 并进它在源码里的 style 属性
|
|
@@ -12502,44 +12818,65 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12502
12818
|
return { implLoad, implRecompare }
|
|
12503
12819
|
}
|
|
12504
12820
|
|
|
12821
|
+
/**
|
|
12822
|
+
* 试用(演示)里走过的路:stack 是 [{ key 哪一屏, state 哪个状态(#30,'' = 页面默认的)}],最多记 30 步。
|
|
12823
|
+
* 点到的正好是上一步那屏(同一状态)就当返回(反向过场);写了 data-back 的按走过的路退一步,没得退才去它的 href
|
|
12824
|
+
*/
|
|
12505
12825
|
function makeDemoNav(x) {
|
|
12506
|
-
const { setDemo, demoSeq, fileTarget } = x
|
|
12507
|
-
|
|
12508
|
-
const
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
const last = d.layers[d.layers.length - 1]
|
|
12516
|
-
return { stack, layers: [last, { id: ++demoSeq.current, key, dir: back ? -1 : 1, shown: false }] }
|
|
12517
|
-
})
|
|
12826
|
+
const { setDemo, demoSeq, fileTarget, defOf = () => '' } = x
|
|
12827
|
+
// 默认状态写不写都是同一屏(order.html 和 order.html?state=default):不然两种写法回默认,返回的路不一样
|
|
12828
|
+
const norm = (a, def = defOf(a.key)) => (a.state && a.state !== def ? a.state : '')
|
|
12829
|
+
const same = (a, b) => !!a && !!b && a.key === b.key && norm(a) === norm(b)
|
|
12830
|
+
const pop = (d, hash = '') => {
|
|
12831
|
+
const stack = d.stack.slice(0, -1)
|
|
12832
|
+
const to = stack[stack.length - 1]
|
|
12833
|
+
const last = d.layers[d.layers.length - 1]
|
|
12834
|
+
return { stack, layers: [last, { id: ++demoSeq.current, key: to.key, state: to.state || '', dir: -1, shown: false, ...(hash ? { hash } : null) }] }
|
|
12518
12835
|
}
|
|
12519
|
-
|
|
12520
|
-
|
|
12836
|
+
// hash:链接里的锚点(换到那一屏 / 那个状态后滚过去),只放在这一层的地址上,不算进走过的路
|
|
12837
|
+
const go = (d, at, hash = '') => {
|
|
12838
|
+
if (same(at, d.stack[d.stack.length - 1])) return d
|
|
12839
|
+
if (d.stack.length > 1 && same(at, d.stack[d.stack.length - 2])) return pop(d, hash) // 点回上一步(?state=default#receipt):锚点照带
|
|
12521
12840
|
const last = d.layers[d.layers.length - 1]
|
|
12522
|
-
return { stack: [d.stack
|
|
12523
|
-
}
|
|
12524
|
-
const
|
|
12841
|
+
return { stack: [...d.stack, at].slice(-30), layers: [last, { id: ++demoSeq.current, key: at.key, state: at.state, dir: 1, shown: false, ...(hash ? { hash } : null) }] }
|
|
12842
|
+
}
|
|
12843
|
+
const demoGo = (path, state, back, hash = '') => {
|
|
12844
|
+
const at = path ? { key: keyOfPath(path, fileTarget), state: state || '' } : null
|
|
12845
|
+
setDemo((d) => (!d ? d : back && d.stack.length > 1 ? pop(d) : at ? go(d, at, /^#[^\s#]{1,200}$/.test(hash || '') ? hash : '') : d))
|
|
12846
|
+
}
|
|
12847
|
+
const demoTo = (key, state = '') => setDemo((d) => (d ? go(d, { key, state: state || '' }) : d))
|
|
12848
|
+
const demoRestart = () => setDemo((d) => {
|
|
12525
12849
|
if (!d || d.stack.length < 2) return d
|
|
12526
|
-
const stack = d.stack.slice(0, -1)
|
|
12527
12850
|
const last = d.layers[d.layers.length - 1]
|
|
12528
|
-
|
|
12851
|
+
const first = d.stack[0]
|
|
12852
|
+
return { stack: [first], layers: [last, { id: ++demoSeq.current, key: first.key, state: first.state || '', dir: -1, shown: false }] }
|
|
12529
12853
|
})
|
|
12854
|
+
const demoBack = () => setDemo((d) => (d && d.stack.length > 1 ? pop(d) : d))
|
|
12530
12855
|
const demoShown = (id) => {
|
|
12531
12856
|
setDemo((d) => (d ? { ...d, layers: d.layers.map((l) => (l.id === id ? { ...l, shown: true } : l)) } : d))
|
|
12532
12857
|
setTimeout(() => setDemo((d) => (d && d.layers.length > 1 && d.layers[d.layers.length - 1].id === id ? { ...d, layers: [d.layers[d.layers.length - 1]] } : d)), 480)
|
|
12533
12858
|
}
|
|
12534
|
-
//
|
|
12535
|
-
|
|
12859
|
+
// 页面自己用脚本跳了(没走我们拦下的链接):只改记下的是哪一屏,不重载。
|
|
12860
|
+
// raw:这页 <meta name="dsh-states"> 写的(页面报上来的)。没写这个状态的(老页面自己拿 ?state= 当参数)当没带状态,
|
|
12861
|
+
// 不然记下来、地址一变又重载一遍,页面自己带的别的参数也丢了
|
|
12862
|
+
const demoHref = (id, href, raw) => {
|
|
12536
12863
|
let key = ''
|
|
12537
|
-
|
|
12864
|
+
let state = ''
|
|
12865
|
+
const dec = parseStates(raw).map((x) => x.name)
|
|
12866
|
+
let given = ''
|
|
12867
|
+
try {
|
|
12868
|
+
const u = new URL(href)
|
|
12869
|
+
key = keyOfPath(decodeURIComponent(u.pathname), fileTarget)
|
|
12870
|
+
given = u.searchParams.get('state') || ''
|
|
12871
|
+
state = STATE_RE.test(given) && dec.includes(given) && given !== dec[0] ? given : ''
|
|
12872
|
+
} catch { return }
|
|
12538
12873
|
setDemo((d) => {
|
|
12539
12874
|
if (!d) return d
|
|
12540
12875
|
const last = d.layers[d.layers.length - 1]
|
|
12541
|
-
|
|
12542
|
-
|
|
12876
|
+
// 还是这一层载的那个地址(跨页链接带的 ?state= 那页没写,地址里照样有):没跳,别改记下的、别再载一遍
|
|
12877
|
+
// 没写状态的页(老页面自己拿 ?state= 当参数)自己换了参数:也不算换屏,别动这一层(一动地址就变、重载,参数丢了)
|
|
12878
|
+
if (last.id !== id || (last.key === key && (!dec.length || (last.state || '') === given || norm(last, dec[0] || defOf(key)) === state))) return d
|
|
12879
|
+
return { stack: [...d.stack.slice(0, -1), { key, state }], layers: d.layers.map((l) => (l.id === id ? { ...l, key, state, hash: l.key === key ? l.hash : '' } : l)) }
|
|
12543
12880
|
})
|
|
12544
12881
|
}
|
|
12545
12882
|
return { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref }
|
|
@@ -12569,6 +12906,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12569
12906
|
const [info, setInfo] = useState({}) // 目录|屏 → { meta, title }(页面报上来的)
|
|
12570
12907
|
const [tops, setTops] = useState({}) // 屏 → 顶栏右边是不是深色(小程序胶囊画白的)
|
|
12571
12908
|
const setTop = (k, dk) => setTops((cur) => (cur[k] === dk ? cur : { ...cur, [k]: dk }))
|
|
12909
|
+
const [stSel, setStSel] = useState({}) // 目录|屏 → 选着看的状态(#30 一页多状态;默认状态不记)
|
|
12910
|
+
const [stMenu, setStMenu] = useState(null) // 状态菜单开在哪:{ key, x, y }
|
|
12572
12911
|
const [sel, setSel] = useState('')
|
|
12573
12912
|
const [panel, setPanel] = useState(false)
|
|
12574
12913
|
const [lookTab, setLookTab] = useState('set') // 外观面板开在哪一页:set 整套 / tw 滑块 / style 换风格 / brand 品牌
|
|
@@ -12588,7 +12927,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12588
12927
|
const palKeyRef = useRef(() => false) // 单键 V T S P R L C:最新的做法
|
|
12589
12928
|
const cvApi = useRef(null) // 画布的缩放:适合画布 / 实际大小(命令面板用)
|
|
12590
12929
|
const [scrMenu, setScrMenu] = useState(false)
|
|
12591
|
-
|
|
12930
|
+
// 目录 → 产品名(画布上认出来的),单页时去掉标题里的它。记在本机:刷新后单看只载得到一屏的标题,别先露出文件夹名、带产品名的长标题
|
|
12931
|
+
const brandMem = useRef(null)
|
|
12932
|
+
if (!brandMem.current) brandMem.current = loadBrands()
|
|
12592
12933
|
const [hist, setHist] = useState(false) // 版本面板
|
|
12593
12934
|
const [versions, setVersions] = useState([])
|
|
12594
12935
|
const [ver, setVer] = useState(null) // 正在看的旧版本
|
|
@@ -12611,6 +12952,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12611
12952
|
const [phone, setPhone] = useState(false) // 手机上看的面板
|
|
12612
12953
|
const [pubP, setPubP] = useState(false) // 公网链接的面板
|
|
12613
12954
|
const [multi, setMulti] = useState(false) // 多尺寸并排
|
|
12955
|
+
const [stAll, setStAll] = useState('') // 一页多状态(#30):把哪一屏的每个状态并排摆出来
|
|
12614
12956
|
const ckGen = useRef(0) // 每量一次、每关一次面板 +1:量完发现不是最新的一次就不算数
|
|
12615
12957
|
const ckOpen = useRef(false) // 面板开着(或正在量):过期的一次结果回来时别清掉新一轮的标记
|
|
12616
12958
|
const [ck, setCk] = useState(null) // 设计体检:null = 面板关着;{ running, list: [{ key, label, url, issues, error }] }
|
|
@@ -12684,6 +13026,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12684
13026
|
const [loadTick, setLoadTick] = useState(0) // 导出面板开着时页面又载入了一次:重新量
|
|
12685
13027
|
const warned = useRef('') // 预检提醒过的结果:同样的结果只拦一次
|
|
12686
13028
|
const [xo, setXo] = useState({ layout: 'auto', custom: '', fit: '', fitH: '', cols: 1 }) // 导出选项
|
|
13029
|
+
const [xStates, setXStates] = useState(null) // { target, map: { key: [{ name, label }] } }:导出面板开着时问服务端各屏写了哪几个状态(收起来的屏也算)
|
|
12687
13030
|
const cmpRef = useRef(null)
|
|
12688
13031
|
const [box, setBox] = useState({ w: 0, h: 0 })
|
|
12689
13032
|
// 灵动条各形态量出来的真宽度(按语言、形态记):估的宽度只在没量过时用,英文字长也不会和两边的小块撞
|
|
@@ -12733,7 +13076,18 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12733
13076
|
const tg = st && st.target
|
|
12734
13077
|
const site = tg ? (tg.kind === 'file' ? 'file:' + String(tg.file || '').replace(/[\\/][^\\/]*$/, '') : 'proxy:' + tg.port) : origin
|
|
12735
13078
|
const busy = !!(st && st.turn)
|
|
12736
|
-
|
|
13079
|
+
// 一页多状态(#30):这屏写了哪几个状态(页面报上来的)、现在看哪个;选了不是默认的那屏,地址带上 ?state=
|
|
13080
|
+
const statesOf = (key) => parseStates((info[site + '|' + key] || {}).states)
|
|
13081
|
+
const stateFor = (key) => {
|
|
13082
|
+
const s = stSel[site + '|' + key]
|
|
13083
|
+
return s && statesOf(key).some((x, i) => i > 0 && x.name === s) ? s : ''
|
|
13084
|
+
}
|
|
13085
|
+
const pickState = (key, name) => {
|
|
13086
|
+
const list = statesOf(key)
|
|
13087
|
+
const v = list.length && name !== list[0].name ? name : ''
|
|
13088
|
+
setStSel((m) => ((m[site + '|' + key] || '') === v ? m : { ...m, [site + '|' + key]: v }))
|
|
13089
|
+
}
|
|
13090
|
+
const screens = ((st && st.screens) || []).map((sc) => { const s = stateFor(sc.key); return s ? { ...sc, url: withState(sc.url, s), state: s } : sc })
|
|
12737
13091
|
|
|
12738
13092
|
// 哪几屏是「刚生成的」:第一次看到它时模型正在干活 → 第一次显示时播生成动画(播过就不再播)
|
|
12739
13093
|
// 这一轮开始时已有的屏记下来:这轮里出了新的一屏,就在画布末尾留个「生成中…」等下一屏;
|
|
@@ -12795,7 +13149,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
12795
13149
|
}, [busy])
|
|
12796
13150
|
|
|
12797
13151
|
const infoOf = (key) => info[site + '|' + key] || null
|
|
12798
|
-
const ik = (sc) => (sc.v ? 'v' + sc.v + '|' : '') + sc.key //
|
|
13152
|
+
const ik = (sc) => (sc.v ? 'v' + sc.v + '|' : '') + sc.key + (sc.xs ? '?state=' + sc.xs : '') // 旧版本的屏单独记标题;导出时按状态展开的那几页(xs)各挂各的
|
|
12799
13153
|
const focus = (st && st.focus) || ''
|
|
12800
13154
|
const main = infoOf(focus) || (screens[0] && infoOf(screens[0].key)) || {}
|
|
12801
13155
|
const meta = parseMeta(main.meta || (st && st.draft && st.draft.meta) || (playR.current.end ? '' : playR.current.meta) || '') // 第一屏还在放草稿(真的没摆出来):按草稿开头写的类型
|
|
@@ -13013,18 +13367,43 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13013
13367
|
.map((key) => ({ key, id: `v${ver.n}|${key}`, v: ver.n, url: vbase + encodeURIComponent(key), label: key.replace(/\.html?$/i, '') }))
|
|
13014
13368
|
: screens
|
|
13015
13369
|
const brand0 = brandIn(shown)
|
|
13016
|
-
|
|
13370
|
+
// 记着的产品名只认现在这版(看旧版本时不记、不作废)。作废:载到的带分隔符的标题里一个都没有它了
|
|
13371
|
+
// (改了名、同一个文件夹换了套设计、开发服务器换了项目);加了一屏不带产品名的、或者产品名挪到前面,还有屏带着就留着
|
|
13372
|
+
const memB = ver ? '' : brandMem.current[site] || ''
|
|
13373
|
+
// 只拿带分隔符的标题当证据(「设置」这种一段的本来就带不了产品名:刷新后先载到它也别作废)
|
|
13374
|
+
const BRAND_SEP = /\s*[·||—]\s*|\s+[-–]\s+/
|
|
13375
|
+
// 载到了 = 页面报过标题(标题和文件名一样、或者空的也算载到);载出错的不算
|
|
13376
|
+
const knownOf = (sc) => {
|
|
13377
|
+
if (!sc.v && snapTitles[snapSite + '|' + sc.key] !== undefined) return true
|
|
13378
|
+
const f = infoOf(ik(sc))
|
|
13379
|
+
return !!f && !f.err
|
|
13380
|
+
}
|
|
13381
|
+
const loaded = memB && !brand0 ? shown.filter(knownOf).map(labelOf) : []
|
|
13382
|
+
const titled = loaded.map((x) => x.split(BRAND_SEP).map((y) => y.trim()).filter(Boolean)).filter((p) => p.length >= 2)
|
|
13383
|
+
// 每屏标题都载到了、哪个都不含记着的名字(同一个文件夹换了套不带分隔符的设计)也作废
|
|
13384
|
+
const noBrand = (titled.length > 0 && !titled.some((p) => p.includes(memB))) || (shown.length > 0 && loaded.length === shown.length && !loaded.some((x) => x.includes(memB)))
|
|
13385
|
+
if (noBrand) delete brandMem.current[site]
|
|
13386
|
+
else if (brand0 && !ver) brandMem.current[site] = brand0
|
|
13017
13387
|
const brand = brand0 || brandMem.current[site] || ''
|
|
13388
|
+
useEffect(() => { if (!ver && (brand0 || noBrand)) saveBrand(site, brand0) }, [site, brand0, noBrand, !!ver]) // noBrand 时 brand0 是空的:删掉
|
|
13018
13389
|
|
|
13019
13390
|
// 手机上看:现在这一屏在预览服务器上的路径;手机开着时,电脑上换屏手机跟着跳
|
|
13020
13391
|
const phoneOn = !!(st && st.phone && st.phone.on)
|
|
13021
13392
|
const demoKey = demo ? demo.layers[demo.layers.length - 1].key : ''
|
|
13393
|
+
// 试用里这屏是哪个状态(#30):写在灵动条的屏名后面
|
|
13394
|
+
const demoStateLabel = () => {
|
|
13395
|
+
const top = demo ? demo.layers[demo.layers.length - 1] : null
|
|
13396
|
+
const list = top && top.state ? statesOf(top.key) : []
|
|
13397
|
+
const x = list.find((y) => y.name === top.state)
|
|
13398
|
+
return x && x !== list[0] ? ' · ' + x.label : ''
|
|
13399
|
+
}
|
|
13022
13400
|
const urlOfKey = (key) => {
|
|
13023
13401
|
const sc = screens.find((x) => x.key === key)
|
|
13024
|
-
if (sc) return sc.url
|
|
13402
|
+
if (sc) return sc.state ? withState(sc.url, '') : sc.url // 画布上给这屏选了状态:试用里没写状态的链接还是落在默认状态
|
|
13025
13403
|
return fileTarget ? `${origin}/${key.split('/').map(encodeURIComponent).join('/')}` : origin + key
|
|
13026
13404
|
}
|
|
13027
|
-
const
|
|
13405
|
+
const demoState = demo ? demo.layers[demo.layers.length - 1].state || '' : ''
|
|
13406
|
+
const curScreen = demo ? { key: demoKey, url: demoState ? withState(urlOfKey(demoKey), demoState) : urlOfKey(demoKey) } : screens.find((x) => x.key === (canvas ? sel || focus : focus)) || screens[0]
|
|
13028
13407
|
let curPath = '/'
|
|
13029
13408
|
try { if (curScreen) { const u = new URL(curScreen.url); curPath = u.pathname + u.search } } catch { /* 地址不对 */ }
|
|
13030
13409
|
const lastFollow = useRef('')
|
|
@@ -13112,7 +13491,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13112
13491
|
showFlash(t('born', { name: title || labelOf(sc) }))
|
|
13113
13492
|
}
|
|
13114
13493
|
|
|
13115
|
-
const remember = (key, m, title, toks, dk, links, nat, err = '') => {
|
|
13494
|
+
const remember = (key, m, title, toks, dk, links, nat, err = '', ext) => {
|
|
13116
13495
|
if (pane === 'export') setLoadTick((n) => n + 1)
|
|
13117
13496
|
const k = site + '|' + key
|
|
13118
13497
|
const sk = snapSite + '|' + key
|
|
@@ -13120,8 +13499,9 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13120
13499
|
const sig = JSON.stringify([toks || [], links || []])
|
|
13121
13500
|
setInfo((cur) => {
|
|
13122
13501
|
const natural = nat === 0 ? null : nat || (cur[k] && cur[k].natural) || null // 画幅放大后页面正好撑满、报空:还按上回量的;0 是这页不再是一整块:清掉
|
|
13123
|
-
|
|
13124
|
-
|
|
13502
|
+
const states = ext ? ext.states || '' : (cur[k] && cur[k].states) || '' // 写了哪几个状态(#30):对比那几处不报,留着上回的
|
|
13503
|
+
return cur[k] && cur[k].meta === m && cur[k].title === title && cur[k].sig === sig && cur[k].dark === dk && String(cur[k].natural) === String(natural) && (cur[k].err || '') === err && (cur[k].states || '') === states ? cur
|
|
13504
|
+
: { ...cur, [k]: { meta: m, title, tokens: toks || [], links: links || [], sig, dark: dk, natural, err, states } }
|
|
13125
13505
|
})
|
|
13126
13506
|
}
|
|
13127
13507
|
|
|
@@ -13241,7 +13621,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13241
13621
|
setPicking(true)
|
|
13242
13622
|
if (!canvas) {
|
|
13243
13623
|
// 单页:把焦点给页面,Esc 在页面里也管用
|
|
13244
|
-
setTimeout(() => { try { const f = stageRef.current && stageRef.current.querySelector('.ddp-frame.cur'); f && f.focus() } catch { /* 用鼠标也行 */ } }, 0)
|
|
13624
|
+
setTimeout(() => { try { const f = stageRef.current && stageRef.current.querySelector('.ddp-frame.cur:not(.held)'); f && f.focus() } catch { /* 用鼠标也行 */ } }, 0)
|
|
13245
13625
|
}
|
|
13246
13626
|
}
|
|
13247
13627
|
|
|
@@ -13341,12 +13721,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13341
13721
|
setPicking(false)
|
|
13342
13722
|
setPanel(false)
|
|
13343
13723
|
setHist(false)
|
|
13344
|
-
|
|
13724
|
+
const state = stateFor(key) // 从这屏现在看着的状态开始
|
|
13725
|
+
setDemo({ stack: [{ key, state }], layers: [{ id: ++demoSeq.current, key, state, dir: 0, shown: false }] })
|
|
13345
13726
|
const inf = infoOf(key)
|
|
13346
13727
|
if (inf && !(inf.links || []).length) say(t('demoNone'))
|
|
13347
13728
|
}
|
|
13348
13729
|
// 演示里跳屏、返回、从头来(makeDemoNav)
|
|
13349
|
-
const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget })
|
|
13730
|
+
const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget, defOf: (key) => { const ss = statesOf(key); return ss.length ? ss[0].name : '' } })
|
|
13350
13731
|
const { implLoad, implRecompare } = makeImpl({ sid, setImpl, setImplRun, say, t })
|
|
13351
13732
|
// 和做出来的比:在比哪一屏(看旧版本时不比)、那屏记着的地址和上次的分数
|
|
13352
13733
|
const implSc = impl && !ver ? screens.find((x) => x.key === impl.key) || null : null
|
|
@@ -13516,11 +13897,12 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13516
13897
|
onEditing: setTxOn,
|
|
13517
13898
|
lang: t('lang'),
|
|
13518
13899
|
onNote: (n) => note(n, sc),
|
|
13519
|
-
onMeta: (m, title, toks, dk, links, nat, err) => remember(ik(sc), m, title, toks, dk, links, nat, err),
|
|
13900
|
+
onMeta: (m, title, toks, dk, links, nat, err, ext) => remember(ik(sc), m, title, toks, dk, links, nat, err, ext),
|
|
13520
13901
|
onLinks: (links) => rememberLinks(ik(sc), links),
|
|
13521
13902
|
onFix: (f) => insert(t(f.err === 'down' ? 'scrFailAskDown' : 'scrFailAsk', { file: f.file || labelOf(sc) }), 'insertedSend'),
|
|
13522
13903
|
onTop: (dk) => setTop(ik(sc), dk),
|
|
13523
13904
|
onBuilt: (title) => onBuilt(sc, title),
|
|
13905
|
+
onStateGo: sc.v || canvas ? undefined : (s) => pickState(sc.key, s),
|
|
13524
13906
|
}))
|
|
13525
13907
|
|
|
13526
13908
|
// 画布上屏太多、离镜头远的:先不挂 iframe,放一张后台截的缩略图(issue #17),截不到就是「挪近就加载」。
|
|
@@ -13531,7 +13913,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13531
13913
|
const sleepScreen = (sc, z, quiet) => h(Device, { kind, w: size[0], h: size[1], fill: false, label: labelOf(sc), top: tops[ik(sc)], os: meta.os },
|
|
13532
13914
|
h('div', { className: 'ddp-scr' + (dark ? ' dk' : '') },
|
|
13533
13915
|
quiet ? null : h('div', { className: 'ddp-away', style: { fontSize: 13 / Math.max(0.25, z || 1) } }, t('canvasAsleep')),
|
|
13534
|
-
snapQ && !sc.v ? h(Snap, { key: snapId + '&key=' + sc.key, src: `${API}scrthumb?${snapQ}&key=${encodeURIComponent(sc.key)}`, blind: /^off/.test((st && st.watch) || ''), onTitle: (title) => snapTitled(sc.key, title) }) : null))
|
|
13916
|
+
snapQ && !sc.v ? h(Snap, { key: snapId + '&key=' + sc.key + (sc.state ? '&state=' + sc.state : ''), src: `${API}scrthumb?${snapQ}&key=${encodeURIComponent(sc.key)}${sc.state ? '&state=' + encodeURIComponent(sc.state) : ''}`, blind: /^off/.test((st && st.watch) || ''), onTitle: (title) => snapTitled(sc.key, title) }) : null))
|
|
13535
13917
|
|
|
13536
13918
|
// 那一屏的接口(截图、体检、业务标注都用);刚载入的等它就绪
|
|
13537
13919
|
const apiOf = async (sc, map = apis.current) => {
|
|
@@ -13568,10 +13950,18 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13568
13950
|
return () => clearTimeout(tm)
|
|
13569
13951
|
}, [hidRev])
|
|
13570
13952
|
const every = hidSig && hid.sig === hidSig ? everyOf(shown, hid.list) : shown
|
|
13571
|
-
|
|
13953
|
+
// 导出用:某屏写了哪几个状态(本地文件问服务端的;别的用页面报上来的)
|
|
13954
|
+
const statesForX = (key) => (fileTarget ? (xStates && xStates.target === targetKey && xStates.map[key]) || [] : statesOf(key))
|
|
13955
|
+
const { withFrames, measureAll, precheck, exportShots, exportHtml, htmlBody, loadEvery } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, every, loadHidden, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, tops, tweak, webFit, statesFor: statesForX, loadStates: fileTarget ? () => post('states', { session: sid }).then((d) => (d && d.map && typeof d.map === 'object' ? d.map : {})) : null,
|
|
13572
13956
|
onWarn: (mode) => { setXFmt(mode === 'pptx' ? 'pptx' : 'pdf'); if (pane !== 'export') openPane('export') } })
|
|
13573
13957
|
// 换了设计:导出面板里挑的屏不算了,回到「全部」
|
|
13574
13958
|
useEffect(() => { setXo((o) => (o.scope && o.scope !== 'all' ? { ...o, scope: 'all', pick: [] } : o)) }, [targetKey])
|
|
13959
|
+
useEffect(() => {
|
|
13960
|
+
if (pane !== 'export' || !fileTarget || ver) return
|
|
13961
|
+
let off = false
|
|
13962
|
+
post('states', { session: sid }).then((d) => { if (!off) setXStates({ target: targetKey, map: (d && d.map) || {}, at: Date.now() }) }, () => {})
|
|
13963
|
+
return () => { off = true }
|
|
13964
|
+
}, [pane, targetKey, st ? st.rev : 0, !!ver])
|
|
13575
13965
|
const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
|
|
13576
13966
|
if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
|
|
13577
13967
|
// 公网链接(#27)开着:右侧栏换了屏、画幅、深浅色、调节值,对方下次打开就按新的(看旧版本时不动)
|
|
@@ -13635,6 +14025,24 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13635
14025
|
return g ? (g.letter || 'a').toUpperCase() : ''
|
|
13636
14026
|
}
|
|
13637
14027
|
const tagOf = (sc) => { const L = takeTag(sc); return L ? h('b', { key: 'g', className: 'ddp-vt', title: t('takeN', { l: L }) }, L) : null }
|
|
14028
|
+
// 一页多状态(#30):写了几个状态的屏,屏名旁一个「状态 ▾」小胶囊(默认状态也显示:一眼看出这屏有几种样子),点开换着看
|
|
14029
|
+
const openStMenu = (key, el) => {
|
|
14030
|
+
if (stMenu && stMenu.key === key) { setStMenu(null); return }
|
|
14031
|
+
const stage = stageRef.current
|
|
14032
|
+
if (!stage || !el) return
|
|
14033
|
+
const r = el.getBoundingClientRect()
|
|
14034
|
+
const R = stage.getBoundingClientRect()
|
|
14035
|
+
setStMenu({ key, x: Math.round(Math.max(8, Math.min(r.left - R.left, R.width - 256))), y: Math.round(Math.min(r.bottom - R.top + 6, Math.max(8, R.height - 300))) })
|
|
14036
|
+
}
|
|
14037
|
+
const stateChip = (sc) => {
|
|
14038
|
+
if (!sc || sc.v) return null
|
|
14039
|
+
const list = statesOf(sc.key)
|
|
14040
|
+
if (!list.length) return null
|
|
14041
|
+
const x = list.find((y) => y.name === (sc.state || '')) || list[0]
|
|
14042
|
+
const on = !!(stMenu && stMenu.key === sc.key)
|
|
14043
|
+
return h('button', { key: 'st', type: 'button', className: 'ddp-stt' + (on ? ' on' : '') + (x === list[0] ? '' : ' alt'), 'aria-haspopup': 'menu', 'aria-expanded': on,
|
|
14044
|
+
...tipA(t('stTip', { n: list.length }), t('dState')), onClick: (e) => openStMenu(sc.key, e.currentTarget) }, h(I.states), h('span', null, x.label), h(I.caret))
|
|
14045
|
+
}
|
|
13638
14046
|
// 几个方向并排时每屏标题旁都挂着「用这版」,不用先点中那一屏才看得到
|
|
13639
14047
|
const badge = (sc) => (infoOf(ik(sc)) || {}).err ? h('em', { key: 'f', className: 'ddp-failtag' }, t('scrFailChip'))
|
|
13640
14048
|
: !sc.v && takesOf(shown.map((x) => x.key), sc.key)
|
|
@@ -13680,13 +14088,16 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13680
14088
|
return base.some(([, , x]) => x[0] === sz[0] && x[1] === sz[1]) ? base : [...base, ['szCustom', kind, sz]]
|
|
13681
14089
|
})()
|
|
13682
14090
|
const inMulti = multi && !!sizeSet && !ver
|
|
14091
|
+
// 一页多状态(#30):这一屏的每个状态并排看(和多尺寸一样是画布上的一种看法)
|
|
14092
|
+
const inStAll = !!stAll && !ver && !demo && !inMulti && !implSc && statesOf(stAll).length > 0
|
|
14093
|
+
const inSide = inMulti || inStAll
|
|
13683
14094
|
// 单页看手机 / 平板时,选择、改字的提示条放在设备上方,给它让出一条(不然压住设备顶边)
|
|
13684
|
-
const hintTop = (picking || textEdit) && !canvas && !
|
|
13685
|
-
const flows = canvas && !
|
|
14095
|
+
const hintTop = (picking || textEdit) && !canvas && !inSide && !ver && !demo && (kind !== 'web' || webFit) // 网页按画幅缩放时也和设备一样让出一条(#20)
|
|
14096
|
+
const flows = canvas && !inSide && !picking && !textEdit ? flowsOf(shown, (sc) => (infoOf(ik(sc)) || {}).links, fileTarget) : []
|
|
13686
14097
|
|
|
13687
14098
|
// ── 设计体检:画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里 ──
|
|
13688
14099
|
// 设计体检:量、开面板、定位、交给模型(makeCheck)
|
|
13689
|
-
const { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues } = makeCheck({ kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, insert, say, t,
|
|
14100
|
+
const { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues, askDrift } = makeCheck({ sid, fileTarget, kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, insert, say, t,
|
|
13690
14101
|
onOpen: () => { setPanel(false); setHist(false); setPhone(false); setPubP(false); setAn(false); setStyleEdit(false) } }) // 1.0:一次只开一个面板(调样式抽屉也算)
|
|
13691
14102
|
// 打开一套设计、模型又干完一轮(turns 变了):面板开着就再查一次(改没改好一眼看到);关着就悄悄量一下,问题数标在按钮上。
|
|
13692
14103
|
// 模型干着活时不量;等一会儿再量:刚写完的屏还在刷新、播生成动画
|
|
@@ -13728,7 +14139,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13728
14139
|
}, 1500)
|
|
13729
14140
|
return () => clearTimeout(timer)
|
|
13730
14141
|
}, [ckReq])
|
|
13731
|
-
const checkOff = !url || !!ver || !!demo ||
|
|
14142
|
+
const checkOff = !url || !!ver || !!demo || inSide || !!implSc
|
|
13732
14143
|
// ── 业务标注(插件页的试验开关开着才有 st.annotations 这个键):面板和体检、版本共用右边那个位置;点选、改字、调样式、画笔时编号收起,退出后回来 ──
|
|
13733
14144
|
useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
|
|
13734
14145
|
const toggleAn = () => {
|
|
@@ -13761,10 +14172,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13761
14172
|
const k = Math.max(1, f.offsetWidth) / Math.max(1, r.width)
|
|
13762
14173
|
api.annotHit((x - r.left) * k, (y - r.top) * k)
|
|
13763
14174
|
}
|
|
13764
|
-
const styleOff = !url || !!ver || !!demo ||
|
|
14175
|
+
const styleOff = !url || !!ver || !!demo || inSide || busy || !!implSc
|
|
13765
14176
|
|
|
13766
14177
|
// ── 画笔标注:画完把台面上看得到的几屏各截一张,按位置摆好,叠上画的东西,存进 refs/,路径放进输入框让模型用 read_image 看(不动剪贴板) ──
|
|
13767
|
-
const markOff = !url || !!ver || !!demo ||
|
|
14178
|
+
const markOff = !url || !!ver || !!demo || inSide || !!implSc
|
|
13768
14179
|
const toggleMark = () => {
|
|
13769
14180
|
markRun.current++
|
|
13770
14181
|
if (mark) { setMark(false); return }
|
|
@@ -13839,6 +14250,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13839
14250
|
sayErr(t('failed', { msg: e.message }))
|
|
13840
14251
|
}
|
|
13841
14252
|
}
|
|
14253
|
+
const hoStep = hoStepOf({ st, root: curRoot, impl: implMap, keys: screens.map((x) => x.key), busy })
|
|
13842
14254
|
const doHandoff = ({ fw, label, dest, only, wx }) => {
|
|
13843
14255
|
insert(t('hoText', {
|
|
13844
14256
|
fw: label,
|
|
@@ -13856,7 +14268,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13856
14268
|
const reload = () => setReloadSeq((x) => x + 1)
|
|
13857
14269
|
|
|
13858
14270
|
// 按钮鼠标停一下出说明卡(HoverTip):名字 + 一句用途;窄了(样式表里)先截屏名,再收字
|
|
13859
|
-
const curKey = implSc ? implSc.key : demo && demo.stack.length ? demo.stack[demo.stack.length - 1] : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
|
|
14271
|
+
const curKey = implSc ? implSc.key : demo && demo.stack.length ? demo.stack[demo.stack.length - 1].key : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
|
|
13860
14272
|
const curSc = screens.find((x) => x.key === curKey)
|
|
13861
14273
|
const stLabel = (st && st.label) || ''
|
|
13862
14274
|
const scrLabel = canvas && screens.length > 1 && !implSc
|
|
@@ -13866,6 +14278,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13866
14278
|
const pickScreen = (key) => {
|
|
13867
14279
|
if (implSc) { implOpen(key); return } // 在和做出来的比:换成比这一屏
|
|
13868
14280
|
setMulti(false)
|
|
14281
|
+
setStAll('')
|
|
13869
14282
|
if (demo) setDemo(null)
|
|
13870
14283
|
setSel(key)
|
|
13871
14284
|
if (canvas || key !== focus || dr) openByUser(key)
|
|
@@ -13874,8 +14287,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13874
14287
|
const exSc = implSc || shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
|
|
13875
14288
|
const exName = exSc ? dropBrand(shortOf(exSc)) + (takeTag(exSc) ? ' · ' + takeTag(exSc) : '') : ''
|
|
13876
14289
|
const libOpen = () => { setLibFocus(''); if (lib) setLib(''); else libDefaultThen((k) => setLib((c) => c || k)) }
|
|
13877
|
-
const onCanvas = canvas && !
|
|
13878
|
-
const toCanvas = () => { homeAway(); setMulti(false); setCmp(false); implClose(); if (demo) setDemo(null); change({ view: 'canvas' }) }
|
|
14290
|
+
const onCanvas = canvas && !inSide && !demo && homeAt !== 'on' && !(ver && cmp) && !implSc
|
|
14291
|
+
const toCanvas = () => { homeAway(); setMulti(false); setStAll(''); setCmp(false); implClose(); if (demo) setDemo(null); change({ view: 'canvas' }) }
|
|
13879
14292
|
// 面板(1.0)开的是哪一张:同一时间只开一个
|
|
13880
14293
|
const packOther = !!packDir && !(fileTarget && st && st.target && packDir === st.target.root)
|
|
13881
14294
|
const shareTab = phone ? 'phone' : pubP ? 'pub' : pane === 'pack' && !packOther ? 'demo' : pane === 'share' && !packOther ? 'submit' : ''
|
|
@@ -13886,7 +14299,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13886
14299
|
const toggleShare = () => (sheet === 'share' ? closeShare() : pubOn && fileTarget ? togglePub() : togglePhone())
|
|
13887
14300
|
// 换屏器:画布时写「画布 5 屏」,单看时写「详情 3 / 5」
|
|
13888
14301
|
const curIdx = screens.findIndex((x) => x.key === curKey)
|
|
13889
|
-
const swLabel = onCanvas || curIdx < 0 ? t('canvasShort') : dropBrand(shortOf(screens[curIdx])) + (takeTag(screens[curIdx]) ? ' · ' + takeTag(screens[curIdx]) : '')
|
|
14302
|
+
const swLabel = inStAll ? t('stAllOn', { name: dropBrand(labelOf(screens.find((x) => x.key === stAll) || { key: stAll, label: stAll.replace(/\.html?$/i, '') })) }) : onCanvas || curIdx < 0 ? t('canvasShort') : dropBrand(shortOf(screens[curIdx])) + (takeTag(screens[curIdx]) ? ' · ' + takeTag(screens[curIdx]) : '')
|
|
13890
14303
|
const swPos = onCanvas || curIdx < 0 ? (screens.length > 1 ? t('nScr', { n: screens.length }) : '') : screens.length > 1 ? `${curIdx + 1} / ${screens.length}` : ''
|
|
13891
14304
|
// 1.0 骨架:标题栏(标志 = 首页 | 项目名 ▾ / ⊞ 屏名 ▾ | 分享 导出 转成代码)+ 底部灵动条(说一句 | 选择 改字 调样式 画笔 | 试用 外观 体检)
|
|
13892
14305
|
// 两边小块:左 版本、右 缩放(画布自己带)。模型在干活时灵动条变成状态胶囊;画笔标注时让给标注自己的底栏
|
|
@@ -13961,6 +14374,8 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13961
14374
|
thumb: snapQ ? (k) => `${API}scrthumb?${snapQ}&key=${encodeURIComponent(k)}` : null,
|
|
13962
14375
|
ratio: size[1] / size[0],
|
|
13963
14376
|
}),
|
|
14377
|
+
// 单看写了几个状态的屏:屏名后面接着「状态 ▾」(画布上每屏的屏名旁各有一个)
|
|
14378
|
+
!onCanvas && !demo && !implSc && !ver && !mark && curKey ? stateChip({ key: curKey, state: stateFor(curKey) }) : null,
|
|
13964
14379
|
h('span', { className: 'dd-sp' }),
|
|
13965
14380
|
h('button', { className: 'ddp-btn' + (sheet === 'share' ? ' sel' : '') + (pubOn || phoneOn ? ' has' : ''), ...tipA(t('shareT'), pubOn || phoneOn ? t('phoneOnTip') : t('dShare')), 'aria-pressed': sheet === 'share', disabled: !url, onClick: toggleShare }, h(I.share), h('span', { className: 'lb' }, t('shareT'))),
|
|
13966
14381
|
h('button', { className: 'ddp-btn' + (sheet === 'export' ? ' sel' : ''), ...tipA(t('exportT'), t('dExport')), 'aria-pressed': sheet === 'export', disabled: !url, onClick: () => openPane('export') }, h(I.download), h('span', { className: 'lb' }, t('exportT'))),
|
|
@@ -13993,7 +14408,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
13993
14408
|
h('button', { className: 'dd-bt pri', ...tipA(t('restore'), t('dRestore')), onClick: doRestore }, t('restore')),
|
|
13994
14409
|
h('button', { className: 'dd-x', ...tipA(t('backNow'), '', 'Esc'), 'aria-label': t('backNow'), onClick: () => { setVer(null); setCmp(false) } }, h(I.close)))
|
|
13995
14410
|
: demo ? h('div', { key: 'dock-demo', className: 'ddp-isl ddp-dock dd-isl dd-mode nocmd' + (capShow || mark ? ' away' : ''), role: 'toolbar', 'aria-label': t('demoOn') },
|
|
13996
|
-
h('span', { className: 'dd-mt' }, h(I.play), h('b', null, t('demoOn')), h('em', null, dropBrand((infoOf(demoKey) || {}).title || demoKey.replace(/\.html?$/i, '')))),
|
|
14411
|
+
h('span', { className: 'dd-mt' }, h(I.play), h('b', null, t('demoOn')), h('em', null, dropBrand((infoOf(demoKey) || {}).title || demoKey.replace(/\.html?$/i, '')) + demoStateLabel())),
|
|
13997
14412
|
h('span', { className: 'dd-vs' }),
|
|
13998
14413
|
h('button', { className: 'dd-bt ghost', ...tipA(t('demoBack'), demo.stack.length < 2 ? t('demoHow') : ''), disabled: demo.stack.length < 2, onClick: demoBack }, h(I.back), t('demoBack')),
|
|
13999
14414
|
h('button', { className: 'dd-bt ghost', ...tipA(t('demoRestart')), disabled: demo.stack.length < 2, onClick: demoRestart }, h(I.refresh), t('demoRestart')),
|
|
@@ -14318,7 +14733,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14318
14733
|
const anL = (anFile && anFile.list) || []
|
|
14319
14734
|
const sub = an ? (anL.length ? t('anUpdated', { n: anL.length, time: hhmm(anFile.mtime) }) : '') : ck ? (ck.running ? t('checking') : t(ckN ? 'checkSum' : 'checkSumOk', { s: (ck.list || []).length, n: ckN })) : ''
|
|
14320
14735
|
const head = hd({ icon: I.shield, title: t('check'), help: an ? t('anHelp') : t('checkNote'), sub, tabs, tab: an ? 'an' : 'ck', onTab: (k) => { if (k === 'an' && !an) toggleAn(); else if (k === 'ck' && !ck) runCheck() } })
|
|
14321
|
-
if (ck) return h(CheckPanel, { t, head, ck, nameOf: dropBrand, onFocus: focusIssue, onFix: fixIssues, onAgain: runCheck, onClose: closeCheck })
|
|
14736
|
+
if (ck) return h(CheckPanel, { t, head, ck, nameOf: dropBrand, onFocus: focusIssue, onFix: fixIssues, onAgain: runCheck, onDrift: askDrift, onClose: closeCheck })
|
|
14322
14737
|
return h(AnnotPanel, {
|
|
14323
14738
|
t,
|
|
14324
14739
|
head,
|
|
@@ -14386,10 +14801,10 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14386
14801
|
if (sheet === 'zip') return h(ZipIssues, { t, head: hd({ icon: I.box, title: t('zipNotOpened') }), issues: zipIssues, onClose: () => { setPane(''); setZipIssues(null) } })
|
|
14387
14802
|
if (sheet === 'export') {
|
|
14388
14803
|
const imgModes = exportItems(t, kind, shown.length, exName).filter(([m]) => m !== 'pdf' && m !== 'pptx' && m !== 'opts')
|
|
14389
|
-
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 ? [] :
|
|
14804
|
+
return h(ExportPanel, { t, head: hd({ icon: I.download, title: t('exportT'), help: xFmt === 'img' ? t('xImgNote') : '', tabs: [['img', t('xImg'), I.image], ['pdf', 'PDF', I.pdf], ['pptx', 'PPT', I.deck]], tab: xFmt, onTab: setXFmt }), fmt: xFmt, imgModes, onImg: (m) => doExport(m), kind, size, opts: xo, setOpts: setXo, screens: every.map(ik).join('|'), items: ((sp) => every.map((sc, i) => ({ key: ik(sc), label: (sp.brand && sp.labels[i]) || dropBrand(labelOf(sc)) })))(splitTitles(every.map(labelOf))), stCount: ver ? null : Object.fromEntries(every.map((sc) => [ik(sc), statesForX(sc.key).length])), curKey: ((k) => ((every.find((sc) => sc.key === k) || shown[0]) ? ik(every.find((sc) => sc.key === k) || shown[0]) : ''))(implSc ? implSc.key : canvas ? sel || focus : focus), canvas: canvas && !implSc, rev: `${st ? st.rev : 0}|${reloadSeq}|${loadTick}|${xo.states && fileTarget ? (xStates && xStates.target === targetKey ? xStates.at : '-') : ''}`, measure: async (tok) => { await loadEvery(); return tok && tok.off ? [] : precheck(tok, !!xo.states && !ver) }, onResize: (s) => change({ size: s }), onExport: (format, keys) => doExport(format, undefined, { ...xo, keys }), onClose: () => setPane('') })
|
|
14390
14805
|
}
|
|
14391
14806
|
if (sheet === 'code') {
|
|
14392
|
-
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 ? '' : 'on', 'aria-current': i
|
|
14807
|
+
const hoSteps = h('ol', { className: 'dd-steps', 'aria-label': t('hoSteps'), title: t('hoTip') }, ...['hoS1', 'hoS2', 'hoS3'].map((k, i) => h('li', { key: k, className: i < hoStep ? 'done' : i === hoStep ? 'on' : '', 'aria-current': i === hoStep ? 'step' : undefined }, h('i', null, i < hoStep ? h(I.check) : String(i + 1)), h('span', null, t(k)))))
|
|
14393
14808
|
const hoList = ((sp) => screens.map((sc, i) => ({ key: sc.key, label: (sp.brand && sp.labels[i]) || dropBrand(labelOf(sc)) })))(splitTitles(screens.map(labelOf)))
|
|
14394
14809
|
return h(HandoffPanel, { t, head: hd({ icon: I.code, title: t('handoff'), help: t('hoHelp'), seg: hoSteps }), sid, root: fileTarget ? st.target.root : '', fileTarget, screens: hoList, impl: implMap, cur: implSc ? implSc.key : (curScreen && curScreen.key) || focus, onGo: doHandoff, onSay: say, onClose: () => setPane(''), onImpl: () => { setPane(''); if (exSc) implOpen(exSc.key) }, implOff: !!ver || !exSc || implFar, onOpen: ver || implFar ? null : (k) => { setPane(''); implOpen(k) } })
|
|
14395
14810
|
}
|
|
@@ -14598,7 +15013,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14598
15013
|
const rightOn = !!sheet && wideP // 右边开着一张面板(只有宽过 1000 才是右边一张)
|
|
14599
15014
|
const rightW = 340 // 面板宽 320 + 离边 10 + 留白 10
|
|
14600
15015
|
const ah = Math.max(0, box.h - TOP_R - BOT_R - dRes)
|
|
14601
|
-
const cvBody = !demo && (
|
|
15016
|
+
const cvBody = !demo && (inSide || (canvas && !(ver && cmp) && !implSc))
|
|
14602
15017
|
let body
|
|
14603
15018
|
navR.current = null
|
|
14604
15019
|
let busyGap = false
|
|
@@ -14617,7 +15032,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14617
15032
|
h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
|
|
14618
15033
|
h(Device, { kind, w: size[0], h: size[1], fill, label, top: tops[l.key], os: meta.os },
|
|
14619
15034
|
h(Screen, { t, remote, onPageDrag: pageDrag,
|
|
14620
|
-
src: urlOfKey(l.key),
|
|
15035
|
+
src: (l.state ? withState(urlOfKey(l.key), l.state) : urlOfKey(l.key)) + (l.hash || ''),
|
|
14621
15036
|
label,
|
|
14622
15037
|
busy: false,
|
|
14623
15038
|
born: false,
|
|
@@ -14628,13 +15043,53 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14628
15043
|
zoom: z,
|
|
14629
15044
|
reloadSeq,
|
|
14630
15045
|
onNav: isTop ? demoGo : undefined,
|
|
14631
|
-
onHref: isTop ? (href) => demoHref(l.id, href) : undefined,
|
|
15046
|
+
onHref: isTop ? (href, raw) => demoHref(l.id, href, raw) : undefined,
|
|
14632
15047
|
onShown: () => demoShown(l.id),
|
|
14633
|
-
onMeta: (m, title, toks, dk, links, nat) => remember(l.key, m, title, toks, dk, links, nat),
|
|
15048
|
+
onMeta: (m, title, toks, dk, links, nat, err, ext) => remember(l.key, m, title, toks, dk, links, nat, '', ext),
|
|
14634
15049
|
onLinks: (links) => rememberLinks(l.key, links),
|
|
14635
15050
|
onTop: (dk) => setTop(l.key, dk),
|
|
14636
15051
|
})))))
|
|
14637
15052
|
}))
|
|
15053
|
+
} else if (inStAll) {
|
|
15054
|
+
// 一页多状态(#30):这一屏的每个状态并排(第一个是默认);点选、改字照常,发给模型时说明是哪个状态
|
|
15055
|
+
const base = screens.find((x) => x.key === stAll) || { key: stAll, url: urlOfKey(stAll), label: stAll.replace(/\.html?$/i, '') }
|
|
15056
|
+
const list = statesOf(stAll)
|
|
15057
|
+
const fake = list.map((x, i) => ({ key: 'st' + i, id: 'st:' + x.name + '|' + base.key, url: withState(base.url, i ? x.name : ''), label: x.label }))
|
|
15058
|
+
body = h(Canvas, {
|
|
15059
|
+
key: 'stall',
|
|
15060
|
+
t,
|
|
15061
|
+
top: TOP_R,
|
|
15062
|
+
bottom: BOT_R + dRes,
|
|
15063
|
+
screens: fake,
|
|
15064
|
+
kind,
|
|
15065
|
+
size,
|
|
15066
|
+
ghost: false,
|
|
15067
|
+
picking: picking || textEdit,
|
|
15068
|
+
sel: '',
|
|
15069
|
+
labelOf: (sc) => sc.label,
|
|
15070
|
+
render: (sc, z, i) => h(Device, { kind, w: size[0], h: size[1], label: labelOf(base), top: tops[ik(base) + '|st' + i], os: meta.os },
|
|
15071
|
+
h(Screen, { t, remote, onPageDrag: pageDrag,
|
|
15072
|
+
src: fake[i].url,
|
|
15073
|
+
label: labelOf(base),
|
|
15074
|
+
busy,
|
|
15075
|
+
born: false,
|
|
15076
|
+
picking,
|
|
15077
|
+
textEdit,
|
|
15078
|
+
dark,
|
|
15079
|
+
tweak,
|
|
15080
|
+
quietPick: true,
|
|
15081
|
+
zoom: z,
|
|
15082
|
+
reloadSeq,
|
|
15083
|
+
onPicked: (payload) => deliver(payload, t('stPickNote', { state: list[i].name, label: list[i].label }) + '\n'),
|
|
15084
|
+
onCancelled: () => setPicking(false),
|
|
15085
|
+
onEdited: (d) => onEdited(base, d),
|
|
15086
|
+
onEditDone: () => setTextEdit(false),
|
|
15087
|
+
onEditing: setTxOn,
|
|
15088
|
+
lang: t('lang'),
|
|
15089
|
+
onNote: (n) => note(n, base),
|
|
15090
|
+
onTop: (dk) => setTop(ik(base) + '|st' + i, dk),
|
|
15091
|
+
})),
|
|
15092
|
+
})
|
|
14638
15093
|
} else if (inMulti) {
|
|
14639
15094
|
// 多尺寸:现在这一屏,按几档宽度并排
|
|
14640
15095
|
const base = curScreen || { key: focus, url, label: st.label }
|
|
@@ -14736,6 +15191,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14736
15191
|
actions,
|
|
14737
15192
|
badge,
|
|
14738
15193
|
tag: tagOf,
|
|
15194
|
+
stateChip,
|
|
14739
15195
|
kind,
|
|
14740
15196
|
size,
|
|
14741
15197
|
ghost,
|
|
@@ -14766,7 +15222,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14766
15222
|
// 画笔标注开着:网页按开标注时的大小定住(侧栏拉窄了就整体缩小,不重排),画的才对得上
|
|
14767
15223
|
const lock = fill && mark && markSize ? markSize : sideLock
|
|
14768
15224
|
const z = sideLock ? Math.max(0.05, Math.min(1, (box.w - aside - 32) / sideLock.w)) : lock ? Math.max(0.05, Math.min(1, box.w / lock.w, ah / lock.h)) : fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - (hintTop || busyGap ? 46 : 0)) / dh))
|
|
14769
|
-
const one = ver ? shown.find((x) => x.key === focus) || shown[0] || { key: focus, url, label: st.label } : { key: focus, url, label: st.label }
|
|
15225
|
+
const one = ver ? shown.find((x) => x.key === focus) || shown[0] || { key: focus, url, label: st.label } : { key: focus, url: stateFor(focus) ? withState(url, stateFor(focus)) : url, label: st.label }
|
|
14770
15226
|
// 单屏时模型在写新的一屏:先看着它写(没在选、改字、调样式、标注的时候),写完换过去
|
|
14771
15227
|
const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !peekR.current
|
|
14772
15228
|
if (watch) singleDraftR.current = dr.key || '*' // 还不知道是哪屏:名字到了再说
|
|
@@ -14803,7 +15259,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14803
15259
|
let chip = null
|
|
14804
15260
|
const sideOpen = rightOn // 右边开着面板:提示放在左边那块的中间
|
|
14805
15261
|
const side = sideOpen ? ' side' : ''
|
|
14806
|
-
const hintText = picking ? t(canvas ||
|
|
15262
|
+
const hintText = picking ? t(canvas || inSide ? 'pickAny' : 'pickOne') : textEdit ? t(canvas || inSide ? 'textAny' : 'textOne') : styleEdit && !sty ? t(canvas ? 'styleAny' : 'styleOne') : ''
|
|
14807
15263
|
if (flash) chip = h('div', { className: 'ddp-chip ok' + side, key: 'ok' }, h(I.check), h('span', null, flash))
|
|
14808
15264
|
|
|
14809
15265
|
return root(
|
|
@@ -14828,6 +15284,13 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14828
15284
|
h('img', { src: implShot, alt: t('implShotT'), onError: () => { setImplShot(''); say(t('implShotGone')) } }),
|
|
14829
15285
|
h('span', null, t('implShotHow'))) : null,
|
|
14830
15286
|
chip,
|
|
15287
|
+
stMenu && statesOf(stMenu.key).length
|
|
15288
|
+
? h(StateMenu, { key: 'stm:' + stMenu.key, t, at: stMenu, name: dropBrand(labelOf(screens.find((x) => x.key === stMenu.key) || { key: stMenu.key, label: stMenu.key.replace(/\.html?$/i, '') })),
|
|
15289
|
+
list: statesOf(stMenu.key), cur: stateFor(stMenu.key) || statesOf(stMenu.key)[0].name,
|
|
15290
|
+
onPick: (n) => { pickState(stMenu.key, n); if (stAll === stMenu.key) setStAll('') },
|
|
15291
|
+
allOn: stAll === stMenu.key, onAll: () => { const k = stMenu.key; setMulti(false); setStAll((c) => (c === k ? '' : k)) },
|
|
15292
|
+
onClose: () => setStMenu(null) })
|
|
15293
|
+
: null,
|
|
14831
15294
|
msgEl(false),
|
|
14832
15295
|
...islands,
|
|
14833
15296
|
palScrim(),
|
|
@@ -14989,7 +15452,7 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
14989
15452
|
// 注意:这里是客户端**服务名**(短的),不是包名
|
|
14990
15453
|
exports.inject = INJECT
|
|
14991
15454
|
// 测试用
|
|
14992
|
-
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 }
|
|
15455
|
+
exports._test = { STYLE, makeDemoNav, implLayout, implAwayUrl, KIND_LIST, KIND_KEY, KIND_SIZE, META_ALIAS, FIXED, SHOW_COLS, FRAME, ASK_EX, ASK_KINDS, KIND_ICON: I, pollGap, webFitOf, precheckOf, fitCanvas, layoutOk, fitHOk, autoSize, pulseStep, MarketDetail, dragKind, droppedOf, pickInfo, pickLabel, pickRanges, pickRule, chipOf, chipRanges, makeT, ZH, EN, formatCheck, formatTweaks, markHit, markPath, STYLES, formatStyle, accentUse, autoStyle, recStyles, styleLook, padInsert, pageOf, pxOf, styleChanges, formatStyleAsk, everyOf, shareOn, takesOf, formatCheckTool, poller, frameOf, paletteOf, formatRef, layoutRow, keyOfPath, flowsOf, flowLines, parseStates, withState, byStates, stateTitle, stateGoPlan, withHashNext, flowMarks, formatPick, whereOf, parseMeta, sizeOf, layoutGrid, fitCam, nearestLive, LIVE_MAX, tokenKind, formatToken, splitTitles, pickColors, hhmm, formatTpl, formatPrep, styleFromTokens, myStyleOf, isZipFile, hoStepOf }
|
|
14993
15456
|
return module.exports
|
|
14994
15457
|
},
|
|
14995
15458
|
})
|