dsh-design-studio 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -32,7 +32,7 @@ window.__ModuleLoader__.load({
32
32
  return module.exports
33
33
  }
34
34
  const h = react.createElement
35
- const { useState, useEffect, useRef, useCallback } = react
35
+ const { useState, useEffect, useRef, useCallback, useMemo } = react
36
36
 
37
37
  const NS = 'dsh-design-studio'
38
38
  const TAB_ID = 'dsh-design-studio'
@@ -195,6 +195,7 @@ window.__ModuleLoader__.load({
195
195
  xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
196
196
  xoLongH: '{n} 个页面比指定高度长,下面会被裁',
197
197
  xoDead: '{n} 个链接点了可能没反应',
198
+ xoAi: '用了 {n} 张 AI 示意图,上线前记得换成真实照片',
198
199
  xoFail: '{n} 屏没量到,结果可能不全',
199
200
  xoAgain: '重新检查',
200
201
  xoGone: '设计换了,这次导出取消了',
@@ -523,6 +524,9 @@ window.__ModuleLoader__.load({
523
524
  screensHd: '屏幕',
524
525
  screensAll: '全部 {n} 屏',
525
526
  screensN: '{name} · {n} 屏',
527
+ screensHidden: '还有 {n} 屏没显示(最多显示 {max} 屏,最新的优先)',
528
+ canvasAsleep: '挪近就加载',
529
+ checkPartial: '屏太多,这次只体检了画布上加载着的 {n} 屏',
526
530
  openOther: '打开别的页面…',
527
531
  phoneOnTip: '手机预览开着',
528
532
  lookSet: '整套',
@@ -564,6 +568,7 @@ window.__ModuleLoader__.load({
564
568
  stBrand: '正在提取品牌',
565
569
  stCode: '正在转成代码',
566
570
  stCompare: '正在逐像素对比',
571
+ stPhotos: '正在挑照片',
567
572
  stShell: '正在跑命令',
568
573
  stRead: '正在看文件',
569
574
  stWeb: '正在查资料',
@@ -997,6 +1002,7 @@ window.__ModuleLoader__.load({
997
1002
  xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
998
1003
  xoLongH: '{n} page(s) are taller than the set height and will be cut off',
999
1004
  xoDead: '{n} link(s) may do nothing when clicked',
1005
+ xoAi: 'Uses {n} AI placeholder photo(s). Replace them with real photos before launch',
1000
1006
  xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
1001
1007
  xoAgain: 'Check again',
1002
1008
  xoGone: 'The design changed, so this export was cancelled',
@@ -1324,6 +1330,9 @@ window.__ModuleLoader__.load({
1324
1330
  screensHd: 'Screens',
1325
1331
  screensAll: 'All {n}',
1326
1332
  screensN: '{name} · {n} screens',
1333
+ screensHidden: '{n} more not shown (up to {max} screens, newest first)',
1334
+ canvasAsleep: 'Move closer to load',
1335
+ checkPartial: 'Too many screens: checked only the {n} loaded on the canvas',
1327
1336
  openOther: 'Open another page…',
1328
1337
  phoneOnTip: 'Phone preview is on',
1329
1338
  lookSet: 'Overall',
@@ -1365,6 +1374,7 @@ window.__ModuleLoader__.load({
1365
1374
  stBrand: 'Extracting the brand',
1366
1375
  stCode: 'Turning it into code',
1367
1376
  stCompare: 'Comparing pixel by pixel',
1377
+ stPhotos: 'Picking photos',
1368
1378
  stShell: 'Running a command',
1369
1379
  stRead: 'Reading files',
1370
1380
  stWeb: 'Looking things up',
@@ -1768,6 +1778,8 @@ window.__ModuleLoader__.load({
1768
1778
  .ddp-menu{position:absolute;right:0;top:33px;min-width:196px;padding:5px;border-radius:11px;background:var(--dsw-alias-bg-layer-1);
1769
1779
  box-shadow:0 12px 32px rgba(0,0,0,.24),0 0 0 .5px var(--dsw-alias-border-l3);animation:ddp-in .16s ${EASE}}
1770
1780
  .ddp-menu .hd{padding:5px 9px 4px;color:var(--dsw-alias-label-tertiary);font-size:11px}
1781
+ .ddp-menu .nt{padding:5px 9px 4px;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:1.5}
1782
+ .ddp-addr em.hid{flex:none;font-style:normal;font-size:11px;color:var(--dsw-alias-label-tertiary)}
1771
1783
  .ddp-menu a{display:flex;align-items:center;gap:9px;height:30px;padding:0 9px;border-radius:7px;color:var(--dsw-alias-label-primary);text-decoration:none}
1772
1784
  .ddp-menu a:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1773
1785
  .ddp-menu a svg{width:15px;height:15px;flex:none;color:var(--dsw-alias-label-secondary)}
@@ -1824,6 +1836,7 @@ window.__ModuleLoader__.load({
1824
1836
  .ddp-world{position:absolute;left:0;top:0;transform-origin:0 0;will-change:transform}
1825
1837
  .ddp-world.anim{transition:transform .45s ${EASE}}
1826
1838
  .ddp-cell{position:absolute;transition:left .45s ${EASE},top .45s ${EASE};animation:ddp-cell .5s ${EASE}}
1839
+ .ddp-canvas.heavy .ddp-cell{transition:none;will-change:translate,scale}
1827
1840
  @keyframes ddp-cell{from{opacity:0;scale:.94}}
1828
1841
  .ddp-cell.sel>.ddp-dev{outline:calc(2px / var(--z)) solid ${ACCENT};outline-offset:calc(5px / var(--z))}
1829
1842
  .ddp-shield{position:absolute;inset:0;z-index:6;cursor:default}
@@ -4415,6 +4428,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4415
4428
  const LAB = 34 // 每屏上面标题占的高度(屏幕像素,不跟着缩放)
4416
4429
  const GAP = 18 // 两屏之间最少隔开的屏幕像素
4417
4430
  const clampZ = (z) => Math.max(ZMIN, Math.min(ZMAX, z))
4431
+ const HEAVY_N = 12 // 超过这么多屏,画布按「重」的来:拖宽度时只挪镜头、列数变了才重排,换行动画走合成层(不然所有 iframe 每一帧都按新比例重绘,整个窗口跟着闪)
4432
+ const LIVE_MAX = 24 // 同时跑几个 iframe。超过这么多屏,画布只挂镜头附近的(选中的那屏总在),导出时分批挂
4433
+ /** 该挂着的几屏:离镜头中心最近的 max 屏,选中的那屏排最前。cx、cy 是镜头中心在画布上的坐标 */
4434
+ function nearestLive(ids, pos, dw, dh, cx, cy, selId, max, prev) {
4435
+ // 挂着的优先留着:镜头稍微挪一点,边上那几屏别来回撤了又载
4436
+ const rows = ids.map((id, i) => ({ id, d: id === selId ? -1 : ((pos[i].x + dw / 2 - cx) ** 2 + (pos[i].y + dh / 2 - cy) ** 2) * (prev && prev.has(id) ? 0.5 : 1) }))
4437
+ rows.sort((a, b) => a.d - b.d)
4438
+ return new Set(rows.slice(0, max).map((x) => x.id))
4439
+ }
4418
4440
 
4419
4441
  /**
4420
4442
  * n 屏排成网格:试每种列数,挑缩进舞台后最大的那种。
@@ -4793,7 +4815,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4793
4815
  // 模型在做什么:按它调的工具说人话(写文件另算,见 busyPhase)
4794
4816
  const TOOL_PHASE = [
4795
4817
  [/^check_design$/, 'stCheck'], [/^look_design$/, 'stLook'], [/^preview_page$/, 'stPreview'], [/^extract_design_system$/, 'stBrand'],
4796
- [/^handoff_design$/, 'stCode'], [/^compare_design$/, 'stCompare'], [/^ask_user_question$/, 'asking'],
4818
+ [/^handoff_design$/, 'stCode'], [/^compare_design$/, 'stCompare'], [/^find_photos$/, 'stPhotos'], [/^ask_user_question$/, 'asking'],
4797
4819
  [/^(bash|shell|sh|zsh|powershell|pwsh|exec|run_command|terminal)$/i, 'stShell'],
4798
4820
  [/^skill$/i, 'stSkill'],
4799
4821
  [/web|fetch|browse|http/i, 'stWeb'],
@@ -6632,7 +6654,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
6632
6654
  }
6633
6655
 
6634
6656
  // 左上屏名 ▾:换屏(画布 / 某一屏)、多尺寸、类型、打开别的页面——「在看什么、怎么看」都在这一个菜单里
6635
- function ScreenMenu({ t, label, title, tip, src, busy, list, cur, canvas, open, setOpen, onPick, onAll, onOther, sizes, kind, onKind }) {
6657
+ function ScreenMenu({ t, label, title, tip, src, busy, list, cur, canvas, open, setOpen, onPick, onAll, onOther, sizes, kind, onKind, hidden, hiddenText }) {
6636
6658
  const ref = useRef(null)
6637
6659
  useDismiss(open, setOpen, ref)
6638
6660
  const n = list.length
@@ -6641,12 +6663,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
6641
6663
  h('button', { className: 'ddp-addr' + (open ? ' sel' : ''), ...(tip ? tipA(tip[0], tip[1]) : { title: title || t('screensT') }), 'data-src': src || undefined, 'aria-haspopup': 'menu', 'aria-expanded': open, onClick: () => setOpen(!open) },
6642
6664
  h('i', { className: 'ddp-dot' + (busy ? ' wait' : '') }),
6643
6665
  (() => { const m = /^(.+?)( · [^·]+)$/.exec(label || ''); return m ? h('span', { className: 'lb2' }, h('b', null, m[1]), h('em', null, m[2])) : h('span', null, label) })(),
6666
+ hidden ? h('em', { className: 'hid', title: hiddenText }, '+' + hidden) : null,
6644
6667
  h(I.caret)),
6645
6668
  open ? h('div', { className: 'ddp-menu l', role: 'menu' },
6646
6669
  h('div', { className: 'hd' }, n > 1 ? t('screensHd') : t('screensT')),
6647
6670
  h('button', { className: canvas && !(sizes && sizes.on) ? 'sel' : '', role: 'menuitemradio', 'aria-checked': canvas, onClick: close(onAll) }, h(I.canvas), h('span', null, t('canvasShort')), n > 1 ? h('em', null, t('screensAll', { n })) : null),
6648
6671
  h('div', { className: 'ls' }, ...list.map((x) => h('button', { key: x.key, className: !canvas && !(sizes && sizes.on) && x.key === cur ? 'sel' : '', role: 'menuitemradio', 'aria-checked': !canvas && x.key === cur, title: x.key, onClick: close(() => onPick(x.key)) },
6649
6672
  h(I.single), h('span', null, x.label)))),
6673
+ hidden ? h('div', { className: 'nt' }, hiddenText) : null,
6650
6674
  sizes ? h('div', { className: 'sp', role: 'separator' }) : null,
6651
6675
  sizes ? h('button', { className: sizes.on ? 'sel' : '', role: 'menuitemcheckbox', 'aria-checked': !!sizes.on, disabled: !!sizes.off, title: sizes.tip, onClick: close(sizes.run) }, h(I.sizes), h('span', null, t('sizesShort')), sizes.note ? h('em', null, sizes.note) : null) : null,
6652
6676
  onKind ? h('div', { className: 'hd' }, t('kind')) : null,
@@ -7210,7 +7234,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7210
7234
  */
7211
7235
  function precheckOf(list, kind, limit) {
7212
7236
  const fixed = kind === 'slides' || kind === 'poster'
7213
- const r = { over: 0, long: 0, dead: 0, fail: 0 }
7237
+ const r = { over: 0, long: 0, dead: 0, fail: 0, ai: new Set(list.flatMap((m) => (Array.isArray(m.aiPhotos) ? m.aiPhotos : []))).size }
7214
7238
  for (const m of list) {
7215
7239
  if (m.failed) { r.fail++; continue }
7216
7240
  const tall = m.pageH > (limit || m.h) + 2
@@ -7281,6 +7305,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7281
7305
  rep.over ? h('p', null, t('xoOver', { n: rep.over })) : null,
7282
7306
  rep.long ? h('p', null, t(longKey, { n: rep.long })) : null,
7283
7307
  rep.dead ? h('p', null, t('xoDead', { n: rep.dead })) : null,
7308
+ rep.ai ? h('p', null, t('xoAi', { n: rep.ai })) : null,
7284
7309
  rep.fail ? h('p', null, t('xoFail', { n: rep.fail })) : null,
7285
7310
  !cut && !rep.dead && !rep.fail ? h('p', null, t('xoClean')) : null,
7286
7311
  rep.over && canFit ? h('button', { className: 'lk', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', '×') })) : null,
@@ -7313,6 +7338,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7313
7338
  if (name) { try { localStorage.setItem('ddp-author', name) } catch { /* 不记也行 */ } }
7314
7339
  try { setRes(await post('pack', { session: sid, dir: root, license: lic, author: name, lang: t('lang') === 'en' ? 'en' : 'zh' })) } catch (e) { setRes({ error: e.message }) } finally { setBusy(false) }
7315
7340
  }
7341
+ const aiN = (res && res.aiPhotos) || 0
7316
7342
  const fixed = res && res.notes ? Object.entries(res.notes.reduce((m, n) => { m[n.code] = (m[n.code] || 0) + 1; return m }, {})).map(([k, n]) => t('pkNote_' + k, { n })).join(t('sep')) : ''
7317
7343
  return h('div', { className: 'ddp-tokens ddp-pack', onPointerDown: (e) => e.stopPropagation() },
7318
7344
  h('header', null, h(I.download), h('b', null, t('pkTitle')), h('button', { className: 'ddp-btn', title: '×', onClick: onClose }, h(I.close))),
@@ -7333,6 +7359,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7333
7359
  h('ol', null, ...res.errors.slice(0, 30).map((e, i) => h('li', { key: i }, e.msg))),
7334
7360
  res.errors.length > 30 || res.more ? h('p', null, t('pkMore', { n: res.errors.length - 30 + (res.more || 0) })) : null) : null,
7335
7361
  fixed ? h('p', { className: 'note' }, t('pkFixed', { list: fixed })) : null,
7362
+ aiN ? h('p', { className: 'note' }, t('xoAi', { n: aiN })) : null,
7336
7363
  res && res.flags && res.flags.length ? h('div', { className: 'note' }, t('pkFlags'), h('ul', null, ...res.flags.slice(0, 8).map((f, i) => h('li', { key: i }, f.msg))),
7337
7364
  res.flags.length > 8 || res.flagsMore ? h('p', null, t('pkMore', { n: res.flags.length - 8 + (res.flagsMore || 0) })) : null) : null,
7338
7365
  res && res.skipped && res.skipped.length ? h('p', { className: 'note' }, t('pkSkipped', { list: res.skipped.slice(0, 8).join(t('sep')) + (res.skipped.length > 8 ? '…' : '') })) : null),
@@ -7380,6 +7407,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7380
7407
  if (r.share.slug) q.set('slug', r.share.slug)
7381
7408
  return `${GALLERY_REPO}/issues/new?${q}`
7382
7409
  }
7410
+ const aiN = (res && res.aiPhotos) || 0
7383
7411
  const fixed = res && res.notes ? Object.entries(res.notes.reduce((m, n) => { m[n.code] = (m[n.code] || 0) + 1; return m }, {})).map(([k, n]) => t('pkNote_' + k, { n })).join(t('sep')) : ''
7384
7412
  const done = res && res.ok && res.share
7385
7413
  return h('div', { className: 'ddp-tokens ddp-pack ddp-share', onPointerDown: (e) => e.stopPropagation() },
@@ -7415,6 +7443,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7415
7443
  h('ol', null, ...res.errors.slice(0, 30).map((e, i) => h('li', { key: i }, e.msg))),
7416
7444
  res.errors.length > 30 || res.more ? h('p', null, t('pkMore', { n: res.errors.length - 30 + (res.more || 0) })) : null) : null,
7417
7445
  fixed ? h('p', { className: 'note' }, t('pkFixed', { list: fixed })) : null,
7446
+ aiN ? h('p', { className: 'note' }, t('xoAi', { n: aiN })) : null,
7418
7447
  res && res.flags && res.flags.length ? h('div', { className: 'note' }, t('pkFlags'), h('ul', null, ...res.flags.slice(0, 8).map((f, i) => h('li', { key: i }, f.msg))),
7419
7448
  res.flags.length > 8 || res.flagsMore ? h('p', null, t('pkMore', { n: res.flags.length - 8 + (res.flagsMore || 0) })) : null) : null),
7420
7449
  h('footer', { className: 'row' },
@@ -7434,6 +7463,21 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7434
7463
  issues.more ? h('p', null, t('pkMore', { n: issues.more })) : null)))
7435
7464
  }
7436
7465
 
7466
+ const GHOST_CELL = '__ghost'
7467
+ const cellsOf = (world) => [...world.children].filter((el) => el.dataset && el.dataset.cell)
7468
+ const labOf = (cell) => cell.querySelector(':scope > .ddp-lab')
7469
+ // 换行前记下画面现在的样子(正在滑的也算):每格的屏幕位置、标题的反向缩放、底纹点阵
7470
+ function snapStage(stage, world) {
7471
+ const bg = getComputedStyle(stage)
7472
+ return {
7473
+ bg: { backgroundSize: bg.backgroundSize, backgroundPosition: bg.backgroundPosition },
7474
+ cells: new Map(cellsOf(world).map((el) => {
7475
+ const lab = labOf(el)
7476
+ return [el.dataset.cell, { rect: el.getBoundingClientRect(), lab: lab ? getComputedStyle(lab).transform : '' }]
7477
+ })),
7478
+ }
7479
+ }
7480
+
7437
7481
  function Canvas(props) {
7438
7482
  const { t, screens, kind, size, ghost, picking, sel, labelOf } = props
7439
7483
  const ref = useRef(null)
@@ -7443,12 +7487,17 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7443
7487
  const [drag, setDrag] = useState(false)
7444
7488
  const [zoomMenu, setZoomMenu] = useState(false)
7445
7489
  const auto = useRef(true)
7490
+ const liveCam = useRef(null) // 拖宽度时直接写到画布上的镜头,React 的 cam 还没追上;平移、缩放要从画面上的这个算
7446
7491
  const camRef = useRef(cam)
7447
- camRef.current = cam
7492
+ camRef.current = liveCam.current || cam
7448
7493
  const lastTap = useRef({ key: '', at: 0 })
7449
7494
  const f = FRAME[kind] || FRAME.web
7450
7495
  const [dw, dh] = deviceBox(kind, size)
7451
7496
  const n = screens.length + (ghost ? 1 : 0)
7497
+ const heavy = !props.items && screens.length > HEAVY_N
7498
+ const heavyRef = useRef(heavy)
7499
+ heavyRef.current = heavy
7500
+ const worldRef = useRef(null)
7452
7501
  // 多尺寸:每块自己的类型和大小(items[i] = { kind, size })
7453
7502
  const items = props.items || null
7454
7503
  const boxes = items ? items.map((it) => deviceBox(it.kind, it.size)) : null
@@ -7461,24 +7510,177 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7461
7510
  const vw = box.w - ins
7462
7511
  const layoutKey = L ? [n, L.cols, dw, dh, box.w, box.h, rt, bh, ins, boxes ? boxes.join(';') : ''].join('|') : ''
7463
7512
  const fitAt = () => { const c = fitCam(L, vw, bh); return { ...c, y: c.y + rt } }
7513
+ // 屏多时拖宽度:新镜头直接写到画布上,不走 React,也不动 --z,这样既跟手又不让 iframe 每帧重绘。
7514
+ // 列数变了(或者松手了)才真重排:先记下每格现在在屏幕上的样子,镜头和格子一次换好,再从记下的样子滑过去,中间没有哪一帧会跳。返回有没有真重排
7515
+ const followRef = useRef(null)
7516
+ const flipFirst = useRef(null)
7517
+ const unpinRef = useRef(false)
7518
+ followRef.current = (w, h, final) => {
7519
+ const sh = Math.max(0, h - rt - (props.bottom || 0))
7520
+ const world = worldRef.current
7521
+ if (!L || !world || !(w > 0) || !(sh > 0)) { setBox({ w, h }); return false }
7522
+ const next = layoutGrid(n, dw, dh, w, sh)
7523
+ const sw = w - (props.inset && w - props.inset >= 240 ? props.inset : 0)
7524
+ if (final || next.cols !== L.cols) {
7525
+ if (w === box.w && h === box.h) {
7526
+ if (liveCam.current && !auto.current) setCam(liveCam.current)
7527
+ else if (liveCam.current) { liveCam.current = null; camRef.current = cam }
7528
+ return false
7529
+ }
7530
+ flipFirst.current = snapStage(ref.current, world)
7531
+ if (auto.current) { const c = fitCam(next, sw, sh); setCam({ ...c, y: c.y + rt }) }
7532
+ else if (liveCam.current) setCam(liveCam.current)
7533
+ setBox({ w, h })
7534
+ return true
7535
+ }
7536
+ if (auto.current) {
7537
+ const c = fitCam({ ...L, z: next.z }, sw, sh)
7538
+ liveCam.current = camRef.current = { ...c, y: c.y + rt }
7539
+ world.style.transform = `translate(${c.x}px, ${c.y + rt}px) scale(${c.z})`
7540
+ }
7541
+ return false
7542
+ }
7543
+ // 屏多的时候只挂镜头附近的,别的先放占位。镜头停下来才换,拖动时不闪、不反复重载
7544
+ const cull = !!props.sleep && !!L && screens.length > LIVE_MAX
7545
+ const [live, setLive] = useState(null)
7546
+ const liveIds = cull ? screens.map((x) => x.id || x.key) : []
7547
+ const liveSig = liveIds.join('|')
7548
+ useEffect(() => {
7549
+ if (!cull || !cam) { if (live) setLive(null); return undefined }
7550
+ const run = () => {
7551
+ const c = camRef.current
7552
+ const selIdx = screens.findIndex((x) => x.key === props.sel)
7553
+ setLive((prev) => {
7554
+ // 「适合画布」时所有屏都在画面里,光是重排就别换加载着的屏,换了会闪
7555
+ const selId = selIdx < 0 ? '' : liveIds[selIdx]
7556
+ if (prev && auto.current && prev.size === Math.min(LIVE_MAX, liveIds.length) && (!selId || prev.has(selId)) && [...prev].every((id) => liveIds.includes(id))) return prev
7557
+ const next = nearestLive(liveIds, L.pos, dw, dh, (vw / 2 - c.x) / c.z, (rt + bh / 2 - c.y) / c.z, selIdx < 0 ? '' : liveIds[selIdx], LIVE_MAX, prev)
7558
+ return prev && prev.size === next.size && [...next].every((id) => prev.has(id)) ? prev : next
7559
+ })
7560
+ }
7561
+ if (!live) { run(); return undefined }
7562
+ const timer = setTimeout(run, 160)
7563
+ return () => clearTimeout(timer)
7564
+ }, [cull, cam, layoutKey, liveSig, props.sel])
7464
7565
 
7465
7566
  useEffect(() => {
7466
7567
  const el = ref.current
7467
7568
  if (!el) return undefined
7468
- const measure = () => setBox({ w: el.clientWidth, h: el.clientHeight })
7469
- measure()
7569
+ const apply = () => setBox({ w: el.clientWidth, h: el.clientHeight })
7570
+ let timer = 0
7571
+ const pin = (v) => { if (worldRef.current) worldRef.current.style.transition = v }
7572
+ const settle = () => { if (followRef.current(el.clientWidth, el.clientHeight, true)) unpinRef.current = true; else pin('') }
7573
+ const measure = () => {
7574
+ clearTimeout(timer)
7575
+ if (!heavyRef.current) { pin(''); apply(); return }
7576
+ pin('none') // 拖动时镜头不做过渡:每帧重开过渡正是闪的来源之一
7577
+ followRef.current(el.clientWidth, el.clientHeight, false)
7578
+ timer = setTimeout(settle, 160)
7579
+ }
7580
+ apply()
7470
7581
  if (typeof ResizeObserver === 'undefined') return undefined
7471
7582
  const ro = new ResizeObserver(measure)
7472
7583
  ro.observe(el)
7473
- return () => ro.disconnect()
7584
+ return () => { clearTimeout(timer); ro.disconnect() }
7474
7585
  }, [])
7475
7586
 
7587
+ // 屏多时的换行动画:格子先到新位置,再用 translate 从旧位置滑过来,全程走合成层,不用每帧重新排版 30 个格子
7588
+ const flipFrom = useRef(null)
7589
+ const flipUntil = useRef(0)
7590
+ const SLIDE = { id: 'ddp-flip', duration: 450, easing: EASE }
7591
+ const stopFlip = (el) => { for (const old of el.getAnimations()) if (old.id === 'ddp-flip') old.cancel() }
7592
+ // first 是镜头和格子换之前的样子,这里量换完的样子,差多少就从那儿滑回来。先量完再统一开动画,别读写交错
7593
+ function playFlip(world, first) {
7594
+ flipUntil.current = performance.now() + 450
7595
+ const list = cellsOf(world)
7596
+ for (const el of [...list, ...list.map(labOf), ref.current]) if (el) stopFlip(el)
7597
+ const jobs = []
7598
+ for (const el of list) {
7599
+ const f = first.cells.get(el.dataset.cell)
7600
+ if (!f) continue
7601
+ const l = el.getBoundingClientRect()
7602
+ if (!l.width || !el.offsetWidth) continue
7603
+ const k = l.width / el.offsetWidth
7604
+ const dx = (f.rect.left + f.rect.width / 2 - l.left - l.width / 2) / k
7605
+ const dy = (f.rect.top + f.rect.height / 2 - l.top - l.height / 2) / k
7606
+ const s = f.rect.width / l.width
7607
+ if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5 && Math.abs(s - 1) < 0.001) continue
7608
+ jobs.push([el, { translate: `${dx}px ${dy}px`, scale: String(s) }, f.lab])
7609
+ }
7610
+ for (const [el, from, labFrom] of jobs) {
7611
+ el.animate([from, { translate: '0 0', scale: '1' }], SLIDE)
7612
+ const lab = labOf(el)
7613
+ if (lab && labFrom && labFrom !== 'none') lab.animate([{ transform: labFrom }, { transform: lab.style.transform }], SLIDE)
7614
+ }
7615
+ ref.current.animate([first.bg, { backgroundSize: ref.current.style.backgroundSize, backgroundPosition: ref.current.style.backgroundPosition }], SLIDE)
7616
+ // 选中屏的连线画在新位置,等格子落定再淡出来,别在半路错位
7617
+ const lines = world.querySelector(':scope > .ddp-flows')
7618
+ if (lines) lines.animate([{ opacity: 0 }, { opacity: 0, offset: 0.7 }, { opacity: 1 }], { duration: 450 })
7619
+ }
7620
+ react.useLayoutEffect(() => {
7621
+ if (!L) return
7622
+ const now = new Map(screens.map((sc, i) => [String(sc.id || sc.key), L.pos[i]]))
7623
+ if (ghost) now.set(GHOST_CELL, L.pos[n - 1])
7624
+ const was = flipFrom.current
7625
+ flipFrom.current = now
7626
+ const first = flipFirst.current
7627
+ flipFirst.current = null
7628
+ const world = worldRef.current
7629
+ if (world && heavy && !reduced()) {
7630
+ if (first) playFlip(world, first)
7631
+ else if (was) {
7632
+ // 别的原因重排(加屏、删屏):镜头有自己的过渡,格子只补世界坐标里的差;上一段没滑完就从当前看到的样子接着滑
7633
+ for (const el of cellsOf(world)) {
7634
+ const a = was.get(el.dataset.cell)
7635
+ const b = now.get(el.dataset.cell)
7636
+ if (!a || !b || (a.x === b.x && a.y === b.y)) continue
7637
+ const cs = getComputedStyle(el)
7638
+ const [ox, oy] = cs.translate && cs.translate !== 'none' ? cs.translate.split(' ').map(parseFloat) : [0, 0]
7639
+ const sc0 = cs.scale && cs.scale !== 'none' ? cs.scale.split(' ')[0] : '1'
7640
+ stopFlip(el)
7641
+ el.animate([{ translate: `${a.x - b.x + (ox || 0)}px ${a.y - b.y + (oy || 0)}px`, scale: sc0 }, { translate: '0 0', scale: '1' }], SLIDE)
7642
+ }
7643
+ }
7644
+ }
7645
+ if (unpinRef.current) { unpinRef.current = false; if (world) world.style.transition = '' }
7646
+ }, [layoutKey])
7647
+
7648
+ // 镜头一提交,画面就以它为准:拖宽度时直接写过 DOM,React 看值没变可能不重写,这里显式写一次
7649
+ react.useLayoutEffect(() => {
7650
+ liveCam.current = null
7651
+ camRef.current = cam
7652
+ const world = worldRef.current
7653
+ if (!world || !cam) return
7654
+ world.style.transform = `translate(${cam.x}px, ${cam.y}px) scale(${cam.z})`
7655
+ // 标题还在往旧倍率滑的时候镜头又变了:从当前看到的样子改滑向新倍率,别滑完再跳一下
7656
+ if (heavy && performance.now() < flipUntil.current) {
7657
+ for (const el of cellsOf(world)) {
7658
+ const lab = labOf(el)
7659
+ const run = lab && lab.getAnimations().find((x) => x.id === 'ddp-flip')
7660
+ if (!run || run.effect.getKeyframes().at(-1).transform === lab.style.transform) continue
7661
+ const from = getComputedStyle(lab).transform
7662
+ stopFlip(lab)
7663
+ lab.animate([{ transform: from }, { transform: lab.style.transform }], SLIDE)
7664
+ flipUntil.current = performance.now() + 450
7665
+ }
7666
+ }
7667
+ const first = flipFirst.current
7668
+ if (!first) return
7669
+ flipFirst.current = null
7670
+ if (heavy && !reduced()) playFlip(world, first)
7671
+ }, [cam])
7672
+
7476
7673
  // 屏数 / 类型 / 舞台大小变了:用户没自己动过镜头就重新摆好
7477
7674
  useEffect(() => {
7478
7675
  if (!L) return
7479
7676
  if (auto.current || !camRef.current) {
7480
- setAnim(!!camRef.current)
7481
- setCam(fitAt())
7677
+ const world = worldRef.current
7678
+ const to = fitAt()
7679
+ const c = camRef.current
7680
+ // 拖着宽度的时候屏数变了:镜头这时不走过渡,和换行一样先记下画面再滑过去
7681
+ if (heavy && world && c && world.style.transition === 'none' && (c.x !== to.x || c.y !== to.y || c.z !== to.z)) flipFirst.current = snapStage(ref.current, world)
7682
+ setAnim(!!c)
7683
+ setCam(to)
7482
7684
  } else if (ins && props.sel) showKey(props.sel) // 自己挪过镜头:只把选中的那屏挪出来,别被面板挡着
7483
7685
  }, [layoutKey])
7484
7686
 
@@ -7582,30 +7784,34 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7582
7784
  while (grid < 12) grid *= 2
7583
7785
  while (grid > 48) grid /= 2
7584
7786
  const lab = (key, body, w = dw) => h('div', { className: 'ddp-lab', 'data-key': key, style: { width: w * z, transform: `scale(${1 / z})` } }, ...body)
7585
- const cells = []
7586
- if (cam && L) {
7787
+ // 只是挪镜头(props、缩放都没变):别重建每一屏,省得所有 iframe 跟着过一遍 React
7788
+ const cells = useMemo(() => {
7789
+ const out = []
7790
+ if (!cam || !L) return out
7587
7791
  screens.forEach((sc, i) => {
7588
7792
  const on = sel === sc.key
7589
7793
  const [cw, ch] = boxes ? boxes[i] : [dw, dh]
7590
7794
  const fr = items ? FRAME[items[i].kind] || FRAME.web : f
7591
- cells.push(h('div', {
7795
+ out.push(h('div', {
7592
7796
  key: sc.id || sc.key,
7797
+ 'data-cell': String(sc.id || sc.key),
7593
7798
  className: 'ddp-cell' + (on ? ' sel' : ''),
7594
7799
  style: { left: L.pos[i].x, top: L.pos[i].y, width: cw, height: ch },
7595
7800
  },
7596
7801
  lab(sc.key, [props.tag ? props.tag(sc) : null, h('span', { key: 's' }, labelOf(sc)), !picking && props.badge ? props.badge(sc) : null, !picking && props.actions ? h('span', { key: 'a', className: 'ddp-act' }, ...props.actions(sc)) : null], cw),
7597
- props.render(sc, z, i),
7802
+ cull && !(live && live.has(sc.id || sc.key)) ? props.sleep(sc, z) : props.render(sc, z, i),
7598
7803
  picking ? null : h('div', { className: 'ddp-shield', 'data-key': sc.key, title: items ? '' : t('openScreen'), style: { borderRadius: fr.r } })))
7599
7804
  })
7600
7805
  if (ghost) {
7601
7806
  const p = L.pos[n - 1]
7602
- cells.push(h('div', { key: '__ghost', className: 'ddp-cell ghost', style: { left: p.x, top: p.y, width: dw, height: dh } },
7807
+ out.push(h('div', { key: '__ghost', 'data-cell': GHOST_CELL, className: 'ddp-cell ghost', style: { left: p.x, top: p.y, width: dw, height: dh } },
7603
7808
  lab('', [h('i', { key: 'i', className: 'sp' }), h('span', { key: 's' }, t('generating'))]),
7604
7809
  h(Device, { kind, w: size[0], h: size[1], label: '' },
7605
7810
  h(GhostDraw, { key: 'gd', t, kind, pulse: props.pulse || 0 }),
7606
7811
  props.draft ? h(DraftFrame, { key: 'df', url: props.draft, z, lang: t('lang'), onEnd: props.onDraftEnd }) : null)))
7607
7812
  }
7608
- }
7813
+ return out
7814
+ }, [props, z, live, layoutKey, !!cam])
7609
7815
  let flowSvg = null
7610
7816
  if (cam && L && props.flows && props.flows.length && !picking) {
7611
7817
  // 只画选中那屏通向哪(不画哪些通向它),底栏、返回这种每屏都有的导航只描框
@@ -7616,12 +7822,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7616
7822
  }
7617
7823
  }
7618
7824
  return h('div', {
7619
- className: 'ddp-canvas' + (drag ? ' drag' : ''),
7825
+ className: 'ddp-canvas' + (drag ? ' drag' : '') + (heavy ? ' heavy' : ''),
7620
7826
  ref,
7621
7827
  onPointerDown,
7622
7828
  style: cam ? { backgroundSize: `${grid}px ${grid}px`, backgroundPosition: `${cam.x}px ${cam.y}px` } : undefined,
7623
7829
  },
7624
7830
  cam && L ? h('div', {
7831
+ ref: worldRef,
7625
7832
  className: 'ddp-world' + (anim ? ' anim' : ''),
7626
7833
  style: { transform: `translate(${cam.x}px, ${cam.y}px) scale(${z})`, '--z': z },
7627
7834
  }, ...cells, flowSvg) : null,
@@ -7632,7 +7839,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7632
7839
  ['', I.minus, t('zoomOut'), false, z <= ZMIN, () => center(1 / 1.25)],
7633
7840
  'sep',
7634
7841
  ['', I.fit, t('fit'), false, false, fit],
7635
- ['', I.single, t('zoomReal'), Math.abs(z - 1) < 0.005, false, () => center(1 / z)],
7842
+ ['', I.single, t('zoomReal'), Math.abs(z - 1) < 0.005, false, () => center(1 / camRef.current.z)],
7636
7843
  ] })))
7637
7844
  }
7638
7845
 
@@ -7727,7 +7934,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7727
7934
  const [tw, setTw] = useState({}) // 拖过的滑块:id → 值(还没写进文件)
7728
7935
  const apis = useRef(new Map()) // 屏 → 截图用的接口
7729
7936
  const ghostApis = useRef(new Map()) // 单看时导出:在背后临时挂上的各屏
7730
- const ghostN = useRef(0)
7937
+ const ghostQueue = useRef(Promise.resolve())
7938
+ const ghostBatch = useRef(0)
7731
7939
  const [backFrames, setBackFrames] = useState(null) // { list, size }:开始时的那些屏,途中换设计也不跟着变
7732
7940
  const designNow = useRef('') // 现在开着哪套设计
7733
7941
  const designSeq = useRef(0) // 换一次设计加一:导出途中换过(换回来也算)就不存了
@@ -7756,6 +7964,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7756
7964
  const draftedR = useRef(new Map()) // 边写边看过的屏 → 什么时候:真文件出来时不再播一遍生成动画
7757
7965
  const pulseR = useRef({ key: '', lines: 0, n: 0 }) // 模型真有动静就加一(占位里的鼠标按它动)
7758
7966
  const singleDraftR = useRef('') // 单屏里正在看着写的那屏:写完换过去看它
7967
+ const peekR = useRef('') // 这轮生成里用户自己点开的那屏:就给他看这屏,别拿在写的草稿盖住,写完也别把他带走
7759
7968
  const playR = useRef({ url: '', key: '', hold: 0, end: false, meta: '', lump: false }) // 在放的草稿(见下面 dr)
7760
7969
  const M = marks.current
7761
7970
  if (M.site !== site) {
@@ -8007,8 +8216,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8007
8216
  if (!patch.focus && poll && poll.state) poll.set({ ...poll.state, ...patch })
8008
8217
  post('view', { session: sid, ...patch }).then((s) => poll && poll.set(s), (e) => say(t('openFailed', { msg: e.message })))
8009
8218
  }
8219
+ // 用户自己点开一屏(双击、菜单、单看按钮)
8220
+ const openByUser = (key) => {
8221
+ singleDraftR.current = ''
8222
+ peekR.current = key || focus
8223
+ change(key ? { view: 'single', focus: key } : { view: 'single' })
8224
+ }
8010
8225
  // 单屏里看着写完的那屏:真文件出来了就换过去看它(不然写完一闪又回到原来那屏)
8011
8226
  useEffect(() => {
8227
+ if (!busy && !dr) peekR.current = ''
8012
8228
  let k = singleDraftR.current
8013
8229
  if (k === '*' && sd && sd.key) k = singleDraftR.current = sd.key
8014
8230
  if (!k || dr) return
@@ -8260,8 +8476,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8260
8476
  useEffect(() => { setDemo(null) }, [site])
8261
8477
 
8262
8478
  const openSingle = () => {
8263
- if (sel && sel !== focus && screens.some((s) => s.key === sel)) change({ view: 'single', focus: sel })
8264
- else change({ view: 'single' })
8479
+ openByUser(sel && sel !== focus && screens.some((s) => s.key === sel) ? sel : '')
8265
8480
  }
8266
8481
 
8267
8482
  const renderScreen = (sc, z, fill) => h(Device, { kind, w: size[0], h: size[1], fill, label: labelOf(sc), top: tops[ik(sc)], os: meta.os },
@@ -8295,6 +8510,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8295
8510
  onBuilt: (title) => onBuilt(sc, title),
8296
8511
  }))
8297
8512
 
8513
+ // 画布上屏太多、离镜头远的:先不挂 iframe,放个占位
8514
+ const sleepScreen = (sc, z) => h(Device, { kind, w: size[0], h: size[1], fill: false, label: labelOf(sc), top: tops[ik(sc)], os: meta.os },
8515
+ h('div', { className: 'ddp-scr' + (dark ? ' dk' : '') }, h('div', { className: 'ddp-away', style: { fontSize: 13 / Math.max(0.25, z || 1) } }, t('canvasAsleep'))))
8516
+
8298
8517
  // ── 导出图片 ──
8299
8518
  // 截一屏:图片和它的 CSS 尺寸(PDF / PPT 按这个定页面大小)
8300
8519
  // 那一屏的接口(截图、体检);刚载入的等它就绪
@@ -8308,36 +8527,62 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8308
8527
  if (!api) throw new Error('not loaded')
8309
8528
  return api
8310
8529
  }
8311
- const captureOf = async (sc, full, map, maxH) => {
8530
+ // 这次导出截到的 AI 示意图(文件名去重):每种导出结束的提示里都带一句「上线前换成真实照片」
8531
+ const aiTail = (ai) => (ai && ai.size ? ' · ' + t('xoAi', { n: ai.size }) : '')
8532
+ const captureOf = async (sc, full, map, maxH, ai) => {
8312
8533
  const api = await apiOf(sc, map)
8313
8534
  const r = await api.capture({ full: !!full, scale: 2, ...(maxH ? { maxH } : {}) })
8314
- return { img: await loadImg(r.png), w: r.w, h: r.h, links: Array.isArray(r.links) ? r.links : [], top: typeof r.top === 'boolean' ? r.top : null }
8535
+ if (ai && Array.isArray(r.aiPhotos)) for (const x of r.aiPhotos) ai.add(x)
8536
+ return { img: await loadImg(r.png), w: r.w, h: r.h, links: Array.isArray(r.links) ? r.links : [], top: typeof r.top === 'boolean' ? r.top : null, title: String(r.title || '').trim() }
8315
8537
  }
8538
+ // 导出用的标题:屏多的时候有的屏没在画布上挂过,手上没有它的标题,用截图时页面报的
8539
+ const exportTitle = (sc, r) => (infoOf(ik(sc)) || {}).title || r.title || sc.label
8316
8540
 
8317
8541
  const targetKey = st && st.target ? (st.target.kind === 'file' ? `file|${st.target.root}` : `proxy|${st.target.port}`) : ''
8318
- const saveImage = async (name, blob) => {
8542
+ const saveImage = async (name, blob, ai) => {
8319
8543
  const png = await blobB64(blob)
8320
8544
  const r = await post('export', { session: sid, name, png, target: targetKey })
8321
8545
  const copied = await copyImage(blob)
8322
8546
  const file = String(r.path || '').split(/[\\/]/).pop()
8323
- say(t(copied ? 'exportedCopied' : 'exported', { name: file }), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
8547
+ say(t(copied ? 'exportedCopied' : 'exported', { name: file }) + aiTail(ai), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
8324
8548
  }
8325
8549
 
8326
8550
  const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
8327
8551
  if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
8328
8552
  // 单看时只挂着正在看的那屏;要所有屏(PDF、PPT、拼图、预检)时按画幅大小在背后挂上,用完就撤
8329
- const withFrames = async (fn) => {
8330
- if (canvas || shown.length < 2) return fn(apis.current)
8553
+ const withFrames = async (fn, only) => {
8554
+ if (!only && ((canvas && shown.length <= LIVE_MAX) || shown.length < 2)) return fn(apis.current)
8331
8555
  // 网页单看时铺满右侧栏,和画幅不一样宽,都在背后重挂;别的类型正在看的那屏直接用(滚动位置、打开的弹窗都还在)
8332
- const list = kind === 'web' ? shown : shown.filter((sc) => !apis.current.has(ik(sc)))
8333
- const back = new Set(list.map(ik))
8334
- ghostN.current++
8335
- setBackFrames({ list, size })
8336
- try { return await fn({ get: (k) => (back.has(k) ? ghostApis.current : apis.current).get(k) }) } finally { if (!--ghostN.current) setBackFrames(null) }
8556
+ // 画布屏多的时候镜头一动画布上的屏就会撤,也都在背后挂
8557
+ const stamp = designSeq.current
8558
+ const run = async () => {
8559
+ if (designSeq.current !== stamp) throw new Error('designChanged') // 排队的时候换了设计
8560
+ // 轮到了才算要挂哪些:排队时前台可能已经换了一屏
8561
+ const list = only || (canvas || kind === 'web' ? shown : shown.filter((sc) => !apis.current.has(ik(sc))))
8562
+ const back = new Set(list.map(ik))
8563
+ const place = new Map(list.map((sc, i) => [ik(sc), i]))
8564
+ // 屏多的时候分批挂:只挂轮到的这一批,别几十个一起跑
8565
+ let at = 0
8566
+ // 每个任务一批新的 iframe:上一批的深浅色、接口都不留(不然拿到上一批「已就绪」的就截了)
8567
+ ghostApis.current.clear()
8568
+ setBackFrames({ list, size, at, dark, batch: ++ghostBatch.current }) // 深浅色跟点导出时的走,和文件名对得上
8569
+ const get = (k) => {
8570
+ const i = place.get(k)
8571
+ if (i !== undefined && (i < at || i >= at + LIVE_MAX)) { at = i; setBackFrames((b) => (b ? { ...b, at: i } : b)) }
8572
+ return (back.has(k) ? ghostApis.current : apis.current).get(k)
8573
+ }
8574
+ try { return await fn({ get }) } finally { setBackFrames(null) }
8575
+ }
8576
+ // 背后挂的屏一次只给一个任务用(预检和导出撞上,会互相把对方要的那批撤掉)
8577
+ const job = ghostQueue.current.then(run, run)
8578
+ ghostQueue.current = job.catch(() => {})
8579
+ return job
8337
8580
  }
8338
8581
  const measureAll = async (map) => {
8582
+ const stamp = designSeq.current
8339
8583
  const list = []
8340
8584
  for (const sc of shown) {
8585
+ if (designSeq.current !== stamp) break // 设计换了:别再等旧的屏
8341
8586
  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 }) }
8342
8587
  }
8343
8588
  return list
@@ -8352,6 +8597,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8352
8597
  const design = designNow.current
8353
8598
  const stamp = designSeq.current
8354
8599
  const gone = () => designSeq.current !== stamp
8600
+ const aiShot = new Set() // 这次导出截到的 AI 示意图(每次导出各记各的,连着导出不串)
8355
8601
  try {
8356
8602
  const prefix = ver ? `v${ver.n}-` : ''
8357
8603
  const suffix = dark ? '-dark' : ''
@@ -8380,9 +8626,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8380
8626
  for (const sc of shown) {
8381
8627
  if (gone()) break
8382
8628
  try {
8383
- const r = await captureOf(sc, long, map, maxH)
8629
+ const r = await captureOf(sc, long, map, maxH, aiShot)
8384
8630
  const cut = maxH && r.h > maxH
8385
- pages.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title: labelOf(sc), links: r.links })
8631
+ pages.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title: exportTitle(sc, r), links: r.links })
8386
8632
  keys.push(sc.key)
8387
8633
  } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
8388
8634
  }
@@ -8401,7 +8647,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8401
8647
  const file = String(r.path || '').split(/[\\/]/).pop()
8402
8648
  const miss = shown.length - pages.length
8403
8649
  const sheets = Math.ceil(pages.length / cols)
8404
- say((miss ? t('exportedDocMiss', { name: file, n: sheets, miss }) : t('exportedDoc', { name: file, n: sheets })) + (deadN ? ' · ' + t('xoDead', { n: deadN }) : ''), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
8650
+ 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(() => {}) })
8405
8651
  })
8406
8652
  return
8407
8653
  }
@@ -8410,7 +8656,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8410
8656
  await withFrames(async (map) => {
8411
8657
  for (const sc of shown) {
8412
8658
  if (gone()) break
8413
- try { const c = await captureOf(sc, false, map); shots.push({ img: c.img, top: c.top, title: labelOf(sc) }) } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
8659
+ 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) }
8414
8660
  }
8415
8661
  })
8416
8662
  if (gone()) { say(t('xoGone')); return }
@@ -8428,21 +8674,26 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8428
8674
  accent: colors.accent || ACCENT,
8429
8675
  mark: t('madeWith'),
8430
8676
  })
8431
- await saveImage(prefix + (sp.brand || 'showcase') + suffix, blob)
8677
+ await saveImage(prefix + (sp.brand || 'showcase') + suffix, blob, aiShot)
8432
8678
  return
8433
8679
  }
8434
8680
  const k = key || (canvas ? sel || focus : focus)
8435
8681
  const sc = shown.find((x) => x.key === k) || shown[0]
8436
8682
  if (!sc) throw new Error('no screen')
8437
8683
  const base = prefix + sc.key.replace(/\.html?$/i, '') + suffix
8438
- const { img, top } = await captureOf(sc, mode === 'long')
8439
- if (mode === 'frame') await saveImage(base, await composeOne(kind, size, img, labelOf(sc), top, meta.os))
8684
+ // 画布屏多的时候这屏可能没挂着(镜头一动也可能撤掉):在背后单独挂一份来截
8685
+ let shot = null
8686
+ if (canvas && shown.length > LIVE_MAX) await withFrames(async (map) => { shot = await captureOf(sc, mode === 'long', map, 0, aiShot) }, [sc])
8687
+ else shot = await captureOf(sc, mode === 'long', undefined, 0, aiShot)
8688
+ if (gone()) { say(t('xoGone')); return }
8689
+ const { img, top } = shot
8690
+ if (mode === 'frame') await saveImage(base, await composeOne(kind, size, img, labelOf(sc), top, meta.os), aiShot)
8440
8691
  else {
8441
8692
  const c = document.createElement('canvas')
8442
8693
  c.width = img.width
8443
8694
  c.height = img.height
8444
8695
  c.getContext('2d').drawImage(img, 0, 0)
8445
- await saveImage(base + (mode === 'long' ? '-full' : ''), await canvasBlob(c))
8696
+ await saveImage(base + (mode === 'long' ? '-full' : ''), await canvasBlob(c), aiShot)
8446
8697
  }
8447
8698
  } catch (e) {
8448
8699
  say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
@@ -8488,7 +8739,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8488
8739
  const actions = (sc) => [
8489
8740
  h('button', { key: 'x', className: 'ddp-btn', title: t('exThis'), onClick: () => doExport(FRAMED[kind] ? 'frame' : 'raw', sc.key) }, h(I.download), h('span', { className: 'lb' }, t('actX'))),
8490
8741
  sc.v ? null : h('button', { key: 'v', className: 'ddp-btn', title: t('variants'), onClick: () => askVariants(sc) }, h(I.sparkle), h('span', { className: 'lb' }, t('actV'))),
8491
- h('button', { key: 'o', className: 'ddp-btn', title: t('openScreen'), onClick: () => change({ view: 'single', focus: sc.key }) }, h(I.single), h('span', { className: 'lb' }, t('actO'))),
8742
+ h('button', { key: 'o', className: 'ddp-btn', title: t('openScreen'), onClick: () => openByUser(sc.key) }, h(I.single), h('span', { className: 'lb' }, t('actO'))),
8492
8743
  ]
8493
8744
 
8494
8745
  // 对比:拖中间的把手
@@ -8526,7 +8777,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8526
8777
  if (ck) for (const sc of ck.list || []) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
8527
8778
  setCk(null)
8528
8779
  }
8529
- const checkList = () => (canvas ? shown : [shown.find((x) => x.key === focus) || { key: focus, url, label: st.label }])
8780
+ // 画布屏多的时候只量挂着的(别的没有页面可量)
8781
+ const checkList = () => (canvas ? (shown.length > LIVE_MAX ? shown.filter((sc) => apis.current.has(ik(sc))) : shown) : [shown.find((x) => x.key === focus) || { key: focus, url, label: st.label }])
8530
8782
  // 几屏一起量(各量各的 iframe),一屏卡住不拖累别的
8531
8783
  const measure = (list, quiet) => Promise.all(list.map(async (sc) => {
8532
8784
  const row = { key: sc.key, v: sc.v, label: labelOf(sc), url: sc.url, issues: [] }
@@ -8542,6 +8794,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8542
8794
  setPanel(false); setHist(false); setPhone(false)
8543
8795
  setCk({ running: true, list: [] })
8544
8796
  const out = await measure(checkList(), false)
8797
+ if (canvas && shown.length > LIVE_MAX) say(t('checkPartial', { n: out.length }))
8545
8798
  setCk({ running: false, list: out })
8546
8799
  setCkCount(total(out))
8547
8800
  // 有问题的第一屏被面板挡着、在画布外面:挪过来
@@ -8553,6 +8806,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8553
8806
  const sc = (ck && ck.list.find((x) => x.key === key)) || null
8554
8807
  if (!sc) return
8555
8808
  if (canvas) { setSel(key); setReveal((r) => ({ key, n: ((r && r.n) || 0) + 1 })) }
8809
+ // 屏多的时候这屏可能撤过(重新载入后页面里的体检标记没了):等它挂上,量一遍再定位
8810
+ if (canvas && shown.length > LIVE_MAX) { apiOf(sc).then((api) => api.check(kind, false).then(() => api.checkFocus(i))).catch((e) => console.warn('[dsh-design-studio] 定位问题失败', key, e)); return }
8556
8811
  const a = apis.current.get(ik(sc))
8557
8812
  if (a) a.checkFocus(i)
8558
8813
  }
@@ -8806,6 +9061,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8806
9061
  }
8807
9062
  useEffect(() => { if (styleOff) setStyleEdit(false) }, [styleOff])
8808
9063
  autoCk.current = { ck, off: checkOff, run: runCheck, list: checkList, measure }
9064
+ // 屏数超过上限:不声不响地少几屏,用户会以为没生成
9065
+ const hiddenN = (st && st.hidden) || 0
9066
+ const hiddenText = hiddenN ? t('screensHidden', { n: hiddenN, max: st.maxScreens }) : ''
9067
+ const hiddenSaid = useRef('')
9068
+ useEffect(() => {
9069
+ const sig = hiddenN ? `${targetKey}|${hiddenN}` : ''
9070
+ if (sig && sig !== hiddenSaid.current) say(hiddenText)
9071
+ hiddenSaid.current = sig
9072
+ }, [hiddenN, targetKey])
8809
9073
  useEffect(() => { if (checkOff && ck) closeCheck() }, [checkOff])
8810
9074
 
8811
9075
  const toggleDemo = () => (demo ? setDemo(null) : startDemo())
@@ -8885,7 +9149,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8885
9149
  setMulti(false)
8886
9150
  if (demo) setDemo(null)
8887
9151
  setSel(key)
8888
- if (canvas || key !== focus) change({ view: 'single', focus: key })
9152
+ if (canvas || key !== focus || dr) openByUser(key)
8889
9153
  }
8890
9154
  // 导出菜单写出是哪一屏(和 doExport 取同一屏)
8891
9155
  const exSc = shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
@@ -8902,7 +9166,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8902
9166
  h('div', { className: 'ddp-isl tl' },
8903
9167
  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'))),
8904
9168
  h('span', { className: 'ddp-sep' }),
8905
- h(ScreenMenu, { t, 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,
9169
+ 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,
8906
9170
  onPick: pickScreen, onAll: () => { setMulti(false); if (demo) setDemo(null); change({ view: 'canvas' }) }, onOther: () => setEditing(true),
8907
9171
  sizes: mark ? null : { on: inMulti, off: !sizeSet || !!ver, tip: sizeSet ? t('sizes') : t('sizesNo'), note: sizeSet ? '' : t('sizesNoShort'), run: () => setMulti(!inMulti) },
8908
9172
  kind, onKind: mark ? null : (k) => change({ kind: k }) })),
@@ -9052,8 +9316,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9052
9316
  toast ? h('div', { className: 'ddp-toast low' }, h('span', null, toast.text)) : null) : null
9053
9317
  // 开着设计时点「首页」:首页叠在画布上(设计库再叠在它上面)
9054
9318
  // 单看时导出:所有屏按画幅大小挂在背后(看不见、点不到,放在视口里是因为视口外的 iframe 浏览器会停掉它的绘制)
9055
- const ghostLayer = backFrames ? h('div', { className: 'ddp-ghost', 'aria-hidden': true }, ...backFrames.list.map((sc) => h('div', { key: ik(sc), className: 'ddp-vp', style: { left: 0, top: 0, width: backFrames.size[0], height: backFrames.size[1] } },
9056
- h(Screen, { t, remote, src: sc.url, label: labelOf(sc), dark, apis: ghostApis.current, apiKey: ik(sc), quietPick: true, zoom: 1, reloadSeq, tweak: sc.v ? null : tweak, styleSel: sty && sty.key === sc.key ? sty.selector : '', styleCss: sty && sty.key === sc.key ? sty.live : null })))) : null
9319
+ const ghostLayer = backFrames ? h('div', { className: 'ddp-ghost', 'aria-hidden': true }, ...backFrames.list.slice(backFrames.at || 0, (backFrames.at || 0) + LIVE_MAX).map((sc) => h('div', { key: backFrames.batch + '|' + ik(sc), className: 'ddp-vp', style: { left: 0, top: 0, width: backFrames.size[0], height: backFrames.size[1] } },
9320
+ h(Screen, { t, remote, src: sc.url, label: labelOf(sc), dark: backFrames.dark, apis: ghostApis.current, apiKey: ik(sc), quietPick: true, zoom: 1, reloadSeq, tweak: sc.v ? null : tweak, styleEdit: styleEdit && !sc.v, styleSel: sty && sty.key === sc.key ? sty.selector : '', styleCss: sty && sty.key === sc.key ? sty.live : null })))) : null
9057
9321
  const root = (...kids) => h('div', rootProps, ...kids, url && homeAt ? homeView(true) : null, libLayer, dropLayer, fileInput, pageFileInput, ghostLayer)
9058
9322
 
9059
9323
  // ── 设计库:打成 zip、拖进来的设计包、存成我的风格 ──
@@ -9404,9 +9668,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9404
9668
  reveal,
9405
9669
  inset: ck || styleEdit || panel || pane || hist || phone ? 296 : 0, // 右边的面板 276 宽,离边 10
9406
9670
  render: (sc, z) => renderScreen(sc, z, false),
9671
+ sleep: sleepScreen,
9407
9672
  flows,
9408
9673
  onSelect: setSel,
9409
- onOpen: (key) => change({ view: 'single', focus: key }),
9674
+ onOpen: (key) => openByUser(key),
9410
9675
  })
