修改配置文件格式
parent
6b909a520f
commit
09a41f23ce
|
|
@ -28,8 +28,8 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
|
|
||||||
this.logoRender = function(option) {
|
this.logoRender = function(option) {
|
||||||
|
|
||||||
$(".layui-logo .logo").attr("src", option.logoImage);
|
$(".layui-logo .logo").attr("src", option.logo.image);
|
||||||
$(".layui-logo .title").html(option.logoTitle);
|
$(".layui-logo .title").html(option.logo.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.menuRender = function(option) {
|
this.menuRender = function(option) {
|
||||||
|
|
@ -38,19 +38,18 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
async: true, //数据形式
|
async: true, //数据形式
|
||||||
theme: "dark-theme",
|
theme: "dark-theme",
|
||||||
height: '100%',
|
height: '100%',
|
||||||
control: option.control ? 'control' : false, // control
|
control: option.menu.control ? 'control' : false, // control
|
||||||
defaultMenu: 1,
|
defaultMenu: 1,
|
||||||
defaultOpen: 0, //默认打开菜单
|
defaultOpen: 0, //默认打开菜单
|
||||||
accordion: option.accordion,
|
accordion: option.menu.accordion,
|
||||||
url: option.data, //数据地址
|
url: option.menu.data, //数据地址
|
||||||
parseData: false, //请求后是否进行数据解析 函数
|
parseData: false
|
||||||
change: option.change
|
|
||||||
})
|
})
|
||||||
sideMenu.selectItem(option.select);
|
sideMenu.selectItem(option.menu.select);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bodyRender = function(option) {
|
this.bodyRender = function(option) {
|
||||||
if (option.muiltTab) {
|
if (option.tab.muiltTab) {
|
||||||
bodyTab = pearTab.render({
|
bodyTab = pearTab.render({
|
||||||
elem: 'content',
|
elem: 'content',
|
||||||
roll: true,
|
roll: true,
|
||||||
|
|
@ -58,14 +57,14 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
index: 0,
|
index: 0,
|
||||||
tabMax: option.tabMax,
|
tabMax: option.tab.tabMax,
|
||||||
closeEvent: function(id) {
|
closeEvent: function(id) {
|
||||||
sideMenu.selectItem(id);
|
sideMenu.selectItem(id);
|
||||||
},
|
},
|
||||||
data: [{
|
data: [{
|
||||||
id: '0',
|
id: option.tab.index.id,
|
||||||
url: option.index,
|
url: option.tab.index.href,
|
||||||
title: option.indexTitle,
|
title: option.tab.index.title,
|
||||||
close: false
|
close: false
|
||||||
}] //初始化数据
|
}] //初始化数据
|
||||||
});
|
});
|
||||||
|
|
@ -92,7 +91,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
})
|
})
|
||||||
|
|
||||||
sideMenu.click(function(dom, data) {
|
sideMenu.click(function(dom, data) {
|
||||||
|
|
||||||
bodyTab.addTabOnly({
|
bodyTab.addTabOnly({
|
||||||
id: data.menuId,
|
id: data.menuId,
|
||||||
title: data.menuTitle,
|
title: data.menuTitle,
|
||||||
|
|
@ -100,12 +98,9 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
icon: data.menuIcon,
|
icon: data.menuIcon,
|
||||||
close: true
|
close: true
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
compatible();
|
compatible();
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
bodyFrame = pearFrame.render({
|
bodyFrame = pearFrame.render({
|
||||||
elem: 'content',
|
elem: 'content',
|
||||||
title: '工作空间 / 首页',
|
title: '工作空间 / 首页',
|
||||||
|
|
@ -113,7 +108,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%'
|
height: '100%'
|
||||||
});
|
});
|
||||||
|
|
||||||
$("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");
|
||||||
|
|
@ -129,7 +123,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) {
|
||||||
bodyFrame.changePage(data.menuUrl, data.menuPath, true);
|
bodyFrame.changePage(data.menuUrl, data.menuPath, true);
|
||||||
compatible()
|
compatible()
|
||||||
|
|
@ -138,17 +131,15 @@ 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.keepLoad)
|
}, option.other.keepLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.themeRender = function(option) {
|
this.themeRender = function(option) {
|
||||||
|
|
||||||
if(option.allowCustom == false){
|
if(option.theme.allowCustom == false){
|
||||||
$(".setting").remove();
|
$(".setting").remove();
|
||||||
}
|
}
|
||||||
var colorId = localStorage.getItem("theme-color");
|
var colorId = localStorage.getItem("theme-color");
|
||||||
|
|
@ -156,17 +147,15 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
var color = getColorById(colorId);
|
var color = getColorById(colorId);
|
||||||
|
|
||||||
if(menu=="null"){
|
if(menu=="null"){
|
||||||
menu = option.defaultMenu;
|
menu = option.theme.defaultMenu;
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
if(option.allowCustom == false){
|
if(option.theme.allowCustom == false){
|
||||||
menu = option.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);
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +202,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
// 自 定 义 加 载 配 色
|
// 自 定 义 加 载 配 色
|
||||||
style += '#preloader{background-color:' + color + '!important;}';
|
style += '#preloader{background-color:' + color + '!important;}';
|
||||||
|
|
||||||
|
|
||||||
// 自 定 义 样 式 选 择 边 框 配 色
|
// 自 定 义 样 式 选 择 边 框 配 色
|
||||||
style +=
|
style +=
|
||||||
'.pearone-color .color-content li.layui-this:after, .pearone-color .color-content li:hover:after {border: ' +
|
'.pearone-color .color-content li.layui-this:after, .pearone-color .color-content li:hover:after {border: ' +
|
||||||
|
|
@ -223,17 +211,12 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
'!important}';
|
'!important}';
|
||||||
|
|
||||||
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 ($("iframe").contents().find("#customTheme").length > 0) {
|
if ($("iframe").contents().find("#customTheme").length > 0) {
|
||||||
|
|
||||||
$("iframe").contents().find("#customTheme").remove();
|
$("iframe").contents().find("#customTheme").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
var theme = "<style>";
|
var theme = "<style>";
|
||||||
theme += '</style>';
|
theme += '</style>';
|
||||||
|
|
||||||
$("iframe").contents().find("head").append(theme);
|
$("iframe").contents().find("head").append(theme);
|
||||||
$("#pearadmin-bg-color").html(style);
|
$("#pearadmin-bg-color").html(style);
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +267,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
num = num || 1;
|
num = num || 1;
|
||||||
num = num * 1;
|
num = num * 1;
|
||||||
var docElm = document.documentElement;
|
var docElm = document.documentElement;
|
||||||
|
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case 1:
|
case 1:
|
||||||
if (docElm.requestFullscreen) {
|
if (docElm.requestFullscreen) {
|
||||||
|
|
@ -316,7 +298,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
|
|
||||||
|
|
||||||
$("body").on("click", ".setting", function() {
|
$("body").on("click", ".setting", function() {
|
||||||
|
|
||||||
var bgColorHtml =
|
var bgColorHtml =
|
||||||
'<li class="layui-this" data-select-bgcolor="dark-theme" >' +
|
'<li class="layui-this" data-select-bgcolor="dark-theme" >' +
|
||||||
'<a href="javascript:;" data-skin="skin-blue" style="" class="clearfix full-opacity-hover">' +
|
'<a href="javascript:;" data-skin="skin-blue" style="" class="clearfix full-opacity-hover">' +
|
||||||
|
|
@ -340,7 +321,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
'<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: #28333E;"></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: #28333E;"></span></div>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</li>';
|
'</li>';
|
||||||
|
|
||||||
var html =
|
var html =
|
||||||
'<div class="pearone-color">\n' +
|
'<div class="pearone-color">\n' +
|
||||||
'<div class="color-title">整体风格</div>\n' +
|
'<div class="color-title">整体风格</div>\n' +
|
||||||
|
|
@ -348,7 +328,6 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
'<ul>\n' + bgColorHtml + '</ul>\n' +
|
'<ul>\n' + bgColorHtml + '</ul>\n' +
|
||||||
'</div>\n' +
|
'</div>\n' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 1,
|
type: 1,
|
||||||
offset: 'r',
|
offset: 'r',
|
||||||
|
|
@ -362,26 +341,21 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
move: false,
|
move: false,
|
||||||
content: html + buildColorHtml() + buildLinkHtml(),
|
content: html + buildColorHtml() + buildLinkHtml(),
|
||||||
success: function(layero, index) {
|
success: function(layero, index) {
|
||||||
|
|
||||||
form.render();
|
form.render();
|
||||||
|
|
||||||
var color = localStorage.getItem("theme-color");
|
var color = localStorage.getItem("theme-color");
|
||||||
var menu = localStorage.getItem("theme-menu");
|
var menu = localStorage.getItem("theme-menu");
|
||||||
|
|
||||||
if (color != "null") {
|
if (color != "null") {
|
||||||
$(".select-color-item").removeClass("layui-icon")
|
$(".select-color-item").removeClass("layui-icon")
|
||||||
.removeClass("layui-icon-ok");
|
.removeClass("layui-icon-ok");
|
||||||
|
|
||||||
$("*[color-id='" + color + "']").addClass("layui-icon")
|
$("*[color-id='" + color + "']").addClass("layui-icon")
|
||||||
.addClass("layui-icon-ok");
|
.addClass("layui-icon-ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu != "null") {
|
if (menu != "null") {
|
||||||
$("*[data-select-bgcolor]").removeClass("layui-this");
|
$("*[data-select-bgcolor]").removeClass("layui-this");
|
||||||
|
|
||||||
$("[data-select-bgcolor='" + menu + "']").addClass("layui-this");
|
$("[data-select-bgcolor='" + menu + "']").addClass("layui-this");
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#layui-layer-shade' + index).click(function() {
|
$('#layui-layer-shade' + index).click(function() {
|
||||||
var $layero = $('#layui-layer' + index);
|
var $layero = $('#layui-layer' + index);
|
||||||
$layero.animate({
|
$layero.animate({
|
||||||
|
|
@ -396,28 +370,21 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
|
|
||||||
|
|
||||||
function getData() {
|
function getData() {
|
||||||
|
|
||||||
$.ajaxSettings.async = false;
|
$.ajaxSettings.async = false;
|
||||||
var data = null;
|
var data = null;
|
||||||
|
|
||||||
$.getJSON("setting.json", function(result) {
|
$.getJSON("setting.json", function(result) {
|
||||||
data = result;
|
data = result;
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajaxSettings.async = true;
|
$.ajaxSettings.async = true;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('body').on('click', '[data-select-bgcolor]', function() {
|
$('body').on('click', '[data-select-bgcolor]', function() {
|
||||||
|
|
||||||
var theme = $(this).attr('data-select-bgcolor');
|
var theme = $(this).attr('data-select-bgcolor');
|
||||||
$('[data-select-bgcolor]').removeClass("layui-this");
|
$('[data-select-bgcolor]').removeClass("layui-this");
|
||||||
$(this).addClass("layui-this");
|
$(this).addClass("layui-this");
|
||||||
localStorage.setItem("theme-menu", theme);
|
localStorage.setItem("theme-menu", theme);
|
||||||
pearAdmin.menuSkin(theme);
|
pearAdmin.menuSkin(theme);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.select-color-item', function() {
|
$('body').on('click', '.select-color-item', function() {
|
||||||
$(".select-color-item").removeClass("layui-icon").removeClass("layui-icon-ok");
|
$(".select-color-item").removeClass("layui-icon").removeClass("layui-icon-ok");
|
||||||
$(this).addClass("layui-icon").addClass("layui-icon-ok");
|
$(this).addClass("layui-icon").addClass("layui-icon-ok");
|
||||||
|
|
@ -426,27 +393,20 @@ 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;
|
||||||
|
|
||||||
var data = getData();
|
var data = getData();
|
||||||
|
|
||||||
$.each(data.colors, function(i, value) {
|
$.each(data.colors, function(i, value) {
|
||||||
|
|
||||||
if (value.id == id) {
|
if (value.id == id) {
|
||||||
color = value;
|
color = value;
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if(flag==false || data.theme.allowCustom == false){
|
||||||
if(flag==false || data.allowCustom == false){
|
|
||||||
|
|
||||||
$.each(data.colors, function(i, value) {
|
$.each(data.colors, function(i, value) {
|
||||||
|
if (value.id == data.theme.defaultColor) {
|
||||||
if (value.id == data.defaultColor) {
|
|
||||||
color = value;
|
color = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -455,29 +415,21 @@ layui.define(['table', 'jquery', 'element', 'form', 'tab', 'menu', 'frame'],
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildLinkHtml() {
|
function buildLinkHtml() {
|
||||||
|
|
||||||
var links = "";
|
var links = "";
|
||||||
|
|
||||||
$.each(getData().links, function(i, value) {
|
$.each(getData().links, function(i, value) {
|
||||||
|
|
||||||
links += '<a class="more-menu-item" href="' + value.href + '" target="_blank">' +
|
links += '<a class="more-menu-item" href="' + value.href + '" target="_blank">' +
|
||||||
'<i class="' + value.icon + '" style="font-size: 19px;"></i> ' + value.title +
|
'<i class="' + value.icon + '" style="font-size: 19px;"></i> ' + value.title +
|
||||||
'</a>'
|
'</a>'
|
||||||
})
|
})
|
||||||
|
|
||||||
return '<div class="more-menu-list">' + links + '</div>';
|
return '<div class="more-menu-list">' + links + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
49
setting.json
49
setting.json
|
|
@ -1,20 +1,29 @@
|
||||||
{
|
{
|
||||||
"keepLoad": 1200,
|
"logo": {
|
||||||
"muiltTab": true,
|
"title": "Pear Admin",
|
||||||
"tabMax": 30,
|
"image": "admin/images/logo.png"
|
||||||
"control": false,
|
},
|
||||||
"index": "view/console/console1.html",
|
"menu": {
|
||||||
"indexTitle": "首页",
|
"data": "admin/data/menu.json",
|
||||||
"accordion": true,
|
"accordion": true,
|
||||||
"data": "admin/data/menu.json",
|
"control": false,
|
||||||
"select": "0",
|
"select": "0"
|
||||||
"logoTitle": "Pear Admin",
|
},
|
||||||
"logoImage": "admin/images/logo.png",
|
"tab": {
|
||||||
"defaultColor": "2",
|
"muiltTab": true,
|
||||||
"defaultMenu": "dark-theme",
|
"tabMax": 30,
|
||||||
"allowCustom": true,
|
"index": {
|
||||||
"colors": [
|
"id": "0",
|
||||||
{
|
"href": "view/console/console1.html",
|
||||||
|
"title": "首页"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"defaultColor": "2",
|
||||||
|
"defaultMenu": "dark-theme",
|
||||||
|
"allowCustom": true
|
||||||
|
},
|
||||||
|
"colors": [{
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"color": "#FF5722"
|
"color": "#FF5722"
|
||||||
},
|
},
|
||||||
|
|
@ -33,8 +42,7 @@
|
||||||
"color": "darkgray"
|
"color": "darkgray"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [
|
"links": [{
|
||||||
{
|
|
||||||
"icon": "layui-icon layui-icon-auz",
|
"icon": "layui-icon layui-icon-auz",
|
||||||
"title": "官方网站",
|
"title": "官方网站",
|
||||||
"href": "http://www.pearadmin.com"
|
"href": "http://www.pearadmin.com"
|
||||||
|
|
@ -49,5 +57,8 @@
|
||||||
"title": "开源地址",
|
"title": "开源地址",
|
||||||
"href": "https://gitee.com/Jmysy/Pear-Admin-Layui"
|
"href": "https://gitee.com/Jmysy/Pear-Admin-Layui"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"other": {
|
||||||
|
"keepLoad": 1200
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue