feat(shell): 状态栏内存显示 + 修外观网格设置(v3.25.74)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 30s

This commit is contained in:
qiqi committed 2026-11-21 07:05:24 +08:00
1 parent 94680fd127
commit f6d104fd95
15 files changed
+139 -27

No files matched your search

+39 -5
View File
@@ -7618,13 +7618,27 @@ const tbCenterSeed = (type, refs) => {
const importCanvasFile = (file, fromDrop, dropX, dropY) => IWWorkbenchLogic.importCanvasFile({ canvasSize, commitCanvas, pushHistory, refs, setNotice, setSel }, file, fromDrop, dropX, dropY)
// 网格样式:优先用 src/canvas-grid.js 的贴图(平移只走 transform,不重绘点阵)
// v3.25.74:改为读取外观设置(网格点大小/间距/颜色/开关)—— 之前硬编码 28/1.2,
// 导致设置里的「网格点大小 / 网格间距 / 显示网格」全部失效(用户反馈)。
const readGridOpts = () => {
if (typeof getComputedStyle !== 'function' || typeof document === 'undefined') return { base: 22, dot: 1.4, color: 'rgba(120,128,140,0.55)', on: true }
try {
const cs = getComputedStyle(document.documentElement)
const gap = parseFloat(cs.getPropertyValue('--iwb-grid-gap')) || 22
const dot = parseFloat(cs.getPropertyValue('--iwb-grid-size')) || 1.4
const col = (cs.getPropertyValue('--iwb-grid-dot') || '').trim() || 'rgba(120,128,140,0.55)'
const onv = parseFloat(cs.getPropertyValue('--iwb-grid-on'))
return { base: Math.max(8, gap), dot: Math.max(0.5, dot), color: col, on: !(onv === 0) }
} catch (e) { return { base: 22, dot: 1.4, color: 'rgba(120,128,140,0.55)', on: true } }
}
refs.gridOpts = readGridOpts()
const gridStyleOf = (x, y, scale) => {
const o = refs.gridOpts || { base: 22, dot: 1.4, color: 'rgba(120,128,140,0.55)', on: true }
if (!o.on) return { display: 'none' }
const G = (typeof window !== 'undefined') ? window.IWBCanvasGrid : null
const st = G && typeof G.styleOf === 'function'
? G.styleOf(x, y, scale, { base: 28, dot: 1.2, color: 'rgba(120,128,140,0.55)' })
: null
const st = G && typeof G.styleOf === 'function' ? G.styleOf(x, y, scale, o) : null
if (st) return st
return { backgroundSize: (28 * scale) + 'px ' + (28 * scale) + 'px', backgroundPosition: x + 'px ' + y + 'px' }
return { backgroundSize: (o.base * scale) + 'px ' + (o.base * scale) + 'px', backgroundPosition: x + 'px ' + y + 'px' }
}
// v3.25.68(借鉴 tldraw 的相机机制):手势期间只改 .iwb-world 的 transform,
@@ -7638,7 +7652,8 @@ const tbCenterSeed = (type, refs) => {
const grid = root.querySelector('.iwb-grid')
const G = (typeof window !== 'undefined') ? window.IWBCanvasGrid : null
if (grid && G && typeof G.applyTo === 'function') {
G.applyTo(grid, x, y, scale, { base: 28, dot: 1.2, color: 'rgba(120,128,140,0.55)' })
const o = refs.gridOpts || { base: 22, dot: 1.4, color: 'rgba(120,128,140,0.55)', on: true }
if (!o.on) { grid.style.display = 'none' } else { grid.style.display = '' ; G.applyTo(grid, x, y, scale, o) }
} else if (grid) {
grid.style.backgroundSize = (28 * scale) + 'px ' + (28 * scale) + 'px'
grid.style.backgroundPosition = x + 'px ' + y + 'px'
@@ -7780,6 +7795,24 @@ const tbCenterSeed = (type, refs) => {
const visibleIds = new Set(nodes.filter(nodeVisible).map((n) => n.id))
try { wSetScaleNow(viewport.scale) } catch (e) { /* ignore */ }
// 进程内存(v3.25.74):状态栏显示,便于对比优化前后的内存占用(4s 轮询,窗口隐藏时不拉)
const [memMb, setMemMb] = React.useState(0)
useEffect(() => {
let alive = true
let timer = null
const tick = () => {
if (!alive) return
if (typeof document !== 'undefined' && document.hidden) { timer = setTimeout(tick, 8000); return }
Promise.resolve().then(() => {
const T = (typeof window !== 'undefined') ? window.__TAURI__ : null
const inv = T && T.core && T.core.invoke
if (typeof inv !== 'function') return 0
return inv('app_memory_mb').catch(() => 0)
}).then((v) => { if (!alive) return; const n = Number(v) || 0; if (n > 0) setMemMb(n) }).catch(() => {}).then(() => { if (alive) timer = setTimeout(tick, 4000) })
}
timer = setTimeout(tick, 1200)
return () => { alive = false; if (timer) clearTimeout(timer) }
}, [])
const scaleText = Math.round(viewport.scale * 100) + '%'
const saveText = saveState === 'saving' ? '正在保存' : saveState === 'saved' ? '保存成功' : saveState === 'error' ? '保存失败' : ''
const connecting = !!conn
@@ -8095,6 +8128,7 @@ const tbCenterSeed = (type, refs) => {
setSettingOpen,
saveState,
saveText,
memMb,
notice,
busy,
progress,