9411
9676
  } else {
9412
9677
  const fill = kind === 'web'
@@ -9421,7 +9686,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9421
9686
  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))
9422
9687
  const one = ver ? shown.find((x) => x.key === focus) || shown[0] || { key: focus, url, label: st.label } : { key: focus, url, label: st.label }
9423
9688
  // 单屏时模型在写新的一屏:先看着它写(没在选、改字、调样式、标注的时候),写完换过去
9424
- const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !lock
9689
+ const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !lock && !peekR.current
9425
9690
  if (watch) singleDraftR.current = dr.key || '*' // 还不知道是哪屏:名字到了再说
9426
9691
  body = h('div', { className: 'ddp-single', style: aside ? { right: aside } : undefined },
9427
9692
  h('div', { className: 'ddp-fit' + (fill && !lock ? ' fill' : ''), style: fill && !lock ? undefined : { width: lock ? lock.w : dw, height: lock ? lock.h : dh, transform: `translate(-50%, -50%) scale(${z})` } },
@@ -9648,7 +9913,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9648
9913
  // 注意:这里是客户端**服务名**(短的),不是包名
9649
9914
  exports.inject = INJECT
9650
9915
  // 测试用
9651
- exports._test = { 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, tokenKind, formatToken, splitTitles, pickColors, hhmm, formatTpl, formatPrep, styleFromTokens, myStyleOf, isZipFile }
9916
+ exports._test = { 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 }
9652
9917
  return module.exports
9653
9918
  },
9654
9919
  })