dsh-design-studio 0.25.3 → 0.27.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
@@ -200,6 +200,11 @@ window.__ModuleLoader__.load({
200
200
  exPptx: 'PPT · 每屏一页(整页图片)',
201
201
  exOpts: '导出选项…',
202
202
  exportedDocMiss: '已导出 {name}({n} 页,{miss} 屏没截到)',
203
+ exHtml: '整套 HTML 演示(双击就能开)',
204
+ exportedHtml: '已导出 {name}({n} 屏,发给别人双击就能看)',
205
+ exportedHtmlMiss: '已导出 {name}({n} 屏,{miss} 屏没读到)',
206
+ htmlTooBig: '图片太多,演示包超过 150 MB,没导出。少放几屏再试',
207
+ htmlNoScreens: '一屏都没读到(文件被挪走或删了?),没导出',
203
208
  xoTitle: '导出选项',
204
209
  xoTip: '不动这里,导出的结果和直接导出一样。',
205
210
  xoWarn: '有内容会被裁掉,先看一眼',
@@ -619,6 +624,51 @@ window.__ModuleLoader__.load({
619
624
  stBrand: '正在提取品牌',
620
625
  stCode: '正在转成代码',
621
626
  stCompare: '正在逐像素对比',
627
+ implCmp: '和做出来的比',
628
+ implShort: '和做出来的比',
629
+ implDesign: '设计稿',
630
+ implSide: '做出来的',
631
+ implHidden: '外框里的 main 露不出来:画幅改成外框自己的 {w}×{h} 再看',
632
+ implOpening: '正在打开做出来的页面…',
633
+ implNeed: '在上面填做出来的页面地址(开发服务器要先跑起来)',
634
+ implBadUrl: '地址不对:只认本机的页面,比如 http://localhost:5173/login、端口 5173,或本地 HTML 文件',
635
+ implSelf: '这是设计稿自己的预览地址:填做出来的那个项目的',
636
+ implHttps: 'https 的开发服务器嵌不进来:换成 http 地址',
637
+ implOpenFail: '打不开做出来的页面({msg})',
638
+ implCmpFail: '没比成:做出来的页面打得开吗?开发服务器起来了吗?',
639
+ implCmpHidden: '没比成:这个画幅下外框里的 main 露不出来',
640
+ implScore: '比完了:差异 {pct}%',
641
+ implDone: '模型刚和做出来的比过「{name}」:差异 {pct}%',
642
+ implSee: '看对比',
643
+ implUrl: '做出来的页面地址',
644
+ implGo: '打开',
645
+ dImplUrl: '点一下换地址',
646
+ implPct: '差异 {pct}%',
647
+ dImplPct: '上次比对:{time},{who};点一下看拼图',
648
+ implByModel: '模型比的',
649
+ implByYou: '你点的',
650
+ implRe: '重新比',
651
+ dImplRe: '照现在的画幅、深浅色逐像素比一次(和 compare_design 一样)',
652
+ implHere: '比这一页',
653
+ implBlocked: '外链不在对比里打开:{href}',
654
+ dImplHere: '做出来的页面换到了 {path}(上次的分数、红框是原来那页的):点这里改成和这一页比',
655
+ implRunning: '在比…',
656
+ implExit: '退出对比',
657
+ implShotT: '上次比对的拼图',
658
+ implShotGone: '拼图没了(重开过 DSH):点「重新比」再出一张',
659
+ implShotHow: '设计稿 | 做出来的 | 差异;点任意处关掉',
660
+ implSplit: '拖线',
661
+ dImplSplit: '左边设计稿、右边做出来的,拖中间的把手',
662
+ implOver: '叠加',
663
+ dImplOver: '做出来的半透明盖在设计稿上',
664
+ implSideBy: '并排',
665
+ dImplSide: '两个并排,滚动同步',
666
+ implOp: '透明度',
667
+ dImplOp: '做出来的那层有多实',
668
+ implDiff: '反色',
669
+ dImplDiff: '一样的地方发黑,对不上的地方发亮',
670
+ implBoxes: '红框',
671
+ dImplBoxes: '标出上次比对差得最多的几块(同样画幅、顶上一屏时)',
622
672
  stPhotos: '正在挑照片',
623
673
  stStyle: '正在挑风格',
624
674
  stFrame: '正在存外框',
@@ -1083,6 +1133,11 @@ window.__ModuleLoader__.load({
1083
1133
  exPptx: 'PowerPoint · one slide per screen (as images)',
1084
1134
  exOpts: 'Export options…',
1085
1135
  exportedDocMiss: 'Exported {name} ({n} pages, {miss} screens could not be captured)',
1136
+ exHtml: 'Clickable HTML demo (opens with a double-click)',
1137
+ exportedHtml: 'Exported {name} ({n} screens; anyone can open it with a double-click)',
1138
+ exportedHtmlMiss: 'Exported {name} ({n} screens, {miss} could not be read)',
1139
+ htmlTooBig: 'Too many images: the demo would be over 150 MB, so nothing was exported. Try with fewer screens',
1140
+ htmlNoScreens: 'None of the screens could be read (moved or deleted?), so nothing was exported',
1086
1141
  xoTitle: 'Export options',
1087
1142
  xoTip: 'Leave these alone and the file comes out the same as a direct export.',
1088
1143
  xoWarn: 'Some content would be cut off. Have a look first',
@@ -1501,6 +1556,51 @@ window.__ModuleLoader__.load({
1501
1556
  stBrand: 'Extracting the brand',
1502
1557
  stCode: 'Turning it into code',
1503
1558
  stCompare: 'Comparing pixel by pixel',
1559
+ implCmp: 'Compare with build',
1560
+ implShort: 'Compare with build',
1561
+ implDesign: 'Design',
1562
+ implSide: 'Built',
1563
+ implHidden: 'The main slot inside the frame does not show at this size: set the canvas size to the frame’s own {w}×{h}',
1564
+ implOpening: 'Opening the built page…',
1565
+ implNeed: 'Enter the built page’s address above (start the dev server first)',
1566
+ implBadUrl: 'Not a usable address: only pages on this computer, such as http://localhost:5173/login, port 5173, or a local HTML file',
1567
+ implSelf: 'That is the design’s own preview address: enter the address of the project you built',
1568
+ implHttps: 'An https dev server cannot be embedded: use its http address',
1569
+ implOpenFail: 'Could not open the built page ({msg})',
1570
+ implCmpFail: 'Could not compare: does the built page open? Is the dev server running?',
1571
+ implCmpHidden: 'Could not compare: the main slot inside the frame does not show at this size',
1572
+ implScore: 'Compared: {pct}% different',
1573
+ implDone: 'The model just compared “{name}” with the build: {pct}% different',
1574
+ implSee: 'View comparison',
1575
+ implUrl: 'Built page address',
1576
+ implGo: 'Open',
1577
+ dImplUrl: 'Click to change the address',
1578
+ implPct: '{pct}% different',
1579
+ dImplPct: 'Last compared {time} by {who}; click to see the comparison image',
1580
+ implByModel: 'the model',
1581
+ implByYou: 'you',
1582
+ implRe: 'Compare again',
1583
+ dImplRe: 'Compare pixel by pixel at the current size and theme (same as compare_design)',
1584
+ implHere: 'Compare this page',
1585
+ implBlocked: 'Outside links don\'t open inside the comparison: {href}',
1586
+ dImplHere: 'The built page moved to {path} (the last score and boxes are for the old page): click to compare against this page instead',
1587
+ implRunning: 'Comparing…',
1588
+ implExit: 'Leave comparison',
1589
+ implShotT: 'Last comparison image',
1590
+ implShotGone: 'The image is gone (DSH was restarted): click Compare again for a new one',
1591
+ implShotHow: 'Design | Built | Difference; click anywhere to close',
1592
+ implSplit: 'Split',
1593
+ dImplSplit: 'Design on the left, build on the right; drag the handle',
1594
+ implOver: 'Overlay',
1595
+ dImplOver: 'The build sits translucent over the design',
1596
+ implSideBy: 'Side',
1597
+ dImplSide: 'Both side by side, scrolling together',
1598
+ implOp: 'Opacity',
1599
+ dImplOp: 'How solid the build layer is',
1600
+ implDiff: 'Invert',
1601
+ dImplDiff: 'Matching areas turn black, mismatches light up',
1602
+ implBoxes: 'Boxes',
1603
+ dImplBoxes: 'Mark the areas that differed most last time (same size, top of the page)',
1504
1604
  stPhotos: 'Picking photos',
1505
1605
  stStyle: 'Picking a style',
1506
1606
  stFrame: 'Saving the frame',
@@ -2497,6 +2597,33 @@ window.__ModuleLoader__.load({
2497
2597
  .ddp-cmp .tag{position:absolute;top:10px;z-index:4;padding:3px 9px;border-radius:999px;background:rgba(0,0,0,.6);color:#fff;font:500 11px/16px -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif;pointer-events:none}
2498
2598
  .ddp-cmp .tag.l{left:10px}
2499
2599
  .ddp-cmp .tag.r{right:10px;background:${ACCENT}}
2600
+ /* 和做出来的比:叠加时真页面盖在设计稿上(isolation:反色只和设计稿混);套了外框时真页面只占槽位那块 */
2601
+ .ddp-icmp{isolation:isolate}
2602
+ .ddp-icmp .im{position:absolute;z-index:2;overflow:hidden;background:#fff}
2603
+ .ddp-icmp .im>.miss{background:rgba(244,244,246,.92)}
2604
+ .ddp-icmp .miss.hid{z-index:3;background:rgba(244,244,246,.92)}
2605
+ .ddp-icmp .bx{position:absolute;z-index:3;overflow:hidden;pointer-events:none}
2606
+ .ddp-icmp .bx>i{position:absolute;box-sizing:border-box;border:2px solid #e8382f;border-radius:2px}
2607
+ .ddp-icmp .bx>i>b{position:absolute;left:-1px;top:-1px;min-width:18px;height:18px;padding:0 4px;border-radius:2px;background:#e8382f;color:#fff;font:700 11px/18px -apple-system,BlinkMacSystemFont,sans-serif;text-align:center;transform-origin:top left}
2608
+ .ddp-iside{position:absolute;top:0;left:0}
2609
+ .ddp-ibn{padding-left:10px}
2610
+ .ddp-ibn.side>b{display:none}
2611
+ .ddp-ibn .ddp-iurl{flex:0 1 auto}
2612
+ .ddp-iurl{min-width:0;max-width:220px;overflow:hidden;text-overflow:ellipsis;height:24px;padding:0 8px;border:0;border-radius:999px;background:rgba(127,127,127,.12);color:var(--dsw-alias-label-primary);font:inherit;cursor:text}
2613
+ .ddp-iurl:hover{background:rgba(127,127,127,.2)}
2614
+ .ddp-iform{display:flex;align-items:center;gap:4px;min-width:0}
2615
+ .ddp-iform input{width:220px;min-width:80px;height:24px;padding:0 9px;border:0;border-radius:999px;background:rgba(127,127,127,.12);color:var(--dsw-alias-label-primary);font:inherit;outline:none}
2616
+ .ddp-iform input:focus{box-shadow:inset 0 0 0 1px ${ACCENT}}
2617
+ .ddp-iscore{flex:none;height:24px;padding:0 9px;border:0;border-radius:999px;background:rgba(232,56,47,.12);color:#d0312a;font:600 12px/24px inherit;font-family:inherit;cursor:zoom-in}
2618
+ .ddp-iscore.ok{background:rgba(34,160,90,.12);color:#1f8a4f}
2619
+ @container (max-width:460px){.ddp-iurl{max-width:90px}.ddp-iform input{width:120px}}
2620
+ .ddp-ibar .ddp-tool{width:auto;min-width:44px;padding:0 6px}
2621
+ .ddp-iop{display:flex;align-items:center;gap:6px;padding:0 6px;font-size:11px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}
2622
+ .ddp-iop input{width:88px;accent-color:${ACCENT}}
2623
+ .ddp-iop span{min-width:30px;text-align:right}
2624
+ .ddp-ishot{position:absolute;inset:0;z-index:20;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:16px;background:rgba(0,0,0,.72);cursor:zoom-out;animation:ddp-in .15s ${EASE}}
2625
+ .ddp-ishot img{max-width:100%;max-height:calc(100% - 30px);border-radius:6px;box-shadow:0 8px 30px rgba(0,0,0,.4)}
2626
+ .ddp-ishot span{color:rgba(255,255,255,.8);font-size:12px}
2500
2627
  /* 屏头小按钮:悬停或选中那屏才出来(平时不占地方,给屏名和「用这版」留位置) */
2501
2628
  .ddp-act{margin-left:auto;display:none;gap:1px;flex:none}
2502
2629
  .ddp-cell:hover .ddp-act,.ddp-cell.sel .ddp-act{display:flex}
@@ -2824,6 +2951,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
2824
2951
 
2825
2952
  const svg = (d, extra) => h('svg', { viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', ...extra }, ...d)
2826
2953
  const I = {
2954
+ // 和做出来的比:两张叠着的页面(后一张虚线)
2955
+ overlay: () => svg([h('rect', { key: 1, x: 3.5, y: 5.5, width: 11, height: 13, rx: 2 }), h('rect', { key: 2, x: 9.5, y: 5.5, width: 11, height: 13, rx: 2, strokeDasharray: '2.5 2' })]),
2956
+ splitV: () => svg([h('rect', { key: 1, x: 3.5, y: 4.5, width: 17, height: 15, rx: 2 }), h('path', { key: 2, d: 'M12 2.5v19' })]),
2957
+ sideBy: () => svg([h('rect', { key: 1, x: 3, y: 5.5, width: 8, height: 13, rx: 1.5 }), h('rect', { key: 2, x: 13, y: 5.5, width: 8, height: 13, rx: 1.5 })]),
2958
+ invert: () => svg([h('circle', { key: 1, cx: 12, cy: 12, r: 8 }), h('path', { key: 2, d: 'M12 4a8 8 0 0 1 0 16z', fill: 'currentColor' })]),
2959
+ boxes: () => svg([h('rect', { key: 1, x: 4.5, y: 6.5, width: 15, height: 11, rx: 1, strokeDasharray: '3 2' }), h('path', { key: 2, d: 'M4.5 6.5h4v4h-4z', fill: 'currentColor', stroke: 'none' })]),
2827
2960
  pick: () => svg([h('path', { key: 1, d: 'M4 4l6.5 16 2.3-6.7L19.5 11z' }), h('path', { key: 2, d: 'M13 13l6 6' })]),
2828
2961
  canvas: () => svg([h('rect', { key: 1, x: 3.5, y: 3.5, width: 7, height: 7, rx: 1.6 }), h('rect', { key: 2, x: 13.5, y: 3.5, width: 7, height: 7, rx: 1.6 }),
2829
2962
  h('rect', { key: 3, x: 3.5, y: 13.5, width: 7, height: 7, rx: 1.6 }), h('rect', { key: 4, x: 13.5, y: 13.5, width: 7, height: 7, rx: 1.6 })]),
@@ -5599,6 +5732,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5599
5732
  holdScroll: () => { if (curRef.current) postTo(curRef.current, { type: 'holdScroll' }) }, // 用户要在这个位置上画:闪改动别再滚回去
5600
5733
  // 画笔标注:这一屏的页面(iframe)现在摆在哪,拼图时按它的位置放截图
5601
5734
  frame: () => wins.current.get(curRef.current) || null,
5735
+ // 和做出来的比:替另一边滚到同一个位置
5736
+ scrollTo: (x, y) => { if (curRef.current) postTo(curRef.current, { type: 'scrollTo', x, y }) },
5602
5737
  }
5603
5738
  }
5604
5739
  // 登记到右侧栏:导出图片时按屏找到它
@@ -5607,8 +5742,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5607
5742
  const k = props.apiKey
5608
5743
  if (!m || !k) return undefined
5609
5744
  m.set(k, api.current)
5610
- return () => { if (m.get(k) === api.current) m.delete(k) }
5611
- }, [props.apiKey])
5745
+ // 和做出来的比:设计稿那边也登记到右侧栏那份(对比开着时导出、截图照样找得到这一屏)
5746
+ const m2 = props.alsoApis
5747
+ const k2 = props.alsoKey
5748
+ if (m2 && k2) m2.set(k2, api.current)
5749
+ return () => {
5750
+ if (m.get(k) === api.current) m.delete(k)
5751
+ if (m2 && k2 && m2.get(k2) === api.current) m2.delete(k2)
5752
+ }
5753
+ }, [props.apiKey, props.alsoKey])
5612
5754
 
5613
5755
  const postTo = (id, msg) => {
5614
5756
  const f = wins.current.get(id)
@@ -5713,6 +5855,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5713
5855
  }
5714
5856
 
5715
5857
  const pickMsg = () => ({ type: 'pick', hint: false }) // 提示放在右侧栏(页面顶上会被手机的灵动岛挡住)
5858
+ // 和做出来的比:页面报滚动(两边同步),套了外框的设计稿还报 main 槽位在哪
5859
+ const syncMsg = (p) => ({ type: 'sync', on: !!p.sync, slot: !!(p.sync && p.sync.slot) })
5716
5860
  // 调样式:开模式、选中右侧栏记着的那个元素、把改到一半的样式再套上(新载的一帧要从头告诉它)
5717
5861
  const styleTo = (id, p) => {
5718
5862
  postTo(id, { type: 'styleMode', on: true })
@@ -5741,6 +5885,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5741
5885
  if (p.demo) postTo(id, { type: 'demo', on: true })
5742
5886
  if (p.textEdit) postTo(id, { type: 'edit', on: true, hint: false })
5743
5887
  if (p.styleEdit) styleTo(id, p)
5888
+ if (p.sync) postTo(id, syncMsg(p))
5744
5889
  if (L.tops.has(id) && p.onTop) p.onTop(L.tops.get(id))
5745
5890
  if (L.anStates.has(id) && p.onAnnotState) p.onAnnotState(L.anStates.get(id))
5746
5891
  if (first && p.onShown) p.onShown()
@@ -5836,7 +5981,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5836
5981
  const seed = L.seeds.get(id) || L.seedOf.get(id) || null
5837
5982
  L.seeds.delete(id)
5838
5983
  L.seedOf.delete(id)
5839
- postTo(id, { type: 'init', seed, relay: true }) // 改动通知由右侧栏转告(见下面「本机预览」),页面别自己开 SSE
5984
+ // 改动通知由右侧栏转告(见下面「本机预览」),页面别自己开 SSE;做出来的页面(ownEvents)不在设计目录里,让它自己听
5985
+ postTo(id, { type: 'init', seed, relay: !P.current.ownEvents })
5840
5986
  break
5841
5987
  }
5842
5988
  case 'ready':
@@ -5862,6 +6008,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5862
6008
  if (p.demo) postTo(id, { type: 'demo', on: true })
5863
6009
  if (p.textEdit) postTo(id, { type: 'edit', on: true, hint: false })
5864
6010
  if (p.styleEdit) styleTo(id, p)
6011
+ if (p.sync) postTo(id, syncMsg(p))
5865
6012
  if (d.changes && d.changes.count && p.onNote) p.onNote({ changes: d.changes, file: '' })
5866
6013
  } else if (id > curRef.current) swap(id, d.changes)
5867
6014
  break
@@ -5870,7 +6017,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5870
6017
  break
5871
6018
  case 'blocked':
5872
6019
  // 别人做的设计里点了站外链接:拦下了,告诉用户一声
5873
- if (isCur) for (const f of blockedSubs) f(typeof d.href === 'string' ? d.href.slice(0, 200) : '')
6020
+ if (isCur) for (const f of blockedSubs) f(typeof d.href === 'string' ? d.href.slice(0, 200) : '', d.why === 'sync')
5874
6021
  break
5875
6022
  case 'dragIn':
5876
6023
  case 'dragOut':
@@ -5887,6 +6034,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5887
6034
  if (isCur && p.onAnnotState) p.onAnnotState(d.list)
5888
6035
  }
5889
6036
  break
6037
+ case 'scrolled':
6038
+ if (isCur && p.sync && p.onScrolled) p.onScrolled({ x: Number(d.x) || 0, y: Number(d.y) || 0, first: d.first === true, set: d.set === true })
6039
+ break
6040
+ case 'slot':
6041
+ if (isCur && p.sync && p.onSlot) p.onSlot(d.box && typeof d.box === 'object' ? d.box : null)
6042
+ break
6043
+ case 'route':
6044
+ if (isCur && p.sync && p.onRoute) p.onRoute(String(d.path || '').slice(0, 2000), d.user === true)
6045
+ break
5890
6046
  case 'top':
5891
6047
  // 每帧记着自己的;只有正显示的那帧算数(预载的换上来时再用,旧帧晚到的不管)
5892
6048
  L.tops.set(id, !!d.dark)
@@ -5950,6 +6106,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5950
6106
  useEffect(() => { if (cur) postTo(cur, { type: 'zoom', z: zq / 100 }) }, [zq])
5951
6107
  useEffect(() => { if (cur) postTo(cur, props.picking ? pickMsg() : { type: 'cancel' }) }, [!!props.picking])
5952
6108
  useEffect(() => { if (cur) postTo(cur, { type: 'theme', dark: !!props.dark }) }, [!!props.dark])
6109
+ const syncSig = props.sync ? (props.sync.slot ? 'slot' : 'page') : ''
6110
+ useEffect(() => { if (cur) postTo(cur, syncMsg(P.current)) }, [syncSig]) // 刚挂上时 cur 还是 0:载好时(ready / 换帧)再发
5953
6111
  useEffect(() => { if (cur) { if (props.styleEdit) styleTo(cur, props); else postTo(cur, { type: 'styleMode', on: false }) } }, [!!props.styleEdit])
5954
6112
  useEffect(() => { if (cur && props.styleEdit) postTo(cur, { type: 'styleSel', selector: props.styleSel || '' }) }, [props.styleSel || ''])
5955
6113
  const cssSig = JSON.stringify(props.styleCss || {})
@@ -6061,6 +6219,188 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
6061
6219
  h(Skeleton, { gone: !!cur }))
6062
6220
  }
6063
6221
 
6222
+ /** 和做出来的比:填做出来的页面地址(横幅里一行) */
6223
+ function ImplUrlForm({ t, initial, busy, onGo, onCancel }) {
6224
+ const ref = useRef(null)
6225
+ useEffect(() => { const el = ref.current; if (el) { el.focus(); el.select() } }, [])
6226
+ return h('form', { className: 'ddp-iform', onSubmit: (e) => { e.preventDefault(); const v = ref.current ? ref.current.value.trim() : ''; if (v) onGo(v) } },
6227
+ h('input', { ref, type: 'text', defaultValue: initial || '', placeholder: 'http://localhost:5173/', spellCheck: false, 'aria-label': t('implUrl'), disabled: busy,
6228
+ onKeyDown: (e) => { if (e.key === 'Escape' && onCancel) { e.preventDefault(); e.stopPropagation(); onCancel() } } }),
6229
+ h('button', { type: 'submit', className: 'ddp-go', disabled: busy }, t('implGo')))
6230
+ }
6231
+
6232
+ // ── 和做出来的比(#25):设计稿和做出来的真页面摆在一起看 ─────────────────────────────
6233
+ // 拖线:中间把手左右拖,左边设计稿、右边做出来的;叠加:真页面半透明盖在设计稿上(反色:一样的地方发黑);并排:两个并排。
6234
+ // 套了外框的设计(DSH 插件、外框库):真页面只盖在 main 槽位上,外框照设计稿显示(和 compare_design 只比槽位一样)。
6235
+ // 两边滚动同步(页面里的设计台脚本报滚动、替另一边滚);上次比对的红框按设计稿那边滚到哪标回去
6236
+ const SYNC_SLOT = { slot: true }
6237
+ const SYNC_PAGE = { slot: false }
6238
+ /**
6239
+ * 真页面跳到的那页(预览服务器上的路径)换回记录用的地址。
6240
+ * 本地 HTML 的预览根可能比 HTML 所在文件夹高几层(页面引用了 ../),按眼前地址的层数退回根再接上。
6241
+ */
6242
+ function implAwayUrl(impl, away) {
6243
+ if (!/^file:/i.test(impl.url)) return new URL(away, impl.url).href
6244
+ let depth = 0
6245
+ try { depth = Math.max(0, new URL(impl.live).pathname.split('/').length - 2) } catch { /* 还没开好:按同一个文件夹 */ }
6246
+ return new URL('.' + away, new URL('../'.repeat(depth) || './', impl.url)).href
6247
+ }
6248
+
6249
+ /**
6250
+ * 真页面摆在哪、红框标不标:套了外框(设计稿报了槽位、没说整屏比)盖在槽位那块;槽位露不出来就不放;
6251
+ * 红框只在比的是同样大小(套了外框比的是槽位)、比的是顶上一屏、同样深浅色、量得到眼前多大时标
6252
+ */
6253
+ function implLayout(slot, rec, size, flat, boxesOn, dark = false) {
6254
+ const whole = !!(rec && rec.whole)
6255
+ const framed = !!slot && !slot.hidden && !whole
6256
+ const hidden = !!slot && !!slot.hidden && !whole
6257
+ const rect = framed ? { left: slot.vx, top: slot.vy, width: slot.w, height: slot.h } : { left: 0, top: 0, right: 0, bottom: 0 }
6258
+ const cw = framed ? slot.w : size[0]
6259
+ const ch = framed ? slot.h : size[1]
6260
+ const boxOk = !!(boxesOn && !hidden && !flat && rec && Array.isArray(rec.boxes) && rec.boxes.length && rec.at !== 'bottom' && !!rec.dark === !!dark && Array.isArray(rec.cmp) && !!rec.slot === framed && rec.cmp[0] === cw && rec.cmp[1] === ch)
6261
+ return { framed, hidden, rect, boxOk }
6262
+ }
6263
+ function ImplCompare(props) {
6264
+ const { t, mode, live, z, flat, lock, dw, dh, gap, kind, size, os, label, top, rec, boxesOn, dark, reloadSeq, missText } = props
6265
+ const apis = useRef(new Map())
6266
+ const [slot, setSlot] = useState(null)
6267
+ const [cx, setCx] = useState(50)
6268
+ const [drag, setDrag] = useState(false)
6269
+ const [pos, setPos] = useState({ x: 0, y: 0 }) // 设计稿那边滚到哪
6270
+ const [ipos, setIpos] = useState({ x: 0, y: 0 }) // 真页面那边滚到哪(设计稿短、真页面长时只有它滚得动)
6271
+ const navFresh = useRef(false) // 用户刚点去了另一页(下一次「刚载好」不滚回原处)
6272
+ const last = useRef({ d: { x: 0, y: 0 }, i: { x: 0, y: 0 } }) // 两边各自滚到哪(真页面比设计稿长时两边不一样)
6273
+ const wrap = useRef(null)
6274
+ const P = useRef(props)
6275
+ P.current = props
6276
+ // 网页铺满、右边开着面板(lock):页面按定住的大小铺满(同「版本对比」);眼前多大量出来(重新比照这个大小比,红框按它对)
6277
+ const fill = flat || !!lock
6278
+ const [view, setView] = useState(null)
6279
+ const vsize = mode === 'side' ? size : view || size
6280
+ const lay = implLayout(slot, rec, vsize, mode !== 'side' && fill && !view, boxesOn, dark)
6281
+ const { framed, hidden, rect } = lay
6282
+ // 真页面换了路由(点了站内链接):比的不是这页了,红框不标,告诉右侧栏
6283
+ const [away, setAway] = useState('')
6284
+ const want = (() => { try { const u = new URL(live); return u.pathname + u.search + u.hash } catch { return '' } })()
6285
+ const wantRef = useRef(want)
6286
+ wantRef.current = want
6287
+ // 基准:开这个地址后页面自己停下的路由(项目常把 / 跳到 /login、hash 路由把 / 变成 /#/):载好后 2 秒内页面自己跳的都算基准;
6288
+ // 用户点过去的(picker 报 user)马上算换页
6289
+ const base = useRef({ path: null, at: 0 })
6290
+ useEffect(() => { setAway(''); base.current = { path: null, at: 0 } }, [live])
6291
+ useEffect(() => { if (P.current.onAway) P.current.onAway(away) }, [away])
6292
+ const onRoute = useMemo(() => (path, user) => {
6293
+ // 用户点去了另一页:新页从顶上开始,别把上一页滚到的位置套上去
6294
+ if (user) { last.current.i = { x: 0, y: 0 }; navFresh.current = true }
6295
+ const b = base.current
6296
+ if (b.path === null || (!user && Date.now() - b.at < 2000)) { base.current = { path, at: b.path === null ? Date.now() : b.at }; setAway(''); return }
6297
+ setAway(path === b.path || path === wantRef.current ? '' : path) // 切看法重载时先报一下原地址、再跳到基准:都不算换页
6298
+ }, [])
6299
+ const boxOk = lay.boxOk && !away
6300
+ useEffect(() => {
6301
+ const el = wrap.current
6302
+ if (!el || typeof ResizeObserver === 'undefined') return undefined
6303
+ const ro = new ResizeObserver(() => {
6304
+ const v = [Math.round(el.offsetWidth), Math.round(el.offsetHeight)]
6305
+ if (v[0] > 0 && v[1] > 0) setView((o) => (o && o[0] === v[0] && o[1] === v[1] ? o : v))
6306
+ })
6307
+ ro.observe(el)
6308
+ return () => ro.disconnect()
6309
+ }, [mode === 'side'])
6310
+ useEffect(() => { if (P.current.onView) P.current.onView(mode === 'side' ? null : view) }, [view, mode === 'side'])
6311
+ // 一边滚了替另一边滚(对面是我们替它滚的,不会再传回来)
6312
+ const from = (me) => (p) => {
6313
+ const at = { x: p.x, y: p.y }
6314
+ // 刚载好报的位置(多半是顶上;换看法、重载了都会重新载):这边原来滚开了就滚回原处,
6315
+ // 没滚过(刚开出来)就跟另一边对齐,不把另一边拽回去
6316
+ if (p.first && me === 'i' && navFresh.current) { navFresh.current = false; last.current.i = at; setIpos(at); return }
6317
+ if (p.first) {
6318
+ const mine = last.current[me]
6319
+ const theirs = last.current[me === 'd' ? 'i' : 'd']
6320
+ const to = mine.x || mine.y ? mine : theirs.x || theirs.y ? theirs : null
6321
+ if (to) { const a = apis.current.get(me); if (a) a.scrollTo(to.x, to.y); return }
6322
+ }
6323
+ last.current[me] = at
6324
+ if (me === 'd') setPos(at) // 红框按设计稿实际滚到哪标
6325
+ else setIpos(at)
6326
+ // 替它滚完它实际停在哪(滚到头停住):只记下,不再转给对面
6327
+ if (p.set) return
6328
+ const other = apis.current.get(me === 'd' ? 'i' : 'd')
6329
+ if (other) other.scrollTo(p.x, p.y)
6330
+ }
6331
+ const onD = useMemo(() => from('d'), [])
6332
+ const onI = useMemo(() => from('i'), [])
6333
+ const onSlot = useMemo(() => (box) => { setSlot(box); if (P.current.onSlot) P.current.onSlot(box) }, [])
6334
+ useEffect(() => { setSlot(null); last.current = { d: { x: 0, y: 0 }, i: { x: 0, y: 0 } }; setPos({ x: 0, y: 0 }); setIpos({ x: 0, y: 0 }) }, [props.designKey])
6335
+ const dragKnob = (e) => {
6336
+ const el = wrap.current
6337
+ if (!el) return
6338
+ e.preventDefault()
6339
+ const target = e.currentTarget
6340
+ try { target.setPointerCapture(e.pointerId) } catch { /* 老浏览器 */ }
6341
+ setDrag(true)
6342
+ const move = (ev) => {
6343
+ const r = el.getBoundingClientRect()
6344
+ if (r.width > 0) setCx(Math.max(0, Math.min(100, ((ev.clientX - r.left) / r.width) * 100)))
6345
+ }
6346
+ const up = () => {
6347
+ target.removeEventListener('pointermove', move)
6348
+ target.removeEventListener('pointerup', up)
6349
+ target.removeEventListener('pointercancel', up)
6350
+ setDrag(false)
6351
+ }
6352
+ target.addEventListener('pointermove', move)
6353
+ target.addEventListener('pointerup', up)
6354
+ target.addEventListener('pointercancel', up)
6355
+ move(e)
6356
+ }
6357
+ // 设计稿那边点了链接跳到别的屏:对比跟着换成那屏(屏名、分数、「重新比」都对上)
6358
+ const onDesignHref = useMemo(() => (href) => {
6359
+ if (!P.current.onDesignNav || !P.current.fileKeys) return
6360
+ let k = ''
6361
+ try { k = keyOfPath(decodeURIComponent(new URL(href).pathname), true) } catch { return }
6362
+ if (k && k !== P.current.designKey && P.current.fileKeys.includes(k)) P.current.onDesignNav(k)
6363
+ }, [])
6364
+ const design = (key, extra) => props.renderDesign({ apis: apis.current, apiKey: key, ...(key === 'd' ? { onHref: onDesignHref } : {}), ...extra })
6365
+ const implEl = () => (live
6366
+ ? h(Screen, { t, src: live, label: t('implSide'), busy: false, born: false, picking: false, dark, zoom: z, reloadSeq, apis: apis.current, apiKey: 'i', sync: SYNC_PAGE, onScrolled: onI, onRoute, ownEvents: true })
6367
+ : h('div', { className: 'miss' }, missText))
6368
+ const implLayer = (style) => (hidden ? null : h('div', { className: 'im', style: { ...rect, ...style } }, implEl()))
6369
+ // 上次比对的红框:跟着设计稿那边的滚动挪
6370
+ // 红框是顶上一屏比出来的:两边任一边滚开了就先收起(固定的顶栏不跟着滚,标了会偏)
6371
+ const top0 = (p) => Math.abs(p.x) < 2 && Math.abs(p.y) < 2
6372
+ const boxes = () => (boxOk && top0(pos) && top0(ipos) ? h('div', { className: 'bx', style: rect, 'aria-hidden': true }, ...rec.boxes.map((b, i) => h('i', { key: i, style: { left: b.x - pos.x, top: b.y - pos.y, width: b.w, height: b.h, borderWidth: Math.max(1, 2 / z) } },
6373
+ h('b', { style: { transform: `scale(${1 / z})` } }, String(i + 1))))) : null)
6374
+ const tagAt = (side) => ({ top: kind === 'app' || kind === 'miniprogram' || kind === 'tablet' ? 60 : 10, transform: `scale(${1 / z})`, transformOrigin: 'top ' + side })
6375
+ const tag = (side, k) => h('span', { className: 'tag ' + side[0], style: tagAt(side) }, t(k))
6376
+ const note = hidden ? h('div', { className: 'miss hid' }, t('implHidden', { w: slot.fw, h: slot.fh })) : null
6377
+ const dev = (children, k) => h(Device, { key: k, kind, w: size[0], h: size[1], fill, label, top, os }, children)
6378
+ if (mode === 'side') {
6379
+ return h('div', { className: 'ddp-fit', style: { width: dw * 2 + gap, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
6380
+ h('div', { className: 'ddp-iside', style: { width: dw, height: dh } },
6381
+ dev(h('div', { className: 'ddp-cmp ddp-icmp' }, h('div', { className: 'ly' }, design('d', { sync: SYNC_SLOT, onScrolled: onD, onSlot })), boxes(), tag('left', 'implDesign')), 'l')),
6382
+ h('div', { className: 'ddp-iside', style: { left: dw + gap, width: dw, height: dh } },
6383
+ dev(h('div', { className: 'ddp-cmp ddp-icmp' }, framed || hidden ? h('div', { className: 'ly' }, design('c', {})) : null, implLayer(), note, boxes(), tag('right', 'implSide')), 'r')))
6384
+ }
6385
+ const W = lock ? lock.w : dw
6386
+ const H = lock ? lock.h : dh
6387
+ const over = mode === 'overlay'
6388
+ const op = Math.max(0, Math.min(100, Number(props.opacity) || 0))
6389
+ return h('div', { className: 'ddp-fit' + (flat ? ' fill' : ''), style: flat ? undefined : { width: W, height: H, transform: `translate(-50%, -50%) scale(${z})` } },
6390
+ dev(h('div', { className: 'ddp-cmp ddp-icmp' + (drag ? ' drag' : '') + (over ? ' ov' : ''), ref: wrap },
6391
+ h('div', { className: 'ly' }, design('d', { sync: SYNC_SLOT, onScrolled: onD, onSlot })),
6392
+ over
6393
+ ? implLayer(props.diff ? { mixBlendMode: 'difference' } : { opacity: op / 100, pointerEvents: op === 0 ? 'none' : undefined })
6394
+ // 右边一层只露出把手右边那块:外层裁宽度,里面整屏往左挪(同「版本对比」);拖到最右也不卸掉真页面(再拖回来不用重载)
6395
+ : h('div', { className: 'ly r', style: { width: Math.max(0.5, 100 - cx) + '%', visibility: cx >= 100 ? 'hidden' : undefined } },
6396
+ h('div', { style: { width: (10000 / Math.max(0.5, 100 - cx)) + '%', left: (-100 * Math.min(cx, 99.5) / Math.max(0.5, 100 - cx)) + '%' } }, implLayer())),
6397
+ note,
6398
+ boxes(),
6399
+ over ? null : h('div', { className: 'ddp-knob', style: { left: cx + '%' }, onPointerDown: dragKnob }, h('i')),
6400
+ over ? null : tag('left', 'implDesign'),
6401
+ over ? null : tag('right', 'implSide')), 'one'))
6402
+ }
6403
+
6064
6404
  /** 类型菜单:网页 / App / 平板 / 海报 / 幻灯片 / 邮件 */
6065
6405
 
6066
6406
  // ── 画笔标注:一层透明画布盖在预览上,画的东西按台面上的坐标(CSS 像素)一笔一笔记着,能撤销、能擦 ──
@@ -8689,7 +9029,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8689
9029
  // x:这一次画面的值(会话、状态、类型、画幅、几屏…)、几个 ref(各屏接口、背后挂的那批、设计序号)和面板里共用的 apiOf / targetKey
8690
9030
  // onWarn:预检发现会被裁时打开导出选项
8691
9031
  function makeExporter(x) {
8692
- 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 } = x
9032
+ 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
8693
9033
  // 截一屏:图片和它的 CSS 尺寸(PDF / PPT 按这个定页面大小)
8694
9034
  // 这次导出截到的 AI 示意图(文件名去重):每种导出结束的提示里都带一句「上线前换成真实照片」
8695
9035
  const aiTail = (ai) => (ai && ai.size ? ' · ' + t('xoAi', { n: ai.size }) : '')
@@ -8857,7 +9197,40 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8857
9197
  say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
8858
9198
  }
8859
9199
  }
8860
- return { withFrames, measureAll, exportShots }
9200
+ // 整套 HTML 演示(#26):服务端把每屏连同样式、图片、图标打进一个 .html,不截图(几秒出来)。
9201
+ // 屏、版本、画幅、深浅色、调节滑块没存的值都按眼前的;外壳在演示页面里能开关
9202
+ const exportHtml = async () => {
9203
+ if (!fileTarget) return
9204
+ say(t('exporting'))
9205
+ try {
9206
+ const list = []
9207
+ const seen = new Set()
9208
+ for (const sc of shown) { // 看旧版本时 shown 就是那一版的几屏(都带 v)
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
+ })
9225
+ const file = String(r.path || '').split(/[\\/]/).pop()
9226
+ 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(() => {}) })
9228
+ } catch (e) {
9229
+ const m = String((e && e.message) || '')
9230
+ say(m === 'designChanged' || m === 'not-file' ? t('xoGone') : m === 'tooBig' ? t('htmlTooBig') : m === 'noScreens' ? t('htmlNoScreens') : t('exportFail', { msg: m }))
9231
+ }
9232
+ }
9233
+ return { withFrames, measureAll, exportShots, exportHtml }
8861
9234
  }
8862
9235
 
8863
9236
  // ── 画笔标注(从预览面板里拆出来的):台面上看得到的几屏截图拼好、叠上画的,存进 refs/ 交给模型,或者复制
@@ -9148,6 +9521,40 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9148
9521
 
9149
9522
  // ── 演示跳屏(从预览面板里拆出来的):点页面里的按钮跳到别的屏,前进从右边滑进来、返回从左边
9150
9523
  // x:setDemo、demoSeq(层的编号)、fileTarget(把链接路径换成哪一屏);开始演示、Esc 收起留在面板里
9524
+ /** 和做出来的比(#25):开真页面(按记着的 / 刚填的地址)、重新比 */
9525
+ function makeImpl(x) {
9526
+ const { sid, setImpl, setImplRun, say, t } = x
9527
+ const errOf = (e) => {
9528
+ const c = (e && e.message) || ''
9529
+ if (c === 'no-url') return ''
9530
+ return c === 'bad-url' ? t('implBadUrl') : c === 'self' ? t('implSelf') : c === 'https' ? t('implHttps') : t('implOpenFail', { msg: c })
9531
+ }
9532
+ const implLoad = (key, url) => {
9533
+ setImpl((c) => (c && c.key === key ? { ...c, busy: true, err: '' } : c))
9534
+ return post('impl', { session: sid, screen: key, ...(url ? { url } : {}) }).then(
9535
+ (d) => setImpl((c) => (c && c.key === key ? { ...c, busy: false, live: d.live || '', url: d.url || '', err: '', edit: false } : c)),
9536
+ (e) => {
9537
+ const msg = errOf(e)
9538
+ if (msg) say(msg)
9539
+ setImpl((c) => (c && c.key === key ? { ...c, busy: false, err: msg, edit: true } : c))
9540
+ })
9541
+ }
9542
+ // 照现在看的尺寸、深浅色比(看到的就是打分的)
9543
+ const implRecompare = (key, size, dark, url) => {
9544
+ setImplRun(true)
9545
+ return post('implcmp', { session: sid, screen: key, url, size: `${size[0]}x${size[1]}`, dark: !!dark })
9546
+ .then((d) => {
9547
+ if (d.error === 'stale') return // 比的时候换了设计 / 地址:这次的不算
9548
+ if (d.error) say(t('implCmpFail'))
9549
+ else if (!d.ok) say(t('implCmpHidden'))
9550
+ else if (d.rec && typeof d.rec.pct === 'number') say(t('implScore', { pct: d.rec.pct.toFixed(1) }))
9551
+ })
9552
+ .catch(() => say(t('implCmpFail')))
9553
+ .finally(() => setImplRun(false))
9554
+ }
9555
+ return { implLoad, implRecompare }
9556
+ }
9557
+
9151
9558
  function makeDemoNav(x) {
9152
9559
  const { setDemo, demoSeq, fileTarget } = x
9153
9560
  const demoGo = (path) => demoTo(keyOfPath(path, fileTarget))
@@ -9230,6 +9637,18 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9230
9637
  const [cmp, setCmp] = useState(false) // 和现在左右对比
9231
9638
  const [cx, setCx] = useState(50)
9232
9639
  const [cmpDrag, setCmpDrag] = useState(false)
9640
+ // 和做出来的比(#25):null 关着;{ key 哪一屏, live 真页面经预览服务器的地址, url 原地址, err, edit 在填地址, busy }
9641
+ const [impl, setImpl] = useState(null)
9642
+ const [implMode, setImplModeS] = useState(() => { try { const v = localStorage.getItem('ddp-impl-mode'); return v === 'overlay' || v === 'side' ? v : 'split' } catch { return 'split' } })
9643
+ const setImplMode = (v) => { setImplModeS(v); try { localStorage.setItem('ddp-impl-mode', v) } catch { /* 记不住就这次有效 */ } }
9644
+ const [implOp, setImplOp] = useState(50) // 叠加时真页面的不透明度
9645
+ const [implDiff, setImplDiff] = useState(false) // 叠加时反色(一样的地方发黑)
9646
+ const [implBoxes, setImplBoxes] = useState(true) // 标出上次比对的红框
9647
+ const [implRun, setImplRun] = useState(false) // 正在重新比
9648
+ const [implSlot, setImplSlot] = useState(null) // 设计稿外框里 main 槽位在哪(没套外框为 null)
9649
+ const [implShot, setImplShot] = useState('') // 在看上次比对的拼图:图片地址
9650
+ const implView = useRef(null) // 对比里设计稿眼前多大(网页铺满时不是画幅):「重新比」照这个比
9651
+ const [implAway, setImplAway] = useState('') // 真页面换到了别的路由(点了站内链接):那条路由
9233
9652
  const [dark, setDark] = useState(false)
9234
9653
  const [phone, setPhone] = useState(false) // 手机上看的面板
9235
9654
  const [multi, setMulti] = useState(false) // 多尺寸并排
@@ -9557,7 +9976,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9557
9976
  }
9558
9977
  // 设计库来的设计里点了站外链接 / 下载:拦下了
9559
9978
  useEffect(() => {
9560
- const f = (href) => showFlash(href === 'download' ? t('blockedDownload') : t('blockedLink', { href: href.replace(/^https?:\/\//, '').slice(0, 40) }))
9979
+ const f = (href, sync) => showFlash(href === 'download' ? t('blockedDownload') : t(sync ? 'implBlocked' : 'blockedLink', { href: href.replace(/^https?:\/\//, '').slice(0, 40) }))
9561
9980
  blockedSubs.add(f)
9562
9981
  return () => { blockedSubs.delete(f) }
9563
9982
  }, [])
@@ -9785,6 +10204,76 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9785
10204
  }
9786
10205
  // 演示里跳屏、返回、从头来(makeDemoNav)
9787
10206
  const { demoGo, demoTo, demoRestart, demoBack, demoShown, demoHref } = makeDemoNav({ setDemo, demoSeq, fileTarget })
10207
+ const { implLoad, implRecompare } = makeImpl({ sid, setImpl, setImplRun, say, t })
10208
+ // 和做出来的比:在比哪一屏(看旧版本时不比)、那屏记着的地址和上次的分数
10209
+ const implSc = impl && !ver ? screens.find((x) => x.key === impl.key) || null : null
10210
+ // 远程看(手机 / 别的电脑开的 DSH 网页):做出来的页面在这台电脑的 localhost 上,那边打不开,不给进
10211
+ const implFar = (() => { try { return /^https?:$/.test(location.protocol) && !LOCAL_HOST.test(location.hostname) } catch { return false } })()
10212
+ const implMap = (st && st.impl) || null
10213
+ const implRec = impl && implMap ? implMap[impl.key] || null : null
10214
+ const implOpen = (key) => {
10215
+ if (!key || !screens.some((x) => x.key === key)) return
10216
+ setPicking(false)
10217
+ setTextEdit(false)
10218
+ setStyleEdit(false)
10219
+ markRun.current++
10220
+ setMark(false)
10221
+ setDemo(null)
10222
+ setMulti(false)
10223
+ setCmp(false)
10224
+ setVer(null)
10225
+ setImplSlot(null)
10226
+ setImplShot('')
10227
+ setImplAway('')
10228
+ setImpl({ key, live: '', url: '', err: '', edit: false, busy: true })
10229
+ implLoad(key)
10230
+ }
10231
+ const implClose = () => { setImpl(null); setImplShot(''); setImplAway('') }
10232
+ // 这屏还没记地址:先填上别的屏用过的开发服务器(同一个项目多半是同一个端口)
10233
+ const implGuess = () => {
10234
+ for (const k of Object.keys(implMap || {})) {
10235
+ try { const u = new URL(implMap[k].url); if (/^https?:$/.test(u.protocol)) return u.origin + '/' } catch { /* 不认识的地址 */ }
10236
+ }
10237
+ return ''
10238
+ }
10239
+ // 模型拿别的地址比过了:换成那个页面
10240
+ const implRecUrl = implRec ? implRec.url : ''
10241
+ useEffect(() => { if (impl && implRecUrl && impl.url && implRecUrl !== impl.url && !impl.edit) implLoad(impl.key) }, [implRecUrl])
10242
+ // 改地址时模型换了地址、用户又按 Esc 取消:收起输入框时换过去(画面和分数要对得上)
10243
+ const implCancel = () => { if (impl && implRecUrl && impl.url && implRecUrl !== impl.url) implLoad(impl.key); else setImpl((c) => (c ? { ...c, edit: false } : c)) }
10244
+ // 那一屏没了、开始看旧版本:退出对比
10245
+ const keysSig = screens.map((x) => x.key).join('\n')
10246
+ useEffect(() => { if (impl && st && (ver || !screens.some((x) => x.key === impl.key))) implClose() }, [keysSig, !!ver])
10247
+ // 模型刚调过 compare_design:提示一声,点「看对比」打开(正在比的就是这屏时不用提示)
10248
+ const implSeen = useRef(null)
10249
+ const implWhoWas = useRef('')
10250
+ const implSig = implMap ? Object.keys(implMap).map((k) => k + ':' + implMap[k].when).join('|') : ''
10251
+ const implWho = st && st.target ? `${st.target.kind}:${st.target.root || st.target.port || ''}` : ''
10252
+ useEffect(() => {
10253
+ if (!implMap) return
10254
+ const prev = implSeen.current
10255
+ const now = {}
10256
+ for (const k of Object.keys(implMap)) now[k] = implMap[k].when
10257
+ implSeen.current = { who: implWho, now }
10258
+ if (!prev || prev.who !== implWho) return
10259
+ const fresh = Object.keys(implMap).filter((k) => implMap[k].by === 'model' && typeof implMap[k].pct === 'number' && implMap[k].when > (prev.now[k] || 0))
10260
+ if (!fresh.length || (impl && fresh.includes(impl.key))) return
10261
+ const k = fresh[fresh.length - 1]
10262
+ const sc = screens.find((x) => x.key === k)
10263
+ say(t('implDone', { name: sc ? dropBrand(shortOf(sc)) : k, pct: implMap[k].pct.toFixed(1) }), implFar ? undefined : { label: t('implSee'), run: () => implOpen(k) })
10264
+ }, [implSig, implWho])
10265
+ // 换了一个设计:关掉对比(同名的屏是另一个设计的,记着的地址、分数也是另一份)
10266
+ useEffect(() => {
10267
+ const was = implWhoWas.current
10268
+ if (implWho) implWhoWas.current = implWho
10269
+ if (was && implWho && was !== implWho && impl) implClose()
10270
+ }, [implWho])
10271
+ useEffect(() => {
10272
+ if (!impl) return undefined
10273
+ const onKey = (e) => { if (e.key === 'Escape' && !overlayUp() && !e.defaultPrevented) { if (implShot) setImplShot(''); else implClose() } }
10274
+ window.addEventListener('keydown', onKey)
10275
+ return () => window.removeEventListener('keydown', onKey)
10276
+ }, [!!impl, implShot])
9788
10277
  useEffect(() => {
9789
10278
  if (!demo) return undefined
9790
10279
  const onKey = (e) => { if (e.key === 'Escape' && !overlayUp()) setDemo(null) }
@@ -9858,7 +10347,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9858
10347
  return api
9859
10348
  }
9860
10349
  // ── 导出图片(makeExporter)──
9861
- const { withFrames, measureAll, exportShots } = makeExporter({ apiOf, targetKey, 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,
10350
+ // 在和做出来的比:导出的「这一屏」是比的那屏,画布没挂着(别的屏在背后挂)
10351
+ const { withFrames, measureAll, exportShots, exportHtml } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, tops, tweak, webFit,
9862
10352
  onWarn: () => { if (pane !== 'export') openPane('export') } })
9863
10353
  const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
9864
10354
  if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
@@ -9867,6 +10357,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9867
10357
  if (mode === 'opts') { if (pane !== 'export') openPane('export'); return }
9868
10358
  if (mode === 'zip') return openPack(fileTarget ? st.target.root : '')
9869
10359
  if (mode === 'share') return openShare(fileTarget ? st.target.root : '')
10360
+ if (mode === 'html') return exportHtml()
9870
10361
  return exportShots(mode, key, opts)
9871
10362
  }
9872
10363
 
@@ -9994,7 +10485,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9994
10485
  }, 1500)
9995
10486
  return () => clearTimeout(timer)
9996
10487
  }, [ckReq])
9997
- const checkOff = !url || !!ver || !!demo || inMulti
10488
+ const checkOff = !url || !!ver || !!demo || inMulti || !!implSc
9998
10489
  // ── 业务标注(插件页的试验开关开着才有 st.annotations 这个键):面板和体检、版本共用右边那个位置;点选、改字、调样式、画笔时编号收起,退出后回来 ──
9999
10490
  useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
10000
10491
  const toggleAn = () => {
@@ -10027,10 +10518,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10027
10518
  const k = Math.max(1, f.offsetWidth) / Math.max(1, r.width)
10028
10519
  api.annotHit((x - r.left) * k, (y - r.top) * k)
10029
10520
  }
10030
- const styleOff = !url || !!ver || !!demo || inMulti || busy
10521
+ const styleOff = !url || !!ver || !!demo || inMulti || busy || !!implSc
10031
10522
 
10032
10523
  // ── 画笔标注:画完把台面上看得到的几屏各截一张,按位置摆好,叠上画的东西,存进 refs/,路径放进输入框让模型用 read_image 看(不动剪贴板) ──
10033
- const markOff = !url || !!ver || !!demo || inMulti
10524
+ const markOff = !url || !!ver || !!demo || inMulti || !!implSc
10034
10525
  const toggleMark = () => {
10035
10526
  markRun.current++
10036
10527
  if (mark) { setMark(false); return }
@@ -10123,7 +10614,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10123
10614
  // 右上 外观 体检 | 导出 ▾ ⋯;底部中间 选择 改字 样式 画笔 | 试用;右下缩放(画布自己带)
10124
10615
  // 鼠标停一下出说明卡(HoverTip):名字 + 一句用途
10125
10616
  // 窄了(样式表里):先截屏名,再收字
10126
- const curKey = canvas ? '' : (focus || (screens[0] && screens[0].key) || '')
10617
+ const curKey = implSc ? implSc.key : canvas ? '' : (focus || (screens[0] && screens[0].key) || '') // 在和做出来的比:是比的那屏
10127
10618
  const curSc = screens.find((x) => x.key === curKey)
10128
10619
  // 产品名:画布上几屏标题都带它时认得出来;单页只拿得到一屏的标题,用记下的那个把它去掉(「订单 · 巷口面馆」→「订单」)
10129
10620
  const brand0 = splitTitles(shown.map(labelOf)).brand
@@ -10135,22 +10626,23 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10135
10626
  return p.length >= 2 && (p[0] === brand || p[p.length - 1] === brand) ? p.filter((y) => y !== brand).join(' · ') : x
10136
10627
  }
10137
10628
  const stLabel = (st && st.label) || ''
10138
- const scrLabel = canvas && screens.length > 1
10629
+ const scrLabel = canvas && screens.length > 1 && !implSc
10139
10630
  ? t('screensN', { name: brand || stLabel, n: screens.length })
10140
10631
  : curSc ? dropBrand(shortOf(curSc)) + (takeTag(curSc) ? ' · ' + takeTag(curSc) : '') : stLabel
10141
10632
  // 菜单里点某一屏:单看这一屏(「全部 n 屏」回画布)
10142
10633
  const pickScreen = (key) => {
10634
+ if (implSc) { implOpen(key); return } // 在和做出来的比:换成比这一屏
10143
10635
  setMulti(false)
10144
10636
  if (demo) setDemo(null)
10145
10637
  setSel(key)
10146
10638
  if (canvas || key !== focus || dr) openByUser(key)
10147
10639
  }
10148
10640
  // 导出菜单写出是哪一屏(和 doExport 取同一屏)
10149
- const exSc = shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
10641
+ const exSc = implSc || shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
10150
10642
  const exName = exSc ? dropBrand(shortOf(exSc)) + (takeTag(exSc) ? ' · ' + takeTag(exSc) : '') : ''
10151
10643
  const libOpen = () => { setLibFocus(''); if (lib) setLib(''); else libDefaultThen((k) => setLib((c) => c || k)) }
10152
- const onCanvas = canvas && !inMulti && !demo && homeAt !== 'on' && !(ver && cmp)
10153
- const toCanvas = () => { homeAway(); setMulti(false); setCmp(false); if (demo) setDemo(null); change({ view: 'canvas' }) }
10644
+ const onCanvas = canvas && !inMulti && !demo && homeAt !== 'on' && !(ver && cmp) && !implSc
10645
+ const toCanvas = () => { homeAway(); setMulti(false); setCmp(false); implClose(); if (demo) setDemo(null); change({ view: 'canvas' }) }
10154
10646
  const dockTight = box.w > 0 && box.w <= 400 // 侧栏很窄:底部工具坞只放得下四个,「试用」进「更多」
10155
10647
  const tool = (cls, on, desc, off, run, Icon, label) => h('button', { className: 'ddp-tool' + (cls ? ' ' + cls : '') + (on ? ' on' : ''), ...tipA(label, desc, on ? 'Esc' : ''), 'aria-pressed': !!on, disabled: !!off, onClick: run }, h(Icon), h('span', null, label))
10156
10648
  const islands = editing
@@ -10163,9 +10655,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10163
10655
  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'))),
10164
10656
  h('button', { className: 'ddp-btn lab' + (onCanvas ? ' sel' : ''), ...tipA(t('canvasShort'), t('dCanvas')), 'aria-pressed': onCanvas, disabled: !url, onClick: toCanvas }, h(I.canvas), h('span', { className: 'lb' }, t('canvasShort'))),
10165
10657
  h('span', { className: 'ddp-sep' }),
10166
- 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,
10658
+ 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 && !implSc, open: scrMenu, setOpen: setScrMenu,
10167
10659
  onPick: pickScreen, onAll: toCanvas, onOther: () => setEditing(true),
10168
- sizes: mark ? null : { on: inMulti, off: !sizeSet || !!ver, tip: sizeSet ? t('sizes') : t('sizesNo'), note: sizeSet ? '' : t('sizesNoShort'), run: () => setMulti(!inMulti) },
10660
+ sizes: mark ? null : { on: inMulti, off: !sizeSet || !!ver, tip: sizeSet ? t('sizes') : t('sizesNo'), note: sizeSet ? '' : t('sizesNoShort'), run: () => { if (implSc) implClose(); setMulti(!inMulti) } },
10169
10661
  fit: kind === 'web' && !mark ? { on: webFit, note: size.join('×'), run: toggleFit } : null,
10170
10662
  kind, onKind: mark ? null : (k) => change({ kind: k }),
10171
10663
  // 自定义画幅(#23):外框类型的画幅跟着外框走,不让改
@@ -10181,14 +10673,16 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10181
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: [
10182
10674
  'hd:' + t('deliverCode'),
10183
10675
  ['', I.code, t('handoff'), pane === 'handoff', !!ver, () => openPane('handoff')],
10676
+ ['', I.overlay, t('implCmp'), !!implSc, !!ver || !exSc || implFar, () => (implSc ? implClose() : implOpen(exSc.key))],
10184
10677
  'hd:' + t('exFiles'),
10185
10678
  ...exportItems(t, kind, shown.length, exName).map(([mode, Icon, label]) => ['', Icon, label, false, false, () => doExport(mode)]),
10679
+ fileTarget ? ['', I.web, t('exHtml'), false, false, () => doExport('html')] : null, // 只有本地文件的设计能打成 HTML(开发服务器的页面靠它跑)
10186
10680
  fileTarget ? 'hd:' + t('deliverShare') : null, // 只有本地的设计才能打包、分享
10187
10681
  fileTarget ? ['', I.box, t('exZip'), false, false, () => doExport('zip')] : null,
10188
10682
  fileTarget ? ['', I.share, t('exShare'), false, false, () => doExport('share')] : null,
10189
10683
  ], foot: t('exWhere') }),
10190
10684
  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: [
10191
- dockTight ? ['', I.play, t('demoShort'), !!demo, !url || !!ver, toggleDemo] : null, // 侧栏太窄,底部工具坞放不下「试用」:挪到这里
10685
+ dockTight ? ['', I.play, t('demoShort'), !!demo, !url || !!ver, () => { if (implSc) implClose(); toggleDemo() }] : null, // 侧栏太窄,底部工具坞放不下「试用」:挪到这里
10192
10686
  dockTight ? 'sep' : null,
10193
10687
  ['', I.history, t('history'), hist || !!ver, !fileTarget, toggleHist],
10194
10688
  ['', I.scan, t('phone'), phone, !url, togglePhone, phoneOn ? t('phoneOnShort') : ''],
@@ -10197,7 +10691,16 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10197
10691
  ['', I.refresh, t('refresh'), false, false, reload],
10198
10692
  ['', I.external, t('external'), false, !url, url],
10199
10693
  ] }))),
10200
- h('div', { key: 'dock', className: 'ddp-isl ddp-dock', role: 'toolbar', 'aria-label': t('toolsT') },
10694
+ implSc ? h('div', { key: 'dock', className: 'ddp-isl ddp-dock ddp-ibar', role: 'toolbar', 'aria-label': t('implCmp') },
10695
+ tool('', implMode === 'split', t('dImplSplit'), false, () => setImplMode('split'), I.splitV, t('implSplit')),
10696
+ tool('', implMode === 'overlay', t('dImplOver'), false, () => setImplMode('overlay'), I.overlay, t('implOver')),
10697
+ tool('', implMode === 'side', t('dImplSide'), false, () => setImplMode('side'), I.sideBy, t('implSideBy')),
10698
+ implMode === 'overlay' ? h('span', { className: 'ddp-sep' }) : null,
10699
+ implMode === 'overlay' ? h('label', { className: 'ddp-iop', ...tipA(t('implOp'), t('dImplOp')) }, h('input', { type: 'range', min: 0, max: 100, step: 5, value: implOp, disabled: implDiff, 'aria-label': t('implOp'), onChange: (e) => setImplOp(Number(e.target.value)) }), h('span', null, implDiff ? '—' : implOp + '%')) : null,
10700
+ implMode === 'overlay' ? tool('', implDiff, t('dImplDiff'), false, () => setImplDiff(!implDiff), I.invert, t('implDiff')) : null,
10701
+ implRec && Array.isArray(implRec.boxes) && implRec.boxes.length ? h('span', { className: 'ddp-sep' }) : null,
10702
+ implRec && Array.isArray(implRec.boxes) && implRec.boxes.length ? tool('', implBoxes, t('dImplBoxes'), false, () => setImplBoxes(!implBoxes), I.boxes, t('implBoxes')) : null)
10703
+ : h('div', { key: 'dock', className: 'ddp-isl ddp-dock', role: 'toolbar', 'aria-label': t('toolsT') },
10201
10704
  tool('pick', picking, t('dPick'), !url || !!ver || !!demo || mark, togglePick, I.pick, t('pick')),
10202
10705
  tool('', textEdit, t('dText'), !url || !!ver || !!demo || busy || mark, toggleText, I.text, t('textShort')),
10203
10706
  tool('', styleEdit, t('dStyle'), styleOff || mark, toggleStyle, I.sliders, t('styleShort')),
@@ -10447,7 +10950,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10447
10950
  return h(ExportPanel, { t, kind, size, opts: xo, setOpts: setXo, screens: shown.map(ik).join('|'), rev: `${st ? st.rev : 0}|${reloadSeq}|${loadTick}`, measure: () => withFrames(measureAll), onResize: (s) => change({ size: s }), onExport: (format) => doExport(format, undefined, xo), onClose: () => setPane('') })
10448
10951
  }
10449
10952
  if (pane === 'handoff') {
10450
- return h(HandoffPanel, { t, sid, root: fileTarget ? st.target.root : '', fileTarget, count: screens.length, cur: (curScreen && curScreen.key) || focus, onGo: doHandoff, onSay: say, onClose: () => setPane('') })
10953
+ 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('') })
10451
10954
  }
10452
10955
  return null
10453
10956
  }
