dsh-design-studio 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +313 -31
- package/lib/doc.js +118 -46
- package/lib/index.js +29 -9
- package/lib/look.js +32 -2
- package/lib/picker.js +275 -3
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -42,7 +42,7 @@ If DSH can't reach the npm registry, it falls back to a mirror in China. To upda
|
|
|
42
42
|
- **Open what you have:** click "Browse…" on the empty page to pick an HTML file, or drop an HTML file or folder onto the sidebar (desktop app); you can also type a path or a dev-server port.
|
|
43
43
|
- **Design check:** one click finds overflowing text, low contrast, small tap targets and tiny text, marked right on the page. In Design mode the model also checks its own work and fixes what it finds.
|
|
44
44
|
- **Versions and compare:** every turn is saved; drag a slider to compare, and go back to any version.
|
|
45
|
-
- **Export and phone preview:** showcase images, PDF and PowerPoint (links between screens still work); scan a QR code to see it on your phone at real size.
|
|
45
|
+
- **Export and phone preview:** showcase images, PDF and PowerPoint (links between screens still work); scan a QR code to see it on your phone at real size. Slides and posters larger than the default canvas now use the page's real size. You can also set it by adding `WIDTHxHEIGHT` after the type, for example `<meta name="dsh-design" content="slides 1440x810">`. Export options let you pick the page size (16:9, 4:3, A3 landscape or custom), what each page shows (one screen, full page or a set height) and two screens per page. If anything would be cut off, you get a checklist first, with a one-click fix that fits the canvas to the content.
|
|
46
46
|
- **Design library and gallery:** everything you've designed, plus saved references and styles, lives in the Library. Browse templates, design systems and style cards others shared, and "Start from this" copies one for you to keep editing. Share your own with "Share to the gallery": it's checked, zipped and submitted on a web page, and listed once reviewed. The gallery catalog comes from npm mirrors and is used only when its signature and checksums match; to keep it offline, turn on "Design library offline" on the Plugins page.
|
|
47
47
|
- **Your brand, and real code:** give a site URL to extract a brand design system and design with it from then on; turn a finished design into React / Vue / HTML (mini programs straight into uni-app or native WeChat code, HBuilderX projects included), compared screen by screen against the design.
|
|
48
48
|
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
- **打开已有的页面**:首页输入框左边的「+」→「打开已有的 HTML…」选一个,或把 HTML 文件 / 文件夹拖进右侧栏就能预览(桌面版);也能输路径或开发服务器端口。
|
|
43
43
|
- **设计体检**:一键查文字溢出、对比度不够、按钮太小、字太小,问题直接标在页面上;模型做完也会自己查一遍再改。
|
|
44
44
|
- **版本和对比**:每轮自动存一版,左右拖动对比,随时回到任意一版。
|
|
45
|
-
- **导出和手机上看**:导出展示图、PDF、PPT
|
|
45
|
+
- **导出和手机上看**:导出展示图、PDF、PPT(屏和屏之间的跳转照样能点);扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
|
|
46
46
|
- **设计库和设计市场**:以前做过的设计、收的参考图和风格都在「设计库」里;市场里逛大家分享的模板、设计系统和风格卡,点「用这个开始」复制一份接着改。自己做的点「分享到设计市场」,查过打成 zip,在网页里交上去,审过就上架。市场目录从 npm 镜像取,签了名、核对过才用;不想让它联网,在插件页打开「设计库不联网」。
|
|
47
47
|
- **照品牌风格做、转成代码**:给官网地址,提一套品牌设计系统,以后都照它做;做好的设计转成 React / Vue / HTML,小程序直接转成 uni-app 或原生小程序代码(HBuilderX 建的项目也认得出),逐屏和设计稿比对。
|
|
48
48
|
|
package/lib/client.js
CHANGED
|
@@ -183,6 +183,39 @@ window.__ModuleLoader__.load({
|
|
|
183
183
|
exShow: '整套展示图',
|
|
184
184
|
exPdf: 'PDF · 每屏一页',
|
|
185
185
|
exPptx: 'PPT · 每屏一页(整页图片)',
|
|
186
|
+
exOpts: '导出选项…',
|
|
187
|
+
exportedDocMiss: '已导出 {name}({n} 页,{miss} 屏没截到)',
|
|
188
|
+
xoTitle: '导出选项',
|
|
189
|
+
xoTip: '不动这里,导出的结果和直接导出一样。',
|
|
190
|
+
xoWarn: '有内容会被裁掉,先看一眼',
|
|
191
|
+
xoChecking: '正在量页面…',
|
|
192
|
+
xoClean: '没有会被裁掉的内容。',
|
|
193
|
+
xoOver: '{n} 个页面比画幅大,会被裁',
|
|
194
|
+
xoLong: '{n} 个页面是长页,只会截首屏',
|
|
195
|
+
xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
|
|
196
|
+
xoLongH: '{n} 个页面比指定高度长,下面会被裁',
|
|
197
|
+
xoDead: '{n} 个链接点了可能没反应',
|
|
198
|
+
xoFail: '{n} 屏没量到,结果可能不全',
|
|
199
|
+
xoAgain: '重新检查',
|
|
200
|
+
xoGone: '设计换了,这次导出取消了',
|
|
201
|
+
xoResize: '按内容改画幅({size})',
|
|
202
|
+
xoFull: '取景改成整页',
|
|
203
|
+
xoLayout: '版面',
|
|
204
|
+
xoAuto: '跟随画幅',
|
|
205
|
+
xoA3: 'A3 横向',
|
|
206
|
+
xoCustom: '自定义',
|
|
207
|
+
xoCustomPh: '宽x高,比如 1920x1080',
|
|
208
|
+
xoView: '每页取景',
|
|
209
|
+
xoViewAuto: '自动',
|
|
210
|
+
xoViewOne: '一屏',
|
|
211
|
+
xoViewPage: '整页',
|
|
212
|
+
xoViewH: '指定高度',
|
|
213
|
+
xoViewHPh: '高度(像素),比如 1200',
|
|
214
|
+
xoCols: '拼版',
|
|
215
|
+
xoCols1: '每页 1 屏',
|
|
216
|
+
xoCols2: '每页 2 屏',
|
|
217
|
+
xoPdf: '导出 PDF',
|
|
218
|
+
xoPpt: '导出 PPT',
|
|
186
219
|
exWhere: '存到设计目录的 exports/;图片还会复制到剪贴板',
|
|
187
220
|
exportedDoc: '已导出 {name}({n} 页)',
|
|
188
221
|
check: '设计体检',
|
|
@@ -952,6 +985,39 @@ window.__ModuleLoader__.load({
|
|
|
952
985
|
exShow: 'Showcase of all screens',
|
|
953
986
|
exPdf: 'PDF · one page per screen',
|
|
954
987
|
exPptx: 'PowerPoint · one slide per screen (as images)',
|
|
988
|
+
exOpts: 'Export options…',
|
|
989
|
+
exportedDocMiss: 'Exported {name} ({n} pages, {miss} screens could not be captured)',
|
|
990
|
+
xoTitle: 'Export options',
|
|
991
|
+
xoTip: 'Leave these alone and the file comes out the same as a direct export.',
|
|
992
|
+
xoWarn: 'Some content would be cut off. Have a look first',
|
|
993
|
+
xoChecking: 'Measuring pages…',
|
|
994
|
+
xoClean: 'Nothing will be cut off.',
|
|
995
|
+
xoOver: '{n} page(s) are larger than the canvas and will be cut off',
|
|
996
|
+
xoLong: '{n} long page(s): only the first screen is captured',
|
|
997
|
+
xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
|
|
998
|
+
xoLongH: '{n} page(s) are taller than the set height and will be cut off',
|
|
999
|
+
xoDead: '{n} link(s) may do nothing when clicked',
|
|
1000
|
+
xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
|
|
1001
|
+
xoAgain: 'Check again',
|
|
1002
|
+
xoGone: 'The design changed, so this export was cancelled',
|
|
1003
|
+
xoResize: 'Fit canvas to content ({size})',
|
|
1004
|
+
xoFull: 'Switch to full page',
|
|
1005
|
+
xoLayout: 'Page size',
|
|
1006
|
+
xoAuto: 'Match canvas',
|
|
1007
|
+
xoA3: 'A3 landscape',
|
|
1008
|
+
xoCustom: 'Custom',
|
|
1009
|
+
xoCustomPh: 'WxH, e.g. 1920x1080',
|
|
1010
|
+
xoView: 'Each page shows',
|
|
1011
|
+
xoViewAuto: 'Auto',
|
|
1012
|
+
xoViewOne: 'One screen',
|
|
1013
|
+
xoViewPage: 'Full page',
|
|
1014
|
+
xoViewH: 'Set height',
|
|
1015
|
+
xoViewHPh: 'Height in px, e.g. 1200',
|
|
1016
|
+
xoCols: 'Per page',
|
|
1017
|
+
xoCols1: '1 screen',
|
|
1018
|
+
xoCols2: '2 screens',
|
|
1019
|
+
xoPdf: 'Export PDF',
|
|
1020
|
+
xoPpt: 'Export PPT',
|
|
955
1021
|
exWhere: 'Saved to exports/ in the design folder; images are also copied to the clipboard',
|
|
956
1022
|
exportedDoc: 'Exported {name} ({n} pages)',
|
|
957
1023
|
check: 'Design check',
|
|
@@ -2057,6 +2123,7 @@ window.__ModuleLoader__.load({
|
|
|
2057
2123
|
.ddp-home.over{position:absolute;inset:0;z-index:10;background-color:var(--dsw-alias-bg-base,var(--dsw-alias-bg-layer-1));animation:ddp-homein .28s ${EASE} both}
|
|
2058
2124
|
.ddp-home.over.out{animation:ddp-homeout .19s ease both;pointer-events:none}
|
|
2059
2125
|
.ddp-home .ddp-start>*{animation:ddp-rise .5s ${EASE} both}
|
|
2126
|
+
.ddp-home .ddp-start>.ddp-askwrap{position:relative;z-index:5}
|
|
2060
2127
|
.ddp-home .ddp-start>:nth-child(2){animation-delay:.05s}
|
|
2061
2128
|
.ddp-home .ddp-start>:nth-child(3){animation-delay:.1s}
|
|
2062
2129
|
.ddp-home .ddp-start>:nth-child(4){animation-delay:.15s}
|
|
@@ -2324,6 +2391,17 @@ window.__ModuleLoader__.load({
|
|
|
2324
2391
|
.ddp-lib .seg button:hover,.ddp-homebar .seg button:hover{color:var(--dsw-alias-label-primary)}
|
|
2325
2392
|
.ddp-lib .seg button.on,.ddp-homebar .seg button.on{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 1px 2px rgba(0,0,0,.12)}
|
|
2326
2393
|
.ddp-lib>.bd{flex:1;min-height:0;overflow:auto;padding:14px}
|
|
2394
|
+
.ddp-xo .seg{display:flex;flex-wrap:wrap;gap:4px;margin:0 6px}
|
|
2395
|
+
.ddp-xo .seg button{height:26px;padding:0 9px;border:1px solid var(--dsw-alias-separator-primary,rgba(127,127,127,.3));border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer}
|
|
2396
|
+
.ddp-xo .seg button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12));color:var(--dsw-alias-label-primary)}
|
|
2397
|
+
.ddp-xo .seg button.on{border-color:${ACCENT};background:color-mix(in srgb,${ACCENT} 10%,transparent);color:var(--dsw-alias-label-primary)}
|
|
2398
|
+
.ddp-xo .chk{margin:4px 6px 0;padding:8px 10px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);font-size:12px;line-height:1.55;color:var(--dsw-alias-label-secondary)}
|
|
2399
|
+
.ddp-xo .chk.warn{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d54941) 9%,transparent);color:var(--dsw-alias-label-primary)}
|
|
2400
|
+
.ddp-xo .chk p{margin:0}
|
|
2401
|
+
.ddp-xo .chk p+p,.ddp-xo .chk .lk{margin-top:4px}
|
|
2402
|
+
.ddp-xo .chk .lk{display:block;text-align:left}
|
|
2403
|
+
.ddp-xo input.who.bad{border-color:var(--dsw-alias-state-error-primary,#d54941)}
|
|
2404
|
+
.ddp-ghost{position:fixed;left:0;top:0;width:100vw;height:100vh;overflow:hidden;opacity:0;pointer-events:none;z-index:-1}
|
|
2327
2405
|
.ddp-pack .lk{border:0;padding:0;background:transparent;color:${ACCENT};font:inherit;cursor:pointer}
|
|
2328
2406
|
.ddp-pack .lk:hover{text-decoration:underline;text-underline-offset:2px}
|
|
2329
2407
|
.ddp-pack input.who{display:block;width:calc(100% - 16px);box-sizing:border-box;height:28px;margin:6px 8px 0;padding:0 9px;border:1px solid var(--dsw-alias-separator-primary,rgba(127,127,127,.3));border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:12px inherit;outline:none}
|
|
@@ -3469,7 +3547,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
3469
3547
|
const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
|
|
3470
3548
|
const SAID_STYLE = /风格|配色|色调|主色|色系|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel)\b/i
|
|
3471
3549
|
// 「风格你定」「配色:随意」「any style」:等于没说(「配色定为蓝白」是说了)
|
|
3472
|
-
const STYLE_FREE = /(风格|配色|色调|主色)[::]
|
|
3550
|
+
const STYLE_FREE = /(风格|配色|色调|主色)\s*(?:[::]\s*)?(你定|您定|你来定|您来定|你决定|你看着办|随意|随便|不限|都行|无所谓|自由发挥)|\b(any|whatever)\s(style|colou?rs?|palette)\b|\b(style|colou?rs?|palette)\s(is\s)?up\sto\syou\b/gi
|
|
3473
3551
|
function autoStyle(text, kind) {
|
|
3474
3552
|
const s = String(text || '')
|
|
3475
3553
|
if (!s.trim()) return null
|
|
@@ -4300,6 +4378,28 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
4300
4378
|
return KIND_SIZE[kind] || KIND_SIZE.web
|
|
4301
4379
|
}
|
|
4302
4380
|
|
|
4381
|
+
// 定死画面的类型:页面比默认画幅大(写死了 1440×810 又没写进 meta)就按页面实际大小。比例不像一页的(几页竖着堆的)不算
|
|
4382
|
+
const AUTO_RATIO = { slides: [1.2, 2.4], poster: [0.45, 2.5] }
|
|
4383
|
+
|
|
4384
|
+
/** 各屏量到的实际大小 → 'WxH'(都没比默认大:'')。和 look.js 的 autoSize 一样 */
|
|
4385
|
+
function autoSize(list, kind) {
|
|
4386
|
+
const range = AUTO_RATIO[kind]
|
|
4387
|
+
if (!range) return ''
|
|
4388
|
+
const [dw, dh] = KIND_SIZE[kind]
|
|
4389
|
+
let W = 0, H = 0
|
|
4390
|
+
for (const n of list) {
|
|
4391
|
+
if (!Array.isArray(n)) continue
|
|
4392
|
+
const w = Math.ceil(+n[0]), h = Math.ceil(+n[1])
|
|
4393
|
+
if (!(w >= 200 && h >= 200 && w <= 4000 && h <= 6000)) continue
|
|
4394
|
+
if ((w <= dw && h <= dh) || w / h < range[0] || w / h > range[1]) continue
|
|
4395
|
+
W = Math.max(W, w)
|
|
4396
|
+
H = Math.max(H, h)
|
|
4397
|
+
}
|
|
4398
|
+
if (!W) return ''
|
|
4399
|
+
// 一组屏共用一个画幅:别的屏量不出比默认大,画幅不能比默认小,不然它们被裁
|
|
4400
|
+
return list.length > 1 ? `${Math.max(W, dw)}x${Math.max(H, dh)}` : `${W}x${H}`
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4303
4403
|
/** 外框加上去之后的整块大小 */
|
|
4304
4404
|
function deviceBox(kind, size) {
|
|
4305
4405
|
const f = FRAME[kind] || FRAME.web
|
|
@@ -5064,6 +5164,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5064
5164
|
postTo(curRef.current, { type: 'check', id, kind, quiet: !!quiet })
|
|
5065
5165
|
setTimeout(() => { if (caps.current.has(id)) { caps.current.delete(id); reject(new Error('timeout')) } }, 15000)
|
|
5066
5166
|
}),
|
|
5167
|
+
// 导出前预检:页面实际多大、有几个点了没反应的链接
|
|
5168
|
+
measure: () => new Promise((resolve, reject) => {
|
|
5169
|
+
if (!curRef.current) { reject(new Error('not loaded')); return }
|
|
5170
|
+
const id = `${Date.now()}-${++seq}`
|
|
5171
|
+
caps.current.set(id, { resolve, reject })
|
|
5172
|
+
postTo(curRef.current, { type: 'measure', id })
|
|
5173
|
+
setTimeout(() => { if (caps.current.has(id)) { caps.current.delete(id); reject(new Error('timeout')) } }, 8000)
|
|
5174
|
+
}),
|
|
5067
5175
|
checkFocus: (i) => { if (curRef.current) postTo(curRef.current, { type: 'checkFocus', i }) },
|
|
5068
5176
|
checkClear: () => { if (curRef.current) postTo(curRef.current, { type: 'checkClear' }) },
|
|
5069
5177
|
unpin: () => { if (curRef.current) postTo(curRef.current, { type: 'unpin' }) }, // 去掉「已选」虚线框
|
|
@@ -5085,7 +5193,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5085
5193
|
if (!f || !f.contentWindow) return
|
|
5086
5194
|
// 远程看:沙盒里的页面是不透明的源,只能发给 *(发的都是界面指令,没有要保密的)
|
|
5087
5195
|
if (f.hasAttribute('srcdoc')) f.contentWindow.postMessage({ dshDesign: 1, ...msg }, '*')
|
|
5088
|
-
else
|
|
5196
|
+
else {
|
|
5197
|
+
// 按这一帧自己的地址发:单看时换到别的设计目录,还是同一个组件,api 里留着的旧闭包记的是旧地址,消息会被浏览器丢掉(导出一直等到超时)
|
|
5198
|
+
let to = ''
|
|
5199
|
+
try { to = new URL(f.getAttribute('src')).origin } catch { /* 地址不对就不发 */ }
|
|
5200
|
+
if (to) f.contentWindow.postMessage({ dshDesign: 1, ...msg }, to)
|
|
5201
|
+
}
|
|
5089
5202
|
}
|
|
5090
5203
|
|
|
5091
5204
|
// 在后台载一帧新的;正在载就记一笔,等它换上来再载
|
|
@@ -5205,7 +5318,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5205
5318
|
L.title = d.title || ''
|
|
5206
5319
|
if (p.dark) postTo(id, { type: 'theme', dark: true })
|
|
5207
5320
|
if (p.tweak) postTo(id, { type: 'tweak', vars: p.tweak.vars, attrs: p.tweak.attrs })
|
|
5208
|
-
if (p.onMeta) p.onMeta(d.meta || '', d.title || '', Array.isArray(d.tokens) ? d.tokens : [], !!d.dark, Array.isArray(d.links) ? d.links : [])
|
|
5321
|
+
if (p.onMeta) p.onMeta(d.meta || '', d.title || '', Array.isArray(d.tokens) ? d.tokens : [], !!d.dark, Array.isArray(d.links) ? d.links : [], d.natural)
|
|
5209
5322
|
if (p.onHref && d.href) p.onHref(d.href)
|
|
5210
5323
|
if (isCur) {
|
|
5211
5324
|
postTo(id, { type: 'reveal' })
|
|
@@ -5269,6 +5382,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5269
5382
|
if (isCur && p.onEditDone) p.onEditDone()
|
|
5270
5383
|
break
|
|
5271
5384
|
case 'checked':
|
|
5385
|
+
case 'measured':
|
|
5272
5386
|
case 'captured': {
|
|
5273
5387
|
const c = caps.current.get(d.id)
|
|
5274
5388
|
if (c) {
|
|
@@ -6414,7 +6528,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
6414
6528
|
items.push(['raw', I.image, t('exRaw', n)])
|
|
6415
6529
|
if (kind !== 'poster' && kind !== 'slides') items.push(['long', I.long, t('exLong', n)]) // 海报、幻灯片画幅是定的,没有「整页」
|
|
6416
6530
|
if (count > 1) items.push(['show', I.canvas, t('exShow')])
|
|
6417
|
-
items.push(['pdf', I.pdf, t('exPdf')], ['pptx', I.deck, t('exPptx')])
|
|
6531
|
+
items.push(['pdf', I.pdf, t('exPdf')], ['pptx', I.deck, t('exPptx')], ['opts', I.sliders, t('exOpts')])
|
|
6418
6532
|
return items
|
|
6419
6533
|
}
|
|
6420
6534
|
|
|
@@ -7090,6 +7204,101 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7090
7204
|
}
|
|
7091
7205
|
|
|
7092
7206
|
/** 打成 zip:选授权 → 检查 → 过了存到「下载」,没过列出来交给模型改 */
|
|
7207
|
+
/**
|
|
7208
|
+
* 导出前预检:list 是各屏量到的大小,limit 是每页取到多高(0 = 一屏,Infinity = 整页)。
|
|
7209
|
+
* over 比画幅大(横向永远会被裁;幻灯片、海报竖向也算);long 长页只截到一部分;dead 点了没反应的链接
|
|
7210
|
+
*/
|
|
7211
|
+
function precheckOf(list, kind, limit) {
|
|
7212
|
+
const fixed = kind === 'slides' || kind === 'poster'
|
|
7213
|
+
const r = { over: 0, long: 0, dead: 0, fail: 0 }
|
|
7214
|
+
for (const m of list) {
|
|
7215
|
+
if (m.failed) { r.fail++; continue }
|
|
7216
|
+
const tall = m.pageH > (limit || m.h) + 2
|
|
7217
|
+
if (m.pageW > m.w + 2 || (fixed && tall)) r.over++
|
|
7218
|
+
if (!fixed && tall) r.long++
|
|
7219
|
+
const from = limit ? 0 : m.sy || 0 // 一屏:只看现在看得到的那段
|
|
7220
|
+
const to = limit || from + m.h
|
|
7221
|
+
r.dead += (Array.isArray(m.dead) ? m.dead : []).filter((y) => y >= from && y < to).length
|
|
7222
|
+
}
|
|
7223
|
+
return r
|
|
7224
|
+
}
|
|
7225
|
+
|
|
7226
|
+
/** 「按内容改画幅」改成多大:'宽x高',不用改或改不了返回 ''。幻灯片、海报按量到的版面,别的只把宽度加上去;竖着堆了好几页的不改高 */
|
|
7227
|
+
function fitCanvas(list, kind, size) {
|
|
7228
|
+
const fixed = kind === 'slides' || kind === 'poster'
|
|
7229
|
+
let [W, H] = size
|
|
7230
|
+
for (const m of list) {
|
|
7231
|
+
if (m.failed) continue
|
|
7232
|
+
if (fixed && Array.isArray(m.natural)) { W = Math.max(W, m.natural[0]); H = Math.max(H, m.natural[1]) } else if (m.pageW > m.w + 2) W = Math.max(W, m.pageW)
|
|
7233
|
+
}
|
|
7234
|
+
return (W === size[0] && H === size[1]) || W > 8000 || H > 8000 ? '' : `${W}x${H}`
|
|
7235
|
+
}
|
|
7236
|
+
|
|
7237
|
+
const layoutOk = (s) => { const m = /^\s*(\d{3,4})\s*[x×*]\s*(\d{3,4})\s*$/.exec(String(s || '')); return !!m && +m[1] >= 200 && +m[2] >= 200 && +m[1] <= 8000 && +m[2] <= 8000 }
|
|
7238
|
+
const fitHOk = (s) => /^\d{3,5}$/.test(String(s).trim()) && +s >= 200 && +s <= 30000
|
|
7239
|
+
|
|
7240
|
+
/** 按高度裁一张截图:h 是图对应的 CSS 高度 */
|
|
7241
|
+
function cropImg(img, h, maxH) {
|
|
7242
|
+
const c = document.createElement('canvas')
|
|
7243
|
+
c.width = img.width
|
|
7244
|
+
c.height = Math.round(img.height * maxH / h)
|
|
7245
|
+
c.getContext('2d').drawImage(img, 0, 0)
|
|
7246
|
+
return c
|
|
7247
|
+
}
|
|
7248
|
+
|
|
7249
|
+
function ExportPanel({ t, kind, size, opts, setOpts, screens, rev, measure, onResize, onExport, onClose }) {
|
|
7250
|
+
const [list, setList] = useState(null)
|
|
7251
|
+
const [working, setWorking] = useState(false)
|
|
7252
|
+
const [again, setAgain] = useState(0)
|
|
7253
|
+
const firstRun = useRef(true)
|
|
7254
|
+
useEffect(() => {
|
|
7255
|
+
let off = false
|
|
7256
|
+
setList(null)
|
|
7257
|
+
const first = firstRun.current
|
|
7258
|
+
firstRun.current = false
|
|
7259
|
+
// 页面刚改过:等它重新载入再量
|
|
7260
|
+
const timer = setTimeout(() => {
|
|
7261
|
+
measure().then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
|
|
7262
|
+
}, first ? 0 : 900)
|
|
7263
|
+
return () => { off = true; clearTimeout(timer) }
|
|
7264
|
+
}, [size.join('x'), screens, rev, again])
|
|
7265
|
+
const limit = opts.fit === 'page' ? Infinity : opts.fit === 'height' && fitHOk(opts.fitH) ? +opts.fitH : 0
|
|
7266
|
+
const rep = list ? precheckOf(list, kind, limit) : null
|
|
7267
|
+
const canFit = list ? fitCanvas(list, kind, size) : ''
|
|
7268
|
+
const cut = rep && (rep.over || rep.long)
|
|
7269
|
+
const longKey = opts.fit === 'height' ? 'xoLongH' : !opts.fit && (kind === 'web' || kind === 'email') ? 'xoLongPpt' : 'xoLong'
|
|
7270
|
+
const seg = (k, items) => h('div', { className: 'seg', role: 'radiogroup' }, ...items.map(([v, label]) => h('button', { key: String(v), type: 'button', role: 'radio', 'aria-checked': opts[k] === v, className: opts[k] === v ? 'on' : '', onClick: () => setOpts({ ...opts, [k]: v }) }, label)))
|
|
7271
|
+
const bad = (opts.layout === 'custom' && !layoutOk(opts.custom)) || (opts.fit === 'height' && !fitHOk(opts.fitH))
|
|
7272
|
+
const go = async (format) => {
|
|
7273
|
+
setWorking(true)
|
|
7274
|
+
try { await onExport(format) } finally { setWorking(false) }
|
|
7275
|
+
}
|
|
7276
|
+
return h('div', { className: 'ddp-tokens ddp-pack ddp-xo', onPointerDown: (e) => e.stopPropagation() },
|
|
7277
|
+
h('header', null, h(I.sliders), h('b', null, t('xoTitle')), h('button', { className: 'ddp-btn', title: '×', onClick: onClose }, h(I.close))),
|
|
7278
|
+
h('p', { className: 'tip' }, t('xoTip')),
|
|
7279
|
+
h('div', { className: 'bd' },
|
|
7280
|
+
!rep ? h('div', { className: 'chk' }, h('p', null, t('xoChecking'))) : h('div', { className: 'chk' + (cut ? ' warn' : '') },
|
|
7281
|
+
rep.over ? h('p', null, t('xoOver', { n: rep.over })) : null,
|
|
7282
|
+
rep.long ? h('p', null, t(longKey, { n: rep.long })) : null,
|
|
7283
|
+
rep.dead ? h('p', null, t('xoDead', { n: rep.dead })) : null,
|
|
7284
|
+
rep.fail ? h('p', null, t('xoFail', { n: rep.fail })) : null,
|
|
7285
|
+
!cut && !rep.dead && !rep.fail ? h('p', null, t('xoClean')) : null,
|
|
7286
|
+
rep.over && canFit ? h('button', { className: 'lk', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', '×') })) : null,
|
|
7287
|
+
rep.long && opts.fit !== 'page' ? h('button', { className: 'lk', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
|
|
7288
|
+
h('button', { className: 'lk', onClick: () => setAgain((n) => n + 1) }, t('xoAgain'))),
|
|
7289
|
+
h('h4', null, t('xoLayout')),
|
|
7290
|
+
seg('layout', [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
|
|
7291
|
+
opts.layout === 'custom' ? h('input', { className: 'who' + (opts.custom && !layoutOk(opts.custom) ? ' bad' : ''), value: opts.custom, maxLength: 11, placeholder: t('xoCustomPh'), 'aria-label': t('xoCustom'), onChange: (e) => setOpts({ ...opts, custom: e.target.value }) }) : null,
|
|
7292
|
+
h('h4', null, t('xoView')),
|
|
7293
|
+
seg('fit', [['', t('xoViewAuto')], ['view', t('xoViewOne')], ['page', t('xoViewPage')], ['height', t('xoViewH')]]),
|
|
7294
|
+
opts.fit === 'height' ? h('input', { className: 'who' + (opts.fitH && !fitHOk(opts.fitH) ? ' bad' : ''), value: opts.fitH, maxLength: 5, inputMode: 'numeric', placeholder: t('xoViewHPh'), 'aria-label': t('xoViewH'), onChange: (e) => setOpts({ ...opts, fitH: e.target.value }) }) : null,
|
|
7295
|
+
h('h4', null, t('xoCols')),
|
|
7296
|
+
seg('cols', [[1, t('xoCols1')], [2, t('xoCols2')]])),
|
|
7297
|
+
h('footer', { className: 'row' },
|
|
7298
|
+
h('button', { disabled: working || bad, onClick: () => go('pptx') }, h('span', null, t('xoPpt'))),
|
|
7299
|
+
h('button', { className: 'go', disabled: working || bad, onClick: () => go('pdf') }, h('span', null, t('xoPdf')))))
|
|
7300
|
+
}
|
|
7301
|
+
|
|
7093
7302
|
function PackPanel({ t, sid, root, onFix, onSay, onClose }) {
|
|
7094
7303
|
const [lic, setLic] = useState('CC0-1.0')
|
|
7095
7304
|
// CC BY 要署名:填过一次记住(只存在这台电脑的浏览器里)
|
|
@@ -7517,6 +7726,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7517
7726
|
const markRun = useRef(0) // 每开 / 关一次标注加一:发送途中关掉(或关了又开)的,旧的那次作废
|
|
7518
7727
|
const [tw, setTw] = useState({}) // 拖过的滑块:id → 值(还没写进文件)
|
|
7519
7728
|
const apis = useRef(new Map()) // 屏 → 截图用的接口
|
|
7729
|
+
const ghostApis = useRef(new Map()) // 单看时导出:在背后临时挂上的各屏
|
|
7730
|
+
const ghostN = useRef(0)
|
|
7731
|
+
const [backFrames, setBackFrames] = useState(null) // { list, size }:开始时的那些屏,途中换设计也不跟着变
|
|
7732
|
+
const designNow = useRef('') // 现在开着哪套设计
|
|
7733
|
+
const designSeq = useRef(0) // 换一次设计加一:导出途中换过(换回来也算)就不存了
|
|
7734
|
+
const [loadTick, setLoadTick] = useState(0) // 导出面板开着时页面又载入了一次:重新量
|
|
7735
|
+
const warned = useRef('') // 预检提醒过的结果:同样的结果只拦一次
|
|
7736
|
+
const [xo, setXo] = useState({ layout: 'auto', custom: '', fit: '', fitH: '', cols: 1 }) // 导出选项
|
|
7520
7737
|
const cmpRef = useRef(null)
|
|
7521
7738
|
const [box, setBox] = useState({ w: 0, h: 0 })
|
|
7522
7739
|
const stageRef = useRef(null)
|
|
@@ -7578,7 +7795,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7578
7795
|
const meta = parseMeta(main.meta || (st && st.draft && st.draft.meta) || (playR.current.end ? '' : playR.current.meta) || '') // 第一屏还在放草稿(真的没摆出来):按草稿开头写的类型
|
|
7579
7796
|
const tokens = main.tokens || []
|
|
7580
7797
|
const kind = (st && st.kind) || meta.kind || 'web'
|
|
7581
|
-
const size = sizeOf((st && st.size) || meta.size, kind)
|
|
7798
|
+
const size = sizeOf((st && st.size) || meta.size || autoSize(screens.map((sc) => (infoOf(ik(sc)) || {}).natural), kind), kind)
|
|
7582
7799
|
const view = (st && st.view) || (screens.length >= 2 && screens.length <= 12 ? 'canvas' : 'single')
|
|
7583
7800
|
const canvas = view === 'canvas'
|
|
7584
7801
|
const writingNew = !!(st && st.writing) && /\.html?$/i.test(st.writing) && !screens.some((s) => s.key === st.writing)
|
|
@@ -7764,11 +7981,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7764
7981
|
showFlash(t('born', { name: title || labelOf(sc) }))
|
|
7765
7982
|
}
|
|
7766
7983
|
|
|
7767
|
-
const remember = (key, m, title, toks, dk, links) => {
|
|
7984
|
+
const remember = (key, m, title, toks, dk, links, nat) => {
|
|
7985
|
+
if (pane === 'export') setLoadTick((n) => n + 1)
|
|
7768
7986
|
const k = site + '|' + key
|
|
7769
7987
|
const sig = JSON.stringify([toks || [], links || []])
|
|
7770
|
-
setInfo((cur) =>
|
|
7771
|
-
|
|
7988
|
+
setInfo((cur) => {
|
|
7989
|
+
const natural = nat === 0 ? null : nat || (cur[k] && cur[k].natural) || null // 画幅放大后页面正好撑满、报空:还按上回量的;0 是这页不再是一整块:清掉
|
|
7990
|
+
return cur[k] && cur[k].meta === m && cur[k].title === title && cur[k].sig === sig && cur[k].dark === dk && String(cur[k].natural) === String(natural) ? cur
|
|
7991
|
+
: { ...cur, [k]: { meta: m, title, tokens: toks || [], links: links || [], sig, dark: dk, natural } }
|
|
7992
|
+
})
|
|
7772
7993
|
}
|
|
7773
7994
|
|
|
7774
7995
|
const rememberLinks = (key, links) => {
|
|
@@ -8068,7 +8289,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8068
8289
|
onEdited: (d) => onEdited(sc, d),
|
|
8069
8290
|
onEditDone: () => setTextEdit(false),
|
|
8070
8291
|
onNote: (n) => note(n, sc),
|
|
8071
|
-
onMeta: (m, title, toks, dk, links) => remember(ik(sc), m, title, toks, dk, links),
|
|
8292
|
+
onMeta: (m, title, toks, dk, links, nat) => remember(ik(sc), m, title, toks, dk, links, nat),
|
|
8072
8293
|
onLinks: (links) => rememberLinks(ik(sc), links),
|
|
8073
8294
|
onTop: (dk) => setTop(ik(sc), dk),
|
|
8074
8295
|
onBuilt: (title) => onBuilt(sc, title),
|
|
@@ -8077,49 +8298,95 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8077
8298
|
// ── 导出图片 ──
|
|
8078
8299
|
// 截一屏:图片和它的 CSS 尺寸(PDF / PPT 按这个定页面大小)
|
|
8079
8300
|
// 那一屏的接口(截图、体检);刚载入的等它就绪
|
|
8080
|
-
const apiOf = async (sc) => {
|
|
8081
|
-
|
|
8082
|
-
|
|
8301
|
+
const apiOf = async (sc, map = apis.current) => {
|
|
8302
|
+
const tries = map === apis.current ? 40 : 120 // 背后现挂的要等它载完
|
|
8303
|
+
let api = map.get(ik(sc))
|
|
8304
|
+
for (let i = 0; i < tries && !(api && api.ready()); i++) {
|
|
8083
8305
|
await new Promise((r) => setTimeout(r, 150))
|
|
8084
|
-
api =
|
|
8306
|
+
api = map.get(ik(sc))
|
|
8085
8307
|
}
|
|
8086
8308
|
if (!api) throw new Error('not loaded')
|
|
8087
8309
|
return api
|
|
8088
8310
|
}
|
|
8089
|
-
const captureOf = async (sc, full) => {
|
|
8090
|
-
const api = await apiOf(sc)
|
|
8091
|
-
const r = await api.capture({ full: !!full, scale: 2 })
|
|
8311
|
+
const captureOf = async (sc, full, map, maxH) => {
|
|
8312
|
+
const api = await apiOf(sc, map)
|
|
8313
|
+
const r = await api.capture({ full: !!full, scale: 2, ...(maxH ? { maxH } : {}) })
|
|
8092
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 }
|
|
8093
8315
|
}
|
|
8094
8316
|
|
|
8317
|
+
const targetKey = st && st.target ? (st.target.kind === 'file' ? `file|${st.target.root}` : `proxy|${st.target.port}`) : ''
|
|
8095
8318
|
const saveImage = async (name, blob) => {
|
|
8096
8319
|
const png = await blobB64(blob)
|
|
8097
|
-
const r = await post('export', { session: sid, name, png })
|
|
8320
|
+
const r = await post('export', { session: sid, name, png, target: targetKey })
|
|
8098
8321
|
const copied = await copyImage(blob)
|
|
8099
8322
|
const file = String(r.path || '').split(/[\\/]/).pop()
|
|
8100
8323
|
say(t(copied ? 'exportedCopied' : 'exported', { name: file }), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
|
|
8101
8324
|
}
|
|
8102
8325
|
|
|
8103
|
-
const
|
|
8326
|
+
const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
|
|
8327
|
+
if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
|
|
8328
|
+
// 单看时只挂着正在看的那屏;要所有屏(PDF、PPT、拼图、预检)时按画幅大小在背后挂上,用完就撤
|
|
8329
|
+
const withFrames = async (fn) => {
|
|
8330
|
+
if (canvas || shown.length < 2) return fn(apis.current)
|
|
8331
|
+
// 网页单看时铺满右侧栏,和画幅不一样宽,都在背后重挂;别的类型正在看的那屏直接用(滚动位置、打开的弹窗都还在)
|
|
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) }
|
|
8337
|
+
}
|
|
8338
|
+
const measureAll = async (map) => {
|
|
8339
|
+
const list = []
|
|
8340
|
+
for (const sc of shown) {
|
|
8341
|
+
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
|
+
}
|
|
8343
|
+
return list
|
|
8344
|
+
}
|
|
8345
|
+
|
|
8346
|
+
const doExport = async (mode, key, opts) => {
|
|
8104
8347
|
setExMenu(false)
|
|
8348
|
+
if (mode === 'opts') { if (pane !== 'export') openPane('export'); return }
|
|
8105
8349
|
if (mode === 'zip') return openPack(fileTarget ? st.target.root : '')
|
|
8106
8350
|
if (mode === 'share') return openShare(fileTarget ? st.target.root : '')
|
|
8107
8351
|
say(t('exporting'))
|
|
8352
|
+
const design = designNow.current
|
|
8353
|
+
const stamp = designSeq.current
|
|
8354
|
+
const gone = () => designSeq.current !== stamp
|
|
8108
8355
|
try {
|
|
8109
8356
|
const prefix = ver ? `v${ver.n}-` : ''
|
|
8110
8357
|
const suffix = dark ? '-dark' : ''
|
|
8111
8358
|
if (mode === 'pdf' || mode === 'pptx') {
|
|
8112
|
-
// 每屏一页。PDF 里网页、邮件放整页长图(页面多高就多高);PPT
|
|
8113
|
-
const
|
|
8359
|
+
// 每屏一页。PDF 里网页、邮件放整页长图(页面多高就多高);PPT 一张幻灯片一个画面。选项面板里可以改
|
|
8360
|
+
const fit = (opts && opts.fit) || ''
|
|
8361
|
+
const long = fit === 'page' || fit === 'height' || (!fit && mode === 'pdf' && (kind === 'web' || kind === 'email'))
|
|
8362
|
+
const maxH = fit === 'height' ? Number(opts.fitH) || 0 : 0
|
|
8363
|
+
let deadN = 0
|
|
8364
|
+
await withFrames(async (map) => {
|
|
8365
|
+
// 从菜单直接点:先量一遍,有内容会被裁就先给看清单(同样的结果只拦一次)
|
|
8366
|
+
if (!opts) {
|
|
8367
|
+
const seen = await measureAll(map)
|
|
8368
|
+
const rep = precheckOf(seen, kind, long ? Infinity : 0)
|
|
8369
|
+
deadN = rep.dead
|
|
8370
|
+
const sig = rep.over || rep.long ? [design, shown.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
|
|
8371
|
+
if (sig && warned.current !== sig) {
|
|
8372
|
+
warned.current = sig
|
|
8373
|
+
say(t('xoWarn'))
|
|
8374
|
+
if (pane !== 'export') openPane('export')
|
|
8375
|
+
return
|
|
8376
|
+
}
|
|
8377
|
+
}
|
|
8114
8378
|
const pages = []
|
|
8115
8379
|
const keys = []
|
|
8116
8380
|
for (const sc of shown) {
|
|
8381
|
+
if (gone()) break
|
|
8117
8382
|
try {
|
|
8118
|
-
const r = await captureOf(sc, long)
|
|
8119
|
-
|
|
8383
|
+
const r = await captureOf(sc, long, map, maxH)
|
|
8384
|
+
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 })
|
|
8120
8386
|
keys.push(sc.key)
|
|
8121
8387
|
} catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
|
|
8122
8388
|
}
|
|
8389
|
+
if (gone()) { say(t('xoGone')); return }
|
|
8123
8390
|
if (!pages.length) throw new Error('no screens')
|
|
8124
8391
|
// 原型里的跳转:路径换成第几页,PDF / PPT 里点了能跳过去
|
|
8125
8392
|
for (const p of pages) {
|
|
@@ -8128,16 +8395,25 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8128
8395
|
const sp = splitTitles(pages.map((x) => x.title))
|
|
8129
8396
|
const folder = st && st.target && st.target.kind === 'file' ? String(st.target.file).split(/[\\/]/).slice(-2, -1)[0] : ''
|
|
8130
8397
|
const title = sp.brand || folder || st.label || ''
|
|
8131
|
-
const
|
|
8398
|
+
const layout = opts ? (opts.layout === 'custom' ? opts.custom.trim() : opts.layout === 'auto' ? '' : opts.layout) : ''
|
|
8399
|
+
const cols = opts && opts.cols === 2 ? 2 : 1
|
|
8400
|
+
const r = await post('doc', { session: sid, format: mode, name: prefix + (title || 'design') + suffix, title, bg: hexOf(pickColors(tokens).bg), pages, layout, cols, target: targetKey })
|
|
8132
8401
|
const file = String(r.path || '').split(/[\\/]/).pop()
|
|
8133
|
-
|
|
8402
|
+
const miss = shown.length - pages.length
|
|
8403
|
+
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(() => {}) })
|
|
8405
|
+
})
|
|
8134
8406
|
return
|
|
8135
8407
|
}
|
|
8136
8408
|
if (mode === 'show') {
|
|
8137
8409
|
const shots = []
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8410
|
+
await withFrames(async (map) => {
|
|
8411
|
+
for (const sc of shown) {
|
|
8412
|
+
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) }
|
|
8414
|
+
}
|
|
8415
|
+
})
|
|
8416
|
+
if (gone()) { say(t('xoGone')); return }
|
|
8141
8417
|
if (!shots.length) throw new Error('no screens')
|
|
8142
8418
|
const sp = splitTitles(shots.map((x) => x.title))
|
|
8143
8419
|
const colors = pickColors(tokens)
|
|
@@ -8169,7 +8445,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8169
8445
|
await saveImage(base + (mode === 'long' ? '-full' : ''), await canvasBlob(c))
|
|
8170
8446
|
}
|
|
8171
8447
|
} catch (e) {
|
|
8172
|
-
say(t('exportFail', { msg: e.message }))
|
|
8448
|
+
say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
|
|
8173
8449
|
}
|
|
8174
8450
|
}
|
|
8175
8451
|
|
|
@@ -8775,7 +9051,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8775
9051
|
}),
|
|
8776
9052
|
toast ? h('div', { className: 'ddp-toast low' }, h('span', null, toast.text)) : null) : null
|
|
8777
9053
|
// 开着设计时点「首页」:首页叠在画布上(设计库再叠在它上面)
|
|
8778
|
-
|
|
9054
|
+
// 单看时导出:所有屏按画幅大小挂在背后(看不见、点不到,放在视口里是因为视口外的 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
|
|
9057
|
+
const root = (...kids) => h('div', rootProps, ...kids, url && homeAt ? homeView(true) : null, libLayer, dropLayer, fileInput, pageFileInput, ghostLayer)
|
|
8779
9058
|
|
|
8780
9059
|
// ── 设计库:打成 zip、拖进来的设计包、存成我的风格 ──
|
|
8781
9060
|
function openPack(dir) {
|
|
@@ -8894,6 +9173,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8894
9173
|
if (pane === 'zip' && zipIssues) {
|
|
8895
9174
|
return h(ZipIssues, { t, issues: zipIssues, onClose: () => { setPane(''); setZipIssues(null) } })
|
|
8896
9175
|
}
|
|
9176
|
+
if (pane === 'export') {
|
|
9177
|
+
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('') })
|
|
9178
|
+
}
|
|
8897
9179
|
if (pane === 'handoff') {
|
|
8898
9180
|
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('') })
|
|
8899
9181
|
}
|
|
@@ -9031,7 +9313,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9031
9313
|
onNav: isTop ? demoGo : undefined,
|
|
9032
9314
|
onHref: isTop ? (href) => demoHref(l.id, href) : undefined,
|
|
9033
9315
|
onShown: () => demoShown(l.id),
|
|
9034
|
-
onMeta: (m, title, toks, dk, links) => remember(l.key, m, title, toks, dk, links),
|
|
9316
|
+
onMeta: (m, title, toks, dk, links, nat) => remember(l.key, m, title, toks, dk, links, nat),
|
|
9035
9317
|
onLinks: (links) => rememberLinks(l.key, links),
|
|
9036
9318
|
onTop: (dk) => setTop(l.key, dk),
|
|
9037
9319
|
})))))
|
|
@@ -9366,7 +9648,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9366
9648
|
// 注意:这里是客户端**服务名**(短的),不是包名
|
|
9367
9649
|
exports.inject = INJECT
|
|
9368
9650
|
// 测试用
|
|
9369
|
-
exports._test = { 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 }
|
|
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 }
|
|
9370
9652
|
return module.exports
|
|
9371
9653
|
},
|
|
9372
9654
|
})
|