整理代码
parent
dc9c52040e
commit
f12a42b4a4
|
|
@ -14,7 +14,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
var bodyTab;
|
var bodyTab;
|
||||||
|
|
||||||
var pearAdmin = new function() {
|
var pearAdmin = new function() {
|
||||||
|
|
||||||
this.render = function(option) {
|
this.render = function(option) {
|
||||||
var option = getData();
|
var option = getData();
|
||||||
this.menuRender(option);
|
this.menuRender(option);
|
||||||
|
|
@ -23,12 +22,10 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
this.logoRender(option);
|
this.logoRender(option);
|
||||||
this.themeRender(option);
|
this.themeRender(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logoRender = function(option) {
|
this.logoRender = function(option) {
|
||||||
$(".layui-logo .logo").attr("src", option.logo.image);
|
$(".layui-logo .logo").attr("src", option.logo.image);
|
||||||
$(".layui-logo .title").html(option.logo.title);
|
$(".layui-logo .title").html(option.logo.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.menuRender = function(option) {
|
this.menuRender = function(option) {
|
||||||
sideMenu = pearMenu.render({
|
sideMenu = pearMenu.render({
|
||||||
elem: 'sideMenu', //依赖容器
|
elem: 'sideMenu', //依赖容器
|
||||||
|
|
@ -44,7 +41,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
})
|
})
|
||||||
sideMenu.selectItem(option.menu.select);
|
sideMenu.selectItem(option.menu.select);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bodyRender = function(option) {
|
this.bodyRender = function(option) {
|
||||||
if (option.tab.muiltTab) {
|
if (option.tab.muiltTab) {
|
||||||
bodyTab = pearTab.render({
|
bodyTab = pearTab.render({
|
||||||
|
|
@ -65,12 +61,10 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
close: false
|
close: false
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
bodyTab.click(function(id) {
|
bodyTab.click(function(id) {
|
||||||
bodyTab.positionTab();
|
bodyTab.positionTab();
|
||||||
sideMenu.selectItem(id);
|
sideMenu.selectItem(id);
|
||||||
})
|
})
|
||||||
|
|
||||||
$("body").on("click", ".refresh", function() {
|
$("body").on("click", ".refresh", function() {
|
||||||
$(".refresh a").removeClass("layui-icon-refresh-1");
|
$(".refresh a").removeClass("layui-icon-refresh-1");
|
||||||
$(".refresh a").addClass("layui-anim");
|
$(".refresh a").addClass("layui-anim");
|
||||||
|
|
@ -86,11 +80,10 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
$(".refresh a").removeClass("layui-icon-loading");
|
$(".refresh a").removeClass("layui-icon-loading");
|
||||||
}, 600)
|
}, 600)
|
||||||
})
|
})
|
||||||
|
|
||||||
sideMenu.click(function(dom, data) {
|
sideMenu.click(function(dom, data) {
|
||||||
|
|
||||||
console.log(data.menuUrl);
|
console.log(data.menuUrl);
|
||||||
|
|
||||||
bodyTab.addTabOnly({
|
bodyTab.addTabOnly({
|
||||||
id: data.menuId,
|
id: data.menuId,
|
||||||
title: data.menuTitle,
|
title: data.menuTitle,
|
||||||
|
|
@ -125,49 +118,44 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
})
|
})
|
||||||
sideMenu.click(function(dom, data) {
|
sideMenu.click(function(dom, data) {
|
||||||
console.log(data.menuUrl);
|
console.log(data.menuUrl);
|
||||||
|
|
||||||
bodyFrame.changePage(data.menuUrl, data.menuPath, true);
|
bodyFrame.changePage(data.menuUrl, data.menuPath, true);
|
||||||
compatible()
|
compatible()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.keepLoad = function(option) {
|
this.keepLoad = function(option) {
|
||||||
compatible()
|
compatible()
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$(".loader-main").fadeOut(option.done);
|
$(".loader-main").fadeOut(option.done);
|
||||||
}, option.other.keepLoad)
|
}, option.other.keepLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.themeRender = function(option) {
|
this.themeRender = function(option) {
|
||||||
|
|
||||||
if(option.theme.allowCustom == false){
|
if (option.theme.allowCustom == false) {
|
||||||
$(".setting").remove();
|
$(".setting").remove();
|
||||||
}
|
}
|
||||||
var colorId = localStorage.getItem("theme-color");
|
var colorId = localStorage.getItem("theme-color");
|
||||||
var menu = localStorage.getItem("theme-menu");
|
var menu = localStorage.getItem("theme-menu");
|
||||||
var color = getColorById(colorId);
|
var color = getColorById(colorId);
|
||||||
|
if (menu == "null") {
|
||||||
if(menu=="null"){
|
|
||||||
menu = option.theme.defaultMenu;
|
menu = option.theme.defaultMenu;
|
||||||
}else{
|
} else {
|
||||||
|
|
||||||
if(option.theme.allowCustom == false){
|
if (option.theme.allowCustom == false) {
|
||||||
menu = option.theme.defaultMenu;
|
menu = option.theme.defaultMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem("theme-color",color.id);
|
localStorage.setItem("theme-color", color.id);
|
||||||
localStorage.setItem("theme-menu",menu);
|
localStorage.setItem("theme-menu", menu);
|
||||||
this.colorSet(color.color);
|
this.colorSet(color.color);
|
||||||
this.menuSkin(menu);
|
this.menuSkin(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.menuSkin = function(theme) {
|
this.menuSkin = function(theme) {
|
||||||
$(".pear-admin").removeClass("light-theme");
|
$(".pear-admin").removeClass("light-theme");
|
||||||
$(".pear-admin").removeClass("dark-theme");
|
$(".pear-admin").removeClass("dark-theme");
|
||||||
$(".pear-admin").addClass(theme);
|
$(".pear-admin").addClass(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.colorSet = function(color) {
|
this.colorSet = function(color) {
|
||||||
|
|
||||||
var style = '';
|
var style = '';
|
||||||
|
|
@ -386,7 +374,7 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
var color = getColorById(colorId);
|
var color = getColorById(colorId);
|
||||||
pearAdmin.colorSet(color.color);
|
pearAdmin.colorSet(color.color);
|
||||||
});
|
});
|
||||||
|
|
||||||
function getColorById(id) {
|
function getColorById(id) {
|
||||||
var color;
|
var color;
|
||||||
var flag = false;
|
var flag = false;
|
||||||
|
|
@ -397,10 +385,10 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(flag==false || data.theme.allowCustom == false){
|
if (flag == false || data.theme.allowCustom == false) {
|
||||||
$.each(data.colors, function(i, value) {
|
$.each(data.colors, function(i, value) {
|
||||||
if (value.id == data.theme.defaultColor) {
|
if (value.id == data.theme.defaultColor) {
|
||||||
color = value;
|
color = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -420,9 +408,11 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
function buildColorHtml() {
|
function buildColorHtml() {
|
||||||
var colors = "";
|
var colors = "";
|
||||||
$.each(getData().colors, function(i, value) {
|
$.each(getData().colors, function(i, value) {
|
||||||
colors += "<span class='select-color-item' color-id='" + value.id + "' style='background-color:" + value.color + ";'></span>";
|
colors += "<span class='select-color-item' color-id='" + value.id + "' style='background-color:" + value.color +
|
||||||
|
";'></span>";
|
||||||
})
|
})
|
||||||
return "<div class='select-color'><div class='select-color-title'>主题色</div><div class='select-color-content'>" + colors + "</div></div>"
|
return "<div class='select-color'><div class='select-color-title'>主题色</div><div class='select-color-content'>" +
|
||||||
|
colors + "</div></div>"
|
||||||
}
|
}
|
||||||
exports('admin', pearAdmin);
|
exports('admin', pearAdmin);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue