diff --git a/pear_admin/__init__.py b/pear_admin/__init__.py index 6734833..206c649 100644 --- a/pear_admin/__init__.py +++ b/pear_admin/__init__.py @@ -1,4 +1,4 @@ -from flask import Flask +from flask import Flask, render_template from configs import config from pear_admin.apis import register_apis @@ -17,4 +17,16 @@ def create_app(config_name="dev"): register_views(app) + @app.errorhandler(403) + def handle_404(e): + return render_template("error/403.html") + + @app.errorhandler(404) + def handle_403(e): + return render_template("error/404.html") + + @app.errorhandler(500) + def handle_500(e): + return render_template("error/500.html") + return app diff --git a/pear_admin/apis/user.py b/pear_admin/apis/user.py index 69775f5..6c2f456 100644 --- a/pear_admin/apis/user.py +++ b/pear_admin/apis/user.py @@ -31,10 +31,10 @@ def create_user(): if data["id"]: del data["id"] role = UserORM(**data) - create_at = data['create_at'] + create_at = data["create_at"] if create_at: - role.create_at = datetime.strptime(create_at, '%Y-%m-%d %H:%M:%S') - role.password = '123456' + role.create_at = datetime.strptime(create_at, "%Y-%m-%d %H:%M:%S") + role.password = "123456" role.save() return {"code": 0, "message": "新增用户成功"} @@ -46,8 +46,8 @@ def change_user(uid): user_obj = UserORM.query.get(uid) for key, value in data.items(): - if key == 'create_at': - value = datetime.strptime(value, '%Y-%m-%d %H:%M:%S') + if key == "create_at": + value = datetime.strptime(value, "%Y-%m-%d %H:%M:%S") setattr(user_obj, key, value) user_obj.save() return {"code": 0, "message": "修改用户信息成功"} diff --git a/static/config/pear.config.json b/static/config/pear.config.json index d8af15c..9bfac57 100644 --- a/static/config/pear.config.json +++ b/static/config/pear.config.json @@ -1,6 +1,6 @@ { "logo": { - "title": "Pear Admin", + "title": "Pear Admin Flask", "image": "/static/admin/images/logo.png" }, "menu": { diff --git a/static/data/ums_rights.csv b/static/data/ums_rights.csv index f53826b..11f7a48 100644 --- a/static/data/ums_rights.csv +++ b/static/data/ums_rights.csv @@ -20,9 +20,6 @@ id,name,code,type,url,icon_sign,status,sort,open_type,pid 118,修改用户,ums:user:update,auth,,,,0,,116 119,查询用户,ums:user:read,auth,,,,0,,116 120,查询用户,ums:user:read,auth,,,,0,,116 -121,数据图表,,menu,,layui-icon layui-icon-chart,,3,,0 -122,折线图,,path,/views/echarts/line,layui-icon layui-icon-face-smile,,0,,121 -123,柱状图,,path,/views/echarts/column,layui-iconlayui-icon-face-smile,,0,,121 124,工作空间,,menu,,layui-icon layui-icon-console,,1,,0 125,工作台,,path,/view/console/index.html,layui-icon layui-icon-console,,2,_component,124 126,首页,,path,/view/analysis/index.html,layui-icon layui-icon-console,,1,_component,124 \ No newline at end of file diff --git a/templates/error/403.html b/templates/error/403.html new file mode 100644 index 0000000..a8d1ac8 --- /dev/null +++ b/templates/error/403.html @@ -0,0 +1,129 @@ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

403

+
+
+ 抱歉, 你无权访问该页面. +
+
+ +
+
\ No newline at end of file diff --git a/templates/error/404.html b/templates/error/404.html new file mode 100644 index 0000000..9f4ddb0 --- /dev/null +++ b/templates/error/404.html @@ -0,0 +1,137 @@ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

404

+
+
+ 抱歉, 你访问的页面不存在. +
+
+ +
+
\ No newline at end of file diff --git a/templates/error/500.html b/templates/error/500.html new file mode 100644 index 0000000..4f4b8c7 --- /dev/null +++ b/templates/error/500.html @@ -0,0 +1,151 @@ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

500

+
+
+ 抱歉, 服务器出错了. +
+
+ +
+
\ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 62a6121..2afa7fc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,7 +6,7 @@ name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> - Pear Admin 4.0 + Pear Admin Flask {% include 'includes/script.html' %} diff --git a/templates/views/role/index.html b/templates/views/role/index.html index 15c0de1..9815661 100644 --- a/templates/views/role/index.html +++ b/templates/views/role/index.html @@ -205,6 +205,7 @@ }); } else if (obj.event === "role-tool-detail") { console.log("角色授权"); + // role-tool-detail } }); diff --git a/templates/views/user/index.html b/templates/views/user/index.html index 8e098d2..be9748a 100644 --- a/templates/views/user/index.html +++ b/templates/views/user/index.html @@ -1,258 +1,264 @@ - - + + 用户管理 - - + + - - -
-
+ + +
+
-
+
+
-
- - - + - + - + }); + +