From d4d8d8b2941883c2e8ee5d75fbc0af860ea6d772 Mon Sep 17 00:00:00 2001 From: zhengxinonly Date: Fri, 19 Nov 2021 18:38:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(jinja2):=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=BD=BF=E7=94=A8=E7=BB=A7=E6=89=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/admin/base.html | 35 ++ templates/admin/common/footer.html | 2 - templates/admin/common/header.html | 5 - templates/admin/department/dept.html | 464 +++++++++-------- templates/admin/department/dept_add.html | 223 ++++----- templates/admin/department/dept_edit.html | 216 ++++---- templates/admin/file/photo.html | 504 ++++++++++--------- templates/admin/file/photo_add.html | 115 ++--- templates/admin/logs_temp/main.html | 137 +++-- templates/admin/rights/rights.html | 523 ++++++++++--------- templates/admin/rights/rights_add.html | 301 ++++++----- templates/admin/rights/rights_edit.html | 364 +++++++------- templates/admin/roles/roles.html | 485 +++++++++--------- templates/admin/roles/roles_add.html | 158 +++--- templates/admin/roles/roles_edit.html | 175 ++++--- templates/admin/roles/roles_power.html | 142 +++--- templates/admin/users/profile.html | 516 +++++++++---------- templates/admin/users/profile_avatar.html | 230 +++++---- templates/admin/users/users.html | 579 +++++++++++----------- templates/admin/users/users_add.html | 169 ++++--- templates/admin/users/users_edit.html | 207 ++++---- 21 files changed, 2781 insertions(+), 2769 deletions(-) create mode 100644 templates/admin/base.html delete mode 100644 templates/admin/common/footer.html delete mode 100644 templates/admin/common/header.html diff --git a/templates/admin/base.html b/templates/admin/base.html new file mode 100644 index 0000000..310472c --- /dev/null +++ b/templates/admin/base.html @@ -0,0 +1,35 @@ + + + + + {#页面标题#} + {% block title %} + Pear Admin Flask + {% endblock %} + + + + + {# 头部导入的 Script,主要为样式 #} + {% block header_script %} + + {% endblock %} + +{#pear 后台边框#} + + +{#页面的主题内容,用于页面进行改写#} +{% block body %} + +{% endblock %} + +{# 当前页面需要依赖的 JavaScript #} +{% block footer_script %} + + +{% endblock %} +{# 当前页面自己编写的 JavaScript #} +{% block models_script %} +{% endblock %} + + \ No newline at end of file diff --git a/templates/admin/common/footer.html b/templates/admin/common/footer.html deleted file mode 100644 index 95923d4..0000000 --- a/templates/admin/common/footer.html +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/templates/admin/common/header.html b/templates/admin/common/header.html deleted file mode 100644 index b717e72..0000000 --- a/templates/admin/common/header.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/templates/admin/department/dept.html b/templates/admin/department/dept.html index d889c3d..6bba93a 100644 --- a/templates/admin/department/dept.html +++ b/templates/admin/department/dept.html @@ -1,256 +1,252 @@ - - - +{% extends 'admin/base.html' %} +{% block title %} 部门新增 - {% include 'admin/common/header.html' %} - -{#pear 后台边框#} - -{#搜索框布局#} -
-
-
-
- -
- {#部门信息搜索字段#} - +{% endblock %} + + +{% block body %} + {#搜索框布局#} +
+
+ +
+ +
+ {#部门信息搜索字段#} + +
+ {#查询按钮--需要触发layui事件#} + + {#重置按钮#} +
- {#查询按钮--需要触发layui事件#} - - {#重置按钮#} - -
- + +
-
-
-
- {#表格字段渲染#} -
+
+
+ {#表格字段渲染#} +
+
-
- - -{#表格工具栏,需要在表格中绑定,且需要自定义事件#} - + {#操作字段,需要在表格中使用#} + -{#操作字段,需要在表格中使用#} - -{#表格内的切换按钮#} - - - -{% include 'admin/common/footer.html' %} - - + {#表格内的切换按钮#} + + + - - \ No newline at end of file + +{% endblock %} diff --git a/templates/admin/department/dept_add.html b/templates/admin/department/dept_add.html index 7feaf6d..bc49a9e 100644 --- a/templates/admin/department/dept_add.html +++ b/templates/admin/department/dept_add.html @@ -1,128 +1,129 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 部门管理 - {% include 'admin/common/header.html' %} - - -
-
-
-
- -
-
    +{% endblock %} + + +{% block body %} + +
    +
    +
    + +
    +
      +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - - +
      + +
      + + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      -
      - - +
      +
      + + +
      -
      - - - -{% include 'admin/common/footer.html' %} + +{% endblock %} - - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/department/dept_edit.html b/templates/admin/department/dept_edit.html index b921f88..6e97e2b 100644 --- a/templates/admin/department/dept_edit.html +++ b/templates/admin/department/dept_edit.html @@ -1,129 +1,129 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 部门修改 - {% include 'admin/common/header.html' %} - - -
      -
      -
      -
      - -
      - +{% endblock %} + + +{% block body %} + +
      +
      +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      - +
      + +
      + - + +
      -
      -
      - -
      - +
      + +
      + +
      -
      -
      - -
      +
      + +
      +
      -
      -
      -
      - - +
      +
      + + +
      -
      - + +{% endblock %} -{% include 'admin/common/footer.html' %} +{% block models_script %} + - - \ No newline at end of file + +{% endblock %} diff --git a/templates/admin/file/photo.html b/templates/admin/file/photo.html index 84ae0b3..d388af5 100644 --- a/templates/admin/file/photo.html +++ b/templates/admin/file/photo.html @@ -1,270 +1,268 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 图片上传 - {% include 'admin/common/header.html' %} - - -
      -
      -
      +{% endblock %} + +{% block body %} +
      +
      +
      +
      -
      +{% endblock %} +{% block models_script %} + + -{% include 'admin/common/footer.html' %} + - + layui.use(['table', 'form', 'jquery', 'element', 'form', 'upload'], function () { + let table = layui.table + let form = layui.form + let $ = layui.jquery + let upload = layui.upload - - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/file/photo_add.html b/templates/admin/file/photo_add.html index aff3ecf..75c7ea6 100644 --- a/templates/admin/file/photo_add.html +++ b/templates/admin/file/photo_add.html @@ -1,66 +1,61 @@ - - - - {% include 'admin/common/header.html' %} - - - -
      -
      -
      -
      -
      - 新增图片 -
      -
      -
      - - - -
      -
      +{% extends 'admin/base.html' %} + +{% block title %} + 新增图片 +{% endblock %} + +{% block body %} +
      +
      +
      +
      +
      + 新增图片 +
      +
      +
      + + + +
      +
      +
      -
      - +{% endblock %} -{% include 'admin/common/footer.html' %} - - - \ No newline at end of file + layui.use(['jquery', 'element', 'form', 'upload'], function () { + var $ = layui.jquery + var element = layui.element + var form = layui.form + var upload = layui.upload + //选完文件后不自动上传 + upload.render({ + elem: '#select-img' + , url: FILE_API.PHOTOS() + , auto: false + , exts: 'jpg|png|gif|bmp|jpeg' + , size: 1000 + , bindAction: '#logo-upload-button' + , done: function (res) { + if (res.success) { + layer.msg(res.message, { icon: 1, time: 500 }, function () { + parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页 + window.parent.location.reload() + }) + } else { + layer.msg(res.message, { icon: 2 }) + } + }, + }) + }) + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/logs_temp/main.html b/templates/admin/logs_temp/main.html index e1af787..61c6a7c 100644 --- a/templates/admin/logs_temp/main.html +++ b/templates/admin/logs_temp/main.html @@ -1,87 +1,86 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 日志 - {% include 'admin/common/header.html' %} - - +{% endblock %} -
      -
      -
      -
        -
      • 登录日志
      • -
      • 访问日志
      • -
      -
      -
      -
      -
      -
      -
      + +{% block body %} +
      +
      +
      +
        +
      • 登录日志
      • +
      • 访问日志
      • +
      +
      +
      +
      +
      +
      +
      +
      -
      - - -{% include 'admin/common/footer.html' %} +{% endblock %} - - + + - - \ No newline at end of file + table.render({ + parseData, + elem: '#log-login-table', + url: MODULE_PATH + 'login_log', + page: true, + cols: get_columns(), + skin: 'line', + toolbar: false, + }) + }) + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/rights/rights.html b/templates/admin/rights/rights.html index d8a8a35..785bc69 100644 --- a/templates/admin/rights/rights.html +++ b/templates/admin/rights/rights.html @@ -1,286 +1,285 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 权限 - {% include 'admin/common/header.html' %} - - -
      -
      -
      -
      - -
      - +{% endblock %} + + +{% block body %} +
      +
      + +
      + +
      + +
      + +
      - - -
      - + +
      -
      -
      -
      -
      +
      +
      +
      +
      -
      +{% endblock %} +{% block models_script %} + + -{% include 'admin/common/footer.html' %} + - + layui.use(['table', 'form', 'jquery', 'treetable', 'popup', 'dtree', 'iconPicker'], function () { + let table = layui.table + let form = layui.form + let $ = layui.jquery + let treetable = layui.treetable + let popup = layui.popup + let iconPicker = layui.iconPicker + let dtree = layui.dtree - - - \ No newline at end of file + +{% endblock %} diff --git a/templates/admin/rights/rights_add.html b/templates/admin/rights/rights_add.html index a0674ce..6065695 100644 --- a/templates/admin/rights/rights_add.html +++ b/templates/admin/rights/rights_add.html @@ -1,172 +1,171 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 权限 - {% include 'admin/common/header.html' %} - - -
      -
      -
      +{% endblock %} + +{% block body %} + +
      -
      - -
      -
        +
        +
        + +
        +
          +
          -
          -
          - -
          - +
          + +
          + +
          -
          -
          - -
          - +
          + +
          + +
          -
          -
          - -
          - - - +
          + +
          + + + +
          -
          -
          - -
          - +
          + +
          + +
          -
          -
          - -
          - +
          + +
          + +
          -
          -
          - -
          - +
          + +
          + +
          -
          -
          - -
          - +
          + +
          + +
          -
          -
          -
          - - +
          +
          + + +
          -
          - - + +{% endblock %} -{% include 'admin/common/footer.html' %} +{% block models_script %} + - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/rights/rights_edit.html b/templates/admin/rights/rights_edit.html index 95750b2..14029ec 100644 --- a/templates/admin/rights/rights_edit.html +++ b/templates/admin/rights/rights_edit.html @@ -1,206 +1,206 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 权限编辑 - {% include 'admin/common/header.html' %} - - -
          -
          -
          -
          - -
          - +{% endblock %} + +{% block body %} + +
          +
          +
          + +
          + +
          -
          -
          - -
          -
            +
            + +
            +
              +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - - - +
              + +
              + + + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              -
              - - +
              +
              + + +
              -
              - - - -{% include 'admin/common/footer.html' %} + - - - \ No newline at end of file + window.init = function (type) { + if (type == '0') { + $('#powerUrlItem').hide() + $('#powerCodeItem').hide() + $('#openTypeItem').hide() + $('#powerUrl').val('') + $('#powerCode').val('') + $('#openType').val('') + } else if (type == '1') { + $('#powerUrlItem').show() + $('#powerCodeItem').show() + $('#openTypeItem').show() + } else if (type == '2') { + $('#powerUrlItem').hide() + $('#openTypeItem').hide() + $('#powerCodeItem').show() + $('#powerUrl').val('') + $('#openType').val('') + } + } + + window.init("{{ power.type }}") + }) + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/roles/roles.html b/templates/admin/roles/roles.html index 37e24b6..f35dbfa 100644 --- a/templates/admin/roles/roles.html +++ b/templates/admin/roles/roles.html @@ -1,255 +1,254 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 角色管理 - {% include 'admin/common/header.html' %} - -
              -
              -
              -
              - -
              - -
              - -
              - +{% endblock %} + +{% block body %} +
              +
              + +
              + +
              + +
              + +
              + +
              + +
              - - -
              - + +
              -
              -
              -
              -
              +
              +
              +
              +
              -
              - -{% include 'admin/common/footer.html' %} - - - - - - - + + + + - - \ No newline at end of file + }) + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/roles/roles_add.html b/templates/admin/roles/roles_add.html index 43832ba..a422864 100644 --- a/templates/admin/roles/roles_add.html +++ b/templates/admin/roles/roles_add.html @@ -1,93 +1,93 @@ - - - +{% extends 'admin/base.html' %} +{% block title %} 角色新增 - {% include 'admin/common/header.html' %} - -
              -
              -
              -
              - -
              - +{% endblock %} + +{% block body %} + +
              +
              +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - - +
              + +
              + + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              -
              - - +
              +
              + + +
              -
              - - + +{% endblock %} -{% include 'admin/common/footer.html' %} - - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/roles/roles_edit.html b/templates/admin/roles/roles_edit.html index f5f333b..7369e7e 100644 --- a/templates/admin/roles/roles_edit.html +++ b/templates/admin/roles/roles_edit.html @@ -1,108 +1,107 @@ - - - +{% extends 'admin/base.html' %} +{% block title %} 角色编辑 - {% include 'admin/common/header.html' %} - -
              -
              -
              +{% endblock %} + +{% block body %} + +
              -
              - -
              - +
              +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              - - +
              + +
              + + +
              -
              -
              - -
              - +
              + +
              + +
              -
              -
              - -
              +
              + +
              +
              -
              -
              -
              - - +
              +
              + + +
              -
              - - + +{% endblock %} -{% include 'admin/common/footer.html' %} - - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/roles/roles_power.html b/templates/admin/roles/roles_power.html index 5aebcd0..5b73395 100644 --- a/templates/admin/roles/roles_power.html +++ b/templates/admin/roles/roles_power.html @@ -1,85 +1,85 @@ - - - +{% extends 'admin/base.html' %} +{% block title %} 角色授权 - {% include 'admin/common/header.html' %} - -
              -
              -
              +{% endblock %} + +{% block body %} + +
              -
                +
                +
                  +
                  -
                  -
                  -
                  - - +
                  +
                  + + +
                  -
                  - + +{% endblock %} -{% include 'admin/common/footer.html' %} +{% block models_script %} + - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/admin/users/profile.html b/templates/admin/users/profile.html index 615d8e9..201581d 100644 --- a/templates/admin/users/profile.html +++ b/templates/admin/users/profile.html @@ -1,174 +1,180 @@ - - - +{% extends 'admin/base.html' %} + +{% block title %} 个人中心 - {% include 'admin/common/header.html' %} - - -
                  - {# 左侧栏 #} -
                  - {# 个人信息卡片 #} -
                  -
                  -
                  -