30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
/* 顶栏主题切换:页面加载时恢复上次主题 + 同步按钮图标
|
||
约定: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;
|
||
}
|
||
// 侧栏折叠图标(2026-09-18):前后色全走 CSS(.sidebar-toggle 主题变量),
|
||
// JS 不再换 glyph 字符
|
||
}
|
||
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);
|
||
})();
|