2021-03-13 13:42:53 +00:00
|
|
|
|
layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme', 'convert'],
|
2020-07-15 21:22:46 +00:00
|
|
|
|
function(exports) {
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const $ = layui.jquery,
|
2020-07-15 21:22:46 +00:00
|
|
|
|
form = layui.form,
|
|
|
|
|
|
element = layui.element,
|
2020-12-06 05:25:55 +00:00
|
|
|
|
yaml = layui.yaml,
|
2020-07-15 21:22:46 +00:00
|
|
|
|
pearTab = layui.tab,
|
2021-03-10 04:19:12 +00:00
|
|
|
|
convert = layui.convert,
|
2020-07-15 21:22:46 +00:00
|
|
|
|
pearMenu = layui.menu,
|
2021-01-16 14:48:49 +00:00
|
|
|
|
pearFrame = layui.frame,
|
2021-03-13 13:42:53 +00:00
|
|
|
|
pearTheme = layui.theme,
|
|
|
|
|
|
message = layui.message;
|
2020-07-15 21:22:46 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
let bodyFrame;
|
|
|
|
|
|
let sideMenu;
|
|
|
|
|
|
let bodyTab;
|
|
|
|
|
|
let config;
|
2021-03-11 04:35:32 +00:00
|
|
|
|
let logout = function() {};
|
2021-03-13 13:42:53 +00:00
|
|
|
|
let msgInstance;
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const body = $('body');
|
|
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
const pearAdmin = new function() {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
|
2021-01-01 12:17:19 +00:00
|
|
|
|
// 默认配置
|
|
|
|
|
|
let configType = 'yml';
|
|
|
|
|
|
let configPath = 'pear.config.yml';
|
2020-11-23 08:17:29 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.setConfigPath = function(path) {
|
2020-11-08 22:27:38 +00:00
|
|
|
|
configPath = path;
|
|
|
|
|
|
}
|
2021-02-20 09:11:38 +00:00
|
|
|
|
|
2021-01-01 12:17:19 +00:00
|
|
|
|
this.setConfigType = function(type) {
|
|
|
|
|
|
configType = type;
|
|
|
|
|
|
}
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
|
|
|
|
|
this.setAvatar = function(url, username) {
|
2021-03-10 04:19:12 +00:00
|
|
|
|
var image = new Image();
|
|
|
|
|
|
image.src = "admin/images/avatar.jpg";
|
2021-03-11 04:35:32 +00:00
|
|
|
|
image.onload = function() {
|
2021-03-10 04:19:12 +00:00
|
|
|
|
$(".layui-nav-img").attr("src", convert.imageToBase64(image));
|
|
|
|
|
|
}
|
2021-03-11 04:35:32 +00:00
|
|
|
|
$(".layui-nav-img").parent().append(username);
|
2021-03-10 04:19:12 +00:00
|
|
|
|
}
|
2020-11-08 22:27:38 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.render = function(initConfig) {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (initConfig !== undefined) {
|
2020-10-11 03:35:31 +00:00
|
|
|
|
applyConfig(initConfig);
|
|
|
|
|
|
} else {
|
2020-12-06 05:25:55 +00:00
|
|
|
|
applyConfig(pearAdmin.readConfig());
|
2020-10-11 03:35:31 +00:00
|
|
|
|
}
|
2020-07-15 21:22:46 +00:00
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.readConfig = function() {
|
2021-02-20 09:11:38 +00:00
|
|
|
|
if (configType === "yml") {
|
2021-01-01 12:17:19 +00:00
|
|
|
|
return yaml.load(configPath);
|
2021-02-20 09:11:38 +00:00
|
|
|
|
} else {
|
2021-01-01 12:17:19 +00:00
|
|
|
|
let data;
|
|
|
|
|
|
$.ajax({
|
2021-02-20 09:11:38 +00:00
|
|
|
|
url: configPath,
|
|
|
|
|
|
type: 'get',
|
|
|
|
|
|
dataType: 'json',
|
2021-01-01 12:17:19 +00:00
|
|
|
|
async: false,
|
2021-02-20 09:11:38 +00:00
|
|
|
|
success: function(result) {
|
2021-01-01 12:17:19 +00:00
|
|
|
|
data = result;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
return data;
|
|
|
|
|
|
}
|
2020-11-08 22:27:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-13 13:42:53 +00:00
|
|
|
|
this.messageRender = function(option) {
|
|
|
|
|
|
var option = {
|
|
|
|
|
|
elem: '.message',
|
|
|
|
|
|
url: option.header.message,
|
|
|
|
|
|
height: '250px'
|
|
|
|
|
|
};
|
|
|
|
|
|
msgInstance = message.render(option);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.logoRender = function(param) {
|
2020-08-04 01:09:52 +00:00
|
|
|
|
$(".layui-logo .logo").attr("src", param.logo.image);
|
|
|
|
|
|
$(".layui-logo .title").html(param.logo.title);
|
2020-07-15 21:22:46 +00:00
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.menuRender = function(param) {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
sideMenu = pearMenu.render({
|
2020-08-04 01:09:52 +00:00
|
|
|
|
elem: 'sideMenu',
|
2020-11-23 08:17:29 +00:00
|
|
|
|
async: param.menu.async !== undefined ? param.menu.async : true,
|
2020-07-21 13:42:43 +00:00
|
|
|
|
theme: "dark-theme",
|
2020-07-15 21:22:46 +00:00
|
|
|
|
height: '100%',
|
2021-03-10 18:42:57 +00:00
|
|
|
|
method: param.menu.method,
|
2020-11-23 08:17:29 +00:00
|
|
|
|
control: param.menu.control ? 'control' : false, // control
|
2020-08-11 11:34:44 +00:00
|
|
|
|
defaultMenu: 0,
|
2020-08-04 01:09:52 +00:00
|
|
|
|
accordion: param.menu.accordion,
|
2020-09-30 04:57:03 +00:00
|
|
|
|
url: param.menu.data,
|
2020-11-08 22:27:38 +00:00
|
|
|
|
data: param.menu.data, //async为false时,传入菜单数组
|
2020-08-11 11:34:44 +00:00
|
|
|
|
parseData: false,
|
2020-11-23 09:25:05 +00:00
|
|
|
|
change: function() {
|
2020-08-11 11:34:44 +00:00
|
|
|
|
compatible();
|
2020-10-12 00:04:24 +00:00
|
|
|
|
},
|
2020-11-23 09:25:05 +00:00
|
|
|
|
done: function() {
|
2020-10-13 16:27:55 +00:00
|
|
|
|
sideMenu.selectItem(param.menu.select);
|
|
|
|
|
|
}
|
2020-10-12 00:04:24 +00:00
|
|
|
|
});
|
2020-07-15 21:22:46 +00:00
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.bodyRender = function(param) {
|
|
|
|
|
|
body.on("click", ".refresh", function() {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const refreshA = $(".refresh a");
|
|
|
|
|
|
refreshA.removeClass("layui-icon-refresh-1");
|
|
|
|
|
|
refreshA.addClass("layui-anim");
|
|
|
|
|
|
refreshA.addClass("layui-anim-rotate");
|
|
|
|
|
|
refreshA.addClass("layui-anim-loop");
|
|
|
|
|
|
refreshA.addClass("layui-icon-loading");
|
2021-02-20 09:11:38 +00:00
|
|
|
|
if (param.tab.muiltTab) bodyTab.refresh(400);
|
|
|
|
|
|
else bodyFrame.refresh(400);
|
2020-11-23 09:25:05 +00:00
|
|
|
|
setTimeout(function() {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
refreshA.addClass("layui-icon-refresh-1");
|
|
|
|
|
|
refreshA.removeClass("layui-anim");
|
|
|
|
|
|
refreshA.removeClass("layui-anim-rotate");
|
|
|
|
|
|
refreshA.removeClass("layui-anim-loop");
|
|
|
|
|
|
refreshA.removeClass("layui-icon-loading");
|
|
|
|
|
|
}, 600)
|
|
|
|
|
|
})
|
2020-08-04 12:31:05 +00:00
|
|
|
|
if (param.tab.muiltTab) {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
bodyTab = pearTab.render({
|
|
|
|
|
|
elem: 'content',
|
|
|
|
|
|
roll: true,
|
|
|
|
|
|
tool: true,
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
height: '100%',
|
2021-01-26 14:21:31 +00:00
|
|
|
|
session: param.tab.session,
|
2020-07-15 21:22:46 +00:00
|
|
|
|
index: 0,
|
2020-08-04 12:31:05 +00:00
|
|
|
|
tabMax: param.tab.tabMax,
|
2020-11-23 09:25:05 +00:00
|
|
|
|
closeEvent: function(id) {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
sideMenu.selectItem(id);
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [{
|
2020-08-04 12:31:05 +00:00
|
|
|
|
id: param.tab.index.id,
|
|
|
|
|
|
url: param.tab.index.href,
|
|
|
|
|
|
title: param.tab.index.title,
|
2020-07-15 21:22:46 +00:00
|
|
|
|
close: false
|
2021-01-26 14:21:31 +00:00
|
|
|
|
}],
|
2021-02-20 09:11:38 +00:00
|
|
|
|
success: function(id) {
|
|
|
|
|
|
if (param.tab.session) {
|
|
|
|
|
|
setTimeout(function() {
|
2021-01-26 15:17:21 +00:00
|
|
|
|
sideMenu.selectItem(id);
|
|
|
|
|
|
bodyTab.positionTab();
|
2021-02-20 09:11:38 +00:00
|
|
|
|
}, 500)
|
2021-01-26 15:17:21 +00:00
|
|
|
|
}
|
2021-01-26 14:21:31 +00:00
|
|
|
|
}
|
2020-07-15 21:22:46 +00:00
|
|
|
|
});
|
2020-11-23 09:25:05 +00:00
|
|
|
|
bodyTab.click(function(id) {
|
2020-10-28 09:33:54 +00:00
|
|
|
|
if (!param.tab.keepState) {
|
|
|
|
|
|
bodyTab.refresh(false);
|
2020-07-31 13:10:34 +00:00
|
|
|
|
}
|
2020-07-15 21:22:46 +00:00
|
|
|
|
bodyTab.positionTab();
|
|
|
|
|
|
sideMenu.selectItem(id);
|
|
|
|
|
|
})
|
2020-11-23 08:17:29 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
sideMenu.click(function(dom, data) {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
bodyTab.addTabOnly({
|
|
|
|
|
|
id: data.menuId,
|
|
|
|
|
|
title: data.menuTitle,
|
|
|
|
|
|
url: data.menuUrl,
|
|
|
|
|
|
icon: data.menuIcon,
|
|
|
|
|
|
close: true
|
|
|
|
|
|
}, 300);
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
2020-07-15 21:22:46 +00:00
|
|
|
|
compatible();
|
2021-02-20 09:11:38 +00:00
|
|
|
|
|
2020-07-15 21:22:46 +00:00
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
bodyFrame = pearFrame.render({
|
|
|
|
|
|
elem: 'content',
|
2020-12-29 10:05:28 +00:00
|
|
|
|
title: '首页',
|
2020-08-11 08:22:32 +00:00
|
|
|
|
url: param.tab.index.href,
|
2020-07-15 21:22:46 +00:00
|
|
|
|
width: '100%',
|
|
|
|
|
|
height: '100%'
|
|
|
|
|
|
});
|
2020-11-23 08:17:29 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
sideMenu.click(function(dom, data) {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
bodyFrame.changePage(data.menuUrl, data.menuPath, true);
|
|
|
|
|
|
compatible()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.keepLoad = function(param) {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
compatible()
|
2020-11-23 09:25:05 +00:00
|
|
|
|
setTimeout(function() {
|
2020-09-30 07:11:18 +00:00
|
|
|
|
$(".loader-main").fadeOut(200);
|
|
|
|
|
|
}, param.other.keepLoad)
|
2020-07-15 21:22:46 +00:00
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.themeRender = function(option) {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (option.theme.allowCustom === false) {
|
2020-07-23 05:37:18 +00:00
|
|
|
|
$(".setting").remove();
|
|
|
|
|
|
}
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const colorId = localStorage.getItem("theme-color");
|
2021-01-16 14:48:49 +00:00
|
|
|
|
const currentColor = getColorById(colorId);
|
|
|
|
|
|
localStorage.setItem("theme-color", currentColor.id);
|
|
|
|
|
|
localStorage.setItem("theme-color-context", currentColor.color);
|
2021-01-17 13:43:58 +00:00
|
|
|
|
pearTheme.changeTheme(window, option.other.autoHead);
|
2020-11-23 08:17:29 +00:00
|
|
|
|
let menu = localStorage.getItem("theme-menu");
|
|
|
|
|
|
if (menu === "null") {
|
2020-07-23 06:03:59 +00:00
|
|
|
|
menu = option.theme.defaultMenu;
|
2020-07-25 07:44:22 +00:00
|
|
|
|
} else {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (option.theme.allowCustom === false) {
|
2020-07-23 06:03:59 +00:00
|
|
|
|
menu = option.theme.defaultMenu;
|
2020-07-23 05:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-25 07:44:22 +00:00
|
|
|
|
localStorage.setItem("theme-menu", menu);
|
2020-07-22 20:41:52 +00:00
|
|
|
|
this.menuSkin(menu);
|
|
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
this.menuSkin = function(theme) {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const pearAdmin = $(".pear-admin");
|
|
|
|
|
|
pearAdmin.removeClass("light-theme");
|
|
|
|
|
|
pearAdmin.removeClass("dark-theme");
|
|
|
|
|
|
pearAdmin.addClass(theme);
|
2020-07-22 20:41:52 +00:00
|
|
|
|
}
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
|
|
|
|
|
this.logout = function(callback) {
|
2021-03-10 04:42:33 +00:00
|
|
|
|
logout = callback;
|
|
|
|
|
|
}
|
2021-03-13 13:42:53 +00:00
|
|
|
|
|
|
|
|
|
|
this.message = function(callback) {
|
|
|
|
|
|
if(callback!=null){
|
|
|
|
|
|
msgInstance.click(callback);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
msgInstance.click(messageTip);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-20 13:32:48 +00:00
|
|
|
|
|
|
|
|
|
|
this.jump = function(id,title,url){
|
|
|
|
|
|
if (config.tab.muiltTab) {
|
|
|
|
|
|
bodyTab.addTabOnly({id: id,title: title,url: url,icon: null,close: true},
|
|
|
|
|
|
300);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
sideMenu.selectItem(id);
|
|
|
|
|
|
bodyFrame.changePage(url, title, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-15 21:22:46 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-03-13 13:42:53 +00:00
|
|
|
|
var messageTip = function(id, title, context, form) {
|
|
|
|
|
|
layer.open({
|
|
|
|
|
|
type: 1,
|
|
|
|
|
|
title: '消息', //标题
|
|
|
|
|
|
area: ['390px', '330px'], //宽高
|
|
|
|
|
|
shade: 0.4, //遮罩透明度
|
|
|
|
|
|
content: "<div style='background-color:whitesmoke;'><div class='layui-card'><div class='layui-card-body'>来源 : " +
|
|
|
|
|
|
form + "</div><div class='layui-card-header' >标题 : " + title +
|
|
|
|
|
|
"</div><div class='layui-card-body' >内容 : " + context + "</div></div></div>", //支持获取DOM元素
|
|
|
|
|
|
btn: ['确认'], //按钮组
|
|
|
|
|
|
scrollbar: false, //屏蔽浏览器滚动条
|
|
|
|
|
|
yes: function(index) { //layer.msg('yes'); //点击确定回调
|
|
|
|
|
|
layer.close(index);
|
|
|
|
|
|
showToast();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-23 09:25:05 +00:00
|
|
|
|
function collaspe() {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
sideMenu.collaspe();
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const admin = $(".pear-admin");
|
|
|
|
|
|
const left = $(".layui-icon-spread-left")
|
|
|
|
|
|
const right = $(".layui-icon-shrink-right")
|
|
|
|
|
|
if (admin.is(".pear-mini")) {
|
|
|
|
|
|
left.addClass("layui-icon-shrink-right")
|
|
|
|
|
|
left.removeClass("layui-icon-spread-left")
|
|
|
|
|
|
admin.removeClass("pear-mini");
|
2020-07-15 21:22:46 +00:00
|
|
|
|
} else {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
right.addClass("layui-icon-spread-left")
|
|
|
|
|
|
right.removeClass("layui-icon-shrink-right")
|
|
|
|
|
|
admin.addClass("pear-mini");
|
2020-07-15 21:22:46 +00:00
|
|
|
|
}
|
2020-11-23 08:17:29 +00:00
|
|
|
|
}
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
|
|
|
|
|
body.on("click", ".logout", function() {
|
2021-03-10 04:42:33 +00:00
|
|
|
|
// 回调
|
|
|
|
|
|
var result = logout();
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
|
|
|
|
|
if (result) {
|
2021-03-10 04:42:33 +00:00
|
|
|
|
// 清空缓存
|
|
|
|
|
|
bodyTab.clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
body.on("click", ".collaspe,.pear-cover", function() {
|
2021-03-10 04:42:33 +00:00
|
|
|
|
collaspe();
|
2020-10-11 03:35:31 +00:00
|
|
|
|
});
|
2020-07-15 21:22:46 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
body.on("click", ".fullScreen", function() {
|
2020-07-15 21:22:46 +00:00
|
|
|
|
if ($(this).hasClass("layui-icon-screen-restore")) {
|
|
|
|
|
|
screenFun(2).then(function() {
|
|
|
|
|
|
$(".fullScreen").eq(0).removeClass("layui-icon-screen-restore");
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
screenFun(1).then(function() {
|
|
|
|
|
|
$(".fullScreen").eq(0).addClass("layui-icon-screen-restore");
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
body.on("click", '[user-menu-id]', function() {
|
2020-10-28 09:33:54 +00:00
|
|
|
|
if (config.tab.muiltTab) {
|
2020-07-27 07:37:24 +00:00
|
|
|
|
bodyTab.addTabOnly({
|
2020-07-27 16:25:02 +00:00
|
|
|
|
id: $(this).attr("user-menu-id"),
|
|
|
|
|
|
title: $(this).attr("user-menu-title"),
|
|
|
|
|
|
url: $(this).attr("user-menu-url"),
|
2020-07-27 07:37:24 +00:00
|
|
|
|
icon: "",
|
|
|
|
|
|
close: true
|
|
|
|
|
|
}, 300);
|
2020-10-28 09:33:54 +00:00
|
|
|
|
} else {
|
2020-07-27 16:25:02 +00:00
|
|
|
|
bodyFrame.changePage($(this).attr("user-menu-url"), "", true);
|
2020-07-27 07:37:24 +00:00
|
|
|
|
}
|
2020-10-11 03:35:31 +00:00
|
|
|
|
});
|
2020-07-15 21:22:46 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
body.on("click", ".setting", function() {
|
2021-02-20 09:11:38 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
let bgColorHtml =
|
2020-07-22 20:41:52 +00:00
|
|
|
|
'<li class="layui-this" data-select-bgcolor="dark-theme" >' +
|
|
|
|
|
|
'<a href="javascript:;" data-skin="skin-blue" style="" class="clearfix full-opacity-hover">' +
|
|
|
|
|
|
'<div><span style="display:block; width: 20%; float: left; height: 12px; background: #28333E;"></span><span style="display:block; width: 80%; float: left; height: 12px; background: white;"></span></div>' +
|
|
|
|
|
|
'<div><span style="display:block; width: 20%; float: left; height: 40px; background: #28333E;"></span><span style="display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;"></span></div>' +
|
|
|
|
|
|
'</a>' +
|
|
|
|
|
|
'</li>';
|
|
|
|
|
|
|
|
|
|
|
|
bgColorHtml +=
|
|
|
|
|
|
'<li data-select-bgcolor="light-theme" >' +
|
|
|
|
|
|
'<a href="javascript:;" data-skin="skin-blue" style="" class="clearfix full-opacity-hover">' +
|
|
|
|
|
|
'<div><span style="display:block; width: 20%; float: left; height: 12px; background: white;"></span><span style="display:block; width: 80%; float: left; height: 12px; background: white;"></span></div>' +
|
|
|
|
|
|
'<div><span style="display:block; width: 20%; float: left; height: 40px; background: white;"></span><span style="display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;"></span></div>' +
|
|
|
|
|
|
'</a>' +
|
|
|
|
|
|
'</li>';
|
2020-07-23 05:37:18 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const html =
|
2020-07-22 20:41:52 +00:00
|
|
|
|
'<div class="pearone-color">\n' +
|
|
|
|
|
|
'<div class="color-title">整体风格</div>\n' +
|
|
|
|
|
|
'<div class="color-content">\n' +
|
|
|
|
|
|
'<ul>\n' + bgColorHtml + '</ul>\n' +
|
|
|
|
|
|
'</div>\n' +
|
|
|
|
|
|
'</div>';
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-07-15 21:22:46 +00:00
|
|
|
|
layer.open({
|
|
|
|
|
|
type: 1,
|
|
|
|
|
|
offset: 'r',
|
2021-03-31 12:30:41 +00:00
|
|
|
|
area: ['320px', '100%'],
|
2020-07-15 21:22:46 +00:00
|
|
|
|
title: false,
|
|
|
|
|
|
shade: 0.1,
|
|
|
|
|
|
closeBtn: 0,
|
|
|
|
|
|
shadeClose: false,
|
|
|
|
|
|
anim: -1,
|
|
|
|
|
|
skin: 'layer-anim-right',
|
|
|
|
|
|
move: false,
|
2020-12-17 16:45:12 +00:00
|
|
|
|
content: html + buildColorHtml() + buildLinkHtml() + bottomTool(),
|
2020-07-15 21:22:46 +00:00
|
|
|
|
success: function(layero, index) {
|
|
|
|
|
|
form.render();
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const color = localStorage.getItem("theme-color");
|
|
|
|
|
|
const menu = localStorage.getItem("theme-menu");
|
2020-07-23 05:37:18 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (color !== "null") {
|
2020-07-22 20:41:52 +00:00
|
|
|
|
$(".select-color-item").removeClass("layui-icon")
|
|
|
|
|
|
.removeClass("layui-icon-ok");
|
|
|
|
|
|
$("*[color-id='" + color + "']").addClass("layui-icon")
|
|
|
|
|
|
.addClass("layui-icon-ok");
|
|
|
|
|
|
}
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (menu !== "null") {
|
2020-07-22 20:41:52 +00:00
|
|
|
|
$("*[data-select-bgcolor]").removeClass("layui-this");
|
2020-07-23 05:37:18 +00:00
|
|
|
|
$("[data-select-bgcolor='" + menu + "']").addClass("layui-this");
|
2020-07-22 20:41:52 +00:00
|
|
|
|
}
|
2020-07-15 21:22:46 +00:00
|
|
|
|
$('#layui-layer-shade' + index).click(function() {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const $layero = $('#layui-layer' + index);
|
2020-07-15 21:22:46 +00:00
|
|
|
|
$layero.animate({
|
|
|
|
|
|
left: $layero.offset().left + $layero.width()
|
|
|
|
|
|
}, 200, function() {
|
|
|
|
|
|
layer.close(index);
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
2021-02-20 09:11:38 +00:00
|
|
|
|
|
2020-12-17 16:45:12 +00:00
|
|
|
|
$('#closeTheme').click(function() {
|
|
|
|
|
|
const $layero = $('#layui-layer' + index);
|
|
|
|
|
|
$layero.animate({
|
|
|
|
|
|
left: $layero.offset().left + $layero.width()
|
|
|
|
|
|
}, 200, function() {
|
|
|
|
|
|
layer.close(index);
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
2020-07-15 21:22:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-10-11 03:35:31 +00:00
|
|
|
|
});
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2021-02-20 09:11:38 +00:00
|
|
|
|
function bottomTool() {
|
2020-12-17 16:45:12 +00:00
|
|
|
|
return "<button id='closeTheme' style='position: absolute;bottom: 20px;left: 20px;' class='pear-btn'>关闭</button>"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
body.on('click', '[data-select-bgcolor]', function() {
|
|
|
|
|
|
const theme = $(this).attr('data-select-bgcolor');
|
2020-07-21 17:31:28 +00:00
|
|
|
|
$('[data-select-bgcolor]').removeClass("layui-this");
|
|
|
|
|
|
$(this).addClass("layui-this");
|
2020-07-22 20:41:52 +00:00
|
|
|
|
localStorage.setItem("theme-menu", theme);
|
|
|
|
|
|
pearAdmin.menuSkin(theme);
|
|
|
|
|
|
});
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-11-23 08:17:29 +00:00
|
|
|
|
body.on('click', '.select-color-item', function() {
|
2020-07-22 20:41:52 +00:00
|
|
|
|
$(".select-color-item").removeClass("layui-icon").removeClass("layui-icon-ok");
|
|
|
|
|
|
$(this).addClass("layui-icon").addClass("layui-icon-ok");
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const colorId = $(".select-color-item.layui-icon-ok").attr("color-id");
|
2021-01-16 14:48:49 +00:00
|
|
|
|
const currentColor = getColorById(colorId);
|
|
|
|
|
|
localStorage.setItem("theme-color", currentColor.id);
|
|
|
|
|
|
localStorage.setItem("theme-color-context", currentColor.color);
|
2021-01-17 13:43:58 +00:00
|
|
|
|
pearTheme.changeTheme(window, config.other.autoHead);
|
2020-07-21 17:31:28 +00:00
|
|
|
|
});
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
|
|
|
|
|
function applyConfig(param) {
|
2020-10-11 03:35:31 +00:00
|
|
|
|
config = param;
|
|
|
|
|
|
pearAdmin.logoRender(param);
|
|
|
|
|
|
pearAdmin.menuRender(param);
|
|
|
|
|
|
pearAdmin.bodyRender(param);
|
|
|
|
|
|
pearAdmin.themeRender(param);
|
|
|
|
|
|
pearAdmin.keepLoad(param);
|
2021-03-13 13:42:53 +00:00
|
|
|
|
if(param.header.message!=false){
|
|
|
|
|
|
pearAdmin.messageRender(param);
|
|
|
|
|
|
}
|
2020-10-11 03:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-22 20:41:52 +00:00
|
|
|
|
function getColorById(id) {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
let color;
|
|
|
|
|
|
let flag = false;
|
2020-09-30 04:57:03 +00:00
|
|
|
|
$.each(config.colors, function(i, value) {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (value.id === id) {
|
2020-07-22 20:41:52 +00:00
|
|
|
|
color = value;
|
2020-07-23 05:37:18 +00:00
|
|
|
|
flag = true;
|
2020-07-22 20:41:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (flag === false || config.theme.allowCustom === false) {
|
2020-09-30 04:57:03 +00:00
|
|
|
|
$.each(config.colors, function(i, value) {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
if (value.id === config.theme.defaultColor) {
|
2020-07-25 07:44:22 +00:00
|
|
|
|
color = value;
|
2020-07-23 05:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2020-07-22 20:41:52 +00:00
|
|
|
|
return color;
|
2020-07-21 17:31:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-22 20:41:52 +00:00
|
|
|
|
function buildLinkHtml() {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
let links = "";
|
2020-09-30 04:57:03 +00:00
|
|
|
|
$.each(config.links, function(i, value) {
|
2020-07-22 20:41:52 +00:00
|
|
|
|
links += '<a class="more-menu-item" href="' + value.href + '" target="_blank">' +
|
|
|
|
|
|
'<i class="' + value.icon + '" style="font-size: 19px;"></i> ' + value.title +
|
|
|
|
|
|
'</a>'
|
2020-07-21 17:31:28 +00:00
|
|
|
|
})
|
2020-07-22 20:41:52 +00:00
|
|
|
|
return '<div class="more-menu-list">' + links + '</div>';
|
2020-07-21 17:31:28 +00:00
|
|
|
|
}
|
2020-07-22 20:41:52 +00:00
|
|
|
|
|
|
|
|
|
|
function buildColorHtml() {
|
2020-11-23 08:17:29 +00:00
|
|
|
|
let colors = "";
|
2020-09-30 04:57:03 +00:00
|
|
|
|
$.each(config.colors, function(i, value) {
|
2020-07-25 07:44:22 +00:00
|
|
|
|
colors += "<span class='select-color-item' color-id='" + value.id + "' style='background-color:" + value.color +
|
|
|
|
|
|
";'></span>";
|
2020-07-21 17:31:28 +00:00
|
|
|
|
})
|
2021-03-31 12:52:54 +00:00
|
|
|
|
return "<div class='select-color'><div class='select-color-title'>主题配色</div><div class='select-color-content'>" +
|
2020-07-25 07:44:22 +00:00
|
|
|
|
colors + "</div></div>"
|
2020-07-21 17:31:28 +00:00
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-08-11 01:25:43 +00:00
|
|
|
|
function compatible() {
|
|
|
|
|
|
if ($(window).width() <= 768) {
|
2020-11-23 09:25:05 +00:00
|
|
|
|
collaspe()
|
2020-08-11 01:25:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
|
2020-08-11 01:25:43 +00:00
|
|
|
|
function screenFun(num) {
|
|
|
|
|
|
num = num || 1;
|
|
|
|
|
|
num = num * 1;
|
2020-11-23 08:17:29 +00:00
|
|
|
|
const docElm = document.documentElement;
|
2020-08-11 01:25:43 +00:00
|
|
|
|
switch (num) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
if (docElm.requestFullscreen) {
|
|
|
|
|
|
docElm.requestFullscreen();
|
|
|
|
|
|
} else if (docElm.mozRequestFullScreen) {
|
|
|
|
|
|
docElm.mozRequestFullScreen();
|
|
|
|
|
|
} else if (docElm.webkitRequestFullScreen) {
|
|
|
|
|
|
docElm.webkitRequestFullScreen();
|
|
|
|
|
|
} else if (docElm.msRequestFullscreen) {
|
|
|
|
|
|
docElm.msRequestFullscreen();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
if (document.exitFullscreen) {
|
|
|
|
|
|
document.exitFullscreen();
|
|
|
|
|
|
} else if (document.mozCancelFullScreen) {
|
|
|
|
|
|
document.mozCancelFullScreen();
|
|
|
|
|
|
} else if (document.webkitCancelFullScreen) {
|
|
|
|
|
|
document.webkitCancelFullScreen();
|
|
|
|
|
|
} else if (document.msExitFullscreen) {
|
|
|
|
|
|
document.msExitFullscreen();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2020-10-28 09:33:54 +00:00
|
|
|
|
return new Promise(function(res, rej) {
|
|
|
|
|
|
res("返回值");
|
|
|
|
|
|
});
|
2020-08-11 01:25:43 +00:00
|
|
|
|
}
|
2021-03-11 04:35:32 +00:00
|
|
|
|
|
2020-07-15 21:22:46 +00:00
|
|
|
|
exports('admin', pearAdmin);
|
2020-09-30 07:11:18 +00:00
|
|
|
|
})
|