perf(theme): onLaunch 提前设导航栏色,缩小冷启动橙->主题色跳变
新增 applyChrome() 在 onLaunch 第一行调用,把导航栏变色点从首页 onShow 提前到 onLaunch,缩短冷启动橙色跳变窗口。app.json 静态橙色在 JS 执行前 生效是框架硬限制,无法完全消除。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -130,11 +130,25 @@ const applyWindowBg = () => {
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动尽早调用:设导航栏色 + 窗口背景。
|
||||
* 原生导航栏在 JS 执行前用 app.json 写死的橙色,这里在 onLaunch 第一时间
|
||||
* 切到用户主题色,把冷启动橙->主题色的跳变窗口压到最小(无法完全消除,
|
||||
* 因为 app.json 静态值在 onLaunch 之前就已应用)。
|
||||
*/
|
||||
const applyChrome = () => {
|
||||
try {
|
||||
_setNavBarColor(getCurrentTheme().primary)
|
||||
applyWindowBg()
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
THEMES,
|
||||
DEFAULT_THEME_ID,
|
||||
BASE_VARS,
|
||||
applyWindowBg,
|
||||
applyChrome,
|
||||
getThemeById,
|
||||
getCurrentTheme,
|
||||
setTheme,
|
||||
|
||||
Reference in New Issue
Block a user