diff --git a/component/pear/modules/admin.js b/component/pear/modules/admin.js index 13e2879..7b89e01 100644 --- a/component/pear/modules/admin.js +++ b/component/pear/modules/admin.js @@ -171,12 +171,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame const currentColor = getColorById(colorId); localStorage.setItem("theme-color", currentColor.id); localStorage.setItem("theme-color-context", currentColor.color); - var themeConfig = { - allowCustom: option.theme.allowCustom, - defaultColor: option.theme.defaultColor, - autoHead: option.other.autoHead, - } - pearTheme.changeTheme(window, themeConfig); + pearTheme.changeTheme(window, option.theme.allowCustom); let menu = localStorage.getItem("theme-menu"); if (menu === "null") { menu = option.theme.defaultMenu; @@ -337,7 +332,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame const currentColor = getColorById(colorId); localStorage.setItem("theme-color", currentColor.id); localStorage.setItem("theme-color-context", currentColor.color); - pearTheme.changeTheme(window); + pearTheme.changeTheme(window, config.theme.allowCustom); }); function applyConfig(param) { diff --git a/component/pear/modules/theme.js b/component/pear/modules/theme.js index b3291e7..08f4208 100644 --- a/component/pear/modules/theme.js +++ b/component/pear/modules/theme.js @@ -3,38 +3,27 @@ layui.define(["jquery","layer"], function (exports) { $ = layui.jquery; var theme = {}; - theme.config = { - allowCustom : false, - defaultColor : {}, - autoHead : false - }; + theme.autoHead = false; - theme.changeTheme = function (target,themeConfig) { - if(themeConfig == undefined){ - themeConfig = this.config; - } + theme.changeTheme = function (target, autoHead) { + this.autoHead = autoHead; - this.themeRender(themeConfig); + const color = localStorage.getItem("theme-color-context"); + this.colorSet(color); if (target.frames.length == 0) return; for (var i = 0; i < target.frames.length; i++) { try { if(target.frames[i].layui == undefined) continue; - target.frames[i].layui.theme.changeTheme(target.frames[i], themeConfig); - } + target.frames[i].layui.theme.changeTheme(target.frames[i], autoHead); + } catch (error) { console.log(error); } } } - theme.themeRender = function (themeConfig) { - this.config = themeConfig; - const color = localStorage.getItem("theme-color-context"); - this.colorSet(color); - } - theme.colorSet = function(color) { let style = ''; @@ -79,7 +68,7 @@ layui.define(["jquery","layer"], function (exports) { style += '.pear-social-entrance {background-color:' + color + '!important}'; style += '.pear-admin .pe-collaspe {background-color:' + color + '!important}'; - if(this.config.autoHead){ + if(this.autoHead){ style += '.pear-admin .layui-header{background-color:' + color + '!important;}.pear-admin .layui-header .layui-nav .layui-nav-item>a{color:white!important;}'; }