From 9a8fec2e9cafe677156562fcc13187247001dcc5 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Wed, 8 Jul 2026 15:04:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(usercenter):=20=E5=8A=A0=20no-FOUC=20?= =?UTF-8?q?=E5=86=85=E8=81=94=E8=84=9A=E6=9C=AC,=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=97=B6=E6=98=8E=E6=9A=97=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E6=95=B4=E9=A1=B5=E9=85=8D=E8=89=B2=E9=97=AA=E7=83=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit layout 之前把 data-theme 硬编码 light、挂载后才由 UIProvider effect 应用保存的主题, 暗色偏好用户每次刷新先见浅色再翻暗色 = 整页配色重绘(叠加内容加载,观感"刷两次")。 照官网 Site.astro 做法:
内联脚本在首屏渲染前读 localStorage(pg_uc_theme/ pg_uc_lang)设好 data-theme 与 html lang。/user/* CSP 允许 unsafe-inline 脚本,直接内联; 脚本为编译期常量、无插值、只读 localStorage,无 XSS 风险。 Co-Authored-By: Claude Opus 4.8