@@ -10554,7 +11057,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10554
11057
 
10555
11058
  // 上下两排浮块中间那块的高度:单页、演示、对比按它缩放
10556
11059
  const ah = Math.max(0, box.h - TOP_R - BOT_R)
10557
- const cvBody = !demo && (inMulti || (canvas && !(ver && cmp)))
11060
+ const cvBody = !demo && (inMulti || (canvas && !(ver && cmp) && !implSc))
10558
11061
  let body
10559
11062
  let busyGap = false
10560
11063
  // 单看、演示、对比共用:网页铺满右侧栏(没开「按画幅显示」时),别的按画幅整屏缩放
@@ -10629,19 +11132,37 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10629
11132
  onTop: (dk) => setTop(ik(base) + '|' + i, dk),
10630
11133
  })),
10631
11134
  })
10632
- } else if (ver && cmp) {
10633
- // 对比:同一屏,左边那一版、右边现在,中间的把手左右拖
10634
- const k = canvas ? sel || focus : focus
10635
- const now = screens.find((x) => x.key === k) || screens[0]
10636
- const has = now && ver.screens.includes(now.key)
10637
- const old = now ? { key: now.key, id: `v${ver.n}|${now.key}`, v: ver.n, url: vbase + encodeURIComponent(now.key), label: now.label } : null
10638
- // 右边开着版本面板:手机这类有外框的让到面板左边(和单看时一样)
11135
+ } else if ((ver && cmp) || implSc) {
11136
+ // 对比:同一屏,左边那一版、右边现在,中间的把手左右拖;和做出来的比(#25)也按这个摆
11137
+ // 右边开着面板:手机这类有外框的让到面板左边(和单看时一样)
10639
11138
  const cmpSide = !!(ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240
10640
- // 网页铺满时也让(#22):按铺满时的大小定住(上面有版本横幅,少 46),整体缩到面板左边,不重排
11139
+ // 网页铺满时也让(#22):按铺满时的大小定住(上面有横幅,少 46),整体缩到面板左边,不重排
10641
11140
  const cmpLock = fill && cmpSide ? { w: box.w, h: ah - 46 } : null
10642
11141
  const aside = cmpSide && (!fill || cmpLock) ? 296 : 0
10643
11142
  const flat = fill && !cmpLock
10644
- const z = cmpLock ? Math.max(0.05, Math.min(1, (box.w - aside - 32) / cmpLock.w)) : fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - (ver ? 46 : 0)) / dh))
11143
+ const z = cmpLock ? Math.max(0.05, Math.min(1, (box.w - aside - 32) / cmpLock.w)) : fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - 46) / dh))
11144
+ if (implSc) {
11145
+ // 并排:两个按画幅并排缩进来(铺满的网页也按画幅,不然两边各占一半宽、和设计的尺寸对不上)
11146
+ const side = implMode === 'side'
11147
+ const GAP = 24
11148
+ const zs = Math.max(0.05, Math.min(1, (box.w - aside - 32 - GAP) / (dw * 2), (ah - 16 - 46) / dh))
11149
+ const sc = implSc
11150
+ body = h('div', { className: 'ddp-single', style: aside ? { right: aside } : undefined },
11151
+ h(ImplCompare, {
11152
+ t, mode: implMode, live: impl.live, z: side ? zs : z, flat: side ? false : flat, lock: side ? null : cmpLock, dw, dh, gap: GAP,
11153
+ kind, size, os: meta.os, label: labelOf(sc), top: tops[ik(sc)], rec: implRec, boxesOn: implBoxes, dark, reloadSeq,
11154
+ opacity: implOp, diff: implDiff, designKey: sc.key, onSlot: setImplSlot, onView: (v) => { implView.current = v }, onAway: setImplAway,
11155
+ fileKeys: fileTarget ? screens.map((x) => x.key) : null, onDesignNav: implOpen,
11156
+ missText: impl.busy ? t('implOpening') : t('implNeed'),
11157
+ renderDesign: (extra) => h(Screen, { t, remote, onPageDrag: pageDrag, src: sc.url, label: labelOf(sc), busy: false, born: false, picking: false, dark, zoom: side ? zs : z, reloadSeq, tweak,
11158
+ onMeta: (m, title, toks, dk) => remember(ik(sc), m, title, toks, dk), onTop: (dk) => setTop(ik(sc), dk), ...extra,
11159
+ ...(extra.apiKey === 'd' ? { alsoApis: apis.current, alsoKey: ik(sc) } : {}) }),
11160
+ }))
11161
+ } else {
11162
+ const k = canvas ? sel || focus : focus
11163
+ const now = screens.find((x) => x.key === k) || screens[0]
11164
+ const has = now && ver.screens.includes(now.key)
11165
+ const old = now ? { key: now.key, id: `v${ver.n}|${now.key}`, v: ver.n, url: vbase + encodeURIComponent(now.key), label: now.label } : null
10645
11166
  // 两边的小标签不跟着画面缩小(缩了看不清);手机、平板躲开状态栏
10646
11167
  const tagAt = (side) => ({ top: kind === 'app' || kind === 'miniprogram' || kind === 'tablet' ? 60 : 10, transform: `scale(${1 / z})`, transformOrigin: 'top ' + side })
10647
11168
  const screenOf = (sc) => h(Screen, { t, remote, onPageDrag: pageDrag, src: sc.url, label: labelOf(sc), busy: false, born: false, picking: false, dark, zoom: z, reloadSeq,
@@ -10658,6 +11179,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10658
11179
  h('div', { className: 'ddp-knob', style: { left: cx + '%' }, onPointerDown: dragKnob }, h('i')),
10659
11180
  h('span', { className: 'tag l', style: tagAt('left') }, t('vN', { n: ver.n })),
10660
11181
  h('span', { className: 'tag r', style: tagAt('right') }, t('cmpNow')))) : null))
