更新依赖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
+21 -3
View File
@@ -1,9 +1,27 @@
SYSTEM_NAME = "Pear Admin"
# 主题面板的链接列表配置
SYSTEM_PANEL_LINKS = [
{
"icon": "layui-icon layui-icon-auz",
"title": "官方网站",
"href": "http://www.pearadmin.com"
},
{
"icon": "layui-icon layui-icon-auz",
"title": "开发文档",
"href": "http://www.pearadmin.com"
},
{
"icon": "layui-icon layui-icon-auz",
"title": "开源地址",
"href": "https://gitee.com/Jmysy/Pear-Admin-Layui"
}
]
# 密钥
# 密钥配置(flask session需要) 记得修改 # 密钥配置(flask session需要) 记得修改
import os
SECRET_KEY = 'pear-admin-flask' SECRET_KEY = 'pear-admin-flask'
UPLOADED_PHOTOS_DEST = 'static/upload' UPLOADED_PHOTOS_DEST = 'static/upload'
UPLOADED_FILES_ALLOW = ['gif', 'jpg'] UPLOADED_FILES_ALLOW = ['gif', 'jpg']
# JSON配置
JSON_AS_ASCII = False JSON_AS_ASCII = False
+73 -1
View File
@@ -1,5 +1,5 @@
from io import BytesIO from io import BytesIO
from flask import session, make_response from flask import session, make_response, current_app
from flask_login import current_user from flask_login import current_user
from applications.models.admin_power import PowerSchema from applications.models.admin_power import PowerSchema
from applications.service.captcha import gen_captcha from applications.service.captcha import gen_captcha
@@ -71,3 +71,75 @@ def get_captcha():
resp = make_response(out.read()) resp = make_response(out.read())
resp.content_type = 'image/png' resp.content_type = 'image/png'
return resp, code return resp, code
def get_render_config():
# 网站配置
config = dict(logo={
# 网站名称
"title": current_app.config.get("SYSTEM_NAME"),
# 网站图标
"image": "/static/admin/admin/images/logo.png"
# 菜单配置
}, menu={
# 菜单数据来源
"data": "/admin/menu",
"collaspe": True,
# 是否同时只打开一个菜单目录
"accordion": True,
"method": "GET",
# 是否开启多系统菜单模式
"control": False,
# 默认选中的菜单项
"select": "0",
# 是否开启异步菜单,false 时 data 属性设置为菜单数据,false 时为 json 文件或后端接口
"async": True
}, tab={
# 是否开启多选项卡
"muiltTab": True,
# 切换选项卡时,是否刷新页面状态
"keepState": True,
# 是否开启 Tab 记忆
"session": True,
# 最大可打开的选项卡数量
"tabMax": 30,
"index": {
# 标识 ID , 建议与菜单项中的 ID 一致
"id": "10",
# 页面地址
"href": "/admin/welcome",
# 标题
"title": "首页"
}
}, theme={
# 默认主题色,对应 colors 配置中的 ID 标识
"defaultColor": "2",
# 默认的菜单主题 dark-theme 黑 / light-theme 白
"defaultMenu": "dark-theme",
# 是否允许用户切换主题,false 时关闭自定义主题面板
"allowCustom": True
}, colors=[{
"id": "1",
"color": "#2d8cf0"
},
{
"id": "2",
"color": "#5FB878"
},
{
"id": "3",
"color": "#1E9FFF"
}, {
"id": "4",
"color": "#FFB800"
}, {
"id": "5",
"color": "darkgray"
}
], links=current_app.config.get("SYSTEM_PANEL_LINKS"), other={
# 主页动画时长
"keepLoad": 1200,
# 布局顶部主题
"autoHead": False
}, header=False)
return config
+8 -1
View File
@@ -1,4 +1,4 @@
from flask import Blueprint, render_template, jsonify, request, session, redirect, url_for from flask import Blueprint, render_template, jsonify, request, session, redirect, url_for, current_app
from flask_login import login_user, login_required, logout_user, current_user from flask_login import login_user, login_required, logout_user, current_user
from applications.service.admin import index_curd from applications.service.admin import index_curd
from applications.service.admin_log import login_log from applications.service.admin_log import login_log
@@ -16,6 +16,13 @@ def index():
return render_template('admin/index.html', user=user) return render_template('admin/index.html', user=user)
# 渲染配置
@admin_index.route('/config')
@login_required
def config():
return index_curd.get_render_config()
# 获取验证码 # 获取验证码
@admin_index.route('/getCaptcha', methods=["GET"]) @admin_index.route('/getCaptcha', methods=["GET"])
def getCaptcha(): def getCaptcha():
-1
View File
@@ -93,7 +93,6 @@ body,
.pear-admin .layui-body { .pear-admin .layui-body {
left: 230px; left: 230px;
bottom: 0px; bottom: 0px;
margin-top: 60px;
padding-bottom: 0px; padding-bottom: 0px;
} }
+5 -1
View File
@@ -37,7 +37,11 @@
} }
.layui-input:focus { .layui-input:focus {
box-shadow: 0px 0px 3px 1px #5FB878 !important; box-shadow: 0px 0px 2px 1px #5FB878 !important;
}
.layui-form-danger:focus{
box-shadow: 0px 0px 2px 1px #f56c6c !important;
} }
.logo { .logo {
-58
View File
@@ -1,58 +0,0 @@
.dept-tree {
width: 100%;
height: -webkit-calc(100vh - 247px);
height: -moz-calc(100vh - 247px);
height: calc(100vh - 247px);
margin-top: 20px;
}
.dtree-laySimple-item-this{
background-color: transparent!important;
}
.dtree-nav-div:hover{
background-color: transparent!important;
}
.button{
margin-top: 10px;
width: 94%;
margin-left: 3%;
display: block;
height: 40px;
line-height: 40px;
padding: 0 15px;
white-space: nowrap;
text-align: center;
font-size: 14.5px;
border: none;
cursor: pointer;
box-sizing: border-box;
display:inline-block;
outline: 0;
border-radius: 2px;
-webkit-appearance: none;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.15);
}
.button-primary{
background-color: #5FB878;
color: white;
}
.button-default{
color: #2f495e;
background-color: #edf2f7;
}
.user-main{
width: calc(100% - 312px);
float: right;
}
.user-left{
width: 300px;
float: left;
}
.user-collasped.user-main{
width: 100%;
}
.user-collasped.user-left{
width: 0px;
}
.user-collasped.user-left .user-group{
display: none;
}
+2 -1
View File
@@ -45,7 +45,8 @@
"title": "基础组件", "title": "基础组件",
"icon": "layui-icon layui-icon-console", "icon": "layui-icon layui-icon-console",
"type": 0, "type": 0,
"children": [{ "children": [
{
"id": 2011, "id": 2011,
"title": "功能按钮", "title": "功能按钮",
"icon": "layui-icon layui-icon-face-smile", "icon": "layui-icon layui-icon-face-smile",
+3 -3
View File
@@ -8,8 +8,8 @@
"password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG", "password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG",
"salt": null, "salt": null,
"status": null, "status": null,
"realName": "超级理员", "realName": "超级'管'理员",
"email": "8540854@qq.com", "email": "854085'4@'qq.com",
"avatar": null, "avatar": null,
"sex": "1", "sex": "1",
"phone": "15543526531", "phone": "15543526531",
@@ -22,7 +22,7 @@
"password": null, "password": null,
"salt": null, "salt": null,
"status": null, "status": null,
"realName": "就仪式", "realName": "就\"眠\"仪式",
"email": null, "email": null,
"avatar": null, "avatar": null,
"sex": "1", "sex": "1",
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,6 +205,8 @@ body::-webkit-scrollbar-corner {
width: 100%; width: 100%;
} }
@media all and (min-width:993px) and (max-width:1199px) {
.pear-col-md-offset1 { .pear-col-md-offset1 {
margin-left: 4.16%; margin-left: 4.16%;
} }
@@ -300,6 +302,8 @@ body::-webkit-scrollbar-corner {
.pear-col-md-offset24 { .pear-col-md-offset24 {
margin-left: 100%; margin-left: 100%;
} }
}
@media all and (max-width:768px) { @media all and (max-width:768px) {
.pear-col-xs1 { .pear-col-xs1 {
@@ -7,6 +7,8 @@
.pear-nav-tree .layui-nav-item>a { .pear-nav-tree .layui-nav-item>a {
height: 56px; height: 56px;
line-height: 56px; line-height: 56px;
padding-top: 0px;
padding-bottom: 0px;
} }
.pear-nav-tree .layui-nav-item dd a { .pear-nav-tree .layui-nav-item dd a {
@@ -14,6 +16,14 @@
line-height: 48px; line-height: 48px;
} }
.pear-side-scroll::-webkit-scrollbar {
width: 0px;
height: 0px;
}
.pear-side-scroll{
width: 230px;
}
.pear-nav-tree .layui-nav-child { .pear-nav-tree .layui-nav-child {
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
@@ -188,7 +198,7 @@
/** 下 拉 图 标 */ /** 下 拉 图 标 */
.pear-nav-tree.arrow .layui-nav-more { .pear-nav-tree.arrow .layui-nav-more {
font-family: layui-icon !important; font-family: layui-icon !important;
font-size: 12px; font-size: 10px;
font-style: normal; font-style: normal;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
@@ -198,7 +208,7 @@
line-height: normal; line-height: normal;
border: none; border: none;
top: 23px; top: 23px;
margin-right: 5px !important; margin-right: 2px !important;
margin: 0; margin: 0;
padding: 0; padding: 0;
display: inline-block; display: inline-block;
@@ -26,6 +26,7 @@
color: #333; color: #333;
font-size: 13.5px; font-size: 13.5px;
line-height: 20px; line-height: 20px;
cursor:pointer;
} }
.pear-tab-menu .item:hover{ .pear-tab-menu .item:hover{
background: #36b368; background: #36b368;
+47 -44
View File
@@ -2,7 +2,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
function(exports) { function(exports) {
"use strict"; "use strict";
const $ = layui.jquery, var $ = layui.jquery,
form = layui.form, form = layui.form,
element = layui.element, element = layui.element,
yaml = layui.yaml, yaml = layui.yaml,
@@ -13,20 +13,20 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
pearTheme = layui.theme, pearTheme = layui.theme,
message = layui.message; message = layui.message;
let bodyFrame; var bodyFrame;
let sideMenu; var sideMenu;
let bodyTab; var bodyTab;
let config; var config;
let logout = function() {}; var logout = function() {};
let msgInstance; var msgInstance;
const body = $('body'); var body = $('body');
const pearAdmin = new function() { var pearAdmin = new function() {
// 默认配置 // 默认配置
let configType = 'yml'; var configType = 'yml';
let configPath = 'pear.config.yml'; var configPath = 'pear.config.yml';
this.setConfigPath = function(path) { this.setConfigPath = function(path) {
configPath = path; configPath = path;
@@ -38,7 +38,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
this.setAvatar = function(url, username) { this.setAvatar = function(url, username) {
var image = new Image(); var image = new Image();
image.src = "admin/images/avatar.jpg"; image.src = url || "admin/images/avatar.jpg";
image.onload = function() { image.onload = function() {
$(".layui-nav-img").attr("src", convert.imageToBase64(image)); $(".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") { if (configType === "yml") {
return yaml.load(configPath); return yaml.load(configPath);
} else { } else {
let data; var data;
$.ajax({ $.ajax({
url: configPath, url: configPath,
type: 'get', type: 'get',
@@ -109,7 +109,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
this.bodyRender = function(param) { this.bodyRender = function(param) {
body.on("click", ".refresh", function() { body.on("click", ".refresh", function() {
const refreshA = $(".refresh a"); var refreshA = $(".refresh a");
refreshA.removeClass("layui-icon-refresh-1"); refreshA.removeClass("layui-icon-refresh-1");
refreshA.addClass("layui-anim"); refreshA.addClass("layui-anim");
refreshA.addClass("layui-anim-rotate"); refreshA.addClass("layui-anim-rotate");
@@ -200,13 +200,13 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
if (option.theme.allowCustom === false) { if (option.theme.allowCustom === false) {
$(".setting").remove(); $(".setting").remove();
} }
const colorId = localStorage.getItem("theme-color"); var colorId = localStorage.getItem("theme-color");
const currentColor = getColorById(colorId); var currentColor = getColorById(colorId);
localStorage.setItem("theme-color", currentColor.id); localStorage.setItem("theme-color", currentColor.id);
localStorage.setItem("theme-color-context", currentColor.color); localStorage.setItem("theme-color-context", currentColor.color);
pearTheme.changeTheme(window, option.other.autoHead); pearTheme.changeTheme(window, option.other.autoHead);
let menu = localStorage.getItem("theme-menu"); var menu = localStorage.getItem("theme-menu");
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) {
@@ -218,7 +218,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
} }
this.menuSkin = function(theme) { this.menuSkin = function(theme) {
const pearAdmin = $(".pear-admin"); var pearAdmin = $(".pear-admin");
pearAdmin.removeClass("light-theme"); pearAdmin.removeClass("light-theme");
pearAdmin.removeClass("dark-theme"); pearAdmin.removeClass("dark-theme");
pearAdmin.addClass(theme); pearAdmin.addClass(theme);
@@ -238,8 +238,13 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
this.jump = function(id, title, url) { this.jump = function(id, title, url) {
if (config.tab.muiltTab) { if (config.tab.muiltTab) {
bodyTab.addTabOnly({id: id,title: title,url: url,icon: null,close: true}, bodyTab.addTabOnly({
300); id: id,
title: title,
url: url,
icon: null,
close: true
}, 300);
} else { } else {
sideMenu.selectItem(id); sideMenu.selectItem(id);
bodyFrame.changePage(url, title, true); bodyFrame.changePage(url, title, true);
@@ -267,9 +272,9 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
function collaspe() { function collaspe() {
sideMenu.collaspe(); sideMenu.collaspe();
const admin = $(".pear-admin"); var admin = $(".pear-admin");
const left = $(".layui-icon-spread-left") var left = $(".layui-icon-spread-left")
const right = $(".layui-icon-shrink-right") var right = $(".layui-icon-shrink-right")
if (admin.is(".pear-mini")) { if (admin.is(".pear-mini")) {
left.addClass("layui-icon-shrink-right") left.addClass("layui-icon-shrink-right")
left.removeClass("layui-icon-spread-left") 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() { body.on("click", ".setting", function() {
let 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">' +
'<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: 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>' + '</a>' +
'</li>'; '</li>';
const 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' +
'<div class="color-content">\n' + '<div class="color-content">\n' +
@@ -360,23 +365,20 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
move: false, move: false,
content: html + buildColorHtml() + buildLinkHtml() + bottomTool(), content: html + buildColorHtml() + buildLinkHtml() + bottomTool(),
success: function(layero, index) { success: function(layero, index) {
form.render();
const color = localStorage.getItem("theme-color"); var color = localStorage.getItem("theme-color");
const 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").addClass("layui-icon-ok");
$("*[color-id='" + color + "']").addClass("layui-icon")
.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() {
const $layero = $('#layui-layer' + index); var $layero = $('#layui-layer' + index);
$layero.animate({ $layero.animate({
left: $layero.offset().left + $layero.width() left: $layero.offset().left + $layero.width()
}, 200, function() { }, 200, function() {
@@ -385,7 +387,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}) })
$('#closeTheme').click(function() { $('#closeTheme').click(function() {
const $layero = $('#layui-layer' + index); var $layero = $('#layui-layer' + index);
$layero.animate({ $layero.animate({
left: $layero.offset().left + $layero.width() left: $layero.offset().left + $layero.width()
}, 200, function() { }, 200, function() {
@@ -401,7 +403,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
} }
body.on('click', '[data-select-bgcolor]', function() { 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"); $('[data-select-bgcolor]').removeClass("layui-this");
$(this).addClass("layui-this"); $(this).addClass("layui-this");
localStorage.setItem("theme-menu", theme); 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() { 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");
const colorId = $(".select-color-item.layui-icon-ok").attr("color-id"); var colorId = $(".select-color-item.layui-icon-ok").attr("color-id");
const currentColor = getColorById(colorId); var currentColor = getColorById(colorId);
localStorage.setItem("theme-color", currentColor.id); localStorage.setItem("theme-color", currentColor.id);
localStorage.setItem("theme-color-context", currentColor.color); localStorage.setItem("theme-color-context", currentColor.color);
pearTheme.changeTheme(window, config.other.autoHead); pearTheme.changeTheme(window, config.other.autoHead);
@@ -431,8 +433,8 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
} }
function getColorById(id) { function getColorById(id) {
let color; var color;
let flag = false; var flag = false;
$.each(config.colors, function(i, value) { $.each(config.colors, function(i, value) {
if (value.id === id) { if (value.id === id) {
color = value; color = value;
@@ -450,9 +452,10 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
} }
function buildLinkHtml() { function buildLinkHtml() {
let links = ""; var links = "";
$.each(config.links, function(i, value) { $.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 + '<i class="' + value.icon + '" style="font-size: 19px;"></i> ' + value.title +
'</a>' '</a>'
}) })
@@ -460,7 +463,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
} }
function buildColorHtml() { function buildColorHtml() {
let colors = ""; var colors = "";
$.each(config.colors, function(i, value) { $.each(config.colors, function(i, value) {
colors += "<span class='select-color-item' color-id='" + value.id + "' style='background-color:" + value.color + colors += "<span class='select-color-item' color-id='" + value.id + "' style='background-color:" + value.color +
";'></span>"; ";'></span>";
@@ -478,7 +481,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
function screenFun(num) { function screenFun(num) {
num = num || 1; num = num || 1;
num = num * 1; num = num * 1;
const docElm = document.documentElement; var docElm = document.documentElement;
switch (num) { switch (num) {
case 1: case 1:
if (docElm.requestFullscreen) { if (docElm.requestFullscreen) {
+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).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); var buttons = $(option.elem);
if (option.time != "" || option.time !=false) { if (option.time != "" || option.time !=false) {
setTimeout(function() { setTimeout(function() {
$(option.elem).attr("disabled", false);
buttons.html(text); buttons.html(text);
option.done(); option.done();
}, option.time); }, option.time);
@@ -41,8 +44,9 @@ layui.define(['jquery'], function(exports) {
* Button stop loaded * Button stop loaded
* */ * */
button.prototype.stop = function(success) { button.prototype.stop = function(success) {
$(this.option.elem).attr("disabled", false);
$(this.option.elem).html(this.option.text); $(this.option.elem).html(this.option.text);
success(); success && success();
} }
exports(MOD_NAME, new button()); 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 { } else {
//renderMenu中需要调用done事件,done事件中需要menu对象,但是此时还未返回menu对象,做个延时提前返回对象 //renderMenu中需要调用done事件,done事件中需要menu对象,但是此时还未返回menu对象,做个延时提前返回对象
window.setTimeout(function() { window.setTimeout(function() { renderMenu(option);}, 500);
renderMenu(option);
}, 500);
} }
// 处理高度
$("#"+opt.elem).height(option.height)
return new pearMenu(opt); return new pearMenu(opt);
} }
@@ -194,7 +195,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
} }
function createMenu(option) { 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">' '" class="layui-nav arrow pear-menu layui-nav-tree pear-nav-tree">'
$.each(option.data, function(i, item) { $.each(option.data, function(i, item) {
var content = '<li class="layui-nav-item" >'; var content = '<li class="layui-nav-item" >';
@@ -227,7 +228,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
menuHtml += content; menuHtml += content;
}); });
// 结 束 菜 单 结 构 的 初 始 化 // 结 束 菜 单 结 构 的 初 始 化
menuHtml += "</ul>"; menuHtml += "</ul></div>";
// 将 菜 单 拼 接 到 初 始 化 容 器 中 // 将 菜 单 拼 接 到 初 始 化 容 器 中
$("#" + option.elem).html(menuHtml); $("#" + option.elem).html(menuHtml);
} }
@@ -54,7 +54,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
var notice = '<li class="layui-nav-item" lay-unselect="">' + 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>' + '<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 noticeTitle = '<ul class="layui-tab-title">';
var noticeContent = '<div class="layui-tab-content" style="height:' + option.height + ';overflow-x: hidden;">'; 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 += '.pear-tab-menu .item:hover{background-color:'+color+'!important}'
style += '.layui-form-danger:focus {border-color:#FF5722 !important}' style += '.layui-form-danger:focus {border-color:#FF5722 !important}'
style += '.pear-admin .user a:hover{color:'+color+'!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"); var colorPane = $("#pear-admin-color");
if(colorPane.length>0){ if(colorPane.length>0){
colorPane.html(style); colorPane.html(style);
@@ -16,7 +16,7 @@ layui.define(['layer', 'table'], function (exports) {
} else { } else {
$.getJSON(param.url, param.where, function (res) { $.getJSON(param.url, param.where, function (res) {
if(param.parseData){ if(param.parseData){
res.data = param.parseData(res); res = param.parseData(res);
param.data = res.data; param.data = res.data;
} }
treetable.init(param, res.data); treetable.init(param, res.data);
+2 -2
View File
@@ -5,7 +5,7 @@ window.rootPath = (function(src) {
layui.config({ layui.config({
base: rootPath + "module/", base: rootPath + "module/",
version: "3.7.6.Release" version: "3.8.0.Release"
}).extend({ }).extend({
admin: "admin", // 框架布局组件 admin: "admin", // 框架布局组件
menu: "menu", // 数据菜单组件 menu: "menu", // 数据菜单组件
@@ -37,7 +37,7 @@ layui.config({
context: "context", // 上下文组件 context: "context", // 上下文组件
http: "http", // ajax请求组件 http: "http", // ajax请求组件
theme: "theme", // 主题转换 theme: "theme", // 主题转换
message: "message" // 通知组件 message: "message", // 通知组件
}).use(['layer', 'theme'], function () { }).use(['layer', 'theme'], function () {
layui.theme.changeTheme(window, false); layui.theme.changeTheme(window, false);
}); });
-66
View File
@@ -1,66 +0,0 @@
{
"logo": {
"title": "Pear Admin",
"image": "admin/images/logo.png"
},
"menu": {
"data": "admin/data/menu.json",
"accordion": true,
"control": false,
"select": "0"
},
"tab": {
"muiltTab": true,
"keepState": true,
"tabMax": 30,
"index": {
"id": "0",
"href": "view/console/console1.html",
"title": "首页"
}
},
"theme": {
"defaultColor": "2",
"defaultMenu": "dark-theme",
"allowCustom": true
},
"colors": [{
"id": "1",
"color": "#2d8cf0"
},
{
"id": "2",
"color": "#5FB878"
},
{
"id": "3",
"color": "#1E9FFF"
}, {
"id": "4",
"color": "#FFB800"
}, {
"id": "5",
"color": "darkgray"
}
],
"links": [{
"icon": "layui-icon layui-icon-auz",
"title": "官方网站",
"href": "http://www.pearadmin.com"
},
{
"icon": "layui-icon layui-icon-auz",
"title": "开发文档",
"href": "http://www.pearadmin.com"
},
{
"icon": "layui-icon layui-icon-auz",
"title": "开源地址",
"href": "https://gitee.com/Jmysy/Pear-Admin-Layui"
}
],
"other": {
"keepLoad": 1200,
"autoHead": false
}
}
-78
View File
@@ -1,78 +0,0 @@
---
## 网站配置
logo:
## 网站名称
title: "Pear Admin"
## 网站图标
image: "/static/admin/admin/images/logo.png"
## 菜单配置
menu:
## 菜单数据来源
data: "/admin/menu"
## 是否同时只打开一个菜单目录
accordion: true
## 是否开启多系统菜单模式
control: false
## 默认选中的菜单项
select: "10"
## 是否开启异步菜单,false 时 data 属性设置为菜单数据,false 时为 json 文件或后端接口
async: true
## 视图内容配置
tab:
## 是否开启多选项卡
muiltTab: true
## 切换选项卡时,是否刷新页面状态
keepState: true
## 是否开启 Tab 记忆
session: true
## 最大可打开的选项卡数量
tabMax: "30"
## 默认选项卡数据
index:
id: "10" ## 标识 ID , 建议与菜单项中的 ID 一致
href: "/admin/welcome" ## 页面地址
title: "首页" ## 标题
## 主题配置
theme:
## 默认主题色,对应 colors 配置中的 ID 标识
defaultColor: "2"
## 默认的菜单主题 dark-theme 黑 / light-theme 白
defaultMenu: "dark-theme"
## 是否允许用户切换主题,false 时关闭自定义主题面板
allowCustom: true
## 供选择的主题色配置列表
colors:
- id: "1"
color: "#2d8cf0"
- id: "2"
color: "#36b368"
- id: "3"
color: "#f6ad55"
- id: "4"
color: "#f56c6c"
- id: "5"
color: "darkgray"
## 主题面板的链接列表配置
links:
- icon: "layui-icon layui-icon-website"
title: "官方网站"
href: "http://www.pearadmin.com"
- icon: "layui-icon layui-icon-read"
title: "开发文档"
href: "http://www.pearadmin.com/doc/"
- icon: "layui-icon layui-icon-fonts-code"
title: "开源地址"
href: "https://gitee.com/pear-admin/Pear-Admin-Layui"
- icon: "layui-icon layui-icon-survey"
title: "问答社区"
href: "http://forum.pearadmin.com/"
## 其他配置
other:
## 主页动画时长
keepLoad: "1200"
## 布局顶部主题
autoHead: false
header:
## 站内消息,数据来源,通过 false 设置关闭
false
+2 -2
View File
@@ -77,8 +77,8 @@
// 框架初始化时会读取 根目录下 pear.config.yml 文件作为初始化配置 // 框架初始化时会读取 根目录下 pear.config.yml 文件作为初始化配置
// 你可以通过 admin.setConfigPath 方法修改配置文件位置 // 你可以通过 admin.setConfigPath 方法修改配置文件位置
// 你可以通过 admin.setConfigType 方法修改配置文件类型 // 你可以通过 admin.setConfigType 方法修改配置文件类型
admin.setConfigType("yml"); admin.setConfigType("json");
admin.setConfigPath("/static/admin/config/pear.config.yml"); admin.setConfigPath("{{ url_for('adminIndex.config') }}");
admin.render(); admin.render();