整理代码

develop
就眠仪式 2020-07-25 15:44:22 +08:00
parent dc9c52040e
commit f12a42b4a4
1 changed files with 19 additions and 29 deletions

View File

@ -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,7 +80,6 @@ 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);
@ -131,14 +124,12 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
}) })
} }
} }
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) {
@ -147,7 +138,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
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 {
@ -161,13 +151,11 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
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 = '';
@ -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);
}) })