dsh-design-studio 0.27.0 → 0.29.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 +2 -2
- package/README.md +2 -2
- package/cordis.patch.yml +1 -1
- package/lib/client.js +513 -79
- package/lib/core.js +346 -28
- package/lib/edits.js +69 -0
- package/lib/handoff.js +19 -4
- package/lib/htmlpack.js +1 -1
- package/lib/index.js +296 -57
- package/lib/picker.js +48 -3
- package/lib/tunnel.js +598 -0
- package/package.json +1 -1
- package/skills/ui-design/SKILL.md +1 -1
package/lib/client.js
CHANGED
|
@@ -221,6 +221,9 @@ window.__ModuleLoader__.load({
|
|
|
221
221
|
xoFail: '{n} 屏没量到,结果可能不全',
|
|
222
222
|
xoAgain: '重新检查',
|
|
223
223
|
xoGone: '设计换了,这次导出取消了',
|
|
224
|
+
xoJobGone: '导出中断了(等太久或 DSH 重启过),请重新导出',
|
|
225
|
+
styleMoved: '设计换了,这次调的样式没保存',
|
|
226
|
+
xoCut: '一次最多导出 1000 屏,最后 {n} 屏没导出',
|
|
224
227
|
xoResize: '按内容改画幅({size})',
|
|
225
228
|
xoFull: '取景改成整页',
|
|
226
229
|
xoLayout: '版面',
|
|
@@ -336,6 +339,8 @@ window.__ModuleLoader__.load({
|
|
|
336
339
|
ckItem: '{i}. {type}:{where}{text} — {detail}',
|
|
337
340
|
ckQuote: '「{text}」',
|
|
338
341
|
exporting: '正在导出…',
|
|
342
|
+
exportingN: '正在截图 {i}/{n}…',
|
|
343
|
+
xoCheckingN: '先检查一遍有没有内容被裁 {i}/{n}…',
|
|
339
344
|
exported: '已导出 {name}',
|
|
340
345
|
exportedCopied: '已导出 {name},也复制到剪贴板了',
|
|
341
346
|
exportFail: '导出失败:{msg}',
|
|
@@ -451,6 +456,11 @@ window.__ModuleLoader__.load({
|
|
|
451
456
|
styleNoWrite: '开发服务器的页面不能直接保存,发到对话让模型改',
|
|
452
457
|
styleBusyTip: '模型在干活,等它停了再保存',
|
|
453
458
|
styleSaved: '样式已保存到 {file}',
|
|
459
|
+
styleShare: '各屏一起改',
|
|
460
|
+
styleShareAt: '写进 {file} 的 {sel}',
|
|
461
|
+
styleShareTip: '用这条样式的元素都跟着变(这一屏有 {n} 处);不勾就只改选中的这一个',
|
|
462
|
+
styleSavedRule: '已写进 {file} 的 {sel},各屏一起变',
|
|
463
|
+
styleSavedOthers: '已写进 {file} 的 {sel};另有 {n} 屏的这个元素之前单独保存过,还是那时的值',
|
|
454
464
|
styleMiss: '源码里没找到这个元素(可能是脚本生成的),改成发到对话',
|
|
455
465
|
styleN: '改了 {n} 项',
|
|
456
466
|
styleAskText: '〔调样式〕{name}({sel}):{list}。{rules}把这些写进它的样式规则({where};能用设计变量就用设计变量),别写成行内 style。\n',
|
|
@@ -510,6 +520,56 @@ window.__ModuleLoader__.load({
|
|
|
510
520
|
phoneFail: '没打开:{msg}',
|
|
511
521
|
phoneHelp: '确认在同一个 Wi-Fi;手机开着代理 / VPN 的先关掉;电脑问「是否允许传入连接」时点允许。',
|
|
512
522
|
phoneTrouble: '打不开?',
|
|
523
|
+
pub: '公网链接(实验)',
|
|
524
|
+
exPub: '发公网链接(实验)',
|
|
525
|
+
pubWhat: '发个链接给不在身边的人看',
|
|
526
|
+
pubP1: '对方不用连同一个 Wi-Fi,微信里点开就能看、能点着换屏',
|
|
527
|
+
pubP2: '只放这套设计的整套演示,电脑上别的东西都碰不到',
|
|
528
|
+
pubP3: '2 小时后自动关,也能随时关;关了链接马上失效',
|
|
529
|
+
pubP4: '走 Cloudflare 的免费临时通道(trycloudflare.com),不经过我们的服务器',
|
|
530
|
+
pubGo: '生成链接',
|
|
531
|
+
pubStarting: '正在连 Cloudflare…',
|
|
532
|
+
pubStartingFine: '一般 10 秒左右',
|
|
533
|
+
pubReady: '公网可见',
|
|
534
|
+
pubLeft: '还剩 {t}',
|
|
535
|
+
pubViews: '打开过 {n} 次',
|
|
536
|
+
pubHow: '微信、浏览器里打开都行',
|
|
537
|
+
pubLive: '改了这几屏,对方刷新就是新的;换到别的设计会自动关。',
|
|
538
|
+
pubWarn: '拿到链接的人都能看,别发到公开的群里。',
|
|
539
|
+
pubCopied: '链接已复制,可以发到微信里',
|
|
540
|
+
pubStop: '停止分享',
|
|
541
|
+
pubNeed: '要先装 cloudflared:Cloudflare 的临时通道工具,免费、不用注册。',
|
|
542
|
+
pubDl: '下载(约 19 MB)',
|
|
543
|
+
pubDlFrom: '从 Cloudflare 官方 GitHub 下载,放进插件自己的目录。',
|
|
544
|
+
pubDling: '正在下载 cloudflared… {p}',
|
|
545
|
+
pubDlFail: '没下载下来:{msg}',
|
|
546
|
+
pubSelf: '也可以自己装:Mac 在终端里运行 brew install cloudflared;Windows 运行 winget install --id Cloudflare.cloudflared。装好后这里会出现「生成链接」。',
|
|
547
|
+
pubDlCancel: '取消下载',
|
|
548
|
+
pubGone: '设计换了(或者现在看的不是本地文件),没有生成。确认要放的是这套设计再点一次。',
|
|
549
|
+
pubScreens: '会放出这 {n} 屏:{names}。之后新加的屏不会自动放出去。',
|
|
550
|
+
pubMoreNames: '…等',
|
|
551
|
+
pubShared: '放出去的是这 {n} 屏:{names}',
|
|
552
|
+
pubBrokenShort: '对方现在打不开',
|
|
553
|
+
pubBroken: '对方现在打开会看到「暂时打不开」:{why}。改好后对方刷新就行,也可以先停止分享。',
|
|
554
|
+
pubDlStalled: '下载卡住了(30 秒没动),多半是连不上 GitHub。可以再试,或者按下面的方法自己装。',
|
|
555
|
+
pubDlNoBuild: '这台电脑的系统没有现成的 cloudflared,要自己装。',
|
|
556
|
+
pubReconnecting: '正在重连',
|
|
557
|
+
pubReconnectingFine: '和 Cloudflare 暂时断了,正在自己重连,链接不变;90 秒还没连上就关掉。',
|
|
558
|
+
pubRetry: '再试',
|
|
559
|
+
pubFail: '没连上 Cloudflare:{msg}',
|
|
560
|
+
pubFailHint: '公司网络、代理软件有时会拦;换个网络或关掉代理再试。',
|
|
561
|
+
pubTooBig: '图片太多,演示超过 150 MB,发不了。少放几屏再试',
|
|
562
|
+
pubNoScreens: '一屏都没读到(文件被挪走或删了?)',
|
|
563
|
+
pubEndExpired: '上一个链接到 2 小时,自动关了。',
|
|
564
|
+
pubEndDropped: '上一个链接断了(网络变了或电脑睡着了),已经失效。',
|
|
565
|
+
pubEndMoved: '换了设计,上一个链接关了。',
|
|
566
|
+
pubAgain: '再生成一个(链接会变)',
|
|
567
|
+
pubTrouble: '对方打不开?',
|
|
568
|
+
pubHelp: '刚生成的链接要等几秒才打得开。微信里提示风险或打不开,让对方点右上角,选「在浏览器打开」。电脑睡着、合上盖子,链接也会断。',
|
|
569
|
+
pubOff: '公网链接关了:{why}',
|
|
570
|
+
pubWhyExpired: '到 2 小时了',
|
|
571
|
+
pubWhyDropped: '通道断了',
|
|
572
|
+
pubWhyMoved: '换了设计',
|
|
513
573
|
zoomIn: '放大',
|
|
514
574
|
zoomOut: '缩小',
|
|
515
575
|
fit: '适合画布',
|
|
@@ -1154,6 +1214,9 @@ window.__ModuleLoader__.load({
|
|
|
1154
1214
|
xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
|
|
1155
1215
|
xoAgain: 'Check again',
|
|
1156
1216
|
xoGone: 'The design changed, so this export was cancelled',
|
|
1217
|
+
xoJobGone: 'The export was interrupted (it waited too long or DSH restarted). Please export again',
|
|
1218
|
+
styleMoved: 'The design changed, so these style tweaks were not saved',
|
|
1219
|
+
xoCut: 'At most 1000 screens per export; the last {n} were left out',
|
|
1157
1220
|
xoResize: 'Fit canvas to content ({size})',
|
|
1158
1221
|
xoFull: 'Switch to full page',
|
|
1159
1222
|
xoLayout: 'Page size',
|
|
@@ -1269,6 +1332,8 @@ window.__ModuleLoader__.load({
|
|
|
1269
1332
|
ckItem: '{i}. {type}: {where}{text} — {detail}',
|
|
1270
1333
|
ckQuote: ' "{text}"',
|
|
1271
1334
|
exporting: 'Exporting…',
|
|
1335
|
+
exportingN: 'Capturing {i}/{n}…',
|
|
1336
|
+
xoCheckingN: 'Checking for cut-off content {i}/{n}…',
|
|
1272
1337
|
exported: 'Exported {name}',
|
|
1273
1338
|
exportedCopied: 'Exported {name} and copied it',
|
|
1274
1339
|
exportFail: 'Export failed: {msg}',
|
|
@@ -1384,6 +1449,11 @@ window.__ModuleLoader__.load({
|
|
|
1384
1449
|
styleNoWrite: 'Dev-server pages cannot be saved here; send it to the chat',
|
|
1385
1450
|
styleBusyTip: 'The model is working; save when it stops',
|
|
1386
1451
|
styleSaved: 'Style saved to {file}',
|
|
1452
|
+
styleShare: 'Change it on every screen',
|
|
1453
|
+
styleShareAt: 'into {sel} in {file}',
|
|
1454
|
+
styleShareTip: 'Everything using this rule changes too ({n} on this screen). Untick to change only the selected element',
|
|
1455
|
+
styleSavedRule: 'Saved into {sel} in {file}; every screen changes',
|
|
1456
|
+
styleSavedOthers: 'Saved into {sel} in {file}. On {n} other screens this element was saved on its own before and keeps that value',
|
|
1387
1457
|
styleMiss: 'Could not find this element in the source (maybe a script made it); sending it to the chat instead',
|
|
1388
1458
|
styleN: '{n} changed',
|
|
1389
1459
|
styleAskText: '[Style] {name} ({sel}): {list}. {rules}Put it in its stylesheet rule ({where}), using design tokens where you can, not an inline style.\n',
|
|
@@ -1443,6 +1513,56 @@ window.__ModuleLoader__.load({
|
|
|
1443
1513
|
phoneFail: 'Could not start: {msg}',
|
|
1444
1514
|
phoneHelp: 'Check both are on the same Wi-Fi, turn off any VPN or proxy on the phone, and allow incoming connections if your computer asks.',
|
|
1445
1515
|
phoneTrouble: "Won't open?",
|
|
1516
|
+
pub: 'Public link (beta)',
|
|
1517
|
+
exPub: 'Public link (beta)',
|
|
1518
|
+
pubWhat: 'Send a link to someone who is not nearby',
|
|
1519
|
+
pubP1: 'No shared Wi-Fi needed: they open it in WeChat or any browser and can click through the screens',
|
|
1520
|
+
pubP2: 'Only this design\'s clickable demo goes out; nothing else on your computer is reachable',
|
|
1521
|
+
pubP3: 'Closes after 2 hours, or whenever you stop it; the link stops working right away',
|
|
1522
|
+
pubP4: 'Uses a free Cloudflare quick tunnel (trycloudflare.com), not our servers',
|
|
1523
|
+
pubGo: 'Create link',
|
|
1524
|
+
pubStarting: 'Connecting to Cloudflare…',
|
|
1525
|
+
pubStartingFine: 'Usually about 10 seconds',
|
|
1526
|
+
pubReady: 'Public',
|
|
1527
|
+
pubLeft: '{t} left',
|
|
1528
|
+
pubViews: 'Opened {n} times',
|
|
1529
|
+
pubHow: 'Opens in WeChat or any browser',
|
|
1530
|
+
pubLive: 'Edits to these screens show up when they refresh. Switching to another design closes the link.',
|
|
1531
|
+
pubWarn: 'Anyone with the link can see it. Don\'t post it in public groups.',
|
|
1532
|
+
pubCopied: 'Link copied. Paste it into a chat',
|
|
1533
|
+
pubStop: 'Stop sharing',
|
|
1534
|
+
pubNeed: 'This needs cloudflared, Cloudflare\'s free tunnel tool (no account needed).',
|
|
1535
|
+
pubDl: 'Download (about 19 MB)',
|
|
1536
|
+
pubDlFrom: 'Downloaded from Cloudflare\'s official GitHub into the plugin\'s own folder.',
|
|
1537
|
+
pubDling: 'Downloading cloudflared… {p}',
|
|
1538
|
+
pubDlFail: 'Download failed: {msg}',
|
|
1539
|
+
pubSelf: 'Or install it yourself: on a Mac run brew install cloudflared; on Windows run winget install --id Cloudflare.cloudflared. Create link shows up here once it is installed.',
|
|
1540
|
+
pubDlCancel: 'Cancel download',
|
|
1541
|
+
pubGone: 'The design changed (or this isn\'t a local file), so no link was created. Check it\'s the right design and try again.',
|
|
1542
|
+
pubScreens: 'Shares these {n} screens: {names}. Screens added later are not shared automatically.',
|
|
1543
|
+
pubMoreNames: ' and more',
|
|
1544
|
+
pubShared: 'Sharing these {n} screens: {names}',
|
|
1545
|
+
pubBrokenShort: 'Visitors can\'t open it now',
|
|
1546
|
+
pubBroken: 'Visitors currently see "Not available": {why}. Once fixed they can just refresh, or you can stop sharing.',
|
|
1547
|
+
pubDlStalled: 'The download stalled (no progress for 30 seconds), probably because GitHub is unreachable. Try again, or install it yourself as below.',
|
|
1548
|
+
pubDlNoBuild: 'There is no ready-made cloudflared for this system. Please install it yourself.',
|
|
1549
|
+
pubReconnecting: 'Reconnecting',
|
|
1550
|
+
pubReconnectingFine: 'Lost the connection to Cloudflare for now and reconnecting. The link stays the same; it closes if not back within 90 seconds.',
|
|
1551
|
+
pubRetry: 'Try again',
|
|
1552
|
+
pubFail: 'Could not reach Cloudflare: {msg}',
|
|
1553
|
+
pubFailHint: 'Office networks and proxy apps sometimes block it. Try another network or turn off the proxy.',
|
|
1554
|
+
pubTooBig: 'Too many images: the demo would be over 150 MB. Try with fewer screens',
|
|
1555
|
+
pubNoScreens: 'None of the screens could be read (moved or deleted?)',
|
|
1556
|
+
pubEndExpired: 'The last link closed after 2 hours.',
|
|
1557
|
+
pubEndDropped: 'The last link dropped (network changed or the computer slept) and no longer works.',
|
|
1558
|
+
pubEndMoved: 'You switched designs, so the last link was closed.',
|
|
1559
|
+
pubAgain: 'Create a new link (it will change)',
|
|
1560
|
+
pubTrouble: "They can't open it?",
|
|
1561
|
+
pubHelp: 'A new link takes a few seconds to start working. If WeChat warns or won\'t open it, tap the top-right menu and open it in the browser. The link also drops if the computer sleeps.',
|
|
1562
|
+
pubOff: 'Public link closed: {why}',
|
|
1563
|
+
pubWhyExpired: '2 hours are up',
|
|
1564
|
+
pubWhyDropped: 'the tunnel dropped',
|
|
1565
|
+
pubWhyMoved: 'you switched designs',
|
|
1446
1566
|
zoomIn: 'Zoom in',
|
|
1447
1567
|
zoomOut: 'Zoom out',
|
|
1448
1568
|
fit: 'Fit',
|
|
@@ -2288,6 +2408,9 @@ window.__ModuleLoader__.load({
|
|
|
2288
2408
|
.ddp-phone .fine{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
2289
2409
|
.ddp-phone .row{display:flex;gap:6px;margin-top:6px}
|
|
2290
2410
|
.ddp-phone .row .ddp-go{height:28px;padding:0 12px;font-size:12px}
|
|
2411
|
+
.ddp-phone .warn{color:#c2410c}
|
|
2412
|
+
.ddp-pub .ddp-publist{margin:2px 0 4px;padding:0 0 0 18px;text-align:left;display:flex;flex-direction:column;gap:3px}
|
|
2413
|
+
.ddp-pub .ddp-publink{width:100%;box-sizing:border-box;height:28px;padding:0 8px;border-radius:7px;border:.5px solid var(--dsw-alias-border-primary,rgba(0,0,0,.15));background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:11px/28px ui-monospace,SFMono-Regular,Menlo,monospace;text-overflow:ellipsis}
|
|
2291
2414
|
@keyframes ddp-pulse{50%{opacity:1}}
|
|
2292
2415
|
.ddp-tokens .none{padding:6px 6px 0;color:var(--dsw-alias-label-secondary);line-height:1.6}
|
|
2293
2416
|
.ddp-tokens .none .ddp-go{margin-top:10px}
|
|
@@ -2368,6 +2491,10 @@ window.__ModuleLoader__.load({
|
|
|
2368
2491
|
.ddp-style .seg button.on{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 1px 2px rgba(0,0,0,.14)}
|
|
2369
2492
|
.ddp-style .note{margin-top:6px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary)}
|
|
2370
2493
|
.ddp-style .cnt{padding:0 14px 6px;font-size:11px;color:var(--dsw-alias-label-tertiary)}
|
|
2494
|
+
.ddp-style label.share{align-items:center;margin:0;padding:0 14px 8px;gap:6px;cursor:pointer}
|
|
2495
|
+
.ddp-style label.share input{margin:0;accent-color:${ACCENT};cursor:pointer}
|
|
2496
|
+
.ddp-style label.share span{flex:none;color:var(--dsw-alias-label-primary)}
|
|
2497
|
+
.ddp-style label.share em{flex:1;min-width:0;max-width:none}
|
|
2371
2498
|
.ddp-styles{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:10px 8px}
|
|
2372
2499
|
.ddp-sc{display:flex;flex-direction:column;gap:5px;min-width:0;padding:0;border:0;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;text-align:left;cursor:pointer}
|
|
2373
2500
|
.ddp-sc .pv{position:relative;display:block;height:74px;border-radius:10px;overflow:hidden;container-type:inline-size;box-shadow:0 0 0 .5px rgba(127,127,127,.35);transition:transform .15s ${EASE},box-shadow .15s}
|
|
@@ -7105,7 +7232,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7105
7232
|
* 拖的时候页面上先看效果(还没写进文件);设计变量列成小块,点一个就用 var(--x)。
|
|
7106
7233
|
* write:{ ok, tip } 能不能写回文件(开发服务器、模型在干活时不能)
|
|
7107
7234
|
*/
|
|
7108
|
-
function StylePanel({ t, sty, tokens, write, onSet, onReset, onAsk, onSave, onClose }) {
|
|
7235
|
+
function StylePanel({ t, sty, tokens, write, onSet, onReset, onAsk, onSave, onShare, onClose }) {
|
|
7109
7236
|
// 刚复制过哪一行:{ key, ok, v },1.5 秒后按钮字换回「复制」;没复制上的提示留着,换了元素才清
|
|
7110
7237
|
const [copied, setCopied] = useState(null)
|
|
7111
7238
|
const copyTimer = useRef(0)
|
|
@@ -7160,6 +7287,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7160
7287
|
}
|
|
7161
7288
|
const w = Math.min(700, Math.max(400, Math.round(parseInt(cur('font-weight'), 10) / 100) * 100 || 400))
|
|
7162
7289
|
const n = Object.keys(sty.live).length
|
|
7290
|
+
const share = shareRule(sty)
|
|
7163
7291
|
return box(
|
|
7164
7292
|
h('p', { className: 'who', title: `${sty.name} · ${sty.selector}` }, ...(() => { const e = elemLabel(t, sty.name, sty.text); return [h('b', null, e.role), e.text ? h('span', null, `「${e.text}」`) : null] })()),
|
|
7165
7293
|
h('div', { className: 'bd' },
|
|
@@ -7174,6 +7302,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7174
7302
|
slider('stylePadX', ['padding-left', 'padding-right'], 48, 'space'),
|
|
7175
7303
|
sty.layout ? slider('styleGap', ['gap'], 48, 'space') : null),
|
|
7176
7304
|
n ? h('div', { className: 'cnt' }, t('styleN', { n: styleChanges(t, sty).length })) : null,
|
|
7305
|
+
n && write.ok && share ? h('label', { className: 'share', title: t('styleShareTip', { n: share.cnt || 1 }) },
|
|
7306
|
+
h('input', { type: 'checkbox', checked: shareOn(sty), onChange: (e) => onShare(e.target.checked) }),
|
|
7307
|
+
h('span', null, t('styleShare')), h('em', null, t('styleShareAt', ruleName(share)))) : null,
|
|
7177
7308
|
n ? h('footer', { className: 'row' },
|
|
7178
7309
|
h('button', { onClick: onReset }, h('span', null, t('styleReset'))),
|
|
7179
7310
|
h('button', { onClick: onAsk, title: t('styleAskTip') }, h('span', null, t('styleAsk'))),
|
|
@@ -7706,6 +7837,145 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7706
7837
|
h('div', { className: 'bd' }, bd))
|
|
7707
7838
|
}
|
|
7708
7839
|
|
|
7840
|
+
/**
|
|
7841
|
+
* 公网链接(#27,实验):把整套 HTML 演示临时放到公网上(cloudflared 临时通道),给链接和二维码。
|
|
7842
|
+
* 开之前先说清楚是公网可见;没装 cloudflared 的先请人下载;连上了显示还剩多久、打开过几次
|
|
7843
|
+
*/
|
|
7844
|
+
function PubPanel({ t, sid, body, fresh, brief, onCopy, onClose }) {
|
|
7845
|
+
const [res, setRes] = useState(null)
|
|
7846
|
+
const [err, setErr] = useState('')
|
|
7847
|
+
const [busy, setBusy] = useState(false)
|
|
7848
|
+
const [, setNow] = useState(0)
|
|
7849
|
+
const resRef = useRef(null)
|
|
7850
|
+
// 回包可能乱序:只认比上一次用过的更晚发出的(关掉以后,之前发出去的 peek 晚到也不会把旧链接显示回来)
|
|
7851
|
+
const seq = useRef(0)
|
|
7852
|
+
const used = useRef(0)
|
|
7853
|
+
const send = (b) => { const n = ++seq.current; return post('pubshare', b).then((d) => { if (n > used.current) { used.current = n; take(d) } return d }) }
|
|
7854
|
+
const take = (d) => { resRef.current = d; setRes(d); setErr('') }
|
|
7855
|
+
useEffect(() => {
|
|
7856
|
+
let alive = true
|
|
7857
|
+
let tm = 0
|
|
7858
|
+
const tick = () => send({ session: sid, peek: true }).catch((e) => { if (alive) setErr(e.message) }).finally(() => {
|
|
7859
|
+
if (!alive) return
|
|
7860
|
+
const r = resRef.current
|
|
7861
|
+
const fast = r && ((r.on && r.state === 'starting') || (r.dl && !r.dl.done))
|
|
7862
|
+
tm = setTimeout(tick, fast ? 700 : 3000)
|
|
7863
|
+
})
|
|
7864
|
+
tick()
|
|
7865
|
+
const clock = setInterval(() => setNow(Date.now()), 1000)
|
|
7866
|
+
return () => { alive = false; seq.current++; used.current = seq.current; clearTimeout(tm); clearInterval(clock) }
|
|
7867
|
+
}, [sid])
|
|
7868
|
+
// 马上不显示旧链接和二维码(之前发出去还没回来的回包作废),再马上问一次完整状态,不等下一次轮询
|
|
7869
|
+
const dropNow = (ended) => {
|
|
7870
|
+
const r = resRef.current
|
|
7871
|
+
used.current = ++seq.current // 不管面板现在显示什么,之前发出去的都作废(第一次 peek 还没回来也一样)
|
|
7872
|
+
if (r && r.on) take({ on: false, ended, tool: r.tool })
|
|
7873
|
+
send({ session: sid, peek: true }).catch(() => {})
|
|
7874
|
+
}
|
|
7875
|
+
// 右侧栏的状态从开变成关(到点、断了、起不来)(起不来的具体原因等 peek 带回来,先不显示个代号)。
|
|
7876
|
+
// 面板正在「连」的时候不管:刚停了又点生成,停的那一刻的旧状态晚到,别把新的闪成关
|
|
7877
|
+
const briefOn = brief ? !!brief.on : null
|
|
7878
|
+
const briefWas = useRef(briefOn)
|
|
7879
|
+
useEffect(() => {
|
|
7880
|
+
const was = briefWas.current
|
|
7881
|
+
briefWas.current = briefOn
|
|
7882
|
+
const r = resRef.current
|
|
7883
|
+
if (was === true && briefOn === false && !(r && r.on && r.state === 'starting')) dropNow((brief && brief.ended) || '')
|
|
7884
|
+
}, [briefOn])
|
|
7885
|
+
// 换了设计(地址栏、拖进来、设计库 / 市场「用这个」……哪条路都算):链接已经跟着关了,面板马上跟上
|
|
7886
|
+
const tk = body().target
|
|
7887
|
+
const tkWas = useRef(tk)
|
|
7888
|
+
useEffect(() => {
|
|
7889
|
+
if (tkWas.current === tk) return
|
|
7890
|
+
tkWas.current = tk
|
|
7891
|
+
dropNow('moved')
|
|
7892
|
+
}, [tk])
|
|
7893
|
+
const start = () => {
|
|
7894
|
+
setBusy(true)
|
|
7895
|
+
// 屏多时先问一遍全部屏(收起来的改了名、刚加的),再按最新的放出去
|
|
7896
|
+
Promise.resolve(fresh ? fresh() : body()).then((b) => send({ session: sid, on: true, ...b })).then((d) => {
|
|
7897
|
+
if (!d.on && d.error === 'no-cloudflared' && !d.tool) return download()
|
|
7898
|
+
}).catch((e) => setErr(e.message)).finally(() => setBusy(false))
|
|
7899
|
+
}
|
|
7900
|
+
const download = () => send({ session: sid, download: true }).catch((e) => setErr(e.message))
|
|
7901
|
+
const cancel = () => send({ session: sid, cancel: true }).catch((e) => setErr(e.message))
|
|
7902
|
+
const stop = () => send({ session: sid, on: false }).catch((e) => setErr(e.message))
|
|
7903
|
+
// 下完了不自动生成:面板回到「会放出这几屏」+「生成链接」,按下载完时的画布让人再看一眼、自己点
|
|
7904
|
+
const left = (ms) => {
|
|
7905
|
+
const x = Math.max(0, Math.round(ms / 1000))
|
|
7906
|
+
return `${Math.floor(x / 3600)}:${String(Math.floor((x % 3600) / 60)).padStart(2, '0')}:${String(x % 60).padStart(2, '0')}`
|
|
7907
|
+
}
|
|
7908
|
+
// 会放出去的是哪几屏(画布上的全部屏,单看一屏时也是全部):生成前写清楚
|
|
7909
|
+
const shotList = (() => {
|
|
7910
|
+
const list = (body().screens || []).map((x) => x.label || x.key)
|
|
7911
|
+
if (!list.length) return ''
|
|
7912
|
+
// 几百屏的设计(#29):只列前 12 个名字
|
|
7913
|
+
return t('pubScreens', { n: list.length, names: list.slice(0, 12).join(t('sep')) + (list.length > 12 ? t('pubMoreNames') : '') })
|
|
7914
|
+
})()
|
|
7915
|
+
const errText = (r) => (r.error === 'tooBig' ? t('pubTooBig') : r.error === 'noScreens' ? t('pubNoScreens') : t('pubFail', { msg: r.message || r.error || '' }))
|
|
7916
|
+
// 接口拒了(点生成的那一刻换了设计、或者现在看的不是本地文件):别说成「没连上 Cloudflare」
|
|
7917
|
+
const errMsg = (m) => (m === 'designChanged' || m === 'not-file' ? t('pubGone') : t('pubFail', { msg: m }))
|
|
7918
|
+
const ended = (r) => (r.ended === 'expired' ? t('pubEndExpired') : r.ended === 'dropped' ? t('pubEndDropped') : r.ended === 'moved' ? t('pubEndMoved') : '')
|
|
7919
|
+
let bd
|
|
7920
|
+
if (err && !res) bd = h('p', null, errMsg(err))
|
|
7921
|
+
else if (!res) bd = h('p', null, t('phoneStarting'))
|
|
7922
|
+
else if (res.on && res.state === 'starting') {
|
|
7923
|
+
bd = [
|
|
7924
|
+
h('span', { key: 'st', className: 'st' }, h('i'), t('pubStarting')),
|
|
7925
|
+
h('p', { key: 'f', className: 'fine' }, t('pubStartingFine')),
|
|
7926
|
+
h('div', { key: 'row', className: 'row' }, h('button', { className: 'ddp-go sec', onClick: stop }, t('pubStop'))),
|
|
7927
|
+
]
|
|
7928
|
+
} else if (res.on) {
|
|
7929
|
+
bd = [
|
|
7930
|
+
h('div', { key: 'qr', className: 'qr' }, h(QrCode, { rows: res.qr || [] })),
|
|
7931
|
+
h('b', { key: 'how', className: 'how' }, t('pubHow')),
|
|
7932
|
+
h('input', { key: 'url', className: 'ddp-publink', readOnly: true, value: res.url, onFocus: (e) => e.target.select(), 'aria-label': t('pub') }),
|
|
7933
|
+
h('span', { key: 'st', className: 'st' + (res.state === 'reconnecting' || res.broken ? '' : ' ok') }, res.state === 'reconnecting' || res.broken ? h('i') : h(I.check), (res.broken ? t('pubBrokenShort') : res.state === 'reconnecting' ? t('pubReconnecting') : t('pubReady')) + ' · ' + t('pubLeft', { t: left(res.expires - Date.now()) }) + (res.views ? ' · ' + t('pubViews', { n: res.views }) : '')),
|
|
7934
|
+
res.state === 'reconnecting' ? h('p', { key: 'rc', className: 'fine warn' }, t('pubReconnectingFine')) : null,
|
|
7935
|
+
res.broken ? h('p', { key: 'broken', className: 'fine warn' }, t('pubBroken', { why: res.broken === 'tooBig' ? t('pubTooBig') : res.broken === 'noScreens' ? t('pubNoScreens') : res.broken })) : null,
|
|
7936
|
+
res.screens && res.screens.length ? h('p', { key: 'scr', className: 'fine' }, t('pubShared', { n: res.screens.length, names: res.screens.join(t('sep')) })) : null,
|
|
7937
|
+
h('p', { key: 'live', className: 'fine' }, t('pubLive')),
|
|
7938
|
+
h('p', { key: 'warn', className: 'fine warn' }, t('pubWarn')),
|
|
7939
|
+
h('div', { key: 'row', className: 'row' },
|
|
7940
|
+
h('button', { className: 'ddp-go sec', onClick: stop }, t('pubStop')),
|
|
7941
|
+
h('button', { className: 'ddp-go', onClick: () => onCopy(res.url) }, t('phoneCopy'))),
|
|
7942
|
+
h('details', { key: 'more', className: 'fine' }, h('summary', null, t('pubTrouble')), h('p', null, t('pubHelp'))),
|
|
7943
|
+
]
|
|
7944
|
+
} else if (res.dl && !res.dl.done && !res.tool) {
|
|
7945
|
+
const pct = res.dl.total ? Math.round((res.dl.got / res.dl.total) * 100) + '%' : Math.round(res.dl.got / 1048576) + ' MB'
|
|
7946
|
+
bd = [
|
|
7947
|
+
h('span', { key: 'st', className: 'st' }, h('i'), t('pubDling', { p: pct })),
|
|
7948
|
+
h('p', { key: 'f', className: 'fine' }, t('pubDlFrom')),
|
|
7949
|
+
h('p', { key: 'self', className: 'fine' }, t('pubSelf')),
|
|
7950
|
+
h('div', { key: 'row', className: 'row' }, h('button', { className: 'ddp-go sec', onClick: cancel }, t('pubDlCancel'))),
|
|
7951
|
+
]
|
|
7952
|
+
} else {
|
|
7953
|
+
// 没开:先说清楚是公网可见;本机没有 cloudflared 的,主按钮变成「下载」(下完接着生成)
|
|
7954
|
+
const why = res.error ? errText(res) : ended(res)
|
|
7955
|
+
const noTool = !res.tool
|
|
7956
|
+
bd = [
|
|
7957
|
+
h('b', { key: 'what', className: 'how' }, t('pubWhat')),
|
|
7958
|
+
h('ul', { key: 'ul', className: 'ddp-publist' }, ['pubP1', 'pubP2', 'pubP3', 'pubP4'].map((k) => h('li', { key: k }, t(k)))),
|
|
7959
|
+
shotList ? h('p', { key: 'scr', className: 'fine' }, shotList) : null,
|
|
7960
|
+
why && res.error !== 'no-cloudflared' ? h('p', { key: 'why', className: 'warn' }, why) : null,
|
|
7961
|
+
res.error === 'tunnel' || res.error === 'timeout' ? h('p', { key: 'hint', className: 'fine' }, t('pubFailHint')) : null,
|
|
7962
|
+
err ? h('p', { key: 'err', className: 'warn' }, errMsg(err)) : null,
|
|
7963
|
+
noTool ? h('p', { key: 'need' }, t('pubNeed')) : null,
|
|
7964
|
+
noTool && res.dl && res.dl.error ? h('p', { key: 'dlf', className: 'warn' }, res.dl.error === 'stalled' ? t('pubDlStalled') : res.dl.error === 'unsupported' ? t('pubDlNoBuild') : t('pubDlFail', { msg: res.dl.error })) : null,
|
|
7965
|
+
h('div', { key: 'row', className: 'row' },
|
|
7966
|
+
noTool && res.dl && res.dl.error ? h('button', { className: 'ddp-go sec', onClick: start, disabled: busy }, t('pubRetry')) : null,
|
|
7967
|
+
noTool
|
|
7968
|
+
? h('button', { className: 'ddp-go', disabled: busy, onClick: download }, t('pubDl'))
|
|
7969
|
+
: h('button', { className: 'ddp-go', onClick: start, disabled: busy }, why ? t('pubAgain') : t('pubGo'))),
|
|
7970
|
+
noTool ? h('p', { key: 'from', className: 'fine' }, t('pubDlFrom')) : null,
|
|
7971
|
+
noTool ? h('p', { key: 'self', className: 'fine' }, t('pubSelf')) : null,
|
|
7972
|
+
]
|
|
7973
|
+
}
|
|
7974
|
+
return h('div', { className: 'ddp-tokens ddp-phone ddp-pub', onPointerDown: (e) => e.stopPropagation() },
|
|
7975
|
+
h('header', null, h(I.web), h('b', null, t('pub')), h('button', { className: 'ddp-btn', title: '×', onClick: onClose }, h(I.close))),
|
|
7976
|
+
h('div', { className: 'bd' }, bd))
|
|
7977
|
+
}
|
|
7978
|
+
|
|
7709
7979
|
/** 版本面板:现在 + 存过的几版(新的在前),点一版看当时的样子 */
|
|
7710
7980
|
function HistoryPanel({ t, versions, ver, onPick, onClose }) {
|
|
7711
7981
|
const files = (list) => {
|
|
@@ -8274,10 +8544,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8274
8544
|
const first = firstRun.current
|
|
8275
8545
|
firstRun.current = false
|
|
8276
8546
|
// 页面刚改过:等它重新载入再量
|
|
8547
|
+
// tok:换了画幅 / 屏 / 文件时这一遍作废(几百屏量一遍要好一会,别排在导出前面空跑)
|
|
8548
|
+
const tok = { off: false }
|
|
8277
8549
|
const timer = setTimeout(() => {
|
|
8278
|
-
measure().then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
|
|
8550
|
+
measure(tok).then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
|
|
8279
8551
|
}, first ? 0 : 900)
|
|
8280
|
-
return () => { off = true; clearTimeout(timer) }
|
|
8552
|
+
return () => { off = true; tok.off = true; clearTimeout(timer) }
|
|
8281
8553
|
}, [size.join('x'), screens, rev, again])
|
|
8282
8554
|
const limit = opts.fit === 'page' ? Infinity : opts.fit === 'height' && fitHOk(opts.fitH) ? +opts.fitH : 0
|
|
8283
8555
|
const rep = list ? precheckOf(list, kind, limit) : null
|
|
@@ -9028,8 +9300,28 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9028
9300
|
// ── 导出图片(从预览面板里拆出来的:只用传进来的,不碰面板自己的状态)──────────────
|
|
9029
9301
|
// x:这一次画面的值(会话、状态、类型、画幅、几屏…)、几个 ref(各屏接口、背后挂的那批、设计序号)和面板里共用的 apiOf / targetKey
|
|
9030
9302
|
// onWarn:预检发现会被裁时打开导出选项
|
|
9303
|
+
/**
|
|
9304
|
+
* 导出用的全部屏(#29):服务端给的那份(list,已排好序,见 hidden 路由),右侧栏挂着的那几屏用它自己的(带画面信息),
|
|
9305
|
+
* 别的(收起来的、刚加还没轮询到的)用 list 里的。list 空 = 没收起来的,就是显示的这些
|
|
9306
|
+
*/
|
|
9307
|
+
function everyOf(shown, list) {
|
|
9308
|
+
if (!list || !list.length) return shown
|
|
9309
|
+
const by = new Map(shown.map((sc) => [sc.key, sc]))
|
|
9310
|
+
return list.map((x) => by.get(x.key) || x)
|
|
9311
|
+
}
|
|
9312
|
+
|
|
9031
9313
|
function makeExporter(x) {
|
|
9032
9314
|
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
|
|
9315
|
+
// 导出用的全部屏(#29):屏多过上限时右侧栏只显示最新的 60 屏,收起来的那些接在前面;没收起来就是显示的这些
|
|
9316
|
+
let every = x.every || shown
|
|
9317
|
+
// 导出前再问一次收起来的是哪些(不用缓存:右侧栏刚加了屏、收起来的改了名,都还没轮询到)
|
|
9318
|
+
let cutN = 0 // 超过 1000 屏(MAX_PAGES):后面这么多屏没导出,提示里说
|
|
9319
|
+
const loadEvery = async () => {
|
|
9320
|
+
if (!x.loadHidden) return every
|
|
9321
|
+
try { const r = await x.loadHidden(true); every = everyOf(shown, r.list); cutN = r.cut || 0 } catch (e) { console.warn('[dsh-design-studio] 取收起来的屏失败', e) }
|
|
9322
|
+
return every
|
|
9323
|
+
}
|
|
9324
|
+
const cutTail = () => (cutN ? ' · ' + t('xoCut', { n: cutN }) : '')
|
|
9033
9325
|
// 截一屏:图片和它的 CSS 尺寸(PDF / PPT 按这个定页面大小)
|
|
9034
9326
|
// 这次导出截到的 AI 示意图(文件名去重):每种导出结束的提示里都带一句「上线前换成真实照片」
|
|
9035
9327
|
const aiTail = (ai) => (ai && ai.size ? ' · ' + t('xoAi', { n: ai.size }) : '')
|
|
@@ -9051,15 +9343,16 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9051
9343
|
}
|
|
9052
9344
|
|
|
9053
9345
|
// 单看时只挂着正在看的那屏;要所有屏(PDF、PPT、拼图、预检)时按画幅大小在背后挂上,用完就撤
|
|
9054
|
-
|
|
9055
|
-
|
|
9346
|
+
// pool:从哪几屏里挂(默认全部屏;拼展示图只用显示的那些)
|
|
9347
|
+
const withFrames = async (fn, only, pool = every) => {
|
|
9348
|
+
if (!only && ((canvas && pool.length <= LIVE_MAX) || pool.length < 2)) return fn(apis.current)
|
|
9056
9349
|
// 网页单看时铺满右侧栏,和画幅不一样宽,都在背后重挂(开了「按画幅显示」也照这样挂,只是多挂一次、慢一点,结果一样);别的类型正在看的那屏直接用(滚动位置、打开的弹窗都还在)
|
|
9057
9350
|
// 画布屏多的时候镜头一动画布上的屏就会撤,也都在背后挂
|
|
9058
9351
|
const stamp = designSeq.current
|
|
9059
9352
|
const run = async () => {
|
|
9060
9353
|
if (designSeq.current !== stamp) throw new Error('designChanged') // 排队的时候换了设计
|
|
9061
9354
|
// 轮到了才算要挂哪些:排队时前台可能已经换了一屏
|
|
9062
|
-
const list = only || (canvas || kind === 'web' ?
|
|
9355
|
+
const list = only || (canvas || kind === 'web' ? pool : pool.filter((sc) => !apis.current.has(ik(sc))))
|
|
9063
9356
|
const back = new Set(list.map(ik))
|
|
9064
9357
|
const place = new Map(list.map((sc, i) => [ik(sc), i]))
|
|
9065
9358
|
// 屏多的时候分批挂:只挂轮到的这一批,别几十个一起跑
|
|
@@ -9079,11 +9372,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9079
9372
|
ghostQueue.current = job.catch(() => {})
|
|
9080
9373
|
return job
|
|
9081
9374
|
}
|
|
9082
|
-
const measureAll = async (map) => {
|
|
9375
|
+
const measureAll = async (map, tok) => {
|
|
9083
9376
|
const stamp = designSeq.current
|
|
9084
9377
|
const list = []
|
|
9085
|
-
for (const sc of
|
|
9086
|
-
if (designSeq.current !== stamp) break //
|
|
9378
|
+
for (const [i, sc] of every.entries()) {
|
|
9379
|
+
if (designSeq.current !== stamp || (tok && tok.off)) break // 设计换了 / 选项面板这一遍作废:别再等旧的屏
|
|
9380
|
+
if (every.length > LIVE_MAX) say(t('xoCheckingN', { i: i + 1, n: every.length }))
|
|
9087
9381
|
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 }) }
|
|
9088
9382
|
}
|
|
9089
9383
|
return list
|
|
@@ -9105,13 +9399,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9105
9399
|
const long = fit === 'page' || fit === 'height' || (!fit && mode === 'pdf' && (kind === 'web' || kind === 'email'))
|
|
9106
9400
|
const maxH = fit === 'height' ? Number(opts.fitH) || 0 : 0
|
|
9107
9401
|
let deadN = 0
|
|
9402
|
+
await loadEvery()
|
|
9403
|
+
if (gone()) { say(t('xoGone')); return }
|
|
9108
9404
|
await withFrames(async (map) => {
|
|
9109
9405
|
// 从菜单直接点:先量一遍,有内容会被裁就先给看清单(同样的结果只拦一次)
|
|
9110
9406
|
if (!opts) {
|
|
9111
9407
|
const seen = await measureAll(map)
|
|
9112
9408
|
const rep = precheckOf(seen, kind, long ? Infinity : 0)
|
|
9113
9409
|
deadN = rep.dead
|
|
9114
|
-
const sig = rep.over || rep.long || rep.moved ? [design,
|
|
9410
|
+
const sig = rep.over || rep.long || rep.moved ? [design, every.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
|
|
9115
9411
|
if (sig && warned.current !== sig) {
|
|
9116
9412
|
warned.current = sig
|
|
9117
9413
|
say(t('xoWarn'))
|
|
@@ -9119,44 +9415,56 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9119
9415
|
return
|
|
9120
9416
|
}
|
|
9121
9417
|
}
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9418
|
+
// 截一批传一批(#29:几百屏的截图攒在一起一次传不动),最后一批带上 done,服务端再拼。
|
|
9419
|
+
// 原型里的跳转写目标屏的 key:服务端拼的时候换成第几页,PDF / PPT 里点了能跳过去
|
|
9420
|
+
const job = Math.random().toString(36).slice(2, 10) + Date.now().toString(36)
|
|
9421
|
+
let batch = []
|
|
9422
|
+
let n = 0
|
|
9423
|
+
const titles = []
|
|
9424
|
+
// at:之前传了几页(服务端核对,中途 job 过期 / 丢了一批就整份报错,不拿半截拼)
|
|
9425
|
+
let sent = 0
|
|
9426
|
+
const flush = async (last) => { const b = batch; batch = []; const r = await post('doc', { session: sid, job, pages: b, at: sent, ...last }); sent += b.length; return r }
|
|
9427
|
+
const cancel = () => post('doc', { session: sid, job, cancel: true }).catch(() => {})
|
|
9428
|
+
try {
|
|
9429
|
+
for (const [i, sc] of every.entries()) {
|
|
9430
|
+
if (gone()) break
|
|
9431
|
+
if (every.length > LIVE_MAX) say(t('exportingN', { i: i + 1, n: every.length }))
|
|
9432
|
+
try {
|
|
9433
|
+
const r = await captureOf(sc, long, map, maxH, aiShot)
|
|
9434
|
+
const cut = maxH && r.h > maxH
|
|
9435
|
+
const title = exportTitle(sc, r)
|
|
9436
|
+
batch.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title, key: sc.key, links: r.links.map((l) => ({ x: l.x, y: l.y, w: l.w, h: l.h, key: keyOfPath(l.path, fileTarget) })) })
|
|
9437
|
+
titles.push(title)
|
|
9438
|
+
n++
|
|
9439
|
+
} catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
|
|
9440
|
+
if (batch.length >= 20) await flush({})
|
|
9441
|
+
}
|
|
9442
|
+
} catch (e) { cancel(); throw e } // 传某一批失败:服务端攒着的那些马上清掉
|
|
9443
|
+
if (gone()) { cancel(); say(t('xoGone')); return }
|
|
9444
|
+
if (!n) throw new Error('no screens')
|
|
9445
|
+
const sp = splitTitles(titles)
|
|
9140
9446
|
const folder = st && st.target && st.target.kind === 'file' ? String(st.target.file).split(/[\\/]/).slice(-2, -1)[0] : ''
|
|
9141
9447
|
const title = sp.brand || folder || st.label || ''
|
|
9142
9448
|
const layout = opts ? (opts.layout === 'custom' ? opts.custom.trim() : opts.layout === 'auto' ? '' : opts.layout) : ''
|
|
9143
9449
|
const cols = opts && opts.cols === 2 ? 2 : 1
|
|
9144
|
-
|
|
9450
|
+
let r
|
|
9451
|
+
try { r = await flush({ done: true, format: mode, name: prefix + (title || 'design') + suffix, title, bg: hexOf(pickColors(tokens).bg), layout, cols, target: targetKey }) } catch (e) { cancel(); throw e }
|
|
9145
9452
|
const file = String(r.path || '').split(/[\\/]/).pop()
|
|
9146
|
-
const miss =
|
|
9147
|
-
const sheets = Math.ceil(
|
|
9148
|
-
say((miss ? t('exportedDocMiss', { name: file, n: sheets, miss }) : t('exportedDoc', { name: file, n: sheets })) + (deadN ? ' · ' + t('xoDead', { n: deadN }) : '') + aiTail(aiShot), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
|
|
9453
|
+
const miss = every.length - n
|
|
9454
|
+
const sheets = Math.ceil(n / cols)
|
|
9455
|
+
say((miss ? t('exportedDocMiss', { name: file, n: sheets, miss }) : t('exportedDoc', { name: file, n: sheets })) + (deadN ? ' · ' + t('xoDead', { n: deadN }) : '') + cutTail() + aiTail(aiShot), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
|
|
9149
9456
|
})
|
|
9150
9457
|
return
|
|
9151
9458
|
}
|
|
9152
9459
|
if (mode === 'show') {
|
|
9153
9460
|
const shots = []
|
|
9461
|
+
// 展示图只拼右侧栏显示的这些(几百屏拼一张看不清)
|
|
9154
9462
|
await withFrames(async (map) => {
|
|
9155
9463
|
for (const sc of shown) {
|
|
9156
9464
|
if (gone()) break
|
|
9157
9465
|
try { const c = await captureOf(sc, false, map, 0, aiShot); shots.push({ img: c.img, top: c.top, title: exportTitle(sc, c) }) } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
|
|
9158
9466
|
}
|
|
9159
|
-
})
|
|
9467
|
+
}, undefined, shown)
|
|
9160
9468
|
if (gone()) { say(t('xoGone')); return }
|
|
9161
9469
|
if (!shots.length) throw new Error('no screens')
|
|
9162
9470
|
const sp = splitTitles(shots.map((x) => x.title))
|
|
@@ -9194,43 +9502,48 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9194
9502
|
await saveImage(base + (mode === 'long' ? '-full' : mode === 'raw' && FRAMED[kind] ? '-plain' : ''), await canvasBlob(c), aiShot)
|
|
9195
9503
|
}
|
|
9196
9504
|
} catch (e) {
|
|
9197
|
-
say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
|
|
9505
|
+
say(e.message === 'designChanged' ? t('xoGone') : e.message === 'jobGone' ? t('xoJobGone') : t('exportFail', { msg: e.message }))
|
|
9198
9506
|
}
|
|
9199
9507
|
}
|
|
9200
9508
|
// 整套 HTML 演示(#26):服务端把每屏连同样式、图片、图标打进一个 .html,不截图(几秒出来)。
|
|
9201
9509
|
// 屏、版本、画幅、深浅色、调节滑块没存的值都按眼前的;外壳在演示页面里能开关
|
|
9510
|
+
// 公网链接(#27)也用这一份:右侧栏眼前的屏、画幅、深浅色、调节值
|
|
9511
|
+
const htmlBody = () => {
|
|
9512
|
+
const list = []
|
|
9513
|
+
const seen = new Set()
|
|
9514
|
+
for (const sc of every) { // 看旧版本时就是那一版的几屏(都带 v);屏多时连收起来的(#29)
|
|
9515
|
+
if (seen.has(sc.key)) continue
|
|
9516
|
+
seen.add(sc.key)
|
|
9517
|
+
list.push(sc)
|
|
9518
|
+
}
|
|
9519
|
+
const sp = splitTitles(list.map((sc) => (infoOf(ik(sc)) || {}).title || sc.label))
|
|
9520
|
+
const folder = st && st.target && st.target.kind === 'file' ? String(st.target.file).split(/[\\/]/).slice(-2, -1)[0] : ''
|
|
9521
|
+
const title = sp.brand || folder || (st && st.label) || ''
|
|
9522
|
+
return {
|
|
9523
|
+
target: targetKey, v: ver ? ver.n : 0,
|
|
9524
|
+
title, lang: t('lang') === 'en' ? 'en' : 'zh', kind, w: size[0], h: size[1], os: meta.os || '', dark: !!dark, tweak: ver ? null : tweak || null, // 旧版本不套调节滑块的值(和画布上一样)
|
|
9525
|
+
// 没开「深色」时页面跟着系统深浅色走:记下右侧栏这会儿是哪种,演示里照这个显示(不跟看的人电脑走)
|
|
9526
|
+
scheme: typeof matchMedia === 'function' && matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light',
|
|
9527
|
+
fit: !!webFit, // 网页开着「按画幅显示」:演示里默认也套浏览器框、按画幅缩放
|
|
9528
|
+
screens: list.map((sc) => ({ key: sc.key, label: labelOf(sc), top: !!(tops && tops[ik(sc)]) })),
|
|
9529
|
+
}
|
|
9530
|
+
}
|
|
9202
9531
|
const exportHtml = async () => {
|
|
9203
9532
|
if (!fileTarget) return
|
|
9204
9533
|
say(t('exporting'))
|
|
9205
9534
|
try {
|
|
9206
|
-
|
|
9207
|
-
const
|
|
9208
|
-
|
|
9209
|
-
if (seen.has(sc.key)) continue
|
|
9210
|
-
seen.add(sc.key)
|
|
9211
|
-
list.push(sc)
|
|
9212
|
-
}
|
|
9213
|
-
const sp = splitTitles(list.map((sc) => (infoOf(ik(sc)) || {}).title || sc.label))
|
|
9214
|
-
const folder = st && st.target && st.target.kind === 'file' ? String(st.target.file).split(/[\\/]/).slice(-2, -1)[0] : ''
|
|
9215
|
-
const title = sp.brand || folder || st.label || ''
|
|
9216
|
-
const r = await post('htmlpack', {
|
|
9217
|
-
session: sid, target: targetKey, v: ver ? ver.n : 0,
|
|
9218
|
-
name: (ver ? `v${ver.n}-` : '') + (title || 'design') + (dark ? '-dark' : ''),
|
|
9219
|
-
title, lang: t('lang') === 'en' ? 'en' : 'zh', kind, w: size[0], h: size[1], os: meta.os || '', dark: !!dark, tweak: ver ? null : tweak || null, // 旧版本不套调节滑块的值(和画布上一样)
|
|
9220
|
-
// 没开「深色」时页面跟着系统深浅色走:记下右侧栏这会儿是哪种,演示里照这个显示(不跟看的人电脑走)
|
|
9221
|
-
scheme: typeof matchMedia === 'function' && matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light',
|
|
9222
|
-
fit: !!webFit, // 网页开着「按画幅显示」:演示里默认也套浏览器框、按画幅缩放
|
|
9223
|
-
screens: list.map((sc) => ({ key: sc.key, label: labelOf(sc), top: !!(tops && tops[ik(sc)]) })),
|
|
9224
|
-
})
|
|
9535
|
+
await loadEvery()
|
|
9536
|
+
const b = htmlBody()
|
|
9537
|
+
const r = await post('htmlpack', { session: sid, ...b, name: (ver ? `v${ver.n}-` : '') + (b.title || 'design') + (dark ? '-dark' : '') })
|
|
9225
9538
|
const file = String(r.path || '').split(/[\\/]/).pop()
|
|
9226
9539
|
const miss = Array.isArray(r.missing) ? r.missing.length : 0
|
|
9227
|
-
say((miss ? t('exportedHtmlMiss', { name: file, n: r.count, miss }) : t('exportedHtml', { name: file, n: r.count })) + (r.ai ? ' · ' + t('xoAi', { n: r.ai }) : ''), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
|
|
9540
|
+
say((miss ? t('exportedHtmlMiss', { name: file, n: r.count, miss }) : t('exportedHtml', { name: file, n: r.count })) + cutTail() + (r.ai ? ' · ' + t('xoAi', { n: r.ai }) : ''), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
|
|
9228
9541
|
} catch (e) {
|
|
9229
9542
|
const m = String((e && e.message) || '')
|
|
9230
9543
|
say(m === 'designChanged' || m === 'not-file' ? t('xoGone') : m === 'tooBig' ? t('htmlTooBig') : m === 'noScreens' ? t('htmlNoScreens') : t('exportFail', { msg: m }))
|
|
9231
9544
|
}
|
|
9232
9545
|
}
|
|
9233
|
-
return { withFrames, measureAll, exportShots, exportHtml }
|
|
9546
|
+
return { withFrames, measureAll, exportShots, exportHtml, htmlBody, loadEvery }
|
|
9234
9547
|
}
|
|
9235
9548
|
|
|
9236
9549
|
// ── 画笔标注(从预览面板里拆出来的):台面上看得到的几屏截图拼好、叠上画的,存进 refs/ 交给模型,或者复制
|
|
@@ -9479,12 +9792,56 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9479
9792
|
|
|
9480
9793
|
// ── 调样式(从预览面板里拆出来的):点一个元素,面板里拖滑块先在页面上看效果;写回文件 = 并进它在源码里的 style 属性
|
|
9481
9794
|
// x:这一次画面的值;开关调样式、Esc 收起留在面板里
|
|
9795
|
+
/**
|
|
9796
|
+
* 调样式「各屏一起改」写进哪条规则:改的几项由同一条外链 .css 规则决定(没有规则管的那几项一起写进去),
|
|
9797
|
+
* 选择器里得有元素自己的 class(见 picker 的 sharedOf);不行给 null(只改这一处)
|
|
9798
|
+
*/
|
|
9799
|
+
function shareRule(sty) {
|
|
9800
|
+
if (!sty || !sty.rules) return null
|
|
9801
|
+
let r0 = null
|
|
9802
|
+
for (const k of Object.keys(sty.live || {})) {
|
|
9803
|
+
const r = sty.rules[k]
|
|
9804
|
+
if (!r || !r.sel) continue // 没有规则管(继承来的 / 只写在行内):跟着写进那条规则
|
|
9805
|
+
if (!r.href || !r.cls || r.maybe) return null
|
|
9806
|
+
if (r0 && (r0.href !== r.href || r0.sel !== r.sel || r0.n !== r.n)) return null
|
|
9807
|
+
r0 = r0 || r
|
|
9808
|
+
}
|
|
9809
|
+
if (!r0) return null
|
|
9810
|
+
try { if (!/\.css$/i.test(new URL(r0.href).pathname)) return null } catch { return null }
|
|
9811
|
+
return r0
|
|
9812
|
+
}
|
|
9813
|
+
/**
|
|
9814
|
+
* 默认:这条规则只管和选中的同一种元素、而且各屏(收起来的也算)带这个 class 的也都是同一种(服务端核对过,见 sharecheck)才勾上;
|
|
9815
|
+
* 「.btn」这种好几种按钮共用的、还没核对完的,默认只改这一个
|
|
9816
|
+
*/
|
|
9817
|
+
const shareOn = (sty) => {
|
|
9818
|
+
if (sty && typeof sty.shared === 'boolean') return sty.shared
|
|
9819
|
+
const r = shareRule(sty)
|
|
9820
|
+
return !!(r && r.uni && sty.shareSeen && sty.shareSeen[r.cls] === true)
|
|
9821
|
+
}
|
|
9822
|
+
/** 面板上怎么说这条规则:文件名、选择器 */
|
|
9823
|
+
function ruleName(r) {
|
|
9824
|
+
let file = ''
|
|
9825
|
+
try { file = decodeURIComponent(new URL(r.href).pathname.split('/').pop() || '') } catch { file = '' }
|
|
9826
|
+
return { file, sel: String(r.sel || '') }
|
|
9827
|
+
}
|
|
9828
|
+
|
|
9482
9829
|
function makeStyleEdit(x) {
|
|
9483
|
-
const { sid, stRef, fileTarget, canvas, setSel, sty, setSty, insert, say, t } = x
|
|
9830
|
+
const { sid, stRef, fileTarget, targetKey, canvas, setSel, sty, setSty, insert, say, t } = x
|
|
9484
9831
|
const onStylePick = (sc, p) => {
|
|
9485
9832
|
if (canvas) setSel(sc.key)
|
|
9486
9833
|
const pg = pageOf(sc, p.href)
|
|
9487
|
-
|
|
9834
|
+
const rules = p.rules && typeof p.rules === 'object' ? p.rules : {}
|
|
9835
|
+
setSty({ key: pg.key, url: pg.url, name: p.name, selector: p.selector, text: p.text, loc: p.loc, base: p.css || {}, vars: p.vars || {}, rules, gradient: !!p.gradient, layout: !!p.layout, live: {}, shareSeen: {} })
|
|
9836
|
+
// 各屏一起改默认勾不勾:问服务端各屏带这个 class 的是不是都同一种(问到之前不勾)
|
|
9837
|
+
if (!fileTarget) return
|
|
9838
|
+
const seen = new Map()
|
|
9839
|
+
for (const r of Object.values(rules)) if (r && r.cls && r.uni && r.sig && r.href && !seen.has(r.cls)) seen.set(r.cls, r.sig)
|
|
9840
|
+
for (const [cls, sig] of seen) {
|
|
9841
|
+
post('sharecheck', { session: sid, cls, sig }).then((d) => {
|
|
9842
|
+
setSty((c) => (c && c.key === pg.key && c.selector === p.selector ? { ...c, shareSeen: { ...c.shareSeen, [cls]: !!(d && d.same) } } : c))
|
|
9843
|
+
}, () => {})
|
|
9844
|
+
}
|
|
9488
9845
|
}
|
|
9489
9846
|
const setStyleProp = (patch) => setSty((c) => (c ? { ...c, live: { ...c.live, ...patch } } : c))
|
|
9490
9847
|
// 交给模型:先问服务端那几条规则在源码第几行(本地文件才有;问不到就只写文件名)
|
|
@@ -9506,15 +9863,35 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9506
9863
|
if (!s0 || !Object.keys(s0.live).length) return
|
|
9507
9864
|
if (!fileTarget) return askStyle()
|
|
9508
9865
|
const saved = s0.live
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9866
|
+
const tk = targetKey // 点保存时是哪套设计:两次保存(规则不行退回行内)都带上,中途换了设计服务端就不写
|
|
9867
|
+
// src:写完以后这几项由谁决定(行内 / 那条规则)、带不带 !important。面板不重新选也照这个算下一次(不然还按旧的带不带 !important)
|
|
9868
|
+
const done = (r, msg, src) => {
|
|
9869
|
+
say(msg)
|
|
9870
|
+
// 写进去的算「原样」了;写的时候又拖过的留着
|
|
9871
|
+
setSty((c) => (c && c.key === s0.key && c.selector === s0.selector
|
|
9872
|
+
? {
|
|
9873
|
+
...c, base: { ...c.base, ...saved }, live: Object.fromEntries(Object.entries(c.live).filter(([k, v]) => saved[k] !== v)),
|
|
9874
|
+
rules: Object.fromEntries(Object.entries(c.rules || {}).map(([k, v]) => [k, v && k in saved ? src(k, v) : v])),
|
|
9875
|
+
} : c))
|
|
9876
|
+
}
|
|
9877
|
+
// 现在生效的值带 !important(规则的,或上次照规则写进行内的):写行内也得带,不然白写(预览里 picker 也是这么带的)
|
|
9878
|
+
const imp = Object.keys(saved).filter((k) => s0.rules && s0.rules[k] && s0.rules[k].imp)
|
|
9879
|
+
const inline = () => post('style', { session: sid, target: tk, key: s0.key, loc: s0.loc, css: saved, name: s0.name, ...(imp.length ? { imp } : {}) }).then((r) => {
|
|
9880
|
+
if (r && r.ok) done(r, t('styleSaved', { file: r.file }), (k, v) => ({ ...v, inline: true, imp: imp.includes(k) }))
|
|
9881
|
+
else if (r && r.reason === 'busy') say(t('styleBusyTip'))
|
|
9882
|
+
else if (r && r.reason === 'moved') say(t('styleMoved'))
|
|
9516
9883
|
else { say(t('styleMiss')); askStyle() }
|
|
9517
9884
|
}, () => askStyle())
|
|
9885
|
+
// 各屏一起改:写进那条共用的规则;规则对不上(文件刚被改过、外框的样式表)就退回只改这一处
|
|
9886
|
+
const rule = shareOn(s0) ? shareRule(s0) : null
|
|
9887
|
+
if (!rule) return inline()
|
|
9888
|
+
const at = ruleName(rule)
|
|
9889
|
+
post('style', { session: sid, target: tk, key: s0.key, loc: s0.loc, css: saved, name: s0.name, rule: { href: rule.href, sel: rule.sel, n: rule.n, cls: rule.cls } }).then((r) => {
|
|
9890
|
+
if (r && r.ok) done(r, r.others ? t('styleSavedOthers', { file: r.file || at.file, sel: at.sel, n: r.others }) : t('styleSavedRule', { file: r.file || at.file, sel: at.sel }), (k, v) => ({ ...v, sel: rule.sel, href: rule.href, n: rule.n, cls: rule.cls, inline: false, imp: Array.isArray(r.imp) && r.imp.includes(k) }))
|
|
9891
|
+
else if (r && r.reason === 'busy') say(t('styleBusyTip'))
|
|
9892
|
+
else if (r && r.reason === 'moved') say(t('styleMoved'))
|
|
9893
|
+
else inline()
|
|
9894
|
+
}, () => inline())
|
|
9518
9895
|
}
|
|
9519
9896
|
return { onStylePick, setStyleProp, askStyle, saveStyle }
|
|
9520
9897
|
}
|
|
@@ -9651,6 +10028,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9651
10028
|
const [implAway, setImplAway] = useState('') // 真页面换到了别的路由(点了站内链接):那条路由
|
|
9652
10029
|
const [dark, setDark] = useState(false)
|
|
9653
10030
|
const [phone, setPhone] = useState(false) // 手机上看的面板
|
|
10031
|
+
const [pubP, setPubP] = useState(false) // 公网链接的面板
|
|
9654
10032
|
const [multi, setMulti] = useState(false) // 多尺寸并排
|
|
9655
10033
|
const ckGen = useRef(0) // 每量一次、每关一次面板 +1:量完发现不是最新的一次就不算数
|
|
9656
10034
|
const ckOpen = useRef(false) // 面板开着(或正在量):过期的一次结果回来时别清掉新一轮的标记
|
|
@@ -10153,13 +10531,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10153
10531
|
setTextEdit(false)
|
|
10154
10532
|
setPanel(false)
|
|
10155
10533
|
setHist(false)
|
|
10156
|
-
setPhone(false)
|
|
10534
|
+
setPhone(false); setPubP(false)
|
|
10157
10535
|
closeCheck()
|
|
10158
10536
|
setStyleEdit(true)
|
|
10159
10537
|
}
|
|
10160
10538
|
useEffect(() => { if (!styleEdit) setSty(null) }, [styleEdit])
|
|
10161
10539
|
// 调样式:选中、预览、交给模型、写回(makeStyleEdit)
|
|
10162
|
-
const { onStylePick, setStyleProp, askStyle, saveStyle } = makeStyleEdit({ sid, stRef, fileTarget, canvas, setSel, sty, setSty, insert, say, t })
|
|
10540
|
+
const { onStylePick, setStyleProp, askStyle, saveStyle } = makeStyleEdit({ sid, stRef, fileTarget, targetKey, canvas, setSel, sty, setSty, insert, say, t })
|
|
10163
10541
|
useEffect(() => {
|
|
10164
10542
|
if (!styleEdit) return undefined
|
|
10165
10543
|
const onKey = (e) => { if (e.key === 'Escape' && !overlayUp()) setStyleEdit(false) }
|
|
@@ -10348,10 +10726,53 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10348
10726
|
}
|
|
10349
10727
|
// ── 导出图片(makeExporter)──
|
|
10350
10728
|
// 在和做出来的比:导出的「这一屏」是比的那屏,画布没挂着(别的屏在背后挂)
|
|
10351
|
-
|
|
10729
|
+
// 屏多过上限(#29):右侧栏只显示最新的 60 屏,导出 PDF / PPT / 整套 HTML 要连收起来的一起(按顺序排在前面)
|
|
10730
|
+
const hidSig = fileTarget && !ver && st && st.hidden ? `${targetKey}|${st.hidden}|${screens.map((x) => x.key).join(',')}` : ''
|
|
10731
|
+
const [hid, setHid] = useState({ sig: '', list: [] })
|
|
10732
|
+
// force:导出 / 开公网链接前用,不认缓存(收起来的屏改了名、刚加了屏,hidSig 看不出来)
|
|
10733
|
+
// 没收起来的设计导出前也问一下(force):刚加了第 61 屏,右侧栏还没轮询到
|
|
10734
|
+
const loadHidden = async (force) => {
|
|
10735
|
+
if (!hidSig && !(force && fileTarget && !ver)) return { list: [] }
|
|
10736
|
+
if (!force && hid.sig === hidSig) return hid
|
|
10737
|
+
const r = await post('hidden', { session: sid })
|
|
10738
|
+
const ok = r && r.target === targetKey
|
|
10739
|
+
const got = { sig: hidSig, list: ok ? (r.list || []).map((x) => ({ key: x.key, url: `${origin}/${encodeURIComponent(x.key)}`, label: x.title || x.key.replace(/\.html?$/i, '') })) : [], cut: ok ? Number(r.cut) || 0 : 0 }
|
|
10740
|
+
if (hidSig) setHid(got)
|
|
10741
|
+
return got
|
|
10742
|
+
}
|
|
10743
|
+
// 目录里的文件改了(改名、加屏):歇 2 秒再问一遍(生成的时候文件一直在变,别每次都问);第一次马上问
|
|
10744
|
+
const hidRev = hidSig ? `${hidSig}|${st ? st.rev : 0}` : ''
|
|
10745
|
+
useEffect(() => {
|
|
10746
|
+
if (!hidRev) return
|
|
10747
|
+
const tm = setTimeout(() => { loadHidden(true).catch(() => {}) }, hid.sig === hidSig ? 2000 : 0)
|
|
10748
|
+
return () => clearTimeout(tm)
|
|
10749
|
+
}, [hidRev])
|
|
10750
|
+
const every = hidSig && hid.sig === hidSig ? everyOf(shown, hid.list) : shown
|
|
10751
|
+
const { withFrames, measureAll, exportShots, exportHtml, htmlBody, loadEvery } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, every, loadHidden, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, tops, tweak, webFit,
|
|
10352
10752
|
onWarn: () => { if (pane !== 'export') openPane('export') } })
|
|
10353
10753
|
const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
|
|
10354
10754
|
if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
|
|
10755
|
+
// 公网链接(#27)开着:右侧栏换了屏、画幅、深浅色、调节值,对方下次打开就按新的(看旧版本时不动)
|
|
10756
|
+
const pubOn = !!(st && st.pub && st.pub.on)
|
|
10757
|
+
const pubKey = pubOn && !ver ? JSON.stringify(htmlBody()) : ''
|
|
10758
|
+
const lastPub = useRef('')
|
|
10759
|
+
useEffect(() => {
|
|
10760
|
+
if (!pubKey) { lastPub.current = ''; return }
|
|
10761
|
+
if (lastPub.current === pubKey) return
|
|
10762
|
+
lastPub.current = pubKey
|
|
10763
|
+
// 刚开的那次也发:参数一样插件那边什么都不做,不一样(开的时候右侧栏正好在变)就补上
|
|
10764
|
+
post('pubshare', { session: sid, update: true, ...JSON.parse(pubKey) }).catch(() => {})
|
|
10765
|
+
}, [pubKey])
|
|
10766
|
+
// 面板关着的时候链接自己关了(到点、断了、换了设计):说一声
|
|
10767
|
+
const pubEnded = st && st.pub && !st.pub.on ? st.pub.ended || '' : ''
|
|
10768
|
+
const pubKnown = !!(st && st.pub) // 设计库 / 拖 ZIP 换设计的回包里没有 pub:当不知道,等完整状态回来再判断
|
|
10769
|
+
const pubWas = useRef(false)
|
|
10770
|
+
useEffect(() => {
|
|
10771
|
+
if (!pubKnown) return
|
|
10772
|
+
if (pubOn) { pubWas.current = true; return }
|
|
10773
|
+
if (pubWas.current && pubEnded && !pubP) say(t('pubOff', { why: t(pubEnded === 'expired' ? 'pubWhyExpired' : pubEnded === 'dropped' ? 'pubWhyDropped' : 'pubWhyMoved') }))
|
|
10774
|
+
pubWas.current = false
|
|
10775
|
+
}, [pubOn, pubEnded, pubKnown])
|
|
10355
10776
|
const doExport = async (mode, key, opts) => {
|
|
10356
10777
|
setExMenu(false)
|
|
10357
10778
|
if (mode === 'opts') { if (pane !== 'export') openPane('export'); return }
|
|
@@ -10444,7 +10865,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10444
10865
|
// ── 设计体检:画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里 ──
|
|
10445
10866
|
// 设计体检:量、开面板、定位、交给模型(makeCheck)
|
|
10446
10867
|
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,
|
|
10447
|
-
onOpen: () => { setPanel(false); setHist(false); setPhone(false); setAn(false) } })
|
|
10868
|
+
onOpen: () => { setPanel(false); setHist(false); setPhone(false); setPubP(false); setAn(false) } })
|
|
10448
10869
|
// 打开一套设计、模型又干完一轮(turns 变了):面板开着就再查一次(改没改好一眼看到);关着就悄悄量一下,问题数标在按钮上。
|
|
10449
10870
|
// 模型干着活时不量;等一会儿再量:刚写完的屏还在刷新、播生成动画
|
|
10450
10871
|
const autoCk = useRef(null)
|
|
@@ -10490,7 +10911,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10490
10911
|
useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
|
|
10491
10912
|
const toggleAn = () => {
|
|
10492
10913
|
if (an) { setAn(false); setAnSel(''); return }
|
|
10493
|
-
setPanel(false); setHist(false); setPhone(false); setPane(''); closeCheck(); setStyleEdit(false); setMark(false)
|
|
10914
|
+
setPanel(false); setHist(false); setPhone(false); setPubP(false); setPane(''); closeCheck(); setStyleEdit(false); setMark(false)
|
|
10494
10915
|
setAn(true)
|
|
10495
10916
|
}
|
|
10496
10917
|
const focusAn = (a) => {
|
|
@@ -10531,6 +10952,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10531
10952
|
setPanel(false)
|
|
10532
10953
|
setHist(false)
|
|
10533
10954
|
setPhone(false)
|
|
10955
|
+
setPubP(false)
|
|
10534
10956
|
closeCheck()
|
|
10535
10957
|
setPane('')
|
|
10536
10958
|
// 之前点选 / 调样式留下的「已选」框别夹在标注里
|
|
@@ -10558,14 +10980,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10558
10980
|
useEffect(() => { if (checkOff) { setAn(false); setAnSel('') } }, [checkOff])
|
|
10559
10981
|
|
|
10560
10982
|
const toggleDemo = () => (demo ? setDemo(null) : startDemo())
|
|
10561
|
-
const openLook = (tab) => { if (tab) setLookTab(tab); setPanel(true); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10562
|
-
const toggleHist = () => { setHist(!hist); setPanel(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10983
|
+
const openLook = (tab) => { if (tab) setLookTab(tab); setPanel(true); setHist(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10984
|
+
const toggleHist = () => { setHist(!hist); setPanel(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10563
10985
|
// 右边同一时间只开一个面板:别的开了,这几个关掉;开这几个时别的关掉
|
|
10564
|
-
const oldOpen = !!(panel || hist || phone || ck || styleEdit)
|
|
10986
|
+
const oldOpen = !!(panel || hist || phone || pubP || ck || styleEdit)
|
|
10565
10987
|
useEffect(() => { if (oldOpen) setPane('') }, [oldOpen])
|
|
10566
10988
|
const openPane = (p) => {
|
|
10567
10989
|
const next = pane === p ? '' : p
|
|
10568
|
-
if (next) { setPanel(false); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10990
|
+
if (next) { setPanel(false); setHist(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10569
10991
|
setPane(next)
|
|
10570
10992
|
}
|
|
10571
10993
|
const setTweak = (k, v) => setTw((c) => {
|
|
@@ -10607,7 +11029,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10607
11029
|
}), 'insertedSend')
|
|
10608
11030
|
setPane('')
|
|
10609
11031
|
}
|
|
10610
|
-
const togglePhone = () => { setPhone(!phone); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
11032
|
+
const togglePhone = () => { setPhone(!phone); setPubP(false); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
11033
|
+
const togglePub = () => { setPubP(!pubP); setPhone(false); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
|
|
10611
11034
|
const reload = () => setReloadSeq((x) => x + 1)
|
|
10612
11035
|
|
|
10613
11036
|
// 浮在画布上的几块,各管一件事,按钮都带字:左上 设计库 | 屏名 ▾(换屏、多尺寸、类型都在这个菜单里);
|
|
@@ -10670,7 +11093,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10670
11093
|
anOn ? h('button', { className: 'ddp-btn lab' + (anUp ? ' sel' : ''), ...tipA(t('an'), anCount && !anUp ? t('dAnN', { n: anCount }) : t('dAn')), disabled: checkOff, onClick: toggleAn },
|
|
10671
11094
|
h(I.note), h('span', { className: 'lb' }, t('an')), anCount && !anUp && !checkOff ? h('span', { className: 'bdg' }, anCount > 99 ? '99+' : String(anCount)) : null) : null,
|
|
10672
11095
|
h('span', { className: 'ddp-sep' }),
|
|
10673
|
-
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: [
|
|
11096
|
+
h(DropMenu, { t, tip: [t('deliver'), t('dExport')], btnCls: 'pri', icon: I.download, label: t('deliver'), caret: true, has: pubOn && !pubP, open: exMenu, setOpen: setExMenu, disabled: !url, items: [
|
|
10674
11097
|
'hd:' + t('deliverCode'),
|
|
10675
11098
|
['', I.code, t('handoff'), pane === 'handoff', !!ver, () => openPane('handoff')],
|
|
10676
11099
|
['', I.overlay, t('implCmp'), !!implSc, !!ver || !exSc || implFar, () => (implSc ? implClose() : implOpen(exSc.key))],
|
|
@@ -10680,6 +11103,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10680
11103
|
fileTarget ? 'hd:' + t('deliverShare') : null, // 只有本地的设计才能打包、分享
|
|
10681
11104
|
fileTarget ? ['', I.box, t('exZip'), false, false, () => doExport('zip')] : null,
|
|
10682
11105
|
fileTarget ? ['', I.share, t('exShare'), false, false, () => doExport('share')] : null,
|
|
11106
|
+
fileTarget ? ['', I.web, t('exPub'), pubP, !!ver, togglePub, pubOn ? t('phoneOnShort') : ''] : null, // 公网链接(实验):只有本地文件的设计(放的是整套 HTML 演示)
|
|
10683
11107
|
], foot: t('exWhere') }),
|
|
10684
11108
|
h(DropMenu, { t, cls: 'ddp-more', tip: [t('more'), phoneOn && !phone ? t('phoneOnTip') + ' · ' + t('dMore') : t('dMore')], icon: I.more, has: phoneOn && !phone, open: more, setOpen: setMore, items: [
|
|
10685
11109
|
dockTight ? ['', I.play, t('demoShort'), !!demo, !url || !!ver, () => { if (implSc) implClose(); toggleDemo() }] : null, // 侧栏太窄,底部工具坞放不下「试用」:挪到这里
|
|
@@ -10947,7 +11371,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
10947
11371
|
return h(ZipIssues, { t, issues: zipIssues, onClose: () => { setPane(''); setZipIssues(null) } })
|
|
10948
11372
|
}
|
|
10949
11373
|
if (pane === 'export') {
|
|
10950
|
-
return h(ExportPanel, { t, kind, size, opts: xo, setOpts: setXo, screens:
|
|
11374
|
+
return h(ExportPanel, { t, kind, size, opts: xo, setOpts: setXo, screens: every.map(ik).join('|'), rev: `${st ? st.rev : 0}|${reloadSeq}|${loadTick}`, measure: async (tok) => { await loadEvery(); return tok && tok.off ? [] : withFrames((map) => (tok && tok.off ? [] : measureAll(map, tok))) }, onResize: (s) => change({ size: s }), onExport: (format) => doExport(format, undefined, xo), onClose: () => setPane('') })
|
|
10951
11375
|
}
|
|
10952
11376
|
if (pane === 'handoff') {
|
|
10953
11377
|
return h(HandoffPanel, { t, sid, root: fileTarget ? st.target.root : '', fileTarget, count: screens.length, cur: implSc ? implSc.key : (curScreen && curScreen.key) || focus, onGo: doHandoff, onSay: say, onClose: () => setPane('') })
|
|
@@ -11200,7 +11624,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
11200
11624
|
sel: sel || focus,
|
|
11201
11625
|
labelOf: shortOf,
|
|
11202
11626
|
reveal,
|
|
11203
|
-
inset: anUp || ck || styleEdit || panel || pane || hist || phone ? 296 : 0, // 右边的面板 276 宽,离边 10
|
|
11627
|
+
inset: anUp || ck || styleEdit || panel || pane || hist || phone || pubP ? 296 : 0, // 右边的面板 276 宽,离边 10
|
|
11204
11628
|
render: (sc, z) => renderScreen(sc, z, false),
|
|
11205
11629
|
sleep: sleepScreen,
|
|
11206
11630
|
flows,
|
|
@@ -11210,7 +11634,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
11210
11634
|
})
|
|
11211
11635
|
} else {
|
|
11212
11636
|
// 右边开着面板(体检、调样式、设计规范、换风格):手机这类有外框的让到面板左边(侧栏够宽时),别被挡住
|
|
11213
|
-
const sideOn = !!(anUp || ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240
|
|
11637
|
+
const sideOn = !!(anUp || ck || styleEdit || panel || pane || hist || phone || pubP) && box.w - 296 >= 240
|
|
11214
11638
|
// 网页铺满时右边开着面板(业务标注、体检、调样式…,#22):按现在的大小定住、整体缩到面板左边,不重排,右边的内容也不被挡
|
|
11215
11639
|
// 高度按铺满时真有的那么高:上面挂着横幅(看旧版本)时少 46,和下面 .ddp-body 的 vb 一样算
|
|
11216
11640
|
const sideLock = fill && sideOn && !mark ? { w: box.w, h: ah - (ver || demo || hintTop ? 46 : 0) } : null
|
|
@@ -11271,6 +11695,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
11271
11695
|
onReset: () => setSty((c) => (c ? { ...c, live: {} } : c)),
|
|
11272
11696
|
onAsk: askStyle,
|
|
11273
11697
|
onSave: saveStyle,
|
|
11698
|
+
onShare: (on) => setSty((c) => (c ? { ...c, shared: on } : c)),
|
|
11274
11699
|
onClose: () => setStyleEdit(false),
|
|
11275
11700
|
}) : null,
|
|
11276
11701
|
panel ? h(LookPanel, {
|
|
@@ -11316,6 +11741,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
11316
11741
|
onStop: () => { post('phone', { session: sid, on: false }).catch(() => {}); setPhone(false); if (poll && poll.state) poll.set({ ...poll.state, phone: { on: false, seen: 0 } }) },
|
|
11317
11742
|
onClose: () => setPhone(false),
|
|
11318
11743
|
}) : null,
|
|
11744
|
+
pubP ? h(PubPanel, {
|
|
11745
|
+
t,
|
|
11746
|
+
sid,
|
|
11747
|
+
body: htmlBody,
|
|
11748
|
+
fresh: async () => { await loadEvery(); return htmlBody() },
|
|
11749
|
+
brief: st && st.pub,
|
|
11750
|
+
onCopy: (link) => { navigator.clipboard.writeText(link).then(() => say(t('pubCopied'))).catch(() => say(link)) },
|
|
11751
|
+
onClose: () => setPubP(false),
|
|
11752
|
+
}) : null,
|
|
11319
11753
|
hist ? h(HistoryPanel, { t, versions, ver, onPick: (v) => { setVer(v); if (!v) setCmp(false) }, onClose: () => setHist(false) }) : null,
|
|
11320
11754
|
mark && !markOff ? h(MarkLayer, { t, sending: markBusy, frames: markFrames, onCancel: () => { markRun.current++; setMark(false) }, onSend: sendMark, onCopy: canCopyImage() ? copyMark : null }) : null,
|
|
11321
11755
|
demo ? h('div', { className: 'ddp-banner' + side },
|
|
@@ -11480,7 +11914,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
11480
11914
|
// 注意:这里是客户端**服务名**(短的),不是包名
|
|
11481
11915
|
exports.inject = INJECT
|
|
11482
11916
|
// 测试用
|
|
11483
|
-
exports._test = { 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, styleLook, padInsert, pageOf, pxOf, styleChanges, formatStyleAsk, 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 }
|
|
11917
|
+
exports._test = { 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, 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 }
|
|
11484
11918
|
return module.exports
|
|
11485
11919
|
},
|
|
11486
11920
|
})
|