Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m8s
现象:风格库 / 浏览器 / 提示词库的面板与画布上的样式节点全部丢样式(DOM 正常、宿主外链
style.css 正常,只有插件动态注入的 <style> 不生效)。
根因:Tauri 会为 index.html 里的内联块加 CSP nonce;CSP3 规定 nonce 一出现 'unsafe-inline'
即被忽略。插件样式是运行时 document.createElement('style') 注入的、没有 nonce,于是被整段丢弃。
这正是 v3.26.9 修过、v3.26.10 回退掉的那条链(当时靠给动态 style 补 nonce 解决)。
我上两版把启动屏做成了内联 <style>+<script>,等于把这个坑重新踩了一遍。
- scripts/boot-splash.js:只导出标记(复用宿主已有的 .iwb-splash* 类),不再有内联样式/脚本
- scripts/build.js:index.html 只内联启动屏标记,样式走外链 style.css
- src/ui-splash.js:React 启动屏挂载时直接移除 #iwb-boot-static 节点
- scripts/check-dist.js:script 数回到 3,并新增断言「index.html 不得含内联 <style>/<script>」
并写明原因,防止下次再踩
9 lines
1.2 KiB
JavaScript
9 lines
1.2 KiB
JavaScript
'use strict'
|
||
// 静态启动屏(v3.26.109):内联进 index.html,浏览器解析完 HTML 就有画面,消掉局域网资料目录的启动白屏。
|
||
// 只用宿主样式表里已有的 .iwb-splash* 类 —— 不能在 index.html 里写内联 <style>/<script>:
|
||
// Tauri 会给内联块加 CSP nonce,CSP3 下 nonce 一出现 'unsafe-inline' 就失效,
|
||
// 插件动态注入的 <style> 会被整段丢弃(v3.26.9 踩过同一个坑)。
|
||
const markup = '<div id="iwb-boot-static" class="iwb-splash" role="status" aria-live="polite">\n <div class="iwb-splash-logo"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" width="100%" height="100%"><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>\n <div class="iwb-splash-title">生图工作台</div>\n <div class="iwb-splash-bar is-indeterminate"><div class="iwb-splash-bar-fill"></div></div>\n <div class="iwb-splash-meta"><span class="iwb-splash-sub">正在启动…</span><span class="iwb-splash-pct"></span></div>\n</div>'
|
||
|
||
module.exports = { markup }
|