Clean code
parent
f61e8f1d82
commit
db5162daad
|
|
@ -171,12 +171,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
|
||||||
const currentColor = getColorById(colorId);
|
const currentColor = getColorById(colorId);
|
||||||
localStorage.setItem("theme-color", currentColor.id);
|
localStorage.setItem("theme-color", currentColor.id);
|
||||||
localStorage.setItem("theme-color-context", currentColor.color);
|
localStorage.setItem("theme-color-context", currentColor.color);
|
||||||
var themeConfig = {
|
pearTheme.changeTheme(window, option.theme.allowCustom);
|
||||||
allowCustom: option.theme.allowCustom,
|
|
||||||
defaultColor: option.theme.defaultColor,
|
|
||||||
autoHead: option.other.autoHead,
|
|
||||||
}
|
|
||||||
pearTheme.changeTheme(window, themeConfig);
|
|
||||||
let menu = localStorage.getItem("theme-menu");
|
let menu = localStorage.getItem("theme-menu");
|
||||||
if (menu === "null") {
|
if (menu === "null") {
|
||||||
menu = option.theme.defaultMenu;
|
menu = option.theme.defaultMenu;
|
||||||
|
|
@ -337,7 +332,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
|
||||||
const currentColor = getColorById(colorId);
|
const currentColor = getColorById(colorId);
|
||||||
localStorage.setItem("theme-color", currentColor.id);
|
localStorage.setItem("theme-color", currentColor.id);
|
||||||
localStorage.setItem("theme-color-context", currentColor.color);
|
localStorage.setItem("theme-color-context", currentColor.color);
|
||||||
pearTheme.changeTheme(window);
|
pearTheme.changeTheme(window, config.theme.allowCustom);
|
||||||
});
|
});
|
||||||
|
|
||||||
function applyConfig(param) {
|
function applyConfig(param) {
|
||||||
|
|
|
||||||
|
|
@ -3,25 +3,20 @@ layui.define(["jquery","layer"], function (exports) {
|
||||||
$ = layui.jquery;
|
$ = layui.jquery;
|
||||||
|
|
||||||
var theme = {};
|
var theme = {};
|
||||||
theme.config = {
|
theme.autoHead = false;
|
||||||
allowCustom : false,
|
|
||||||
defaultColor : {},
|
|
||||||
autoHead : false
|
|
||||||
};
|
|
||||||
|
|
||||||
theme.changeTheme = function (target,themeConfig) {
|
theme.changeTheme = function (target, autoHead) {
|
||||||
if(themeConfig == undefined){
|
this.autoHead = autoHead;
|
||||||
themeConfig = this.config;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.themeRender(themeConfig);
|
const color = localStorage.getItem("theme-color-context");
|
||||||
|
this.colorSet(color);
|
||||||
|
|
||||||
if (target.frames.length == 0) return;
|
if (target.frames.length == 0) return;
|
||||||
|
|
||||||
for (var i = 0; i < target.frames.length; i++) {
|
for (var i = 0; i < target.frames.length; i++) {
|
||||||
try {
|
try {
|
||||||
if(target.frames[i].layui == undefined) continue;
|
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) {
|
catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
@ -29,12 +24,6 @@ layui.define(["jquery","layer"], function (exports) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
theme.themeRender = function (themeConfig) {
|
|
||||||
this.config = themeConfig;
|
|
||||||
const color = localStorage.getItem("theme-color-context");
|
|
||||||
this.colorSet(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
theme.colorSet = function(color) {
|
theme.colorSet = function(color) {
|
||||||
|
|
||||||
let style = '';
|
let style = '';
|
||||||
|
|
@ -79,7 +68,7 @@ layui.define(["jquery","layer"], function (exports) {
|
||||||
|
|
||||||
style += '.pear-social-entrance {background-color:' + color + '!important}';
|
style += '.pear-social-entrance {background-color:' + color + '!important}';
|
||||||
style += '.pear-admin .pe-collaspe {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;}';
|
style += '.pear-admin .layui-header{background-color:' + color + '!important;}.pear-admin .layui-header .layui-nav .layui-nav-item>a{color:white!important;}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue