Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m24s
用户把资料目录放局域网:点开后先有 15s 纯白板,然后进度条 1s 闪过。 原因有两层: 1) app.js 顶部 `await IWBStorageFile.ready()` 在 React 首次渲染之前,存储装载多久白板就多久; 而 index.html 里没有任何静态画面,WebView 只能显示空白。 2) 那段装载里有一串串行网络往返:串行建 9 个子目录、读 data.json、逐个读画布、 再加 5 个一次性维护(migrateBlobs/backfillGalleryThumbs/stripInlineGalleryThumbs/ rotateTrash/dropLegacyDisplayThumbs),局域网下每次往返几百毫秒就是十几秒。 - scripts/boot-splash.js(新增)+ scripts/build.js:index.html 内联静态启动屏 (logo/标题/进度条/阶段文字/已等待秒数),不依赖脚本即可出画面;React 启动屏挂载时顶掉它 - src/storage-file.js:ensureDirs 改并发(9 次往返 → 1 次);一次性维护延后到首屏后 1.2s; prepare 阶段按 4 步上报(授权 / 建目录 / 整理文件名 / 完成) - src/runtime-boot-progress.js:阶段权重改为 prepare 0-10 / data 10-16 / canvases 16-70 / library 70-80 / finalize 80-96,进度条从第一秒起覆盖整段装载 - scripts/check-dist.js:index.html script 数 3→4(含内联启动屏),并断言启动屏存在 - tests/boot-progress-test.js:同步新的阶段边界
74 lines
4.2 KiB
JavaScript
74 lines
4.2 KiB
JavaScript
'use strict'
|
|
// 静态启动屏(v3.26.109):内联进 index.html,不依赖任何脚本就能出画面。
|
|
// 为什么:资料目录放在局域网时,app.js 要等「存储装载」完成才渲染 React,
|
|
// 那段时间原本是纯白板(实测 15s)。
|
|
|
|
const css = `<style>
|
|
#iwb-boot-static{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;background:#f6f6f7;color:#1c1d1f;font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;transition:opacity .45s ease}
|
|
#iwb-boot-static.iwb-boot-out{opacity:0;pointer-events:none}
|
|
#iwb-boot-static .bs-logo{width:54px;height:54px;color:#575d69;animation:bs-bob 1.2s ease-in-out infinite}
|
|
#iwb-boot-static .bs-title{font-size:18px;font-weight:700;letter-spacing:1px}
|
|
#iwb-boot-static .bs-bar{width:300px;height:6px;border-radius:999px;background:#e8e9ec;border:1px solid #d8dade;overflow:hidden;position:relative}
|
|
#iwb-boot-static .bs-fill{position:absolute;left:0;top:0;bottom:0;width:8%;border-radius:999px;background:linear-gradient(90deg,#6b7280,#575d69);transition:width .32s cubic-bezier(.2,.7,.3,1)}
|
|
#iwb-boot-static .bs-fill::after{content:"";position:absolute;inset:0;transform:translateX(-100%);background:linear-gradient(90deg,transparent,#fff,transparent);animation:bs-sheen 1.5s ease-in-out infinite}
|
|
#iwb-boot-static .bs-meta{width:300px;display:flex;align-items:baseline;justify-content:space-between;gap:12px;font-size:12px;color:#5c6068}
|
|
#iwb-boot-static .bs-pct{font-variant-numeric:tabular-nums;font-weight:600;color:#1c1d1f}
|
|
@keyframes bs-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-9px)}}
|
|
@keyframes bs-sheen{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}
|
|
@media (prefers-color-scheme:dark){
|
|
#iwb-boot-static{background:#161a19;color:#e9eaea}
|
|
#iwb-boot-static .bs-logo{color:#c9cbcd}
|
|
#iwb-boot-static .bs-bar{background:#23282a;border-color:#2f3638}
|
|
#iwb-boot-static .bs-fill{background:linear-gradient(90deg,#e8e8e8,#c9cbcd)}
|
|
#iwb-boot-static .bs-meta{color:#a8adb0}
|
|
#iwb-boot-static .bs-pct{color:#e9eaea}
|
|
}
|
|
@media (prefers-reduced-motion:reduce){#iwb-boot-static .bs-logo,#iwb-boot-static .bs-fill::after{animation:none}}
|
|
</style>`
|
|
|
|
const markup = `<div id="iwb-boot-static" role="status" aria-live="polite">
|
|
<svg class="bs-logo" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><circle cx="17.5" cy="17.5" r="3.5"/></svg>
|
|
<div class="bs-title">生图工作台</div>
|
|
<div class="bs-bar"><div class="bs-fill" id="bs-fill"></div></div>
|
|
<div class="bs-meta"><span id="bs-sub">正在启动…</span><span class="bs-pct" id="bs-pct"></span></div>
|
|
</div>`
|
|
|
|
// 轮询进度总线:真实百分比(IWBBootProgress 就绪后),之前显示已等待秒数
|
|
const script = `<script>
|
|
(function () {
|
|
var t0 = Date.now()
|
|
var box = document.getElementById('iwb-boot-static')
|
|
var fill = document.getElementById('bs-fill')
|
|
var sub = document.getElementById('bs-sub')
|
|
var pct = document.getElementById('bs-pct')
|
|
var lastPct = -1
|
|
function hide () {
|
|
if (!box) return
|
|
box.className = 'iwb-boot-out'
|
|
setTimeout(function () { if (box && box.parentNode) box.parentNode.removeChild(box) }, 500)
|
|
}
|
|
window.__iwbHideBootStatic = hide
|
|
function apply () {
|
|
if (!box) return
|
|
var bp = window.IWBBootProgress
|
|
var s = bp && bp.snapshot ? bp.snapshot() : null
|
|
if (s) {
|
|
if (!s.indeterminate && s.pct !== lastPct) {
|
|
lastPct = s.pct
|
|
fill.style.width = Math.max(8, s.pct) + '%'
|
|
pct.textContent = s.pct + '%'
|
|
}
|
|
sub.textContent = s.detail ? (s.label + ' · ' + s.detail) : s.label
|
|
if (s.done) { hide(); return }
|
|
} else {
|
|
var sec = Math.floor((Date.now() - t0) / 1000)
|
|
sub.textContent = '正在启动…' + (sec >= 2 ? ' ' + sec + 's' : '')
|
|
}
|
|
requestAnimationFrame(apply)
|
|
}
|
|
requestAnimationFrame(apply)
|
|
})()
|
|
</script>`
|
|
|
|
module.exports = { css, markup, script }
|