dsh-design-studio 0.16.0 → 0.16.1
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/browser.js +14 -3
- package/lib/client.js +33 -13
- package/lib/core.js +9 -2
- package/lib/handoff.js +9 -1
- package/lib/look.js +16 -6
- package/lib/picker.js +84 -8
- package/package.json +1 -1
package/lib/browser.js
CHANGED
|
@@ -13,6 +13,7 @@ import { spawn, execFile } from 'node:child_process'
|
|
|
13
13
|
|
|
14
14
|
const IDLE_MS = 90000 // 闲置多久关掉
|
|
15
15
|
const CALL_MS = 30000 // 一条指令最多等多久
|
|
16
|
+
const CLOSE_MS = 600 // 让浏览器自己关,最多等多久再强杀
|
|
16
17
|
const LOAD_MS = 15000 // 页面载入最多等多久(到点照样往下走:有个图一直载不完也能量)
|
|
17
18
|
const MAX_PAGES = 3 // 同时开几个页面
|
|
18
19
|
const MAX_PSEUDO = 1500 // 伪元素最多问几个宿主的框(多了只问靠后的:底栏一般写在最后)
|
|
@@ -69,6 +70,7 @@ function sweep(dir = os.tmpdir(), now = Date.now()) {
|
|
|
69
70
|
export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = IDLE_MS, launch = spawn, platform = process.platform } = {}) {
|
|
70
71
|
let proc = null
|
|
71
72
|
let starting = null
|
|
73
|
+
let closing = null // 正在等浏览器自己退出
|
|
72
74
|
let dir = ''
|
|
73
75
|
let seq = 0
|
|
74
76
|
let open = 0
|
|
@@ -151,6 +153,7 @@ export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = ID
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
async function start() {
|
|
156
|
+
if (closing) await closing // 上一个还在关:等它退了再开,别往快关掉的浏览器发命令
|
|
154
157
|
if (proc) return
|
|
155
158
|
if (starting) return starting
|
|
156
159
|
if (!bin) throw new Error('no-browser')
|
|
@@ -181,15 +184,23 @@ export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = ID
|
|
|
181
184
|
function stop() {
|
|
182
185
|
clearTimeout(idle)
|
|
183
186
|
const p = proc
|
|
184
|
-
if (!p) return
|
|
185
|
-
|
|
187
|
+
if (!p || closing) return
|
|
188
|
+
// 等它真退出:这段时间来的新任务不能接着用这条快断的管道
|
|
189
|
+
let done
|
|
190
|
+
closing = new Promise((r) => { done = r })
|
|
191
|
+
const kill = setTimeout(() => { try { p.kill('SIGKILL') } catch { /* 已经退了 */ } }, platform === 'win32' ? CLOSE_MS * 5 : CLOSE_MS)
|
|
192
|
+
p.once('exit', () => { clearTimeout(kill); closing = null; done() })
|
|
186
193
|
if (platform === 'win32') {
|
|
194
|
+
try { p.stdio[3].end() } catch { /* 已经断了 */ }
|
|
187
195
|
execFile('taskkill', ['/pid', String(p.pid), '/T', '/F'], (err) => {
|
|
188
196
|
if (!err) return
|
|
189
197
|
log(err)
|
|
190
198
|
try { p.kill() } catch { /* 已经退了 */ }
|
|
191
199
|
})
|
|
192
|
-
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
// 先让它自己关:系统临时目录里的 com.google.Chrome.XXXXXX 只有它自己删得掉,强杀就留下了。等一会儿还没退再杀
|
|
203
|
+
try { p.stdio[3].write(`${JSON.stringify({ id: ++seq, method: 'Browser.close' })}\0`); p.stdio[3].end() } catch { /* 已经断了 */ }
|
|
193
204
|
}
|
|
194
205
|
|
|
195
206
|
/** 插件停用:关掉浏览器,排队等页面的都失败,之后再也不开 */
|
package/lib/client.js
CHANGED
|
@@ -193,6 +193,8 @@ window.__ModuleLoader__.load({
|
|
|
193
193
|
xoOver: '{n} 个页面比画幅大,会被裁',
|
|
194
194
|
xoLong: '{n} 个页面是长页,只会截首屏',
|
|
195
195
|
xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
|
|
196
|
+
xoMoved: '{n} 个页面现在不在页顶,只会截现在看到的这一段',
|
|
197
|
+
xoMovedPpt: '{n} 个页面现在不在页顶,PPT 只会截现在看到的这一段',
|
|
196
198
|
xoLongH: '{n} 个页面比指定高度长,下面会被裁',
|
|
197
199
|
xoDead: '{n} 个链接点了可能没反应',
|
|
198
200
|
xoAi: '用了 {n} 张 AI 示意图,上线前记得换成真实照片',
|
|
@@ -498,6 +500,7 @@ window.__ModuleLoader__.load({
|
|
|
498
500
|
dMore: '版本、在手机上看、刷新、在浏览器里打开',
|
|
499
501
|
dZoom: '按住 {mod} 滚动也能缩放',
|
|
500
502
|
dScreen: '换一屏、看全部、多尺寸、换类型',
|
|
503
|
+
dCanvas: '回到画布,看全部的屏',
|
|
501
504
|
toolsT: '工具',
|
|
502
505
|
editAddr: '换一个地址',
|
|
503
506
|
textShort: '改字',
|
|
@@ -1000,6 +1003,8 @@ window.__ModuleLoader__.load({
|
|
|
1000
1003
|
xoOver: '{n} page(s) are larger than the canvas and will be cut off',
|
|
1001
1004
|
xoLong: '{n} long page(s): only the first screen is captured',
|
|
1002
1005
|
xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
|
|
1006
|
+
xoMoved: '{n} page(s) are scrolled away from the top: only what is showing now is captured',
|
|
1007
|
+
xoMovedPpt: '{n} page(s) are scrolled away from the top: the PPT only captures what is showing now',
|
|
1003
1008
|
xoLongH: '{n} page(s) are taller than the set height and will be cut off',
|
|
1004
1009
|
xoDead: '{n} link(s) may do nothing when clicked',
|
|
1005
1010
|
xoAi: 'Uses {n} AI placeholder photo(s). Replace them with real photos before launch',
|
|
@@ -1304,6 +1309,7 @@ window.__ModuleLoader__.load({
|
|
|
1304
1309
|
dMore: 'Versions, view on phone, refresh, open in browser',
|
|
1305
1310
|
dZoom: 'Hold {mod} and scroll to zoom too',
|
|
1306
1311
|
dScreen: 'Switch screens, see all, sizes or type',
|
|
1312
|
+
dCanvas: 'Back to the canvas to see every screen',
|
|
1307
1313
|
toolsT: 'Tools',
|
|
1308
1314
|
editAddr: 'Change address',
|
|
1309
1315
|
textShort: 'Text',
|
|
@@ -2267,6 +2273,10 @@ window.__ModuleLoader__.load({
|
|
|
2267
2273
|
.ddp-demo .lay.out.b{transform:translateX(12%)}
|
|
2268
2274
|
.ddp-banner{position:absolute;left:50%;top:10px;transform:translateX(-50%);z-index:6;display:flex;align-items:center;gap:6px;max-width:calc(100% - 20px);padding:4px 4px 4px 12px;border-radius:999px;
|
|
2269
2275
|
background:var(--dsw-alias-bg-layer-1);box-shadow:0 8px 24px rgba(0,0,0,.18),0 0 0 .5px var(--dsw-alias-border-l3);font-size:12px;white-space:nowrap;animation:ddp-in .2s ${EASE}}
|
|
2276
|
+
.ddp-banner.side{left:calc((100% - 296px) / 2);max-width:calc(100% - 320px)}
|
|
2277
|
+
.ddp-banner.side>em{display:none}
|
|
2278
|
+
.ddp-stage.isl:has(>.ddp-banner:not(.side))>.ddp-tokens{top:100px;max-height:calc(100% - 100px - 74px)}
|
|
2279
|
+
.ddp-stage.isl.bz:has(>.ddp-banner:not(.side))>.ddp-tokens{top:142px;max-height:calc(100% - 142px - 74px)}
|
|
2270
2280
|
.ddp-banner>svg{width:14px;height:14px;flex:none;color:${ACCENT}}
|
|
2271
2281
|
.ddp-banner>span{overflow:hidden;text-overflow:ellipsis;min-width:0;margin-right:2px}
|
|
2272
2282
|
/* 试用横幅:「试用中」蓝字、屏名正文、提示淡;窄了先收提示 */
|
|
@@ -2567,6 +2577,8 @@ window.__ModuleLoader__.load({
|
|
|
2567
2577
|
|
|
2568
2578
|
.ddp-libwrap>.ddp-toast{z-index:3}
|
|
2569
2579
|
/* 浮块窄了:先截屏名,到 440 再收按钮上的字,400 收工具坞里的演示(演示时横幅上能退出) */
|
|
2580
|
+
@container (max-width:560px){.ddp-top>.tl .lab .lb{display:none}.ddp-top>.tl .ddp-btn.lab{padding:0 6px}}
|
|
2581
|
+
@container (max-width:490px){.ddp-top .lab .lb,.ddp-top .pri .lb{display:none}.ddp-top .ddp-btn.lab{padding:0 6px}}
|
|
2570
2582
|
@container (max-width:440px){.ddp-isl .lab .lb,.ddp-isl .pri .lb{display:none}.ddp-isl .ddp-btn.lab{padding:0 6px}.ddp-tool{width:36px;height:36px}.ddp-tool span{display:none}.ddp-dock .ddp-sep{height:20px}}
|
|
2571
2583
|
@container (max-width:380px){.ddp-tool{width:32px}.ddp-kind.ddp-where{min-width:64px}}
|
|
2572
2584
|
/* 标注底栏:右侧栏窄时「这支笔怎么用」折成两行,不被三个按钮挤成省略号 */
|
|
@@ -5197,6 +5209,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
5197
5209
|
checkFocus: (i) => { if (curRef.current) postTo(curRef.current, { type: 'checkFocus', i }) },
|
|
5198
5210
|
checkClear: () => { if (curRef.current) postTo(curRef.current, { type: 'checkClear' }) },
|
|
5199
5211
|
unpin: () => { if (curRef.current) postTo(curRef.current, { type: 'unpin' }) }, // 去掉「已选」虚线框
|
|
5212
|
+
holdScroll: () => { if (curRef.current) postTo(curRef.current, { type: 'holdScroll' }) }, // 用户要在这个位置上画:闪改动别再滚回去
|
|
5200
5213
|
// 画笔标注:这一屏的页面(iframe)现在摆在哪,拼图时按它的位置放截图
|
|
5201
5214
|
frame: () => wins.current.get(curRef.current) || null,
|
|
5202
5215
|
}
|
|
@@ -7234,12 +7247,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7234
7247
|
*/
|
|
7235
7248
|
function precheckOf(list, kind, limit) {
|
|
7236
7249
|
const fixed = kind === 'slides' || kind === 'poster'
|
|
7237
|
-
const r = { over: 0, long: 0, dead: 0, fail: 0, ai: new Set(list.flatMap((m) => (Array.isArray(m.aiPhotos) ? m.aiPhotos : []))).size }
|
|
7250
|
+
const r = { over: 0, long: 0, moved: 0, dead: 0, fail: 0, ai: new Set(list.flatMap((m) => (Array.isArray(m.aiPhotos) ? m.aiPhotos : []))).size }
|
|
7238
7251
|
for (const m of list) {
|
|
7239
7252
|
if (m.failed) { r.fail++; continue }
|
|
7240
7253
|
const tall = m.pageH > (limit || m.h) + 2
|
|
7241
7254
|
if (m.pageW > m.w + 2 || (fixed && tall)) r.over++
|
|
7242
|
-
if (!fixed && tall) r.long++
|
|
7255
|
+
if (!fixed && tall) { if (!limit && (m.sy || 0) > 1) r.moved++; else r.long++ } // 一屏:滚过的截的是现在这段,不是首屏
|
|
7243
7256
|
const from = limit ? 0 : m.sy || 0 // 一屏:只看现在看得到的那段
|
|
7244
7257
|
const to = limit || from + m.h
|
|
7245
7258
|
r.dead += (Array.isArray(m.dead) ? m.dead : []).filter((y) => y >= from && y < to).length
|
|
@@ -7289,8 +7302,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7289
7302
|
const limit = opts.fit === 'page' ? Infinity : opts.fit === 'height' && fitHOk(opts.fitH) ? +opts.fitH : 0
|
|
7290
7303
|
const rep = list ? precheckOf(list, kind, limit) : null
|
|
7291
7304
|
const canFit = list ? fitCanvas(list, kind, size) : ''
|
|
7292
|
-
const cut = rep && (rep.over || rep.long)
|
|
7305
|
+
const cut = rep && (rep.over || rep.long || rep.moved)
|
|
7293
7306
|
const longKey = opts.fit === 'height' ? 'xoLongH' : !opts.fit && (kind === 'web' || kind === 'email') ? 'xoLongPpt' : 'xoLong'
|
|
7307
|
+
const movedKey = !opts.fit && (kind === 'web' || kind === 'email') ? 'xoMovedPpt' : 'xoMoved'
|
|
7294
7308
|
const seg = (k, items) => h('div', { className: 'seg', role: 'radiogroup' }, ...items.map(([v, label]) => h('button', { key: String(v), type: 'button', role: 'radio', 'aria-checked': opts[k] === v, className: opts[k] === v ? 'on' : '', onClick: () => setOpts({ ...opts, [k]: v }) }, label)))
|
|
7295
7309
|
const bad = (opts.layout === 'custom' && !layoutOk(opts.custom)) || (opts.fit === 'height' && !fitHOk(opts.fitH))
|
|
7296
7310
|
const go = async (format) => {
|
|
@@ -7304,12 +7318,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
7304
7318
|
!rep ? h('div', { className: 'chk' }, h('p', null, t('xoChecking'))) : h('div', { className: 'chk' + (cut ? ' warn' : '') },
|
|
7305
7319
|
rep.over ? h('p', null, t('xoOver', { n: rep.over })) : null,
|
|
7306
7320
|
rep.long ? h('p', null, t(longKey, { n: rep.long })) : null,
|
|
7321
|
+
rep.moved ? h('p', null, t(movedKey, { n: rep.moved })) : null,
|
|
7307
7322
|
rep.dead ? h('p', null, t('xoDead', { n: rep.dead })) : null,
|
|
7308
7323
|
rep.ai ? h('p', null, t('xoAi', { n: rep.ai })) : null,
|
|
7309
7324
|
rep.fail ? h('p', null, t('xoFail', { n: rep.fail })) : null,
|
|
7310
7325
|
!cut && !rep.dead && !rep.fail ? h('p', null, t('xoClean')) : null,
|
|
7311
7326
|
rep.over && canFit ? h('button', { className: 'lk', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', '×') })) : null,
|
|
7312
|
-
rep.long && opts.fit !== 'page' ? h('button', { className: 'lk', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
|
|
7327
|
+
(rep.long || rep.moved) && opts.fit !== 'page' ? h('button', { className: 'lk', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
|
|
7313
7328
|
h('button', { className: 'lk', onClick: () => setAgain((n) => n + 1) }, t('xoAgain'))),
|
|
7314
7329
|
h('h4', null, t('xoLayout')),
|
|
7315
7330
|
seg('layout', [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
|
|
@@ -8613,7 +8628,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8613
8628
|
const seen = await measureAll(map)
|
|
8614
8629
|
const rep = precheckOf(seen, kind, long ? Infinity : 0)
|
|
8615
8630
|
deadN = rep.dead
|
|
8616
|
-
const sig = rep.over || rep.long ? [design, shown.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
|
|
8631
|
+
const sig = rep.over || rep.long || rep.moved ? [design, shown.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
|
|
8617
8632
|
if (sig && warned.current !== sig) {
|
|
8618
8633
|
warned.current = sig
|
|
8619
8634
|
say(t('xoWarn'))
|
|
@@ -8693,7 +8708,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8693
8708
|
c.width = img.width
|
|
8694
8709
|
c.height = img.height
|
|
8695
8710
|
c.getContext('2d').drawImage(img, 0, 0)
|
|
8696
|
-
await saveImage(base + (mode === 'long' ? '-full' : ''), await canvasBlob(c), aiShot)
|
|
8711
|
+
await saveImage(base + (mode === 'long' ? '-full' : mode === 'raw' && FRAMED[kind] ? '-plain' : ''), await canvasBlob(c), aiShot)
|
|
8697
8712
|
}
|
|
8698
8713
|
} catch (e) {
|
|
8699
8714
|
say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
|
|
@@ -8873,7 +8888,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
8873
8888
|
closeCheck()
|
|
8874
8889
|
setPane('')
|
|
8875
8890
|
// 之前点选 / 调样式留下的「已选」框别夹在标注里
|
|
8876
|
-
for (const a of apis.current.values()) if (a && a.unpin) a.unpin()
|
|
8891
|
+
for (const a of apis.current.values()) { if (a && a.unpin) a.unpin(); if (a && a.holdScroll) a.holdScroll() }
|
|
8877
8892
|
setMarkSize(box.w && box.h > TOP_R + BOT_R ? { w: box.w, h: box.h - TOP_R - BOT_R } : null)
|
|
8878
8893
|
setMark(true)
|
|
8879
8894
|
}
|
|
@@ -9155,6 +9170,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9155
9170
|
const exSc = shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
|
|
9156
9171
|
const exName = exSc ? dropBrand(shortOf(exSc)) + (takeTag(exSc) ? ' · ' + takeTag(exSc) : '') : ''
|
|
9157
9172
|
const libOpen = () => { setLibFocus(''); if (lib) setLib(''); else libDefaultThen((k) => setLib((c) => c || k)) }
|
|
9173
|
+
const onCanvas = canvas && !inMulti && !demo && homeAt !== 'on' && !(ver && cmp)
|
|
9174
|
+
const toCanvas = () => { homeAway(); setMulti(false); setCmp(false); if (demo) setDemo(null); change({ view: 'canvas' }) }
|
|
9158
9175
|
const dockTight = box.w > 0 && box.w <= 400 // 侧栏很窄:底部工具坞只放得下四个,「试用」进「更多」
|
|
9159
9176
|
const tool = (cls, on, desc, off, run, Icon, label) => h('button', { className: 'ddp-tool' + (cls ? ' ' + cls : '') + (on ? ' on' : ''), ...tipA(label, desc, on ? 'Esc' : ''), 'aria-pressed': !!on, disabled: !!off, onClick: run }, h(Icon), h('span', null, label))
|
|
9160
9177
|
const islands = editing
|
|
@@ -9165,9 +9182,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9165
9182
|
h('div', { key: 'top', className: 'ddp-top' },
|
|
9166
9183
|
h('div', { className: 'ddp-isl tl' },
|
|
9167
9184
|
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'))),
|
|
9185
|
+
h('button', { className: 'ddp-btn lab' + (onCanvas ? ' sel' : ''), ...tipA(t('canvasShort'), t('dCanvas')), 'aria-pressed': onCanvas, disabled: !url, onClick: toCanvas }, h(I.canvas), h('span', { className: 'lb' }, t('canvasShort'))),
|
|
9168
9186
|
h('span', { className: 'ddp-sep' }),
|
|
9169
9187
|
h(ScreenMenu, { t, hidden: hiddenN, hiddenText, label: scrLabel, tip: [scrLabel || stLabel, t('dScreen')], src: stLabel, busy, list: screens.map((x) => { const L = takeTag(x); return { key: x.key, label: dropBrand(shortOf(x)) + (L ? ' · ' + L : '') } }), cur: curKey, canvas: canvas && !inMulti && !demo, open: scrMenu, setOpen: setScrMenu,
|
|
9170
|
-
onPick: pickScreen, onAll:
|
|
9188
|
+
onPick: pickScreen, onAll: toCanvas, onOther: () => setEditing(true),
|
|
9171
9189
|
sizes: mark ? null : { on: inMulti, off: !sizeSet || !!ver, tip: sizeSet ? t('sizes') : t('sizesNo'), note: sizeSet ? '' : t('sizesNoShort'), run: () => setMulti(!inMulti) },
|
|
9172
9190
|
kind, onKind: mark ? null : (k) => change({ kind: k }) })),
|
|
9173
9191
|
h('div', { className: 'ddp-isl tr' },
|
|
@@ -9629,12 +9647,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9629
9647
|
const old = now ? { key: now.key, id: `v${ver.n}|${now.key}`, v: ver.n, url: vbase + encodeURIComponent(now.key), label: now.label } : null
|
|
9630
9648
|
const fill = kind === 'web'
|
|
9631
9649
|
const [dw, dh] = deviceBox(kind, size)
|
|
9632
|
-
|
|
9650
|
+
// 右边开着版本面板:手机这类有外框的让到面板左边(和单看时一样)
|
|
9651
|
+
const aside = !fill && !!(ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240 ? 296 : 0
|
|
9652
|
+
const z = fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - (ver ? 46 : 0)) / dh))
|
|
9633
9653
|
// 两边的小标签不跟着画面缩小(缩了看不清);手机、平板躲开状态栏
|
|
9634
9654
|
const tagAt = (side) => ({ top: kind === 'app' || kind === 'miniprogram' || kind === 'tablet' ? 60 : 10, transform: `scale(${1 / z})`, transformOrigin: 'top ' + side })
|
|
9635
9655
|
const screenOf = (sc) => h(Screen, { t, remote, onPageDrag: pageDrag, src: sc.url, label: labelOf(sc), busy: false, born: false, picking: false, dark, zoom: z, reloadSeq,
|
|
9636
9656
|
apis: apis.current, apiKey: 'cmp|' + ik(sc), onMeta: (m, title, toks, dk) => remember(ik(sc), m, title, toks, dk), onTop: (dk) => setTop(ik(sc), dk) })
|
|
9637
|
-
body = h('div', { className: 'ddp-single' },
|
|
9657
|
+
body = h('div', { className: 'ddp-single', style: aside ? { right: aside } : undefined },
|
|
9638
9658
|
h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
|
|
9639
9659
|
// 胶囊那块露的是哪一边(把手拖过胶囊中间就是左边那一版),胶囊就跟哪一边的顶栏
|
|
9640
9660
|
now ? h(Device, { kind, w: size[0], h: size[1], fill, label: labelOf(now), top: tops[ik(has && (cx / 100) * size[0] > size[0] - CAP.right - CAP.w / 2 ? old : now)], os: meta.os },
|
|
@@ -9769,7 +9789,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9769
9789
|
}) : null,
|
|
9770
9790
|
hist ? h(HistoryPanel, { t, versions, ver, onPick: (v) => { setVer(v); if (!v) setCmp(false) }, onClose: () => setHist(false) }) : null,
|
|
9771
9791
|
mark && !markOff ? h(MarkLayer, { t, sending: markBusy, frames: markFrames, onCancel: () => { markRun.current++; setMark(false) }, onSend: sendMark, onCopy: canCopyImage() ? copyMark : null }) : null,
|
|
9772
|
-
demo ? h('div', { className: 'ddp-banner' },
|
|
9792
|
+
demo ? h('div', { className: 'ddp-banner' + side },
|
|
9773
9793
|
h(I.play),
|
|
9774
9794
|
h('b', null, t('demoOn')),
|
|
9775
9795
|
h('span', { className: 'nm' }, dropBrand((infoOf(demoKey) || {}).title || demoKey.replace(/\.html?$/i, ''))),
|
|
@@ -9777,9 +9797,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
|
|
|
9777
9797
|
h('button', { className: 'ddp-btn', ...tipA(t('demoBack')), disabled: demo.stack.length < 2, onClick: demoBack }, h(I.back)),
|
|
9778
9798
|
h('button', { className: 'ddp-btn', ...tipA(t('demoRestart')), disabled: demo.stack.length < 2, onClick: demoRestart }, h(I.refresh)),
|
|
9779
9799
|
h('button', { className: 'ddp-btn', ...tipA(t('demoExit'), '', 'Esc'), onClick: () => setDemo(null) }, h(I.close))) : null,
|
|
9780
|
-
ver ? h('div', { className: 'ddp-banner' },
|
|
9800
|
+
ver ? h('div', { className: 'ddp-banner' + side },
|
|
9781
9801
|
h(I.history),
|
|
9782
|
-
h('span',
|
|
9802
|
+
h('span', { title: t('viewing', { n: ver.n, time: hhmm(ver.at) }) }, side ? t('vN', { n: ver.n }) : t('viewing', { n: ver.n, time: hhmm(ver.at) })),
|
|
9783
9803
|
h('button', { className: 'ddp-go sec' + (cmp ? ' on' : ''), onClick: () => setCmp(!cmp) }, t('compare')),
|
|
9784
9804
|
h('button', { className: 'ddp-go pri', onClick: doRestore }, t('restore')),
|
|
9785
9805
|
h('button', { className: 'ddp-btn', title: t('backNow'), onClick: () => { setVer(null); setCmp(false) } }, h(I.close))) : null,
|
package/lib/core.js
CHANGED
|
@@ -67,8 +67,13 @@ export function parseSize(input) {
|
|
|
67
67
|
|
|
68
68
|
/** 右侧显示的几屏:超过上限时留最新生成的,最早的先收起来。keep:正打开的那屏,不在里面也留着(挤掉最早的一屏) */
|
|
69
69
|
export function listScreens(root, keep = '') {
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const born = screensByBirth(root)
|
|
71
|
+
let kept = born.slice(-MAX_SCREENS)
|
|
72
|
+
if (keep && !kept.includes(keep)) {
|
|
73
|
+
if (kept.length >= MAX_SCREENS) kept.shift()
|
|
74
|
+
// 按创建顺序放回原位(打开文件夹取的是最早的一屏,别排到最后);不在顶层的(一般不会有)放最后
|
|
75
|
+
kept = born.includes(keep) ? born.filter((x) => x === keep || kept.includes(x)) : [...kept, keep]
|
|
76
|
+
}
|
|
72
77
|
return inManifestOrder(root, kept)
|
|
73
78
|
}
|
|
74
79
|
|
|
@@ -922,6 +927,8 @@ export function createTracker({ open, drafts = null, skipPorts = () => new Set()
|
|
|
922
927
|
if (p) settle(sessionId, st, part, absOf(sessionId, p))
|
|
923
928
|
}
|
|
924
929
|
}
|
|
930
|
+
// 第一屏的草稿开始流了:右侧栏关着就什么都看不到,弹一次(规矩和模型开了新页面一样,「自动打开预览」关着不弹)
|
|
931
|
+
if (draft && !st.target && autoOpen()) st.openRev++
|
|
925
932
|
if (draft && !draft.origin) {
|
|
926
933
|
open({ kind: 'file', file: draft.serve, root }).then((r) => {
|
|
927
934
|
if (st.draft === draft) draft.origin = r.origin
|
package/lib/handoff.js
CHANGED
|
@@ -181,6 +181,14 @@ export function within(p, root) {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/** 把允许的目录当场解析成真实路径钉住,返回判断函数(之后目录被换成软链,边界也不跟着变) */
|
|
184
|
+
/** 本机时间,写明时区:2026-11-10 12:07(UTC+8) */
|
|
185
|
+
export function localStamp(d) {
|
|
186
|
+
const p = (n) => String(n).padStart(2, '0')
|
|
187
|
+
const off = -d.getTimezoneOffset()
|
|
188
|
+
const a = Math.abs(off)
|
|
189
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}(UTC${off < 0 ? '-' : '+'}${Math.floor(a / 60)}${a % 60 ? ':' + p(a % 60) : ''})`
|
|
190
|
+
}
|
|
191
|
+
|
|
184
192
|
export function pinRoots(roots) {
|
|
185
193
|
const pins = roots.filter(Boolean).map((r) => fold(realish(r)))
|
|
186
194
|
return (p) => {
|
|
@@ -385,7 +393,7 @@ export function handoffMd({ root, rows, kind, size, framework, dest, project, sy
|
|
|
385
393
|
else lines.push(`- 做到:\`${dest}\``)
|
|
386
394
|
lines.push(`- 框架:${fwLabel}`)
|
|
387
395
|
if (system) lines.push(`- 设计系统:${system}(设计用的是它的 tokens.css / components.css,项目里也照它)`)
|
|
388
|
-
lines.push(`- 生成时间:${now
|
|
396
|
+
lines.push(`- 生成时间:${localStamp(now)}`, '')
|
|
389
397
|
if (kind === 'miniprogram' && !mini) {
|
|
390
398
|
// 小程序的设计、选的是网页框架:做成手机网页,别混进小程序的写法
|
|
391
399
|
lines.push('## 小程序设计做成网页(H5)', '')
|
package/lib/look.js
CHANGED
|
@@ -478,12 +478,14 @@ function metricsLine(m) {
|
|
|
478
478
|
*/
|
|
479
479
|
/** 一条问题认得出是同一个(复查时比上次修好了哪些、新出了哪些) */
|
|
480
480
|
const issueKey = (it) => `${it.type}|${it.sel}|${it.text || ''}|${it.msg || ''}|${it.src || ''}`
|
|
481
|
+
// 复查时比较用:同一个原因的叠字,叠在哪儿都算同一个
|
|
482
|
+
const compareKey = (it) => (it.type === 'overlap' && it.cause && it.cause.sel ? `overlap|cause|${it.cause.sel}|${it.cause.prop}` : issueKey(it))
|
|
481
483
|
const rowKey = (r, dark) => `${r.key}|${r.w}x${r.h}${dark ? '|dark' : ''}`
|
|
482
484
|
|
|
483
485
|
/** 这次量出来的(每屏每种尺寸一组问题),下次复查拿来比 */
|
|
484
486
|
export function issueSnapshot(rows, dark = false) {
|
|
485
487
|
const out = new Map()
|
|
486
|
-
for (const r of rows) if (!r.error) out.set(rowKey(r, dark), new Set(r.issues.map(
|
|
488
|
+
for (const r of rows) if (!r.error) out.set(rowKey(r, dark), new Set(r.issues.map(compareKey)))
|
|
487
489
|
return out
|
|
488
490
|
}
|
|
489
491
|
|
|
@@ -508,18 +510,26 @@ export function formatMeasure(rows, { sizes, where, missing = [], more = 0, dark
|
|
|
508
510
|
const failed = rows.filter((r) => r.error).length
|
|
509
511
|
// 和上次同样的屏、同样的尺寸比:修好了几个、新出了几个(新的在清单里标出来)
|
|
510
512
|
const fresh = new Set()
|
|
511
|
-
|
|
513
|
+
const gone = new Set()
|
|
514
|
+
const wasThere = new Set()
|
|
515
|
+
const unsure = new Set() // 上次有、这次这个尺寸没量成:不知道还在不在
|
|
516
|
+
const nowThere = new Set(rows.flatMap((r) => r.issues.map((it) => `${r.key}|${compareKey(it)}`)))
|
|
512
517
|
let compared = 0
|
|
513
518
|
if (prev) {
|
|
514
519
|
for (const r of rows) {
|
|
515
|
-
const before =
|
|
520
|
+
const before = prev.get(rowKey(r, dark))
|
|
516
521
|
if (!before) continue
|
|
522
|
+
for (const k of before) (r.error ? unsure : wasThere).add(`${r.key}|${k}`)
|
|
523
|
+
if (r.error) continue
|
|
517
524
|
compared++
|
|
518
|
-
const now = new Set(r.issues.map(
|
|
519
|
-
for (const k of before) if (!now.has(k))
|
|
525
|
+
const now = new Set(r.issues.map(compareKey))
|
|
526
|
+
for (const k of before) if (!now.has(k)) gone.add(`${r.key}|${k}`)
|
|
520
527
|
for (const k of now) if (!before.has(k)) fresh.add(`${r.key}|${k}`)
|
|
521
528
|
}
|
|
522
529
|
}
|
|
530
|
+
// 和「发现 N 个」同一个单位:一个问题在几种尺寸上都出现算一个。这屏别的尺寸上还在的不算修好,换了个尺寸出现的也不算新出
|
|
531
|
+
const fixed = [...gone].filter((k) => !nowThere.has(k) && !unsure.has(k)).length
|
|
532
|
+
for (const k of fresh) if (wasThere.has(k) || unsure.has(k)) fresh.delete(k)
|
|
523
533
|
const sz = sizes.map(([w, h]) => sizeText(w, h)).join('、')
|
|
524
534
|
const status = failed === rows.length
|
|
525
535
|
? '一次都没量成,这次检查没完成(原因见下)。'
|
|
@@ -557,7 +567,7 @@ export function formatMeasure(rows, { sizes, where, missing = [], more = 0, dark
|
|
|
557
567
|
let i = 0
|
|
558
568
|
for (const [k, { it, at }] of seen) {
|
|
559
569
|
if (sameCause.has(`${key}|${k}`)) continue
|
|
560
|
-
const tag = (fresh.has(`${key}|${
|
|
570
|
+
const tag = (fresh.has(`${key}|${compareKey(it)}`) ? '[新] ' : '') + (at.length < ok && mine.length > 1 ? `[${at.join('、')}] ` : '')
|
|
561
571
|
const what = [it.sel, it.text ? `「${it.text}」` : ''].filter(Boolean).join('')
|
|
562
572
|
const pic = pics.get(`${key}|${k}`)
|
|
563
573
|
const upper = pic && pic.k === `${key}|${k}` && pic.upper ? `;${pic.upper === 'self' ? `「${String(it.text || '').slice(0, 12)}」` : `「${String(it.otherText || '').slice(0, 12)}」`}画在上面` : ''
|
package/lib/picker.js
CHANGED
|
@@ -681,12 +681,53 @@
|
|
|
681
681
|
return r.bottom > 0 && r.right > 0 && r.top < innerHeight && r.left < innerWidth
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
|
|
684
|
+
// 为了闪改动自动滚走之前的位置(页面和外面几层滚动区)。闪完滚回去,不然预览一直停在那儿,「一屏」类导出截的就是被滚走的画面。
|
|
685
|
+
// 用户自己动了页面就作废:滚到哪算哪
|
|
686
|
+
let scrollHome = null
|
|
687
|
+
let scrollHomeTimer = 0
|
|
688
|
+
const FLASH_MS = 420 + 2900
|
|
689
|
+
const RETURN_MS = 1000 // 平滑滚回去最多要这么久;这段时间里截图、测量还能立刻跳回原位
|
|
690
|
+
const dropScrollHome = () => { clearTimeout(scrollHomeTimer); scrollHome = null }
|
|
691
|
+
for (const ev of ['wheel', 'touchmove', 'pointerdown']) addEventListener(ev, () => { if (scrollHome) dropScrollHome() }, { capture: true, passive: true })
|
|
692
|
+
addEventListener('keydown', (e) => { if (scrollHome && /^(Arrow|Page|Home$|End$| $|Tab$)/.test(e.key)) dropScrollHome() }, true)
|
|
693
|
+
const scrollersOf = (el) => {
|
|
694
|
+
const out = []
|
|
695
|
+
for (let a = el.parentElement; a && a !== document.documentElement; a = a.parentElement) {
|
|
696
|
+
if (a !== document.scrollingElement && (a.scrollHeight > a.clientHeight + 1 || a.scrollWidth > a.clientWidth + 1)) out.push({ el: a, x: a.scrollLeft, y: a.scrollTop })
|
|
697
|
+
}
|
|
698
|
+
return out
|
|
699
|
+
}
|
|
700
|
+
/** 滚回自动滚走之前的位置(导出前不等动画) */
|
|
701
|
+
function goScrollHome(behavior) {
|
|
702
|
+
const h = scrollHome
|
|
703
|
+
if (!h) return
|
|
704
|
+
clearTimeout(scrollHomeTimer)
|
|
705
|
+
if (behavior === 'smooth') scrollHomeTimer = setTimeout(dropScrollHome, RETURN_MS)
|
|
706
|
+
else scrollHome = null
|
|
707
|
+
try { scrollTo({ left: h.x, top: h.y, behavior }) } catch { scrollTo(h.x, h.y) }
|
|
708
|
+
for (const s of h.inner) { try { s.el.scrollTo({ left: s.x, top: s.y, behavior }) } catch { /* 元素没了 */ } }
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/** 用户要在现在这个位置上操作(画笔标注):别滚回去,正在滚回去也停下 */
|
|
712
|
+
function holdScroll() {
|
|
713
|
+
const h = scrollHome
|
|
714
|
+
if (!h) return
|
|
715
|
+
dropScrollHome()
|
|
716
|
+
try { scrollTo({ left: scrollX, top: scrollY, behavior: 'instant' }) } catch { /* 停不住就算了 */ }
|
|
717
|
+
for (const s of h.inner) { try { s.el.scrollTo({ left: s.el.scrollLeft, top: s.el.scrollTop, behavior: 'instant' }) } catch { /* 元素没了 */ } }
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** 闪一下;改的地方都不在屏幕里就先滚过去,闪完滚回来。窗口在后台时没人看,不滚 */
|
|
685
721
|
function play(els) {
|
|
686
722
|
if (!els.length) return
|
|
687
|
-
if (els.some(inView)) return flash(els)
|
|
723
|
+
if (els.some(inView) || document.hidden) return flash(els)
|
|
724
|
+
const inner = scrollersOf(els[0])
|
|
725
|
+
if (!scrollHome) scrollHome = { x: scrollX, y: scrollY, inner }
|
|
726
|
+
else for (const s of inner) if (!scrollHome.inner.some((o) => o.el === s.el)) scrollHome.inner.push(s)
|
|
688
727
|
try { els[0].scrollIntoView({ behavior: 'smooth', block: 'center' }) } catch { els[0].scrollIntoView() }
|
|
689
728
|
setTimeout(() => flash(els), 420)
|
|
729
|
+
clearTimeout(scrollHomeTimer)
|
|
730
|
+
scrollHomeTimer = setTimeout(() => goScrollHome('smooth'), FLASH_MS)
|
|
690
731
|
}
|
|
691
732
|
|
|
692
733
|
// ── 生成动画:元素按从上到下的顺序浮现,扫描光带一起往下走 ─────────────────
|
|
@@ -991,7 +1032,7 @@
|
|
|
991
1032
|
let pending = null
|
|
992
1033
|
let busy = false
|
|
993
1034
|
|
|
994
|
-
const seedNow = () => ({ href: here(), scroll: { x: scrollX, y: scrollY }, sig: snapshot().map })
|
|
1035
|
+
const seedNow = () => ({ href: here(), scroll: scrollHome ? { x: scrollHome.x, y: scrollHome.y } : { x: scrollX, y: scrollY }, sig: snapshot().map })
|
|
995
1036
|
|
|
996
1037
|
/** 选择器列表按顶层逗号拆开(括号、方括号里的逗号不算) */
|
|
997
1038
|
function splitSelectors(text) {
|
|
@@ -1686,7 +1727,16 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
1686
1727
|
|
|
1687
1728
|
/** 页面里跳到别的屏的地方:路径 + 在视口里的位置(画布上从这里画一条线到那一屏)
|
|
1688
1729
|
* shown:只要这会儿露在外面的(画布连线用;导出、交接要全部) */
|
|
1689
|
-
|
|
1730
|
+
/** 这个元素跟着哪条挪到底部的栏走:往上找,先碰到别的 fixed 就是它自己定位,不跟栏走 */
|
|
1731
|
+
function barDyOf(el, bars) {
|
|
1732
|
+
for (let a = el; a && a.nodeType === 1; a = a.parentElement) {
|
|
1733
|
+
if (bars.has(a)) return bars.get(a)
|
|
1734
|
+
if (getComputedStyle(a).position === 'fixed') return undefined
|
|
1735
|
+
}
|
|
1736
|
+
return undefined
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
function linksOf(shown, bars) {
|
|
1690
1740
|
const out = []
|
|
1691
1741
|
const seen = new Set()
|
|
1692
1742
|
for (const el of document.querySelectorAll(LINK_SEL)) {
|
|
@@ -1707,7 +1757,8 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
1707
1757
|
if (seen.has(k)) continue
|
|
1708
1758
|
seen.add(k)
|
|
1709
1759
|
const text = clip(String(el.innerText || el.getAttribute('aria-label') || el.getAttribute('title') || '').replace(/\s+/g, ' ').trim(), 24)
|
|
1710
|
-
|
|
1760
|
+
const barDy = bars && bars.size ? barDyOf(el, bars) : undefined
|
|
1761
|
+
out.push({ path: p, x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height), text, ...(barDy === undefined ? null : { barDy }) })
|
|
1711
1762
|
}
|
|
1712
1763
|
return out
|
|
1713
1764
|
}
|
|
@@ -2029,10 +2080,12 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
2029
2080
|
}
|
|
2030
2081
|
|
|
2031
2082
|
async function capture(opts) {
|
|
2083
|
+
goScrollHome('instant') // 正在为闪改动滚走:按原来的位置截
|
|
2032
2084
|
const full = !!opts.full
|
|
2033
2085
|
const scale = Math.min(3, Math.max(1, Number(opts.scale) || 2))
|
|
2034
2086
|
const de = document.documentElement
|
|
2035
2087
|
const W = Math.ceil(de.clientWidth || innerWidth)
|
|
2088
|
+
const bars = new Map() // 整页图里挪到底部的栏 → 往下挪了多少
|
|
2036
2089
|
const H = Math.ceil(full ? Math.min(Number(opts.maxH) || Infinity, Math.max(de.scrollHeight, document.body ? document.body.scrollHeight : 0, innerHeight)) : innerHeight) // maxH:指定高度,别先画一张超长的图
|
|
2037
2090
|
const box = makeSandbox()
|
|
2038
2091
|
const inline = makeInliner()
|
|
@@ -2144,6 +2197,15 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
2144
2197
|
const y = parseFloat(cs.top)
|
|
2145
2198
|
if (Number.isFinite(x) && Number.isFinite(y)) st += `left:${x - bodyAt.l}px;top:${y - bodyAt.t}px;right:auto;bottom:auto;`
|
|
2146
2199
|
}
|
|
2200
|
+
// 整页:贴着窗口底部的固定元素(标签栏、操作条、悬浮按钮)放到整张图的底部。内联的 top 是按窗口算好的像素,上下都写死时 top 说了算,不挪就钉在第一屏底部、盖住中间的内容
|
|
2201
|
+
if (full && H > innerHeight && cs.position === 'fixed' && el.namespaceURI !== SVGNS && el.ownerDocument === document && document.body.contains(el) && !fixedHeld(el)) {
|
|
2202
|
+
const r = el.getBoundingClientRect()
|
|
2203
|
+
const y = parseFloat(cs.top)
|
|
2204
|
+
if (Number.isFinite(y) && r.height > 0 && r.height < innerHeight / 2 && r.top >= innerHeight / 2 && r.bottom <= innerHeight + 1 && bottomPinned(el)) {
|
|
2205
|
+
st += `top:${y + H - innerHeight}px;bottom:auto;`
|
|
2206
|
+
bars.set(el, H - innerHeight)
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2147
2209
|
// 原来一行放得下的字,画成图时也别折行(宽度是定死的,字体渲染差一丁点就会挤到第二行)
|
|
2148
2210
|
if (el.namespaceURI !== SVGNS && cs.whiteSpace !== 'nowrap' && oneLine(el)) st += 'white-space:nowrap;'
|
|
2149
2211
|
c.setAttribute('style', st)
|
|
@@ -2349,7 +2411,7 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
2349
2411
|
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
2350
2412
|
ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
|
|
2351
2413
|
const png = await new Promise((resolve, reject) => canvas.toBlob((b) => (b ? resolve(b) : reject(new Error('toBlob 失败'))), 'image/png'))
|
|
2352
|
-
return { png, w: W, h: H, scale, top }
|
|
2414
|
+
return { png, w: W, h: H, scale, top, bars }
|
|
2353
2415
|
} finally {
|
|
2354
2416
|
box.remove()
|
|
2355
2417
|
}
|
|
@@ -2384,6 +2446,16 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
2384
2446
|
}
|
|
2385
2447
|
|
|
2386
2448
|
/** 固定元素是不是被某个祖先(transform、filter 之类)接管了位置:接管了就跟着那个祖先走,不用挪 */
|
|
2449
|
+
/** 是靠 bottom 贴着窗口底部的(标签栏、悬浮按钮),不是写了 top 碰巧在下半屏的浮层。认不出来就当不是,留在原位 */
|
|
2450
|
+
function bottomPinned(el) {
|
|
2451
|
+
try {
|
|
2452
|
+
const m = el.computedStyleMap()
|
|
2453
|
+
return String(m.get('top')) === 'auto' && String(m.get('bottom')) !== 'auto'
|
|
2454
|
+
} catch {
|
|
2455
|
+
return false
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2387
2459
|
function fixedHeld(el) {
|
|
2388
2460
|
for (let a = el.parentElement; a; a = a.parentElement) if (holds(getComputedStyle(a), true)) return true
|
|
2389
2461
|
return false
|
|
@@ -2524,7 +2596,8 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
2524
2596
|
try {
|
|
2525
2597
|
const r = await capture(d)
|
|
2526
2598
|
// 整页图从文档顶上画起,链接加上滚动距离;只截视口时就是视口里的位置
|
|
2527
|
-
|
|
2599
|
+
// 挪到整张图底部的栏:里面的链接跟着栏走,它本来就不随页面滚
|
|
2600
|
+
const links = linksOf(false, r.bars).map(({ barDy, ...l }) => (!d.full ? l : barDy === undefined ? { ...l, x: l.x + scrollX, y: l.y + scrollY } : { ...l, y: l.y + barDy }))
|
|
2528
2601
|
.filter((l) => l.x < r.w && l.y < r.h && l.x + l.w > 0 && l.y + l.h > 0)
|
|
2529
2602
|
post({ type: 'captured', id: d.id, png: r.png, w: r.w, h: r.h, scale: r.scale, title: document.title, links, top: r.top, href: here(), aiPhotos: aiPhotosNow() })
|
|
2530
2603
|
} catch (e) {
|
|
@@ -2534,6 +2607,7 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
2534
2607
|
|
|
2535
2608
|
// 导出前预检:这一页实际多大、有几个点了没反应的链接(href="#"、指向不存在的文件)
|
|
2536
2609
|
async function onMeasure(d) {
|
|
2610
|
+
goScrollHome('instant') // 正在为闪改动滚走:按原来的位置量
|
|
2537
2611
|
try {
|
|
2538
2612
|
if (document.readyState !== 'complete') await new Promise((r) => { addEventListener('load', r, { once: true }); setTimeout(r, 1500) })
|
|
2539
2613
|
const de = document.documentElement
|
|
@@ -4145,6 +4219,7 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
4145
4219
|
async function onCheck(d) {
|
|
4146
4220
|
let r
|
|
4147
4221
|
try {
|
|
4222
|
+
goScrollHome('instant') // 量的时候要滚动,别把闪改动的回位打断、停在半路
|
|
4148
4223
|
await settle()
|
|
4149
4224
|
r = runCheck(String(d.kind || 'web'))
|
|
4150
4225
|
} catch (e) {
|
|
@@ -4262,12 +4337,13 @@ background:rgba(20,20,22,.86);color:#e8e8ea;font:12px/18px -apple-system,system-
|
|
|
4262
4337
|
else if (d.type === 'snapshot') post({ type: 'snap', seed: seedNow() })
|
|
4263
4338
|
else if (d.type === 'busy') { busy = !!d.on; watchHmr() }
|
|
4264
4339
|
else if (d.type === 'unpin') unpin()
|
|
4340
|
+
else if (d.type === 'holdScroll') holdScroll()
|
|
4265
4341
|
else if (d.type === 'reload') selfReload()
|
|
4266
4342
|
else if (d.type === 'capture') onCapture(d)
|
|
4267
4343
|
else if (d.type === 'measure') onMeasure(d)
|
|
4268
4344
|
else if (d.type === 'check') onCheck(d)
|
|
4269
4345
|
else if (d.type === 'checkClear') { clearMarks(); lastIssues = [] }
|
|
4270
|
-
else if (d.type === 'checkFocus') focusIssue(Number(d.i))
|
|
4346
|
+
else if (d.type === 'checkFocus') { holdScroll(); focusIssue(Number(d.i)) } // 用户点了别的地方要看,别再滚回去
|
|
4271
4347
|
else if (d.type === 'theme') { setDark(d.dark); postTop(); setTimeout(postTop, 400) }
|
|
4272
4348
|
else if (d.type === 'demo') demo = !!d.on
|
|
4273
4349
|
else if (d.type === 'edit') setTextEdit(!!d.on, d.hint !== false)
|