更新依赖pear-admin-layui到3.8.3,增加前端渲染配置接口
This commit is contained in:
@@ -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需要) 记得修改
|
||||
import os
|
||||
|
||||
SECRET_KEY = 'pear-admin-flask'
|
||||
|
||||
UPLOADED_PHOTOS_DEST = 'static/upload'
|
||||
UPLOADED_FILES_ALLOW = ['gif','jpg']
|
||||
|
||||
JSON_AS_ASCII = False
|
||||
UPLOADED_FILES_ALLOW = ['gif', 'jpg']
|
||||
# JSON配置
|
||||
JSON_AS_ASCII = False
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 applications.models.admin_power import PowerSchema
|
||||
from applications.service.captcha import gen_captcha
|
||||
@@ -71,3 +71,75 @@ def get_captcha():
|
||||
resp = make_response(out.read())
|
||||
resp.content_type = 'image/png'
|
||||
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
|
||||
|
||||
@@ -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 applications.service.admin import index_curd
|
||||
from applications.service.admin_log import login_log
|
||||
@@ -16,6 +16,13 @@ def index():
|
||||
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"])
|
||||
def getCaptcha():
|
||||
|
||||
Reference in New Issue
Block a user