dsh-design-studio 0.16.0 → 0.17.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 +3 -1
- package/README.md +3 -1
- package/cordis.patch.yml +4 -0
- package/lib/annotations-row.js +14 -0
- package/lib/annotations.js +214 -0
- package/lib/browser.js +14 -3
- package/lib/client.js +353 -40
- package/lib/core.js +9 -2
- package/lib/handoff.js +16 -4
- package/lib/index.js +81 -10
- package/lib/look.js +19 -7
- package/lib/photos.js +9 -0
- package/lib/picker.js +337 -8
- package/lib/serve.js +3 -2
- package/lib/styles.js +203 -0
- package/lib/tool.js +3 -2
- package/locale/annotations/en.json +6 -0
- package/locale/annotations/zh.json +6 -0
- package/package.json +4 -1
- package/skills/ui-design/SKILL.md +5 -3
- package/skills/ui-design/references/annotations.md +64 -0
package/lib/client.js
CHANGED
|
@@ -121,6 +121,9 @@ window.__ModuleLoader__.load({
|
|
|
121
121
|
chipTweak: '滑块调整',
|
|
122
122
|
chipTwMake: '做调节滑块',
|
|
123
123
|
chipTwFix: '修调节滑块',
|
|
124
|
+
chipAnMake: '写业务标注',
|
|
125
|
+
chipAnFix: '修业务标注',
|
|
126
|
+
chipAn: '标注 {id}',
|
|
124
127
|
chipSysEx: '提取设计系统',
|
|
125
128
|
chipSysAp: '套用设计系统',
|
|
126
129
|
chipLook: '风格 · {name}',
|
|
@@ -193,6 +196,8 @@ window.__ModuleLoader__.load({
|
|
|
193
196
|
xoOver: '{n} 个页面比画幅大,会被裁',
|
|
194
197
|
xoLong: '{n} 个页面是长页,只会截首屏',
|
|
195
198
|
xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
|
|
199
|
+
xoMoved: '{n} 个页面现在不在页顶,只会截现在看到的这一段',
|
|
200
|
+
xoMovedPpt: '{n} 个页面现在不在页顶,PPT 只会截现在看到的这一段',
|
|
196
201
|
xoLongH: '{n} 个页面比指定高度长,下面会被裁',
|
|
197
202
|
xoDead: '{n} 个链接点了可能没反应',
|
|
198
203
|
xoAi: '用了 {n} 张 AI 示意图,上线前记得换成真实照片',
|
|
@@ -228,6 +233,7 @@ window.__ModuleLoader__.load({
|
|
|
228
233
|
checkFixTip: '把这些问题发到对话,让模型修',
|
|
229
234
|
checkAgain: '再查一次',
|
|
230
235
|
checkFail: '没查成:{msg}',
|
|
236
|
+
checkLayout: '页面还没排好版,这次没量成,过一会儿再查一次',
|
|
231
237
|
checkNote: '只量得出排版上的硬伤,好不好看还得你看',
|
|
232
238
|
checkCount: '设计体检:上次量出 {n} 个问题,点开看',
|
|
233
239
|
checkAsk: '〔设计体检〕发现 {n} 个问题:',
|
|
@@ -494,10 +500,33 @@ window.__ModuleLoader__.load({
|
|
|
494
500
|
dLook: '改配色、字体,或整套换个风格',
|
|
495
501
|
dCheck: '找出文字溢出、重叠、看不清、按钮太小',
|
|
496
502
|
dCheckN: '上次找到 {n} 个问题,点开看',
|
|
503
|
+
an: '业务标注',
|
|
504
|
+
dAn: '界面上看不出来的规则:页面上出编号,右边列卡片,两边能互相定位',
|
|
505
|
+
dAnN: '{n} 条业务规则,点开看',
|
|
506
|
+
anEmpty: '这套设计还没有业务标注。新做的设计模型会自动写,已有的设计可以让它补上。',
|
|
507
|
+
anMake: '让模型标注',
|
|
508
|
+
anFix: '让模型修',
|
|
509
|
+
anBad: '标注文件有 {n} 处问题:',
|
|
510
|
+
anLost: '{n} 条未定位',
|
|
511
|
+
anLostTag: '未定位',
|
|
512
|
+
anOpenTag: '待确认',
|
|
513
|
+
anUpdated: '共 {n} 条 · 文件 {time} 更新',
|
|
514
|
+
anWhole: '整屏说明',
|
|
515
|
+
anSend: '发到对话',
|
|
516
|
+
anSendTip: '放进输入框,接着说这条要怎么改',
|
|
517
|
+
anGone: '不在这套设计里',
|
|
518
|
+
anT_rule: '业务规则',
|
|
519
|
+
anT_state: '状态边界',
|
|
520
|
+
anT_logic: '逻辑',
|
|
521
|
+
anT_flow: '流程',
|
|
522
|
+
anT_metric: '口径',
|
|
523
|
+
anT_data: '口径',
|
|
524
|
+
anMore: '另有 {n} 条',
|
|
497
525
|
dExport: '转成代码、存图片 / PDF / PPT、打包分享',
|
|
498
526
|
dMore: '版本、在手机上看、刷新、在浏览器里打开',
|
|
499
527
|
dZoom: '按住 {mod} 滚动也能缩放',
|
|
500
528
|
dScreen: '换一屏、看全部、多尺寸、换类型',
|
|
529
|
+
dCanvas: '回到画布,看全部的屏',
|
|
501
530
|
toolsT: '工具',
|
|
502
531
|
editAddr: '换一个地址',
|
|
503
532
|
textShort: '改字',
|
|
@@ -569,6 +598,7 @@ window.__ModuleLoader__.load({
|
|
|
569
598
|
stCode: '正在转成代码',
|
|
570
599
|
stCompare: '正在逐像素对比',
|
|
571
600
|
stPhotos: '正在挑照片',
|
|
601
|
+
stStyle: '正在挑风格',
|
|
572
602
|
stShell: '正在跑命令',
|
|
573
603
|
stRead: '正在看文件',
|
|
574
604
|
stWeb: '正在查资料',
|
|
@@ -596,6 +626,9 @@ window.__ModuleLoader__.load({
|
|
|
596
626
|
twFix: '让模型修好',
|
|
597
627
|
twMakeText: '〔调节滑块〕给这套设计做 3–5 个调节滑块:挑最值得试的维度(比如留白、圆角、主色、卡片排法),照 ui-design 技能「调节滑块」一节写进设计目录的 tweaks.json,把样式接上,做完用 check_design 查一遍。',
|
|
598
628
|
twFixText: '〔调节滑块〕tweaks.json 有问题:{errs}。照 ui-design 技能「调节滑块」一节改好。',
|
|
629
|
+
anMakeText: '〔业务标注〕给这套设计写业务标注:照 ui-design 技能「业务标注」一节写进设计目录的 annotations.json,只写界面上看不出来的规则、状态、边界和口径。',
|
|
630
|
+
anFixText: '〔业务标注〕annotations.json 要修:{errs}。照 ui-design 技能的 references/annotations.md 改好:定位不到的把 selector 和 fallbackText 改对,元素没了就删掉这条。',
|
|
631
|
+
anOneText: '〔业务标注 {id}〕{page} 里的「{title}」这条,改成:',
|
|
599
632
|
twAskHead: '〔调节〕我在右侧调节滑块里调成了下面这样:',
|
|
600
633
|
twAskTail: '照这个改设计(改样式源文件,tweaks.json 里对应的 value 也改成新值)。',
|
|
601
634
|
twAskTip: '让模型照这几个值改设计(可以顺手调整相关的地方)',
|
|
@@ -928,6 +961,9 @@ window.__ModuleLoader__.load({
|
|
|
928
961
|
chipTweak: 'Tweaked values',
|
|
929
962
|
chipTwMake: 'Make tweaks',
|
|
930
963
|
chipTwFix: 'Fix tweaks',
|
|
964
|
+
chipAnMake: 'Write business notes',
|
|
965
|
+
chipAnFix: 'Fix business notes',
|
|
966
|
+
chipAn: 'Note {id}',
|
|
931
967
|
chipSysEx: 'Extract design system',
|
|
932
968
|
chipSysAp: 'Apply design system',
|
|
933
969
|
chipLook: 'Style · {name}',
|
|
@@ -1000,6 +1036,8 @@ window.__ModuleLoader__.load({
|
|
|
1000
1036
|
xoOver: '{n} page(s) are larger than the canvas and will be cut off',
|
|
1001
1037
|
xoLong: '{n} long page(s): only the first screen is captured',
|
|
1002
1038
|
xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
|
|
1039
|
+
xoMoved: '{n} page(s) are scrolled away from the top: only what is showing now is captured',
|
|
1040
|
+
xoMovedPpt: '{n} page(s) are scrolled away from the top: the PPT only captures what is showing now',
|
|
1003
1041
|
xoLongH: '{n} page(s) are taller than the set height and will be cut off',
|
|
1004
1042
|
xoDead: '{n} link(s) may do nothing when clicked',
|
|
1005
1043
|
xoAi: 'Uses {n} AI placeholder photo(s). Replace them with real photos before launch',
|
|
@@ -1035,6 +1073,7 @@ window.__ModuleLoader__.load({
|
|
|
1035
1073
|
checkFixTip: 'Send these issues to the chat for the model to fix',
|
|
1036
1074
|
checkAgain: 'Check again',
|
|
1037
1075
|
checkFail: 'Check failed: {msg}',
|
|
1076
|
+
checkLayout: 'The page was not laid out yet, so it was not measured. Check again in a moment.',
|
|
1038
1077
|
checkNote: 'Only measurable layout problems; whether it looks good is still up to you',
|
|
1039
1078
|
checkCount: 'Design check: {n} problems last time. Click to see them',
|
|
1040
1079
|
checkAsk: '[Design check] Found {n} problems:',
|
|
@@ -1300,10 +1339,33 @@ window.__ModuleLoader__.load({
|
|
|
1300
1339
|
dLook: 'Change colors and fonts, or switch the whole style',
|
|
1301
1340
|
dCheck: 'Find overflowing or overlapping text, low contrast and tiny tap targets',
|
|
1302
1341
|
dCheckN: '{n} problems last time. Click to see them',
|
|
1342
|
+
an: 'Notes',
|
|
1343
|
+
dAn: 'Rules the UI does not show: numbered markers on the page, cards on the right, each locating the other',
|
|
1344
|
+
dAnN: '{n} business notes. Click to see them',
|
|
1345
|
+
anEmpty: 'This design has no business notes yet. The model writes them for new designs; for an existing one, ask it to add them.',
|
|
1346
|
+
anMake: 'Ask the model',
|
|
1347
|
+
anFix: 'Ask the model to fix',
|
|
1348
|
+
anBad: 'The notes file has {n} problems:',
|
|
1349
|
+
anLost: '{n} not located',
|
|
1350
|
+
anLostTag: 'Not located',
|
|
1351
|
+
anOpenTag: 'To confirm',
|
|
1352
|
+
anUpdated: '{n} notes · file updated {time}',
|
|
1353
|
+
anWhole: 'Whole screen',
|
|
1354
|
+
anSend: 'Send to chat',
|
|
1355
|
+
anSendTip: 'Put it in the message box, then say what to change',
|
|
1356
|
+
anGone: 'Not in this design',
|
|
1357
|
+
anT_rule: 'Rule',
|
|
1358
|
+
anT_state: 'State',
|
|
1359
|
+
anT_logic: 'Logic',
|
|
1360
|
+
anT_flow: 'Flow',
|
|
1361
|
+
anT_metric: 'Metric',
|
|
1362
|
+
anT_data: 'Metric',
|
|
1363
|
+
anMore: '{n} more',
|
|
1303
1364
|
dExport: 'Build as code, save images / PDF / PPT, or pack and share',
|
|
1304
1365
|
dMore: 'Versions, view on phone, refresh, open in browser',
|
|
1305
1366
|
dZoom: 'Hold {mod} and scroll to zoom too',
|
|
1306
1367
|
dScreen: 'Switch screens, see all, sizes or type',
|
|
1368
|
+
dCanvas: 'Back to the canvas to see every screen',
|
|
1307
1369
|
toolsT: 'Tools',
|
|
1308
1370
|
editAddr: 'Change address',
|
|
1309
1371
|
textShort: 'Text',
|
|
@@ -1375,6 +1437,7 @@ window.__ModuleLoader__.load({
|
|
|
1375
1437
|
stCode: 'Turning it into code',
|
|
1376
1438
|
stCompare: 'Comparing pixel by pixel',
|
|
1377
1439
|
stPhotos: 'Picking photos',
|
|
1440
|
+
stStyle: 'Picking a style',
|
|
1378
1441
|
stShell: 'Running a command',
|
|
1379
1442
|
stRead: 'Reading files',
|
|
1380
1443
|
stWeb: 'Looking things up',
|
|
@@ -1402,6 +1465,9 @@ window.__ModuleLoader__.load({
|
|
|
1402
1465
|
twFix: 'Ask the model to fix it',
|
|
1403
1466
|
twMakeText: '[Tweaks] Make 3–5 tweaks for this design: pick the dimensions most worth trying (spacing, radius, brand color, card layout…), write them to tweaks.json in the design folder as the ui-design skill describes under "Tweaks", wire up the styles, then run check_design.',
|
|
1404
1467
|
twFixText: '[Tweaks] tweaks.json has problems: {errs}. Fix it as the ui-design skill describes under "Tweaks".',
|
|
1468
|
+
anMakeText: '[Business notes] Write business notes for this design: put them in annotations.json in the design folder as the ui-design skill describes under "Business annotations". Only the rules, states, edge cases and metrics the UI does not show.',
|
|
1469
|
+
anFixText: '[Business notes] annotations.json needs fixing: {errs}. Fix it following references/annotations.md in the ui-design skill: correct the selector and fallbackText of anything that cannot be located, and delete the note if its element is gone.',
|
|
1470
|
+
anOneText: '[Business note {id}] "{title}" on {page}. Change it to:',
|
|
1405
1471
|
twAskHead: '[Tweaks] I set the tweaks in the sidebar to these values:',
|
|
1406
1472
|
twAskTail: 'Change the design to match (edit the style sources and update the matching values in tweaks.json).',
|
|
1407
1473
|
twAskTip: 'Let the model apply these values (and adjust related details)',
|
|
@@ -1677,6 +1743,7 @@ window.__ModuleLoader__.load({
|
|
|
1677
1743
|
mark: 'M4 20l4.5-1L19 8.5a2.1 2.1 0 0 0-3-3L5.5 16z M14 7.5l3 3',
|
|
1678
1744
|
text: 'M5 7V5h14v2 M12 5v14 M9 19h6',
|
|
1679
1745
|
style: 'M4 7h9 M17 7h3 M4 17h3 M11 17h9 M13 7a2 2 0 1 0 4 0a2 2 0 1 0-4 0 M7 17a2 2 0 1 0 4 0a2 2 0 1 0-4 0',
|
|
1746
|
+
note: 'M4 5h16v11H10l-4 4v-4H4z M8 9h8 M8 12h5',
|
|
1680
1747
|
layers: 'M12 3l9 5-9 5-9-5z M3 13l9 5 9-5',
|
|
1681
1748
|
check: 'M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0 M8 12.5l2.7 2.7L16 10',
|
|
1682
1749
|
code: 'M8 7l-5 5 5 5 M16 7l5 5-5 5',
|
|
@@ -2039,6 +2106,31 @@ window.__ModuleLoader__.load({
|
|
|
2039
2106
|
.ddp-drop .in b{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500}
|
|
2040
2107
|
.ddp-home .lk{border:0;padding:0;background:transparent;color:${ACCENT};font:inherit;cursor:pointer}
|
|
2041
2108
|
.ddp-home .lk:hover{text-decoration:underline;text-underline-offset:2px}
|
|
2109
|
+
.ddp-ancard{position:relative;margin:0 0 6px;padding:8px 10px;border-radius:9px;box-shadow:inset 0 0 0 1px var(--dsw-alias-separator-primary,rgba(127,127,127,.2));cursor:pointer;font-size:12px;line-height:18px}
|
|
2110
|
+
.ddp-ancard:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.08))}
|
|
2111
|
+
.ddp-ancard.sel{box-shadow:inset 0 0 0 1.5px #4d6bfe;background:rgba(77,107,254,.06)}
|
|
2112
|
+
.ddp-ancard.lost{opacity:.78}
|
|
2113
|
+
.ddp-ancard .hd{display:flex;align-items:center;gap:6px;min-height:20px;font-size:11px;color:var(--dsw-alias-label-secondary)}
|
|
2114
|
+
.ddp-ancard .no{min-width:18px;height:18px;padding:0 4px;box-sizing:border-box;border-radius:9px;border:1.5px solid #4d6bfe;color:#4d6bfe;font:700 11px/15px system-ui,sans-serif;text-align:center;flex:none}
|
|
2115
|
+
.ddp-ancard.sel .no{background:#4d6bfe;color:#fff}
|
|
2116
|
+
.ddp-ancard .id{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary)}
|
|
2117
|
+
.ddp-ancard .tag{flex:none;padding:0 5px;border-radius:4px;font-size:10px;line-height:16px;background:rgba(245,158,11,.16);color:#b45309}
|
|
2118
|
+
.ddp-ancard .tag.lost{background:rgba(229,72,77,.14);color:#e5484d}
|
|
2119
|
+
.ddp-ancard .ti{margin-top:4px;font-weight:600;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
2120
|
+
.ddp-ancard .md{margin-top:2px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
|
|
2121
|
+
.ddp-ancard .md p{margin:2px 0}
|
|
2122
|
+
.ddp-ancard .md ul{margin:2px 0;padding-left:16px}
|
|
2123
|
+
.ddp-ancard code{padding:0 3px;border-radius:3px;background:rgba(127,127,127,.14);font:11px/16px ui-monospace,SFMono-Regular,Menlo,monospace;overflow-wrap:anywhere}
|
|
2124
|
+
.ddp-ancard .ft{margin-top:6px;padding-top:6px;border-top:1px dashed var(--dsw-alias-separator-primary,rgba(127,127,127,.25));display:flex;flex-wrap:wrap;gap:6px;align-items:baseline;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere}
|
|
2125
|
+
.ddp-ancard .ft.sm{margin-top:3px;padding-top:0;border-top:0}
|
|
2126
|
+
.ddp-ancard .send{display:none;position:absolute;right:6px;bottom:6px;height:22px;padding:0 8px;border:0;border-radius:6px;background:var(--dsw-alias-bg-layer1,#fff);box-shadow:0 0 0 1px var(--dsw-alias-separator-primary,rgba(127,127,127,.25));color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;cursor:pointer}
|
|
2127
|
+
.ddp-ancard:hover .send,.ddp-ancard:focus-within .send,.ddp-ancard.sel .send{display:block}
|
|
2128
|
+
.ddp-ancard .send:hover{color:var(--dsw-alias-label-primary)}
|
|
2129
|
+
.ddp-anerr{margin:0 8px 8px;padding:7px 9px;border-radius:8px;background:rgba(229,72,77,.09);font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;max-height:30%;overflow:auto;flex:none}
|
|
2130
|
+
.ddp-anerr b{font-weight:600;color:#e5484d}
|
|
2131
|
+
.ddp-anerr p{margin:3px 0 0}
|
|
2132
|
+
.ddp-anp footer.row{align-items:center}
|
|
2133
|
+
.ddp-anp footer .lostn{flex:none;padding:0 4px;font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
|
|
2042
2134
|
.ddp-ck{align-items:flex-start}
|
|
2043
2135
|
.ddp-ck .no{width:18px;height:18px;flex:none;margin-top:1px;border-radius:9px;background:#f59e0b;color:#fff;font:700 10px/18px system-ui,sans-serif;text-align:center}
|
|
2044
2136
|
.ddp-ck .no.hi{background:#e5484d}
|
|
@@ -2267,6 +2359,10 @@ window.__ModuleLoader__.load({
|
|
|
2267
2359
|
.ddp-demo .lay.out.b{transform:translateX(12%)}
|
|
2268
2360
|
.ddp-banner{position:absolute;left:50%;top:10px;transform:translateX(-50%);z-index:6;display:flex;align-items:center;gap:6px;max-width:calc(100% - 20px);padding:4px 4px 4px 12px;border-radius:999px;
|
|
2269
2361
|
background:var(--dsw-alias-bg-layer-1);box-shadow:0 8px 24px rgba(0,0,0,.18),0 0 0 .5px var(--dsw-alias-border-l3);font-size:12px;white-space:nowrap;animation:ddp-in .2s ${EASE}}
|
|
2362
|
+
.ddp-banner.side{left:calc((100% - 296px) / 2);max-width:calc(100% - 320px)}
|
|
2363
|
+
.ddp-banner.side>em{display:none}
|
|
2364
|
+
.ddp-stage.isl:has(>.ddp-banner:not(.side))>.ddp-tokens{top:100px;max-height:calc(100% - 100px - 74px)}
|
|
2365
|
+
.ddp-stage.isl.bz:has(>.ddp-banner:not(.side))>.ddp-tokens{top:142px;max-height:calc(100% - 142px - 74px)}
|
|
2270
2366
|
.ddp-banner>svg{width:14px;height:14px;flex:none;color:${ACCENT}}
|
|
2271
2367
|
.ddp-banner>span{overflow:hidden;text-overflow:ellipsis;min-width:0;margin-right:2px}
|
|
2272
2368
|
/* 试用横幅:「试用中」蓝字、屏名正文、提示淡;窄了先收提示 */
|
|
@@ -2567,6 +2663,12 @@ window.__ModuleLoader__.load({
|
|
|
2567
2663
|
|
|
2568
2664
|
.ddp-libwrap>.ddp-toast{z-index:3}
|
|
2569
2665
|
/* 浮块窄了:先截屏名,到 440 再收按钮上的字,400 收工具坞里的演示(演示时横幅上能退出) */
|
|
2666
|
+
@container (max-width:560px){.ddp-top>.tl .lab .lb{display:none}.ddp-top>.tl .ddp-btn.lab{padding:0 6px}}
|
|
2667
|
+
@container (max-width:490px){.ddp-top .lab .lb,.ddp-top .pri .lb{display:none}.ddp-top .ddp-btn.lab{padding:0 6px}}
|
|
2668
|
+
@container (min-width:860px){.ddp-stage.isl.an3>.ddp-busy:not(.side){top:58px;max-width:calc(100% - 24px)}.ddp-stage.isl.an3.bz:has(>.ddp-busy:not(.side))>.ddp-hint,.ddp-stage.isl.an3.bz:has(>.ddp-busy:not(.side))>.ddp-toast:not(.mk),.ddp-stage.isl.an3.bz:has(>.ddp-busy:not(.side))>.ddp-banner,.ddp-stage.isl.an3.bz:has(>.ddp-busy:not(.side))>.ddp-tokens{top:100px}.ddp-stage.isl.an3.bz:has(>.ddp-busy:not(.side))>.ddp-toast.low{top:146px}}
|
|
2669
|
+
@container (max-width:640px){.ddp-top.an3>.tl .lab .lb{display:none}.ddp-top.an3>.tl .ddp-btn.lab{padding:0 6px}}
|
|
2670
|
+
@container (max-width:570px){.ddp-top.an3 .lab .lb,.ddp-top.an3 .pri .lb{display:none}.ddp-top.an3 .ddp-btn.lab{padding:0 6px}}
|
|
2671
|
+
@container (max-width:380px){.ddp-top.an3 .ddp-kind.ddp-where{min-width:30px}.ddp-top.an3 .ddp-addr>span,.ddp-top.an3 .ddp-addr>.ddp-dot{display:none}.ddp-top.an3 .ddp-addr{padding:0 6px;justify-content:center}.ddp-top.an3>.tl .ddp-sep{display:none}}
|
|
2570
2672
|
@container (max-width:440px){.ddp-isl .lab .lb,.ddp-isl .pri .lb{display:none}.ddp-isl .ddp-btn.lab{padding:0 6px}.ddp-tool{width:36px;height:36px}.ddp-tool span{display:none}.ddp-dock .ddp-sep{height:20px}}
|
|
2571
2673
|
@container (max-width:380px){.ddp-tool{width:32px}.ddp-kind.ddp-where{min-width:64px}}
|
|
2572
2674
|
/* 标注底栏:右侧栏窄时「这支笔怎么用」折成两行,不被三个按钮挤成省略号 */
|
|
@@ -2652,6 +2754,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
2652
2754
|
refresh: () => svg([h('path', { key: 1, d: 'M20 11a8 8 0 1 0-2.3 5.7' }), h('path', { key: 2, d: 'M20 5v6h-6' })]),
|
|
2653
2755
|
external: () => svg([h('path', { key: 1, d: 'M14 4h6v6' }), h('path', { key: 2, d: 'M20 4l-9 9' }), h('path', { key: 3, d: 'M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5' })]),
|
|
2654
2756
|
check: () => svg([h('path', { key: 1, d: 'M5 12.5l4.5 4.5L19 7.5', strokeWidth: 2.4 })]),
|
|
2757
|
+
note: () => svg([h('path', { key: 1, d: 'M4 5h16v11H10l-4 4v-4H4z' }), h('path', { key: 2, d: 'M8 9h8' }), h('path', { key: 3, d: 'M8 12h5' })]),
|
|
2655
2758
|
stetho: () => svg([h('path', { key: 1, d: 'M6 3.5H5a1 1 0 0 0-1 1V9a5 5 0 0 0 10 0V4.5a1 1 0 0 0-1-1h-1' }), h('path', { key: 2, d: 'M9 14v1.5a4.5 4.5 0 0 0 9 0V13' }), h('circle', { key: 3, cx: 18, cy: 11, r: 2 })]),
|
|
2656
2759
|
pdf: () => svg([h('path', { key: 1, d: 'M14 3.5H7a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5z' }), h('path', { key: 2, d: 'M14 3.5v5h5' }), h('path', { key: 3, d: 'M8.5 13h7M8.5 16.5h4.5' })]),
|
|
2657
2760
|
deck: () => svg([h('rect', { key: 1, x: 3, y: 4, width: 18, height: 12.5, rx: 1.8 }), h('path', { key: 2, d: 'M12 16.5V20M8.5 20.5h7' }), h('path', { key: 3, d: 'M7 12.5l3-3 2.5 2 4-4' })]),
|
|
@@ -2696,20 +2799,32 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
2696
2799
|
function poller(sid) {
|
|
2697
2800
|
let p = pollers.get(sid)
|
|
2698
2801
|
if (p) return p
|
|
2699
|
-
p = { state: null, subs: new Set(), timer: null, refs: 0, inflight: false }
|
|
2802
|
+
p = { state: null, subs: new Set(), timer: null, refs: 0, inflight: false, gen: 0 }
|
|
2700
2803
|
const tick = async () => {
|
|
2701
2804
|
p.timer = null
|
|
2702
2805
|
if (!p.inflight) {
|
|
2703
2806
|
p.inflight = true
|
|
2807
|
+
const gen = p.gen
|
|
2704
2808
|
try {
|
|
2705
|
-
const
|
|
2706
|
-
|
|
2809
|
+
const anSig = p.state && p.state.annotations && p.state.annotations.sig // 业务标注没变就不用再传一遍
|
|
2810
|
+
const r = await fetch(`${API}state?session=${encodeURIComponent(sid)}${anSig ? `&an=${encodeURIComponent(anSig)}` : ''}`, { credentials: 'same-origin', cache: 'no-store' })
|
|
2811
|
+
if (r.ok) {
|
|
2812
|
+
const s = await r.json()
|
|
2813
|
+
// 等回包时别处已经换了状态(换屏、打开):这一份过期了,下一轮再取
|
|
2814
|
+
if (gen === p.gen) {
|
|
2815
|
+
const had = p.state && p.state.annotations
|
|
2816
|
+
const same = s.annotations && s.annotations.same
|
|
2817
|
+
if (same && had && had.sig === s.annotations.sig) s.annotations = had
|
|
2818
|
+
if (!same || s.annotations === had) p.apply(s)
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2707
2821
|
} catch { /* 下一轮再试 */ }
|
|
2708
2822
|
p.inflight = false
|
|
2709
2823
|
}
|
|
2710
2824
|
if (p.refs > 0) p.timer = setTimeout(tick, p.state && p.state.turn ? 700 : 1500)
|
|
2711
2825
|
}
|
|
2712
|
-
p.set = (s) => {
|
|
2826
|
+
p.set = (s) => { p.gen++; p.apply(s) }
|
|
2827
|
+
p.apply = (s) => {
|
|
2713
2828
|
if (JSON.stringify(s) === JSON.stringify(p.state)) return
|
|
2714
2829
|
strictBy.set(sid, new Set(s && Array.isArray(s.strict) ? s.strict : []))
|
|
2715
2830
|
p.state = s
|
|
@@ -3008,6 +3123,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
3008
3123
|
card: (v, t, s) => [['b', t('chipTweak')], ...s.split('\n').filter((l) => l.startsWith('- ')).slice(0, 5).map((l) => ['span', l.slice(2)])] },
|
|
3009
3124
|
{ i: 'style', label: (v, t) => t('chipTwMake'), alts: both('twMakeText'), card: (v, t) => [['b', t('chipTwMake')], ['span', 'tweaks.json']] },
|
|
3010
3125
|
{ i: 'style', label: (v, t) => t('chipTwFix'), alts: both('twFixText'), card: (v, t) => [['b', t('chipTwFix')], ['p', v.errs]] },
|
|
3126
|
+
{ i: 'note', label: (v, t) => t('chipAnMake'), alts: both('anMakeText'), card: (v, t) => [['b', t('chipAnMake')], ['span', 'annotations.json']] },
|
|
3127
|
+
{ i: 'note', label: (v, t) => t('chipAnFix'), alts: both('anFixText'), card: (v, t) => [['b', t('chipAnFix')], ['p', v.errs]] },
|
|
3128
|
+
{ i: 'note', label: (v, t) => t('chipAn', { id: v.id }), alts: both('anOneText', { id: '[^\\n〕\\]]*' }), card: (v, t) => [['b', t('chipAn', { id: v.id })], ['p', v.title], ['span', v.page]] },
|
|
3011
3129
|
{ i: 'look', label: (v, t) => t('chipSysEx'), alts: both('sysExtractText'), card: (v, t) => [['b', t('chipSysEx')], ['code', v.src]] },
|
|
3012
3130
|
{ i: 'look', label: (v, t) => t('chipSysAp'), alts: both('sysApplyText'), card: (v, t) => [['b', t('chipSysAp')], ['code', v.name], ['span', v.dir]] },
|
|
3013
3131
|
{ i: 'look', label: (v, t) => t('chipLook', { name: v.name }), alts: L.map((x) => tplSrc(x.styleText, { name: '[^\\n]*?', ask: lit(['styleStart', 'styleRestyle', 'styleAuto']) })),
|
|
@@ -3558,13 +3676,11 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
3558
3676
|
const AUTO_SPREAD = ['minimal', 'editorial', 'playful', 'fresh', 'tech', 'glass', 'dark', 'sport']
|
|
3559
3677
|
// 「北欧风」「清新风:首页…」「中国风的界面」算说了风格;先去掉「通风」「台风」「新风系统」「风控」「风景」这类不是风格的词
|
|
3560
3678
|
const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
|
|
3561
|
-
const SAID_STYLE = /风格|配色|色调|主色|色系|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel)\b/i
|
|
3562
|
-
// 「风格你定」「配色:随意」「any style」:等于没说(「配色定为蓝白」是说了)
|
|
3563
|
-
const STYLE_FREE = /(风格|配色|色调|主色)\s*(?:[::]\s*)?(你定|您定|你来定|您来定|你决定|你看着办|随意|随便|不限|都行|无所谓|自由发挥)|\b(any|whatever)\s(style|colou?rs?|palette)\b|\b(style|colou?rs?|palette)\s(is\s)?up\sto\syou\b/gi
|
|
3679
|
+
const SAID_STYLE = /风格|配色|色调|主色|色系|[红橙黄绿青蓝紫粉黑白灰棕金银米]色|蓝白|黑白|黑金|红白|绿白|深色|浅色|暗色|亮色|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel|dark|light)\b/i
|
|
3564
3680
|
function autoStyle(text, kind) {
|
|
3565
3681
|
const s = String(text || '')
|
|
3566
3682
|
if (!s.trim()) return null
|
|
3567
|
-
const said = s.replace(
|
|
3683
|
+
const said = s.replace(NOT_STYLE_FENG, ' ')
|
|
3568
3684
|
if (SAID_STYLE.test(said) || STYLES.some((x) => said.includes(x.zh) || new RegExp(`\\b${x.en}\\s+(style|look|theme|aesthetic|vibe)\\b`, 'i').test(said))) return null
|
|
3569
3685
|
const by = (id) => STYLES.find((x) => x.id === id) || null
|
|
3570
3686
|
for (const [id, re] of AUTO_STYLE) if (re.test(s)) return by(id)
|
|
@@ -3819,7 +3935,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
3819
3935
|
const n = list.reduce((m, x) => m + x.issues.length, 0)
|
|
3820
3936
|
const lines = [t(head, { n, s: list.length })]
|
|
3821
3937
|
for (const sc of list) {
|
|
3822
|
-
if (sc.error && head !== 'checkAsk') lines.push('', t('ckToolErr', { label: sc.label, msg: sc.error }))
|
|
3938
|
+
if (sc.error && head !== 'checkAsk') lines.push('', t('ckToolErr', { label: sc.label, msg: sc.error === 'layout' ? t('checkLayout') : sc.error }))
|
|
3823
3939
|
if (!sc.issues.length) continue
|
|
3824
3940
|
const sz = head === 'checkAsk' ? '' : sizeLine(t, sc.metrics)
|
|
3825
3941
|
lines.push('', t('ckScreen', { label: sc.label, where: whereOf(sc.url, st) }) + (sz ? ` · ${sz}` : ''))
|
|
@@ -4815,7 +4931,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
4815
4931
|
// 模型在做什么:按它调的工具说人话(写文件另算,见 busyPhase)
|
|
4816
4932
|
const TOOL_PHASE = [
|
|
4817
4933
|
[/^check_design$/, 'stCheck'], [/^look_design$/, 'stLook'], [/^preview_page$/, 'stPreview'], [/^extract_design_system$/, 'stBrand'],
|
|
4818
|
-
[/^handoff_design$/, 'stCode'], [/^compare_design$/, 'stCompare'], [/^find_photos$/, 'stPhotos'], [/^ask_user_question$/, 'asking'],
|
|
4934
|
+
[/^handoff_design$/, 'stCode'], [/^compare_design$/, 'stCompare'], [/^find_photos$/, 'stPhotos'], [/^pick_style$/, 'stStyle'], [/^ask_user_question$/, 'asking'],
|
|
4819
4935
|
[/^(bash|shell|sh|zsh|powershell|pwsh|exec|run_command|terminal)$/i, 'stShell'],
|
|
4820
4936
|
[/^skill$/i, 'stSkill'],
|
|
4821
4937
|
[/web|fetch|browse|http/i, 'stWeb'],
|
|
@@ -5159,7 +5275,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5159
5275
|
const rem = remOf(props)
|
|
5160
5276
|
const wins = useRef(new Map())
|
|
5161
5277
|
const life = useRef(null)
|
|
5162
|
-
if (!life.current) life.current = { next: 1, loading: 0, again: false, file: '', seeds: new Map(), seedOf: new Map(), readied: new Set(), tops: new Map(), snapTimer: null, gen: 0, at: '', deps: null }
|
|
5278
|
+
if (!life.current) life.current = { next: 1, loading: 0, again: false, file: '', seeds: new Map(), seedOf: new Map(), readied: new Set(), tops: new Map(), anStates: new Map(), pageOf: new Map(), snapTimer: null, gen: 0, at: '', deps: null }
|
|
5163
5279
|
const curRef = useRef(0)
|
|
5164
5280
|
const P = useRef(props)
|
|
5165
5281
|
P.current = props
|
|
@@ -5196,7 +5312,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5196
5312
|
}),
|
|
5197
5313
|
checkFocus: (i) => { if (curRef.current) postTo(curRef.current, { type: 'checkFocus', i }) },
|
|
5198
5314
|
checkClear: () => { if (curRef.current) postTo(curRef.current, { type: 'checkClear' }) },
|
|
5315
|
+
annotFocus: (id) => { if (curRef.current) postTo(curRef.current, { type: 'annotFocus', id }) },
|
|
5316
|
+
annotPage: () => life.current.pageOf.get(curRef.current) || '', // 这一帧实际显示的屏(设计里的链接能带走)
|
|
5317
|
+
annotHome: (id) => { if (P.current.annotGo) P.current.annotGo.current = id; life.current.at = ''; load(null) }, // 走开了:重新载回这一屏,载好再定位
|
|
5318
|
+
annotHit: (x, y) => { if (curRef.current) postTo(curRef.current, { type: 'annotHit', x, y }) },
|
|
5199
5319
|
unpin: () => { if (curRef.current) postTo(curRef.current, { type: 'unpin' }) }, // 去掉「已选」虚线框
|
|
5320
|
+
holdScroll: () => { if (curRef.current) postTo(curRef.current, { type: 'holdScroll' }) }, // 用户要在这个位置上画:闪改动别再滚回去
|
|
5200
5321
|
// 画笔标注:这一屏的页面(iframe)现在摆在哪,拼图时按它的位置放截图
|
|
5201
5322
|
frame: () => wins.current.get(curRef.current) || null,
|
|
5202
5323
|
}
|
|
@@ -5269,6 +5390,11 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5269
5390
|
}
|
|
5270
5391
|
|
|
5271
5392
|
// 一帧好了:淡入换上来
|
|
5393
|
+
/** 这一帧该标哪些(设计里的链接能把这一帧带到别的屏,按它实际显示的那屏取) */
|
|
5394
|
+
const annotsOf = (p, id) => {
|
|
5395
|
+
const k = life.current.pageOf.get(id)
|
|
5396
|
+
return p.annotsFor && k && k !== p.annotKey ? p.annotsFor(k) : p.annots
|
|
5397
|
+
}
|
|
5272
5398
|
const swap = (id, changes) => {
|
|
5273
5399
|
const L = life.current
|
|
5274
5400
|
if (L.loading === id) L.loading = 0
|
|
@@ -5285,11 +5411,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5285
5411
|
if (p.textEdit) postTo(id, { type: 'edit', on: true, hint: false })
|
|
5286
5412
|
if (p.styleEdit) styleTo(id, p)
|
|
5287
5413
|
if (L.tops.has(id) && p.onTop) p.onTop(L.tops.get(id))
|
|
5414
|
+
if (L.anStates.has(id) && p.onAnnotState) p.onAnnotState(L.anStates.get(id))
|
|
5288
5415
|
if (first && p.onShown) p.onShown()
|
|
5289
5416
|
if (first) { if (build && p.onBuilt) p.onBuilt(L.title || '') } else if (p.onNote) p.onNote({ changes, file: L.file, build })
|
|
5290
5417
|
L.file = ''
|
|
5291
5418
|
setTimeout(() => setFrames((fs) => fs.filter((f) => f.id >= curRef.current || f.id > id)), 450)
|
|
5292
5419
|
for (const k of [...L.tops.keys()]) if (k < id) L.tops.delete(k)
|
|
5420
|
+
for (const k of [...L.anStates.keys()]) if (k < id) L.anStates.delete(k)
|
|
5421
|
+
for (const k of [...L.pageOf.keys()]) if (k < id) L.pageOf.delete(k)
|
|
5293
5422
|
if (L.again) {
|
|
5294
5423
|
L.again = false
|
|
5295
5424
|
postTo(id, { type: 'snapshot' })
|
|
@@ -5340,6 +5469,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5340
5469
|
L.title = d.title || ''
|
|
5341
5470
|
if (p.dark) postTo(id, { type: 'theme', dark: true })
|
|
5342
5471
|
if (p.tweak) postTo(id, { type: 'tweak', vars: p.tweak.vars, attrs: p.tweak.attrs })
|
|
5472
|
+
try { if (d.href) L.pageOf.set(id, keyOfPath(decodeURIComponent(new URL(d.href).pathname), true)) } catch { /* 地址不认识:当没跳 */ }
|
|
5473
|
+
{
|
|
5474
|
+
const list = annotsOf(p, id)
|
|
5475
|
+
if (list) {
|
|
5476
|
+
postTo(id, { type: 'annots', list, sel: p.annotSel || '' })
|
|
5477
|
+
// 单页时点了别的屏的卡片:这一屏载好了再滚过去
|
|
5478
|
+
if (p.annotGo && list.some((x) => x.id === p.annotGo.current)) { postTo(id, { type: 'annotFocus', id: p.annotGo.current }); p.annotGo.current = '' }
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5343
5481
|
if (p.onMeta) p.onMeta(d.meta || '', d.title || '', Array.isArray(d.tokens) ? d.tokens : [], !!d.dark, Array.isArray(d.links) ? d.links : [], d.natural)
|
|
5344
5482
|
if (p.onHref && d.href) p.onHref(d.href)
|
|
5345
5483
|
if (isCur) {
|
|
@@ -5364,6 +5502,16 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5364
5502
|
case 'dropIn':
|
|
5365
5503
|
if (p.onPageDrag) p.onPageDrag(d)
|
|
5366
5504
|
break
|
|
5505
|
+
case 'annotPick':
|
|
5506
|
+
if (isCur && p.onAnnotPick) p.onAnnotPick(String(d.id || ''))
|
|
5507
|
+
break
|
|
5508
|
+
case 'annotState':
|
|
5509
|
+
// 每帧记着自己的;只有正显示的那帧算数(预载的换上来时再用,旧帧晚到的不管)
|
|
5510
|
+
if (Array.isArray(d.list)) {
|
|
5511
|
+
L.anStates.set(id, d.list)
|
|
5512
|
+
if (isCur && p.onAnnotState) p.onAnnotState(d.list)
|
|
5513
|
+
}
|
|
5514
|
+
break
|
|
5367
5515
|
case 'top':
|
|
5368
5516
|
// 每帧记着自己的;只有正显示的那帧算数(预载的换上来时再用,旧帧晚到的不管)
|
|
5369
5517
|
L.tops.set(id, !!d.dark)
|
|
@@ -5435,6 +5583,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5435
5583
|
// 调节滑块:拖的时候改页面上的 CSS 变量 / <html> 属性(新载的一帧在 ready 时套上)
|
|
5436
5584
|
const twSig = JSON.stringify(props.tweak || null)
|
|
5437
5585
|
useEffect(() => { if (cur) postTo(cur, { type: 'tweak', vars: (props.tweak || {}).vars || {}, attrs: (props.tweak || {}).attrs || {} }) }, [twSig])
|
|
5586
|
+
// 业务标注:编号画在页面里(新载的一帧在 ready 时再发一次);点选、改字这些模式下 annots 是 null,编号收起
|
|
5587
|
+
const anSig = JSON.stringify(props.annots || null)
|
|
5588
|
+
useEffect(() => { if (cur) postTo(cur, { type: 'annots', list: annotsOf(props, cur) || [], sel: props.annotSel || '' }) }, [anSig, props.annotVer])
|
|
5589
|
+
useEffect(() => { if (cur && props.annots) postTo(cur, { type: 'annotSel', id: props.annotSel || '' }) }, [props.annotSel || ''])
|
|
5438
5590
|
useEffect(() => {
|
|
5439
5591
|
// 刚退出改字(点按钮、Esc、模型开始干活):页面会把正在改的那一处交上来,这一小会儿还收
|
|
5440
5592
|
if (editWas.current && !props.textEdit) editOffAt.current = Date.now()
|
|
@@ -6150,19 +6302,86 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
6150
6302
|
h('div', { className: 'bd' },
|
|
6151
6303
|
...list.filter((sc) => sc.issues.length || sc.error).map((sc) => h('div', { key: sc.key },
|
|
6152
6304
|
multi ? h('h4', null, sc.label) : null,
|
|
6153
|
-
sc.error ? h('div', { className: 'none' }, t('checkFail', { msg: sc.error })) : null,
|
|
6305
|
+
sc.error ? h('div', { className: 'none' }, sc.error === 'layout' ? t('checkLayout') : t('checkFail', { msg: sc.error })) : null,
|
|
6154
6306
|
...sc.issues.map((it, i) => h('button', { key: i, className: 'ddp-tok ddp-ck', title: it.sel || '', onClick: () => onFocus(sc.key, i) },
|
|
6155
6307
|
h('span', { className: 'no' + (it.sev > 1 ? ' hi' : '') }, String(i + 1)),
|
|
6156
6308
|
h('span', { className: 'tx' },
|
|
6157
6309
|
h('span', { className: 'nm' }, t('ck_' + it.type) + (it.text ? ` · ${it.text}` : '')),
|
|
6158
6310
|
h('span', { className: 'vl' }, checkDetail(t, it))))))),
|
|
6159
|
-
!ck.running && !n ? h('div', { className: 'ok' }, h(I.check), h('span', null, t('checkNone'))) : null),
|
|
6311
|
+
!ck.running && !n && !list.some((sc) => sc.error) ? h('div', { className: 'ok' }, h(I.check), h('span', null, t('checkNone'))) : null),
|
|
6160
6312
|
n ? h('p', { className: 'tip' }, t('checkNote')) : null,
|
|
6161
6313
|
h('footer', { className: 'row' },
|
|
6162
6314
|
h('button', { onClick: onAgain, disabled: ck.running }, h(I.refresh), h('span', null, t('checkAgain'))),
|
|
6163
6315
|
n ? h('button', { className: 'go', onClick: onFix, disabled: ck.running, title: t('checkFixTip') }, h(I.sparkle), h('span', null, t('checkFix'))) : null))
|
|
6164
6316
|
}
|
|
6165
6317
|
|
|
6318
|
+
/** 业务标注的正文:换行、**加粗**、`行内代码`、- 列表,别的原样显示(全走文字节点,不拼 HTML) */
|
|
6319
|
+
const anInline = (s) => String(s).split(/(\*\*[^*\n]+\*\*|`[^`\n]+`)/).map((x, i) => (
|
|
6320
|
+
/^\*\*[^*\n]+\*\*$/.test(x) ? h('b', { key: i }, x.slice(2, -2)) : /^`[^`\n]+`$/.test(x) ? h('code', { key: i }, x.slice(1, -1)) : x))
|
|
6321
|
+
function anBody(text) {
|
|
6322
|
+
const out = []
|
|
6323
|
+
let items = null
|
|
6324
|
+
String(text || '').split('\n').forEach((raw, i) => {
|
|
6325
|
+
const line = raw.trim()
|
|
6326
|
+
const m = /^[-*]\s+(.*)$/.exec(line)
|
|
6327
|
+
if (m) {
|
|
6328
|
+
if (!items) { items = []; out.push(h('ul', { key: i }, items)) }
|
|
6329
|
+
items.push(h('li', { key: i }, anInline(m[1])))
|
|
6330
|
+
return
|
|
6331
|
+
}
|
|
6332
|
+
items = null
|
|
6333
|
+
if (line) out.push(h('p', { key: i }, anInline(line)))
|
|
6334
|
+
})
|
|
6335
|
+
return out
|
|
6336
|
+
}
|
|
6337
|
+
|
|
6338
|
+
/** 业务标注面板:按屏分组,每条一张卡片;定位不到的排在这一屏最后 */
|
|
6339
|
+
function AnnotPanel({ t, file, screens, labelOfKey, states, sel, onFocus, onSend, onMake, onFix, onClose }) {
|
|
6340
|
+
const ref = useRef(null)
|
|
6341
|
+
useEffect(() => {
|
|
6342
|
+
if (!sel || !ref.current) return
|
|
6343
|
+
const el = [...ref.current.querySelectorAll('[data-an]')].find((x) => x.getAttribute('data-an') === sel)
|
|
6344
|
+
if (el) el.scrollIntoView({ block: 'nearest', behavior: 'smooth' })
|
|
6345
|
+
}, [sel])
|
|
6346
|
+
const list = (file && file.list) || []
|
|
6347
|
+
const errors = (file && file.errors) || []
|
|
6348
|
+
const blank = !list.length && !errors.length // 没有文件,或者文件里一条都没有
|
|
6349
|
+
const known = new Set(screens)
|
|
6350
|
+
const isLost = (a) => !known.has(a.page) || !!(states[a.id] && states[a.id].how === '')
|
|
6351
|
+
const lost = list.filter(isLost)
|
|
6352
|
+
const pages = [...screens.filter((k) => list.some((a) => a.page === k)), ...new Set(list.filter((a) => !known.has(a.page)).map((a) => a.page))]
|
|
6353
|
+
const card = (a) => {
|
|
6354
|
+
const gone = isLost(a)
|
|
6355
|
+
const whole = !a.selector && !a.fallbackText
|
|
6356
|
+
const typeName = a.type ? (['rule', 'state', 'logic', 'flow', 'metric', 'data'].includes(a.type) ? t('anT_' + a.type) : a.type) : ''
|
|
6357
|
+
const go = () => onFocus(a)
|
|
6358
|
+
return h('div', { key: a.id, 'data-an': a.id, role: 'button', tabIndex: 0, className: 'ddp-ancard' + (sel === a.id ? ' sel' : '') + (gone ? ' lost' : ''), onClick: go, onKeyDown: (e) => { if (e.key === 'Enter' && e.target === e.currentTarget) go() } },
|
|
6359
|
+
h('div', { className: 'hd' },
|
|
6360
|
+
h('span', { className: 'no' }, String(a.n)),
|
|
6361
|
+
typeName ? h('span', { className: 'ty' }, typeName) : null,
|
|
6362
|
+
h('span', { className: 'id' }, a.id),
|
|
6363
|
+
a.status === 'open' ? h('span', { className: 'tag' }, t('anOpenTag')) : null,
|
|
6364
|
+
gone ? h('span', { className: 'tag lost' }, t('anLostTag')) : null),
|
|
6365
|
+
h('div', { className: 'ti' }, a.title),
|
|
6366
|
+
a.detail ? h('div', { className: 'md' }, anBody(a.detail)) : null,
|
|
6367
|
+
a.anchorLabel || a.selector || whole ? h('div', { className: 'ft' }, whole ? t('anWhole') : a.anchorLabel, a.selector ? h('code', null, a.selector) : null) : null,
|
|
6368
|
+
a.source || a.tags.length || a.related.length ? h('div', { className: 'ft sm' }, [a.source, a.tags.join(' · '), a.related.length ? '→ ' + a.related.join(', ') : ''].filter(Boolean).join(' · ')) : null,
|
|
6369
|
+
h('button', { className: 'send', title: t('anSendTip'), onClick: (e) => { e.stopPropagation(); onSend(a) } }, t('anSend')))
|
|
6370
|
+
}
|
|
6371
|
+
return h('div', { className: 'ddp-tokens ddp-check ddp-anp', ref, onPointerDown: (e) => e.stopPropagation() },
|
|
6372
|
+
h('header', null, h(I.note), h('b', null, t('an')), h('button', { className: 'ddp-btn', title: '×', onClick: onClose }, h(I.close))),
|
|
6373
|
+
list.length ? h('p', { className: 'tip' }, t('anUpdated', { n: list.length, time: hhmm(file.mtime) })) : null,
|
|
6374
|
+
blank ? h('div', { className: 'bd' }, h('div', { className: 'none' }, t('anEmpty'))) : null,
|
|
6375
|
+
errors.length ? h('div', { className: 'ddp-anerr' }, h('b', null, t('anBad', { n: errors.length })), errors.slice(0, 6).map((x, i) => h('p', { key: i }, x)), errors.length > 6 ? h('p', null, t('anMore', { n: errors.length - 6 })) : null) : null,
|
|
6376
|
+
list.length ? h('div', { className: 'bd' }, pages.map((k) => h('div', { key: k },
|
|
6377
|
+
h('h4', null, known.has(k) ? labelOfKey(k) : `${k} · ${t('anGone')}`),
|
|
6378
|
+
[...list.filter((a) => a.page === k && !isLost(a)), ...list.filter((a) => a.page === k && isLost(a))].map(card)))) : null,
|
|
6379
|
+
blank ? h('footer', { className: 'row' }, h('button', { className: 'go', onClick: onMake }, h(I.sparkle), h('span', null, t('anMake')))) : null,
|
|
6380
|
+
file && (errors.length || lost.length) ? h('footer', { className: 'row' },
|
|
6381
|
+
lost.length ? h('span', { className: 'lostn' }, t('anLost', { n: lost.length })) : null,
|
|
6382
|
+
h('button', { className: 'go', onClick: () => onFix(lost) }, h(I.sparkle), h('span', null, t('anFix')))) : null)
|
|
6383
|
+
}
|
|
6384
|
+
|
|
6166
6385
|
/**
|
|
6167
6386
|
* 调样式面板:选中的元素的字号、字重、颜色、背景、圆角、内边距、间距。
|
|
6168
6387
|
* 拖的时候页面上先看效果(还没写进文件);设计变量列成小块,点一个就用 var(--x)。
|
|
@@ -7234,12 +7453,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7234
7453
|
*/
|
|
7235
7454
|
function precheckOf(list, kind, limit) {
|
|
7236
7455
|
const fixed = kind === 'slides' || kind === 'poster'
|
|
7237
|
-
const r = { over: 0, long: 0, dead: 0, fail: 0, ai: new Set(list.flatMap((m) => (Array.isArray(m.aiPhotos) ? m.aiPhotos : []))).size }
|
|
7456
|
+
const r = { over: 0, long: 0, moved: 0, dead: 0, fail: 0, ai: new Set(list.flatMap((m) => (Array.isArray(m.aiPhotos) ? m.aiPhotos : []))).size }
|
|
7238
7457
|
for (const m of list) {
|
|
7239
7458
|
if (m.failed) { r.fail++; continue }
|
|
7240
7459
|
const tall = m.pageH > (limit || m.h) + 2
|
|
7241
7460
|
if (m.pageW > m.w + 2 || (fixed && tall)) r.over++
|
|
7242
|
-
if (!fixed && tall) r.long++
|
|
7461
|
+
if (!fixed && tall) { if (!limit && (m.sy || 0) > 1) r.moved++; else r.long++ } // 一屏:滚过的截的是现在这段,不是首屏
|
|
7243
7462
|
const from = limit ? 0 : m.sy || 0 // 一屏:只看现在看得到的那段
|
|
7244
7463
|
const to = limit || from + m.h
|
|
7245
7464
|
r.dead += (Array.isArray(m.dead) ? m.dead : []).filter((y) => y >= from && y < to).length
|
|
@@ -7289,8 +7508,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7289
7508
|
const limit = opts.fit === 'page' ? Infinity : opts.fit === 'height' && fitHOk(opts.fitH) ? +opts.fitH : 0
|
|
7290
7509
|
const rep = list ? precheckOf(list, kind, limit) : null
|
|
7291
7510
|
const canFit = list ? fitCanvas(list, kind, size) : ''
|
|
7292
|
-
const cut = rep && (rep.over || rep.long)
|
|
7511
|
+
const cut = rep && (rep.over || rep.long || rep.moved)
|
|
7293
7512
|
const longKey = opts.fit === 'height' ? 'xoLongH' : !opts.fit && (kind === 'web' || kind === 'email') ? 'xoLongPpt' : 'xoLong'
|
|
7513
|
+
const movedKey = !opts.fit && (kind === 'web' || kind === 'email') ? 'xoMovedPpt' : 'xoMoved'
|
|
7294
7514
|
const seg = (k, items) => h('div', { className: 'seg', role: 'radiogroup' }, ...items.map(([v, label]) => h('button', { key: String(v), type: 'button', role: 'radio', 'aria-checked': opts[k] === v, className: opts[k] === v ? 'on' : '', onClick: () => setOpts({ ...opts, [k]: v }) }, label)))
|
|
7295
7515
|
const bad = (opts.layout === 'custom' && !layoutOk(opts.custom)) || (opts.fit === 'height' && !fitHOk(opts.fitH))
|
|
7296
7516
|
const go = async (format) => {
|
|
@@ -7304,12 +7524,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7304
7524
|
!rep ? h('div', { className: 'chk' }, h('p', null, t('xoChecking'))) : h('div', { className: 'chk' + (cut ? ' warn' : '') },
|
|
7305
7525
|
rep.over ? h('p', null, t('xoOver', { n: rep.over })) : null,
|
|
7306
7526
|
rep.long ? h('p', null, t(longKey, { n: rep.long })) : null,
|
|
7527
|
+
rep.moved ? h('p', null, t(movedKey, { n: rep.moved })) : null,
|
|
7307
7528
|
rep.dead ? h('p', null, t('xoDead', { n: rep.dead })) : null,
|
|
7308
7529
|
rep.ai ? h('p', null, t('xoAi', { n: rep.ai })) : null,
|
|
7309
7530
|
rep.fail ? h('p', null, t('xoFail', { n: rep.fail })) : null,
|
|
7310
7531
|
!cut && !rep.dead && !rep.fail ? h('p', null, t('xoClean')) : null,
|
|
7311
7532
|
rep.over && canFit ? h('button', { className: 'lk', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', '×') })) : null,
|
|
7312
|
-
rep.long && opts.fit !== 'page' ? h('button', { className: 'lk', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
|
|
7533
|
+
(rep.long || rep.moved) && opts.fit !== 'page' ? h('button', { className: 'lk', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
|
|
7313
7534
|
h('button', { className: 'lk', onClick: () => setAgain((n) => n + 1) }, t('xoAgain'))),
|
|
7314
7535
|
h('h4', null, t('xoLayout')),
|
|
7315
7536
|
seg('layout', [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
|
|
@@ -7757,12 +7978,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7757
7978
|
}
|
|
7758
7979
|
setCam({ ...d.cam, x: d.cam.x + dx, y: d.cam.y + dy })
|
|
7759
7980
|
}
|
|
7760
|
-
const up = () => {
|
|
7981
|
+
const up = (ev) => {
|
|
7761
7982
|
window.removeEventListener('pointermove', move)
|
|
7762
7983
|
window.removeEventListener('pointerup', up)
|
|
7763
7984
|
setDrag(false)
|
|
7764
7985
|
if (d.moved) return
|
|
7765
7986
|
if (props.onSelect) props.onSelect(d.key)
|
|
7987
|
+
if (props.onHit && d.key) props.onHit(d.key, ev.clientX, ev.clientY) // 挡板盖着页面:点的是不是业务标注的编号,让页面自己判断
|
|
7766
7988
|
const now = Date.now()
|
|
7767
7989
|
if (d.key && props.onOpen && lastTap.current.key === d.key && now - lastTap.current.at < 380) props.onOpen(d.key)
|
|
7768
7990
|
lastTap.current = { key: d.key, at: now }
|
|
@@ -7887,7 +8109,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7887
8109
|
const [dark, setDark] = useState(false)
|
|
7888
8110
|
const [phone, setPhone] = useState(false) // 手机上看的面板
|
|
7889
8111
|
const [multi, setMulti] = useState(false) // 多尺寸并排
|
|
8112
|
+
const ckGen = useRef(0) // 每量一次、每关一次面板 +1:量完发现不是最新的一次就不算数
|
|
8113
|
+
const ckOpen = useRef(false) // 面板开着(或正在量):过期的一次结果回来时别清掉新一轮的标记
|
|
7890
8114
|
const [ck, setCk] = useState(null) // 设计体检:null = 面板关着;{ running, list: [{ key, label, url, issues, error }] }
|
|
8115
|
+
const [an, setAn] = useState(false) // 业务标注:面板开着(页面上同时出编号)
|
|
8116
|
+
const [anSel, setAnSel] = useState('') // 选中的那条(id)
|
|
8117
|
+
const [anStates, setAnStates] = useState({}) // id → { how, count }:页面里定位的结果
|
|
8118
|
+
const anGo = useRef('') // 单页时点了别的屏的卡片:那一屏载好后滚到这条
|
|
7891
8119
|
const [ckCount, setCkCount] = useState(0) // 最近一次体检(模型干完活会悄悄查一次)有几个问题:面板关着时标在按钮上
|
|
7892
8120
|
const [reveal, setReveal] = useState(null) // 画布上要露出来的那一屏 { key, n }(体检里点了一条)
|
|
7893
8121
|
const [demo, setDemo] = useState(null) // 演示:{ stack: [屏…], layers: [{ id, key, dir, shown }] }
|
|
@@ -8099,6 +8327,20 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8099
8327
|
useEffect(() => { twGen.current++; setTw({}); setTv({}) }, [site])
|
|
8100
8328
|
// 拖的滑块 + 外观面板里直接改的颜色:一起发给页面先看效果
|
|
8101
8329
|
const tweak = Object.keys(tw).length || Object.keys(tv).length ? (() => { const m = tweakMsg(tlist, tw); return { vars: { ...m.vars, ...tv }, attrs: m.attrs } })() : null
|
|
8330
|
+
// 业务标注:开关开着才有 st.annotations 这个键(null = 还没有文件)
|
|
8331
|
+
const anOn = !!st && Object.prototype.hasOwnProperty.call(st, 'annotations')
|
|
8332
|
+
const anFile = anOn ? st.annotations : null
|
|
8333
|
+
const anCount = anFile ? anFile.list.length : 0
|
|
8334
|
+
const anUp = an && anOn && !styleEdit && !mark // 面板在右边显示着(调样式、画笔占着那个位置时让开)
|
|
8335
|
+
const anShowsMarks = anUp && !picking && !textEdit // 页面上出编号
|
|
8336
|
+
const anByPage = useMemo(() => {
|
|
8337
|
+
const out = new Map()
|
|
8338
|
+
for (const a of (anFile && anFile.list) || []) {
|
|
8339
|
+
if (!out.has(a.page)) out.set(a.page, [])
|
|
8340
|
+
out.get(a.page).push({ id: a.id, n: a.n, selector: a.selector, fallbackText: a.fallbackText })
|
|
8341
|
+
}
|
|
8342
|
+
return out
|
|
8343
|
+
}, [anFile ? anFile.sig : ''])
|
|
8102
8344
|
|
|
8103
8345
|
// 看旧版本:画布上换成那一版的几屏(按现在的顺序,那一版独有的接在后面)
|
|
8104
8346
|
const vbase = ver ? `${origin}/__dsh_design__/v/${ver.n}/` : ''
|
|
@@ -8246,7 +8488,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8246
8488
|
return () => ro.disconnect()
|
|
8247
8489
|
}, [!!url])
|
|
8248
8490
|
|
|
8249
|
-
useEffect(() => { setPicking(false); setTextEdit(false); setStyleEdit(false); setSel(''); setVer(null); setCmp(false) }, [site])
|
|
8491
|
+
useEffect(() => { setPicking(false); setTextEdit(false); setStyleEdit(false); setSel(''); setVer(null); setCmp(false); setAn(false); setAnSel(''); setAnStates({}) }, [site])
|
|
8250
8492
|
|
|
8251
8493
|
// 版本列表:面板开着时拉一次,存了新版本(vrev 变了)再拉
|
|
8252
8494
|
const vrev = st ? st.vrev : 0
|
|
@@ -8491,6 +8733,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8491
8733
|
styleSel: sty && sty.key === sc.key ? sty.selector : '',
|
|
8492
8734
|
styleCss: sty && sty.key === sc.key ? sty.live : null,
|
|
8493
8735
|
tweak: sc.v ? null : tweak,
|
|
8736
|
+
annots: sc.v || !anShowsMarks ? null : anByPage.get(sc.key) || null,
|
|
8737
|
+
annotKey: sc.key,
|
|
8738
|
+
annotsFor: sc.v || !anShowsMarks ? null : (k) => anByPage.get(k) || [],
|
|
8739
|
+
annotVer: anShowsMarks && anFile ? anFile.sig : '',
|
|
8740
|
+
annotSel: anSel,
|
|
8741
|
+
annotGo: anGo,
|
|
8742
|
+
onAnnotPick: (id) => { setAnSel(id); if (canvas) setSel(sc.key) },
|
|
8743
|
+
onAnnotState: (list) => setAnStates((m) => ({ ...m, ...Object.fromEntries(list.map((x) => [x.id, x])) })),
|
|
8494
8744
|
onStylePick: (p) => onStylePick(sc, p),
|
|
8495
8745
|
onStyleCancel: () => setStyleEdit(false),
|
|
8496
8746
|
dark,
|
|
@@ -8613,7 +8863,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8613
8863
|
const seen = await measureAll(map)
|
|
8614
8864
|
const rep = precheckOf(seen, kind, long ? Infinity : 0)
|
|
8615
8865
|
deadN = rep.dead
|
|
8616
|
-
const sig = rep.over || rep.long ? [design, shown.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
|
|
8866
|
+
const sig = rep.over || rep.long || rep.moved ? [design, shown.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
|
|
8617
8867
|
if (sig && warned.current !== sig) {
|
|
8618
8868
|
warned.current = sig
|
|
8619
8869
|
say(t('xoWarn'))
|
|
@@ -8693,7 +8943,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8693
8943
|
c.width = img.width
|
|
8694
8944
|
c.height = img.height
|
|
8695
8945
|
c.getContext('2d').drawImage(img, 0, 0)
|
|
8696
|
-
await saveImage(base + (mode === 'long' ? '-full' : ''), await canvasBlob(c), aiShot)
|
|
8946
|
+
await saveImage(base + (mode === 'long' ? '-full' : mode === 'raw' && FRAMED[kind] ? '-plain' : ''), await canvasBlob(c), aiShot)
|
|
8697
8947
|
}
|
|
8698
8948
|
} catch (e) {
|
|
8699
8949
|
say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
|
|
@@ -8774,6 +9024,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8774
9024
|
|
|
8775
9025
|
// ── 设计体检:画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里 ──
|
|
8776
9026
|
const closeCheck = () => {
|
|
9027
|
+
ckGen.current++
|
|
9028
|
+
ckOpen.current = false
|
|
8777
9029
|
if (ck) for (const sc of ck.list || []) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
|
|
8778
9030
|
setCk(null)
|
|
8779
9031
|
}
|
|
@@ -8791,9 +9043,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8791
9043
|
}))
|
|
8792
9044
|
const total = (list) => list.reduce((m, x) => m + x.issues.length, 0)
|
|
8793
9045
|
const runCheck = async () => {
|
|
8794
|
-
setPanel(false); setHist(false); setPhone(false)
|
|
9046
|
+
setPanel(false); setHist(false); setPhone(false); setAn(false)
|
|
8795
9047
|
setCk({ running: true, list: [] })
|
|
9048
|
+
const g = ++ckGen.current
|
|
9049
|
+
ckOpen.current = true
|
|
8796
9050
|
const out = await measure(checkList(), false)
|
|
9051
|
+
if (g !== ckGen.current) { // 量的时候面板关了 / 又量了一轮:这份结果作废;面板关着的话,这一轮画上的标记也清掉
|
|
9052
|
+
if (!ckOpen.current) for (const sc of out) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
|
|
9053
|
+
return out
|
|
9054
|
+
}
|
|
8797
9055
|
if (canvas && shown.length > LIVE_MAX) say(t('checkPartial', { n: out.length }))
|
|
8798
9056
|
setCk({ running: false, list: out })
|
|
8799
9057
|
setCkCount(total(out))
|
|
@@ -8857,6 +9115,39 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8857
9115
|
closeCheck()
|
|
8858
9116
|
}
|
|
8859
9117
|
const checkOff = !url || !!ver || !!demo || inMulti
|
|
9118
|
+
|
|
9119
|
+
// ── 业务标注(插件页的试验开关开着才有 st.annotations 这个键):面板和体检、版本共用右边那个位置;点选、改字、调样式、画笔时编号收起,退出后回来 ──
|
|
9120
|
+
useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
|
|
9121
|
+
const toggleAn = () => {
|
|
9122
|
+
if (an) { setAn(false); setAnSel(''); return }
|
|
9123
|
+
setPanel(false); setHist(false); setPhone(false); setPane(''); closeCheck(); setStyleEdit(false); setMark(false)
|
|
9124
|
+
setAn(true)
|
|
9125
|
+
}
|
|
9126
|
+
const focusAn = (a) => {
|
|
9127
|
+
setAnSel(a.id)
|
|
9128
|
+
const sc = shown.find((x) => x.key === a.page)
|
|
9129
|
+
if (!sc) return
|
|
9130
|
+
if (!canvas && a.page !== focus) { anGo.current = a.id; pickScreen(a.page); return }
|
|
9131
|
+
if (canvas) { setSel(a.page); setReveal((r) => ({ key: a.page, n: ((r && r.n) || 0) + 1 })) }
|
|
9132
|
+
apiOf(sc).then((api) => {
|
|
9133
|
+
const at = api.annotPage()
|
|
9134
|
+
if (at && at !== a.page) api.annotHome(a.id)
|
|
9135
|
+
else api.annotFocus(a.id)
|
|
9136
|
+
}).catch((e) => console.warn('[dsh-design-studio] 定位标注失败', a.id, e))
|
|
9137
|
+
}
|
|
9138
|
+
const fixAn = (lost) => {
|
|
9139
|
+
const bad = [...((anFile && anFile.errors) || []), ...lost.map((a) => `${a.id}(${a.page})${t('anLostTag')}`)].map((x) => String(x).replace(/\s*\n\s*/g, ' '))
|
|
9140
|
+
insert(t('anFixText', { errs: bad.slice(0, 12).join(';') + (bad.length > 12 ? ';' + t('anMore', { n: bad.length - 12 }) : '') }), 'insertedSend')
|
|
9141
|
+
}
|
|
9142
|
+
const hitAn = (key, x, y) => {
|
|
9143
|
+
const sc = shown.find((s) => s.key === key)
|
|
9144
|
+
const api = sc && apis.current.get(ik(sc))
|
|
9145
|
+
const f = api && typeof api.frame === 'function' ? api.frame() : null
|
|
9146
|
+
if (!f) return
|
|
9147
|
+
const r = f.getBoundingClientRect()
|
|
9148
|
+
const k = Math.max(1, f.offsetWidth) / Math.max(1, r.width)
|
|
9149
|
+
api.annotHit((x - r.left) * k, (y - r.top) * k)
|
|
9150
|
+
}
|
|
8860
9151
|
const styleOff = !url || !!ver || !!demo || inMulti || busy
|
|
8861
9152
|
|
|
8862
9153
|
// ── 画笔标注:画完把台面上看得到的几屏各截一张,按位置摆好,叠上画的东西,存进 refs/,路径放进输入框让模型用 read_image 看(不动剪贴板) ──
|
|
@@ -8873,7 +9164,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8873
9164
|
closeCheck()
|
|
8874
9165
|
setPane('')
|
|
8875
9166
|
// 之前点选 / 调样式留下的「已选」框别夹在标注里
|
|
8876
|
-
for (const a of apis.current.values()) if (a && a.unpin) a.unpin()
|
|
9167
|
+
for (const a of apis.current.values()) { if (a && a.unpin) a.unpin(); if (a && a.holdScroll) a.holdScroll() }
|
|
8877
9168
|
setMarkSize(box.w && box.h > TOP_R + BOT_R ? { w: box.w, h: box.h - TOP_R - BOT_R } : null)
|
|
8878
9169
|
setMark(true)
|
|
8879
9170
|
}
|
|
@@ -9071,16 +9362,17 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9071
9362
|
hiddenSaid.current = sig
|
|
9072
9363
|
}, [hiddenN, targetKey])
|
|
9073
9364
|
useEffect(() => { if (checkOff && ck) closeCheck() }, [checkOff])
|
|
9365
|
+
useEffect(() => { if (checkOff) { setAn(false); setAnSel('') } }, [checkOff])
|
|
9074
9366
|
|
|
9075
9367
|
const toggleDemo = () => (demo ? setDemo(null) : startDemo())
|
|
9076
|
-
const openLook = (tab) => { if (tab) setLookTab(tab); setPanel(true); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false) }
|
|
9077
|
-
const toggleHist = () => { setHist(!hist); setPanel(false); setPhone(false); closeCheck(); setStyleEdit(false) }
|
|
9368
|
+
const openLook = (tab) => { if (tab) setLookTab(tab); setPanel(true); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
9369
|
+
const toggleHist = () => { setHist(!hist); setPanel(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
9078
9370
|
// 右边同一时间只开一个面板:别的开了,这几个关掉;开这几个时别的关掉
|
|
9079
9371
|
const oldOpen = !!(panel || hist || phone || ck || styleEdit)
|
|
9080
9372
|
useEffect(() => { if (oldOpen) setPane('') }, [oldOpen])
|
|
9081
9373
|
const openPane = (p) => {
|
|
9082
9374
|
const next = pane === p ? '' : p
|
|
9083
|
-
if (next) { setPanel(false); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false) }
|
|
9375
|
+
if (next) { setPanel(false); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
9084
9376
|
setPane(next)
|
|
9085
9377
|
}
|
|
9086
9378
|
const setTweak = (k, v) => setTw((c) => {
|
|
@@ -9122,7 +9414,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9122
9414
|
}), 'insertedSend')
|
|
9123
9415
|
setPane('')
|
|
9124
9416
|
}
|
|
9125
|
-
const togglePhone = () => { setPhone(!phone); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false) }
|
|
9417
|
+
const togglePhone = () => { setPhone(!phone); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
9126
9418
|
const reload = () => setReloadSeq((x) => x + 1)
|
|
9127
9419
|
|
|
9128
9420
|
// 浮在画布上的几块,各管一件事,按钮都带字:左上 设计库 | 屏名 ▾(换屏、多尺寸、类型都在这个菜单里);
|
|
@@ -9155,25 +9447,30 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9155
9447
|
const exSc = shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
|
|
9156
9448
|
const exName = exSc ? dropBrand(shortOf(exSc)) + (takeTag(exSc) ? ' · ' + takeTag(exSc) : '') : ''
|
|
9157
9449
|
const libOpen = () => { setLibFocus(''); if (lib) setLib(''); else libDefaultThen((k) => setLib((c) => c || k)) }
|
|
9450
|
+
const onCanvas = canvas && !inMulti && !demo && homeAt !== 'on' && !(ver && cmp)
|
|
9451
|
+
const toCanvas = () => { homeAway(); setMulti(false); setCmp(false); if (demo) setDemo(null); change({ view: 'canvas' }) }
|
|
9158
9452
|
const dockTight = box.w > 0 && box.w <= 400 // 侧栏很窄:底部工具坞只放得下四个,「试用」进「更多」
|
|
9159
9453
|
const tool = (cls, on, desc, off, run, Icon, label) => h('button', { className: 'ddp-tool' + (cls ? ' ' + cls : '') + (on ? ' on' : ''), ...tipA(label, desc, on ? 'Esc' : ''), 'aria-pressed': !!on, disabled: !!off, onClick: run }, h(Icon), h('span', null, label))
|
|
9160
9454
|
const islands = editing
|
|
9161
|
-
? [h('div', { key: 'top', className: 'ddp-top' },
|
|
9455
|
+
? [h('div', { key: 'top', className: 'ddp-top' + (anOn ? ' an3' : '') },
|
|
9162
9456
|
h('div', { className: 'ddp-isl tl wide' },
|
|
9163
9457
|
h(AddressForm, { t, sid, initial: st && st.target && st.target.kind === 'file' ? st.target.file : st && st.label ? st.label : '', autoFocus: true, onDone: () => setEditing(false), onBrowse: browse })))]
|
|
9164
9458
|
: [
|
|
9165
|
-
h('div', { key: 'top', className: 'ddp-top' },
|
|
9459
|
+
h('div', { key: 'top', className: 'ddp-top' + (anOn ? ' an3' : '') },
|
|
9166
9460
|
h('div', { className: 'ddp-isl tl' },
|
|
9167
9461
|
h('button', { className: 'ddp-btn lab' + (homeAt === 'on' ? ' sel' : ''), ...tipA(t('homeBtn'), t('dHome'), homeAt === 'on' ? 'Esc' : ''), 'aria-pressed': homeAt === 'on', onClick: () => (homeAt === 'on' ? homeClose() : homeOpen()) }, h(I.home), h('span', { className: 'lb' }, t('homeBtn'))),
|
|
9462
|
+
h('button', { className: 'ddp-btn lab' + (onCanvas ? ' sel' : ''), ...tipA(t('canvasShort'), t('dCanvas')), 'aria-pressed': onCanvas, disabled: !url, onClick: toCanvas }, h(I.canvas), h('span', { className: 'lb' }, t('canvasShort'))),
|
|
9168
9463
|
h('span', { className: 'ddp-sep' }),
|
|
9169
9464
|
h(ScreenMenu, { t, hidden: hiddenN, hiddenText, label: scrLabel, tip: [scrLabel || stLabel, t('dScreen')], src: stLabel, busy, list: screens.map((x) => { const L = takeTag(x); return { key: x.key, label: dropBrand(shortOf(x)) + (L ? ' · ' + L : '') } }), cur: curKey, canvas: canvas && !inMulti && !demo, open: scrMenu, setOpen: setScrMenu,
|
|
9170
|
-
onPick: pickScreen, onAll:
|
|
9465
|
+
onPick: pickScreen, onAll: toCanvas, onOther: () => setEditing(true),
|
|
9171
9466
|
sizes: mark ? null : { on: inMulti, off: !sizeSet || !!ver, tip: sizeSet ? t('sizes') : t('sizesNo'), note: sizeSet ? '' : t('sizesNoShort'), run: () => setMulti(!inMulti) },
|
|
9172
9467
|
kind, onKind: mark ? null : (k) => change({ kind: k }) })),
|
|
9173
9468
|
h('div', { className: 'ddp-isl tr' },
|
|
9174
9469
|
h('button', { className: 'ddp-btn lab' + (panel ? ' sel' : ''), ...tipA(t('look'), t('dLook')), onClick: () => (panel ? setPanel(false) : openLook()) }, h(I.palette), h('span', { className: 'lb' }, t('look'))),
|
|
9175
9470
|
h('button', { className: 'ddp-btn lab' + (ck ? ' sel' : ''), ...tipA(t('checkShort'), ckCount && !ck ? t('dCheckN', { n: ckCount }) : t('dCheck')), disabled: checkOff, onClick: () => (ck ? closeCheck() : runCheck()) },
|
|
9176
9471
|
h(I.stetho), h('span', { className: 'lb' }, t('checkShort')), ckCount && !ck && !checkOff ? h('span', { className: 'bdg' }, ckCount > 99 ? '99+' : String(ckCount)) : null),
|
|
9472
|
+
anOn ? h('button', { className: 'ddp-btn lab' + (anUp ? ' sel' : ''), ...tipA(t('an'), anCount && !anUp ? t('dAnN', { n: anCount }) : t('dAn')), disabled: checkOff, onClick: toggleAn },
|
|
9473
|
+
h(I.note), h('span', { className: 'lb' }, t('an')), anCount && !anUp && !checkOff ? h('span', { className: 'bdg' }, anCount > 99 ? '99+' : String(anCount)) : null) : null,
|
|
9177
9474
|
h('span', { className: 'ddp-sep' }),
|
|
9178
9475
|
h(DropMenu, { t, tip: [t('deliver'), t('dExport')], btnCls: 'pri', icon: I.download, label: t('deliver'), caret: true, open: exMenu, setOpen: setExMenu, disabled: !url, items: [
|
|
9179
9476
|
'hd:' + t('deliverCode'),
|
|
@@ -9629,12 +9926,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9629
9926
|
const old = now ? { key: now.key, id: `v${ver.n}|${now.key}`, v: ver.n, url: vbase + encodeURIComponent(now.key), label: now.label } : null
|
|
9630
9927
|
const fill = kind === 'web'
|
|
9631
9928
|
const [dw, dh] = deviceBox(kind, size)
|
|
9632
|
-
|
|
9929
|
+
// 右边开着版本面板:手机这类有外框的让到面板左边(和单看时一样)
|
|
9930
|
+
const aside = !fill && !!(ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240 ? 296 : 0
|
|
9931
|
+
const z = fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - (ver ? 46 : 0)) / dh))
|
|
9633
9932
|
// 两边的小标签不跟着画面缩小(缩了看不清);手机、平板躲开状态栏
|
|
9634
9933
|
const tagAt = (side) => ({ top: kind === 'app' || kind === 'miniprogram' || kind === 'tablet' ? 60 : 10, transform: `scale(${1 / z})`, transformOrigin: 'top ' + side })
|
|
9635
9934
|
const screenOf = (sc) => h(Screen, { t, remote, onPageDrag: pageDrag, src: sc.url, label: labelOf(sc), busy: false, born: false, picking: false, dark, zoom: z, reloadSeq,
|
|
9636
9935
|
apis: apis.current, apiKey: 'cmp|' + ik(sc), onMeta: (m, title, toks, dk) => remember(ik(sc), m, title, toks, dk), onTop: (dk) => setTop(ik(sc), dk) })
|
|
9637
|
-
body = h('div', { className: 'ddp-single' },
|
|
9936
|
+
body = h('div', { className: 'ddp-single', style: aside ? { right: aside } : undefined },
|
|
9638
9937
|
h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
|
|
9639
9938
|
// 胶囊那块露的是哪一边(把手拖过胶囊中间就是左边那一版),胶囊就跟哪一边的顶栏
|
|
9640
9939
|
now ? h(Device, { kind, w: size[0], h: size[1], fill, label: labelOf(now), top: tops[ik(has && (cx / 100) * size[0] > size[0] - CAP.right - CAP.w / 2 ? old : now)], os: meta.os },
|
|
@@ -9666,21 +9965,22 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9666
9965
|
sel: sel || focus,
|
|
9667
9966
|
labelOf: shortOf,
|
|
9668
9967
|
reveal,
|
|
9669
|
-
inset: ck || styleEdit || panel || pane || hist || phone ? 296 : 0, // 右边的面板 276 宽,离边 10
|
|
9968
|
+
inset: anUp || ck || styleEdit || panel || pane || hist || phone ? 296 : 0, // 右边的面板 276 宽,离边 10
|
|
9670
9969
|
render: (sc, z) => renderScreen(sc, z, false),
|
|
9671
9970
|
sleep: sleepScreen,
|
|
9672
9971
|
flows,
|
|
9673
9972
|
onSelect: setSel,
|
|
9973
|
+
onHit: anUp && anShowsMarks ? hitAn : null,
|
|
9674
9974
|
onOpen: (key) => openByUser(key),
|
|
9675
9975
|
})
|
|
9676
9976
|
} else {
|
|
9677
9977
|
const fill = kind === 'web'
|
|
9678
9978
|
const [dw, dh] = deviceBox(kind, size)
|
|
9679
9979
|
// 右边开着面板(体检、调样式、设计规范、换风格):手机这类有外框的让到面板左边(侧栏够宽时),别被挡住
|
|
9680
|
-
const sideOn = !!(ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240
|
|
9980
|
+
const sideOn = !!(anUp || ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240
|
|
9681
9981
|
const aside = !fill && sideOn ? 296 : 0
|
|
9682
9982
|
// 生成中:右侧栏窄(或开着面板)时状态条在上排浮块下面,手机这类给它让一条;宽的时候它在上排中间,不用让。网页不让(一让就重排)
|
|
9683
|
-
busyGap = busy && !fill && (box.w < 860 || sideOn)
|
|
9983
|
+
busyGap = busy && !fill && (anOn || box.w < 860 || sideOn)
|
|
9684
9984
|
// 画笔标注开着:网页按开标注时的大小定住(侧栏拉窄了就整体缩小,不重排),画的才对得上
|
|
9685
9985
|
const lock = fill && mark && markSize ? markSize : null
|
|
9686
9986
|
const z = 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 - (ver || hintTop || busyGap ? 46 : 0)) / dh))
|
|
@@ -9698,13 +9998,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9698
9998
|
}
|
|
9699
9999
|
|
|
9700
10000
|
let chip = null
|
|
9701
|
-
const sideOpen = !!(ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240 // 右边开着面板:提示放在左边那块的中间
|
|
10001
|
+
const sideOpen = !!(anUp || ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240 // 右边开着面板:提示放在左边那块的中间
|
|
9702
10002
|
const side = sideOpen ? ' side' : ''
|
|
9703
10003
|
const hintText = picking ? t(canvas || inMulti ? 'pickAny' : 'pickOne') : textEdit ? t(canvas || inMulti ? 'textAny' : 'textOne') : styleEdit && !sty ? t(canvas ? 'styleAny' : 'styleOne') : ''
|
|
9704
10004
|
if (flash) chip = h('div', { className: 'ddp-chip ok' + side, key: 'ok' }, h(I.check), h('span', null, flash))
|
|
9705
10005
|
|
|
9706
10006
|
return root(
|
|
9707
|
-
h('div', { className: 'ddp-stage isl' + (busy ? ' bz' : ''), ref: stageRef },
|
|
10007
|
+
h('div', { className: 'ddp-stage isl' + (busy ? ' bz' : '') + (anOn ? ' an3' : ''), ref: stageRef },
|
|
9708
10008
|
h('div', { className: 'ddp-body' + (cvBody ? '' : ' pad' + (ver || demo || hintTop || busyGap ? ' vb' : '') + (ease ? ' ease' : '')) }, body),
|
|
9709
10009
|
busy ? h('div', { className: 'ddp-glow' }) : null,
|
|
9710
10010
|
busy ? h('div', { className: 'ddp-ring' }) : null,
|
|
@@ -9713,6 +10013,19 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9713
10013
|
// 提示只占一个位置:有新消息(toast)时它先让开,消息走了再回来
|
|
9714
10014
|
hintText && !toast ? h('div', { className: 'ddp-hint' + (sideOpen ? ' side' : '') }, hintText) : null,
|
|
9715
10015
|
ck ? h(CheckPanel, { t, ck, onFocus: focusIssue, onFix: fixIssues, onAgain: runCheck, onClose: closeCheck }) : null,
|
|
10016
|
+
anUp ? h(AnnotPanel, {
|
|
10017
|
+
t,
|
|
10018
|
+
file: anFile,
|
|
10019
|
+
screens: shown.map((x) => x.key),
|
|
10020
|
+
labelOfKey: (k) => { const sc = shown.find((x) => x.key === k); return sc ? labelOf(sc) : k },
|
|
10021
|
+
states: anStates,
|
|
10022
|
+
sel: anSel,
|
|
10023
|
+
onFocus: focusAn,
|
|
10024
|
+
onSend: (a) => insert(t('anOneText', { id: a.id, title: a.title, page: a.page }), 'inserted'),
|
|
10025
|
+
onMake: () => insert(t('anMakeText'), 'insertedSend'),
|
|
10026
|
+
onFix: fixAn,
|
|
10027
|
+
onClose: toggleAn,
|
|
10028
|
+
}) : null,
|
|
9716
10029
|
styleEdit ? h(StylePanel, {
|
|
9717
10030
|
t,
|
|
9718
10031
|
sty,
|
|
@@ -9769,7 +10082,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9769
10082
|
}) : null,
|
|
9770
10083
|
hist ? h(HistoryPanel, { t, versions, ver, onPick: (v) => { setVer(v); if (!v) setCmp(false) }, onClose: () => setHist(false) }) : null,
|
|
9771
10084
|
mark && !markOff ? h(MarkLayer, { t, sending: markBusy, frames: markFrames, onCancel: () => { markRun.current++; setMark(false) }, onSend: sendMark, onCopy: canCopyImage() ? copyMark : null }) : null,
|
|
9772
|
-
demo ? h('div', { className: 'ddp-banner' },
|
|
10085
|
+
demo ? h('div', { className: 'ddp-banner' + side },
|
|
9773
10086
|
h(I.play),
|
|
9774
10087
|
h('b', null, t('demoOn')),
|
|
9775
10088
|
h('span', { className: 'nm' }, dropBrand((infoOf(demoKey) || {}).title || demoKey.replace(/\.html?$/i, ''))),
|
|
@@ -9777,9 +10090,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9777
10090
|
h('button', { className: 'ddp-btn', ...tipA(t('demoBack')), disabled: demo.stack.length < 2, onClick: demoBack }, h(I.back)),
|
|
9778
10091
|
h('button', { className: 'ddp-btn', ...tipA(t('demoRestart')), disabled: demo.stack.length < 2, onClick: demoRestart }, h(I.refresh)),
|
|
9779
10092
|
h('button', { className: 'ddp-btn', ...tipA(t('demoExit'), '', 'Esc'), onClick: () => setDemo(null) }, h(I.close))) : null,
|
|
9780
|
-
ver ? h('div', { className: 'ddp-banner' },
|
|
10093
|
+
ver ? h('div', { className: 'ddp-banner' + side },
|
|
9781
10094
|
h(I.history),
|
|
9782
|
-
h('span',
|
|
10095
|
+
h('span', { title: t('viewing', { n: ver.n, time: hhmm(ver.at) }) }, side ? t('vN', { n: ver.n }) : t('viewing', { n: ver.n, time: hhmm(ver.at) })),
|
|
9783
10096
|
h('button', { className: 'ddp-go sec' + (cmp ? ' on' : ''), onClick: () => setCmp(!cmp) }, t('compare')),
|
|
9784
10097
|
h('button', { className: 'ddp-go pri', onClick: doRestore }, t('restore')),
|
|
9785
10098
|
h('button', { className: 'ddp-btn', title: t('backNow'), onClick: () => { setVer(null); setCmp(false) } }, h(I.close))) : null,
|