更新依赖pear-admin-layui到3.8.3,增加前端渲染配置接口

This commit is contained in:
mkg
2021-06-05 13:10:29 +08:00
parent a1fbf5a0ae
commit 375d3a10b2
26 changed files with 5850 additions and 388 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -205,101 +205,105 @@ body::-webkit-scrollbar-corner {
width: 100%;
}
.pear-col-md-offset1 {
margin-left: 4.16%;
@media all and (min-width:993px) and (max-width:1199px) {
.pear-col-md-offset1 {
margin-left: 4.16%;
}
.pear-col-md-offset2 {
margin-left: 8.33%;
}
.pear-col-md-offset3 {
margin-left: 12.5%;
}
.pear-col-md-offset4 {
margin-left: 16.66%;
}
.pear-col-md-offset5 {
margin-left: 20.83%;
}
.pear-col-md-offset6 {
margin-left: 25%;
}
.pear-col-md-offset7 {
margin-left: 29.16%;
}
.pear-col-md-offset8 {
margin-left: 33.33%;
}
.pear-col-md-offset9 {
margin-left: 37.5%;
}
.pear-col-md-offset10 {
margin-left: 41.66%;
}
.pear-col-md-offset11 {
margin-left: 45.83%;
}
.pear-col-md-offset12 {
margin-left: 50%;
}
.pear-col-md-offset13 {
margin-left: 54.16%;
}
.pear-col-md-offset14 {
margin-left: 58.33%;
}
.pear-col-md-offset15 {
margin-left: 62.5%;
}
.pear-col-md-offset16 {
margin-left: 66.66%;
}
.pear-col-md-offset17 {
margin-left: 70.83%;
}
.pear-col-md-offset18 {
margin-left: 75%;
}
.pear-col-md-offset19 {
margin-left: 79.16%;
}
.pear-col-md-offset20 {
margin-left: 83.33%;
}
.pear-col-md-offset21 {
margin-left: 87.5%;
}
.pear-col-md-offset22 {
margin-left: 91.66%;
}
.pear-col-md-offset23 {
margin-left: 95.83%;
}
.pear-col-md-offset24 {
margin-left: 100%;
}
}
.pear-col-md-offset2 {
margin-left: 8.33%;
}
.pear-col-md-offset3 {
margin-left: 12.5%;
}
.pear-col-md-offset4 {
margin-left: 16.66%;
}
.pear-col-md-offset5 {
margin-left: 20.83%;
}
.pear-col-md-offset6 {
margin-left: 25%;
}
.pear-col-md-offset7 {
margin-left: 29.16%;
}
.pear-col-md-offset8 {
margin-left: 33.33%;
}
.pear-col-md-offset9 {
margin-left: 37.5%;
}
.pear-col-md-offset10 {
margin-left: 41.66%;
}
.pear-col-md-offset11 {
margin-left: 45.83%;
}
.pear-col-md-offset12 {
margin-left: 50%;
}
.pear-col-md-offset13 {
margin-left: 54.16%;
}
.pear-col-md-offset14 {
margin-left: 58.33%;
}
.pear-col-md-offset15 {
margin-left: 62.5%;
}
.pear-col-md-offset16 {
margin-left: 66.66%;
}
.pear-col-md-offset17 {
margin-left: 70.83%;
}
.pear-col-md-offset18 {
margin-left: 75%;
}
.pear-col-md-offset19 {
margin-left: 79.16%;
}
.pear-col-md-offset20 {
margin-left: 83.33%;
}
.pear-col-md-offset21 {
margin-left: 87.5%;
}
.pear-col-md-offset22 {
margin-left: 91.66%;
}
.pear-col-md-offset23 {
margin-left: 95.83%;
}
.pear-col-md-offset24 {
margin-left: 100%;
}
@media all and (max-width:768px) {
.pear-col-xs1 {
@@ -7,6 +7,8 @@
.pear-nav-tree .layui-nav-item>a {
height: 56px;
line-height: 56px;
padding-top: 0px;
padding-bottom: 0px;
}
.pear-nav-tree .layui-nav-item dd a {
@@ -14,6 +16,14 @@
line-height: 48px;
}
.pear-side-scroll::-webkit-scrollbar {
width: 0px;
height: 0px;
}
.pear-side-scroll{
width: 230px;
}
.pear-nav-tree .layui-nav-child {
padding-top: 5px;
padding-bottom: 5px;
@@ -188,7 +198,7 @@
/** 下 拉 图 标 */
.pear-nav-tree.arrow .layui-nav-more {
font-family: layui-icon !important;
font-size: 12px;
font-size: 10px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@@ -198,7 +208,7 @@
line-height: normal;
border: none;
top: 23px;
margin-right: 5px !important;
margin-right: 2px !important;
margin: 0;
padding: 0;
display: inline-block;
@@ -26,6 +26,7 @@
color: #333;
font-size: 13.5px;
line-height: 20px;
cursor:pointer;
}
.pear-tab-menu .item:hover{
background: #36b368;
+62 -59
View File
@@ -2,7 +2,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
function(exports) {
"use strict";
const $ = layui.jquery,
var $ = layui.jquery,
form = layui.form,
element = layui.element,
yaml = layui.yaml,
@@ -13,20 +13,20 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
pearTheme = layui.theme,
message = layui.message;
let bodyFrame;
let sideMenu;
let bodyTab;
let config;
let logout = function() {};
let msgInstance;
var bodyFrame;
var sideMenu;
var bodyTab;
var config;
var logout = function() {};
var msgInstance;
const body = $('body');
var body = $('body');
const pearAdmin = new function() {
var pearAdmin = new function() {
// 默认配置
let configType = 'yml';
let configPath = 'pear.config.yml';
var configType = 'yml';
var configPath = 'pear.config.yml';
this.setConfigPath = function(path) {
configPath = path;
@@ -38,7 +38,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
this.setAvatar = function(url, username) {
var image = new Image();
image.src = "admin/images/avatar.jpg";
image.src = url || "admin/images/avatar.jpg";
image.onload = function() {
$(".layui-nav-img").attr("src", convert.imageToBase64(image));
}
@@ -57,7 +57,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
if (configType === "yml") {
return yaml.load(configPath);
} else {
let data;
var data;
$.ajax({
url: configPath,
type: 'get',
@@ -109,7 +109,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
this.bodyRender = function(param) {
body.on("click", ".refresh", function() {
const refreshA = $(".refresh a");
var refreshA = $(".refresh a");
refreshA.removeClass("layui-icon-refresh-1");
refreshA.addClass("layui-anim");
refreshA.addClass("layui-anim-rotate");
@@ -200,13 +200,13 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
if (option.theme.allowCustom === false) {
$(".setting").remove();
}
const colorId = localStorage.getItem("theme-color");
const currentColor = getColorById(colorId);
var colorId = localStorage.getItem("theme-color");
var currentColor = getColorById(colorId);
localStorage.setItem("theme-color", currentColor.id);
localStorage.setItem("theme-color-context", currentColor.color);
pearTheme.changeTheme(window, option.other.autoHead);
let menu = localStorage.getItem("theme-menu");
if (menu === "null") {
var menu = localStorage.getItem("theme-menu");
if (menu == null) {
menu = option.theme.defaultMenu;
} else {
if (option.theme.allowCustom === false) {
@@ -218,7 +218,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}
this.menuSkin = function(theme) {
const pearAdmin = $(".pear-admin");
var pearAdmin = $(".pear-admin");
pearAdmin.removeClass("light-theme");
pearAdmin.removeClass("dark-theme");
pearAdmin.addClass(theme);
@@ -227,19 +227,24 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
this.logout = function(callback) {
logout = callback;
}
this.message = function(callback) {
if(callback!=null){
if (callback != null) {
msgInstance.click(callback);
}else{
} else {
msgInstance.click(messageTip);
}
}
this.jump = function(id,title,url){
this.jump = function(id, title, url) {
if (config.tab.muiltTab) {
bodyTab.addTabOnly({id: id,title: title,url: url,icon: null,close: true},
300);
bodyTab.addTabOnly({
id: id,
title: title,
url: url,
icon: null,
close: true
}, 300);
} else {
sideMenu.selectItem(id);
bodyFrame.changePage(url, title, true);
@@ -267,9 +272,9 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
function collaspe() {
sideMenu.collaspe();
const admin = $(".pear-admin");
const left = $(".layui-icon-spread-left")
const right = $(".layui-icon-shrink-right")
var admin = $(".pear-admin");
var left = $(".layui-icon-spread-left")
var right = $(".layui-icon-shrink-right")
if (admin.is(".pear-mini")) {
left.addClass("layui-icon-shrink-right")
left.removeClass("layui-icon-spread-left")
@@ -323,7 +328,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
body.on("click", ".setting", function() {
let bgColorHtml =
var bgColorHtml =
'<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>' +
@@ -339,7 +344,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
'</a>' +
'</li>';
const html =
var html =
'<div class="pearone-color">\n' +
'<div class="color-title">整体风格</div>\n' +
'<div class="color-content">\n' +
@@ -360,23 +365,20 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
move: false,
content: html + buildColorHtml() + buildLinkHtml() + bottomTool(),
success: function(layero, index) {
form.render();
const color = localStorage.getItem("theme-color");
const menu = localStorage.getItem("theme-menu");
var color = localStorage.getItem("theme-color");
var menu = localStorage.getItem("theme-menu");
if (color !== "null") {
$(".select-color-item").removeClass("layui-icon")
.removeClass("layui-icon-ok");
$("*[color-id='" + color + "']").addClass("layui-icon")
.addClass("layui-icon-ok");
$(".select-color-item").removeClass("layui-icon").removeClass("layui-icon-ok");
$("*[color-id='" + color + "']").addClass("layui-icon").addClass("layui-icon-ok");
}
if (menu !== "null") {
$("*[data-select-bgcolor]").removeClass("layui-this");
$("[data-select-bgcolor='" + menu + "']").addClass("layui-this");
}
$('#layui-layer-shade' + index).click(function() {
const $layero = $('#layui-layer' + index);
var $layero = $('#layui-layer' + index);
$layero.animate({
left: $layero.offset().left + $layero.width()
}, 200, function() {
@@ -385,7 +387,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
})
$('#closeTheme').click(function() {
const $layero = $('#layui-layer' + index);
var $layero = $('#layui-layer' + index);
$layero.animate({
left: $layero.offset().left + $layero.width()
}, 200, function() {
@@ -401,7 +403,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}
body.on('click', '[data-select-bgcolor]', function() {
const theme = $(this).attr('data-select-bgcolor');
var theme = $(this).attr('data-select-bgcolor');
$('[data-select-bgcolor]').removeClass("layui-this");
$(this).addClass("layui-this");
localStorage.setItem("theme-menu", theme);
@@ -411,8 +413,8 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
body.on('click', '.select-color-item', function() {
$(".select-color-item").removeClass("layui-icon").removeClass("layui-icon-ok");
$(this).addClass("layui-icon").addClass("layui-icon-ok");
const colorId = $(".select-color-item.layui-icon-ok").attr("color-id");
const currentColor = getColorById(colorId);
var colorId = $(".select-color-item.layui-icon-ok").attr("color-id");
var currentColor = getColorById(colorId);
localStorage.setItem("theme-color", currentColor.id);
localStorage.setItem("theme-color-context", currentColor.color);
pearTheme.changeTheme(window, config.other.autoHead);
@@ -425,14 +427,14 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
pearAdmin.bodyRender(param);
pearAdmin.themeRender(param);
pearAdmin.keepLoad(param);
if(param.header.message!=false){
pearAdmin.messageRender(param);
if (param.header.message != false) {
pearAdmin.messageRender(param);
}
}
function getColorById(id) {
let color;
let flag = false;
var color;
var flag = false;
$.each(config.colors, function(i, value) {
if (value.id === id) {
color = value;
@@ -450,9 +452,10 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}
function buildLinkHtml() {
let links = "";
var links = "";
$.each(config.links, function(i, value) {
links += '<a class="more-menu-item" href="' + value.href + '" target="_blank">' +
// value.target 存在,则为新窗口打开,增加 target="_blank" 属性
links += '<a class="more-menu-item" href="' + value.href + '" '+(value.target?' target="_blank" ':'')+'>' +
'<i class="' + value.icon + '" style="font-size: 19px;"></i> ' + value.title +
'</a>'
})
@@ -460,7 +463,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}
function buildColorHtml() {
let colors = "";
var colors = "";
$.each(config.colors, function(i, value) {
colors += "<span class='select-color-item' color-id='" + value.id + "' style='background-color:" + value.color +
";'></span>";
@@ -478,7 +481,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
function screenFun(num) {
num = num || 1;
num = num * 1;
const docElm = document.documentElement;
var docElm = document.documentElement;
switch (num) {
case 1:
if (docElm.requestFullscreen) {
@@ -507,17 +510,17 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
res("返回值");
});
}
function isFullscreen(){
return document.fullscreenElement ||
document.msFullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement || false;
function isFullscreen() {
return document.fullscreenElement ||
document.msFullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement || false;
}
window.onresize = function() {
if (!isFullscreen()) {
$(".fullScreen").eq(0).removeClass("layui-icon-screen-restore");
$(".fullScreen").eq(0).removeClass("layui-icon-screen-restore");
}
}
+5 -1
View File
@@ -25,10 +25,13 @@ layui.define(['jquery'], function(exports) {
$(option.elem).html("<i class='layui-anim layui-anim-rotate layui-icon layui-anim-loop layui-icon-loading'/>");
$(option.elem).attr("disabled", "disabled");
var buttons = $(option.elem);
if (option.time != "" || option.time !=false) {
setTimeout(function() {
$(option.elem).attr("disabled", false);
buttons.html(text);
option.done();
}, option.time);
@@ -41,8 +44,9 @@ layui.define(['jquery'], function(exports) {
* Button stop loaded
* */
button.prototype.stop = function(success) {
$(this.option.elem).attr("disabled", false);
$(this.option.elem).html(this.option.text);
success();
success && success();
}
exports(MOD_NAME, new button());
File diff suppressed because one or more lines are too long
+6 -5
View File
@@ -42,10 +42,11 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
}
} else {
//renderMenu中需要调用done事件,done事件中需要menu对象,但是此时还未返回menu对象,做个延时提前返回对象
window.setTimeout(function() {
renderMenu(option);
}, 500);
window.setTimeout(function() { renderMenu(option);}, 500);
}
// 处理高度
$("#"+opt.elem).height(option.height)
return new pearMenu(opt);
}
@@ -194,7 +195,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
}
function createMenu(option) {
var menuHtml = '<ul lay-filter="' + option.elem +
var menuHtml = '<div style="height:100%!important;" class="pear-side-scroll layui-side-scroll ' + option.theme + '"><ul lay-filter="' + option.elem +
'" class="layui-nav arrow pear-menu layui-nav-tree pear-nav-tree">'
$.each(option.data, function(i, item) {
var content = '<li class="layui-nav-item" >';
@@ -227,7 +228,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
menuHtml += content;
});
// 结 束 菜 单 结 构 的 初 始 化
menuHtml += "</ul>";
menuHtml += "</ul></div>";
// 将 菜 单 拼 接 到 初 始 化 容 器 中
$("#" + option.elem).html(menuHtml);
}
@@ -54,7 +54,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
var notice = '<li class="layui-nav-item" lay-unselect="">' +
'<a href="#" class="notice layui-icon layui-icon-notice"><span class="layui-badge-dot"></span></a>' +
'<div class="layui-nav-child layui-tab pear-notice" style="left: -200px;">';
'<div class="layui-nav-child layui-tab pear-notice" style="margin-top: 0px;;left: -200px;">';
var noticeTitle = '<ul class="layui-tab-title">';
var noticeContent = '<div class="layui-tab-content" style="height:' + option.height + ';overflow-x: hidden;">';
@@ -70,6 +70,9 @@ layui.define(["jquery","layer"], function (exports) {
style += '.pear-tab-menu .item:hover{background-color:'+color+'!important}'
style += '.layui-form-danger:focus {border-color:#FF5722 !important}'
style += '.pear-admin .user a:hover{color:'+color+'!important}'
style += '.pear-admin .user .layui-this a:hover{color:white!important}'
style += '.pear-notice .layui-this{color:'+color+'!important}'
style += '.layui-form-radio:hover *, .layui-form-radioed, .layui-form-radioed>i{color:' + color + ' !important}';
var colorPane = $("#pear-admin-color");
if(colorPane.length>0){
colorPane.html(style);
@@ -16,7 +16,7 @@ layui.define(['layer', 'table'], function (exports) {
} else {
$.getJSON(param.url, param.where, function (res) {
if(param.parseData){
res.data = param.parseData(res);
res = param.parseData(res);
param.data = res.data;
}
treetable.init(param, res.data);
+2 -2
View File
@@ -5,7 +5,7 @@ window.rootPath = (function(src) {
layui.config({
base: rootPath + "module/",
version: "3.7.6.Release"
version: "3.8.0.Release"
}).extend({
admin: "admin", // 框架布局组件
menu: "menu", // 数据菜单组件
@@ -37,7 +37,7 @@ layui.config({
context: "context", // 上下文组件
http: "http", // ajax请求组件
theme: "theme", // 主题转换
message: "message" // 通知组件
message: "message", // 通知组件
}).use(['layer', 'theme'], function () {
layui.theme.changeTheme(window, false);
});