feature/issue-189
main
修复 issue #189 [P1] 驾驶舱主题 token 全局注入后页面卸载不清理,污染全局 CSS 变量(生产交付审计发现)。
cockpit/index.vue 加载模板时把 theme token 通过 document.documentElement.style.setProperty() 直接注入 :root,但 onUnmounted 只清理了定时器,没有清理注入的变量。后果:进过驾驶舱再切到其他页面(或切换模板),全局 CSS 变量被残留值污染,其他页面颜色异常。
cockpit/index.vue
document.documentElement.style.setProperty()
:root
onUnmounted
injectedTokens: Array<{ key, prev }>
setProperty(key, prev)
removeProperty(key)
说明:issue 还提到更优方案是注入到驾驶舱容器元素(scoped 作用域)。当前采用「记录旧值 + 恢复」方案,改动最小、风险最低,同样彻底消除全局污染;scoped 容器方案涉及子组件 CSS 变量继承链验证,留作后续优化。
pnpm build
fixes #189
问题:cockpit/index.vue 加载模板时把 theme token 通过 setProperty 注入 :root,但 onUnmounted 仅 clearInterval 未清理, 导致进过驾驶舱/切换模板后全局 CSS 变量被残留值污染,其他页面颜色异常。 修复: 1. 注入前记录被改动的变量名及旧值(injectedTokens)。 2. onUnmounted 时逐个恢复旧值(有旧值则 setProperty 恢复, 原本无则 removeProperty 移除),杜绝全局污染。 验收:进驾驶舱再切到其他页面,全局 CSS 变量无残留值,颜色正常。 (本环境无 pnpm,构建验证转 bot_qa)
内容已由 bot_dev1 手工合并进 main(merge commit be2730f),关闭本 PR。
No dependencies set.
The note is not visible to the blocked user.
概述
修复 issue #189 [P1] 驾驶舱主题 token 全局注入后页面卸载不清理,污染全局 CSS 变量(生产交付审计发现)。
问题
cockpit/index.vue加载模板时把 theme token 通过document.documentElement.style.setProperty()直接注入:root,但onUnmounted只清理了定时器,没有清理注入的变量。后果:进过驾驶舱再切到其他页面(或切换模板),全局 CSS 变量被残留值污染,其他页面颜色异常。修复
injectedTokens: Array<{ key, prev }>)。onUnmounted时逐个恢复:有旧值则setProperty(key, prev)恢复,原本无则removeProperty(key)移除。验收
:root上本次注入的变量已恢复/移除,全局颜色正常pnpm build:本环境无 pnpm/node_modules,转 bot_qa 构建环境验证fixes #189
内容已由 bot_dev1 手工合并进 main(merge commit be2730f),关闭本 PR。
Pull request closed