11182
+ }
10661
11183
  } else if (canvas) {
10662
11184
  body = h(Canvas, {
10663
11185
  key: 'grid',
@@ -10719,7 +11241,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10719
11241
 
10720
11242
  return root(
10721
11243
  h('div', { className: 'ddp-stage isl' + (busy ? ' bz' : '') + (anOn ? ' an3' : ''), ref: stageRef },
10722
- h('div', { className: 'ddp-body' + (cvBody ? '' : ' pad' + (ver || demo || hintTop || busyGap ? ' vb' : '') + (ease ? ' ease' : '')) }, body),
11244
+ h('div', { className: 'ddp-body' + (cvBody ? '' : ' pad' + (ver || demo || implSc || hintTop || busyGap ? ' vb' : '') + (ease ? ' ease' : '')) }, body),
10723
11245
  busy ? h('div', { className: 'ddp-glow' }) : null,
10724
11246
  busy ? h('div', { className: 'ddp-ring' }) : null,
10725
11247
  busy ? busyBar(sideOpen) : null,
@@ -10810,8 +11332,26 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10810
11332
  h('button', { className: 'ddp-go sec' + (cmp ? ' on' : ''), onClick: () => setCmp(!cmp) }, t('compare')),
10811
11333
  h('button', { className: 'ddp-go pri', onClick: doRestore }, t('restore')),
10812
11334
  h('button', { className: 'ddp-btn', title: t('backNow'), onClick: () => { setVer(null); setCmp(false) } }, h(I.close))) : null,
11335
+ implSc ? h('div', { className: 'ddp-banner ddp-ibn' + side },
11336
+ h(I.overlay),
11337
+ h('b', null, t('implShort')),
11338
+ !impl.edit && !impl.url && impl.busy ? h('span', { className: 'nm' }, t('implOpening'))
11339
+ : impl.edit || !impl.url
11340
+ ? h(ImplUrlForm, { key: impl.key, t, initial: impl.url || implGuess(), busy: impl.busy, onGo: (v) => implLoad(impl.key, v), onCancel: impl.url ? implCancel : null })
11341
+ : h('button', { className: 'ddp-iurl', ...tipA(impl.url, t('dImplUrl')), onClick: () => setImpl((c) => (c ? { ...c, edit: true } : c)) }, impl.url.replace(/^https?:\/\//, '').replace(/^file:\/\/.*\//, '')),
11342
+ implAway && impl.url && !impl.edit
11343
+ ? h('button', { className: 'ddp-go', ...tipA(t('implHere'), t('dImplHere', { path: implAway })), onClick: () => { try { implLoad(impl.key, implAwayUrl(impl, implAway)) } catch { /* 认不出的地址 */ } } }, t('implHere'))
11344
+ : implRec && typeof implRec.pct === 'number' && !impl.edit
11345
+ ? h('button', { className: 'ddp-iscore' + (implRec.pct < 3 ? ' ok' : ''), ...tipA(t('implPct', { pct: implRec.pct.toFixed(1) }), t('dImplPct', { time: hhmm(implRec.when), who: implRec.by === 'model' ? t('implByModel') : t('implByYou') })),
11346
+ onClick: () => setImplShot(`${API}implshot?session=${encodeURIComponent(sid)}&screen=${encodeURIComponent(impl.key)}&v=${implRec.when}`) }, t('implPct', { pct: implRec.pct.toFixed(1) }))
11347
+ : null,
11348
+ impl.url && !impl.edit && !implAway ? h('button', { className: 'ddp-go sec', disabled: implRun, ...tipA(t('implRe'), t('dImplRe')), onClick: () => implRecompare(impl.key, (implMode !== 'side' && implView.current) || size, dark, impl.url) }, implRun ? t('implRunning') : t('implRe')) : null,
11349
+ h('button', { className: 'ddp-btn', ...tipA(t('implExit'), '', 'Esc'), onClick: implClose }, h(I.close))) : null,
11350
+ implShot ? h('div', { className: 'ddp-ishot', role: 'dialog', 'aria-label': t('implShotT'), onClick: () => setImplShot('') },
11351
+ h('img', { src: implShot, alt: t('implShotT'), onError: () => { setImplShot(''); say(t('implShotGone')) } }),
11352
+ h('span', null, t('implShotHow'))) : null,
10813
11353
  chip,
10814
- toast ? h('div', { className: 'ddp-toast' + (mark ? ' mk' : ver || demo ? ' low' : '') + (sideOpen && !mark ? ' side' : ''), role: 'status' }, h('span', null, toast.text),
11354
+ toast ? h('div', { className: 'ddp-toast' + (mark ? ' mk' : ver || demo || implSc ? ' low' : '') + (sideOpen && !mark ? ' side' : ''), role: 'status' }, h('span', null, toast.text),
10815
11355
  toast.act ? h('button', { onClick: () => { toast.act.run(); setToast('') } }, toast.act.label) : null) : null,
10816
11356
  ...islands,
10817
11357
  h(HoverTip, { key: 'tip' })))
@@ -10940,7 +11480,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10940
11480
  // 注意:这里是客户端**服务名**(短的),不是包名
10941
11481
  exports.inject = INJECT
10942
11482
  // 测试用
10943
- exports._test = { makeDemoNav, 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 }
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 }
10944
11484
  return module.exports
10945
11485
  },
10946
11486
  })