pipeline-app/wwwroot/theme_toggle.js
yumoqing 4ef2825b59 feat(topbar): 语言按钮前加主题切换+最小化窗口按钮(参考sage)
- 主题按钮:dark/light切换,localStorage持久化,刷新恢复;图标随主题变
- 最小化窗口按钮:bricks.app.show_windows_panel(app-dock.svg图标)
- theme_toggle.js:页面加载恢复主题+同步图标(注册any权限,防401渲染中断)
- merge_i18n补两按钮tip词条
2026-08-29 16:50:44 +08:00

28 lines
967 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 顶栏主题切换:页面加载时恢复上次主题 + 同步按钮图标
约定light 主题显示 🌙点击切暗dark 主题显示 ☀️(点击切亮) */
(function(){
if (typeof bricks === 'undefined') return;
var KEY = 'pipeline_ui_theme';
function applyTheme(t){
document.documentElement.setAttribute('data-theme', t);
var btn = bricks.getWidgetById('theme_toggle_btn', bricks.app);
if (btn && btn.dom_element){
btn.opts.label = (t === 'light') ? '🌙' : '☀️';
btn.dom_element.textContent = btn.opts.label;
}
}
window.applyPipelineTheme = applyTheme;
function _start(){
if (bricks.app && bricks.getWidgetById){
var t = null;
try { t = localStorage.getItem(KEY); } catch(e) {}
applyTheme(t || 'light');
} else {
setTimeout(_start, 300);
}
}
setTimeout(_start, 300);
})();