瀏覽代碼

修改后台超用户配置

邹景立 3 年之前
父節點
當前提交
d53fed33e1

+ 1 - 0
app/admin/controller/Index.php

@@ -48,6 +48,7 @@ class Index extends Controller
             $this->redirect(sysuri('admin/login/index'));
         } else {
             $this->title = '系统管理后台';
+            $this->isSuper = AdminService::instance()->isSuper();
             $this->fetch();
         }
     }

+ 1 - 1
app/admin/controller/Queue.php

@@ -46,7 +46,7 @@ class Queue extends Controller
      */
     public function index()
     {
-        if (AdminService::instance()->isSuper()) {
+        if ($this->isSuper = AdminService::instance()->isSuper()) {
             $process = ProcessService::instance();
             if ($process->iswin() || empty($_SERVER['USER'])) {
                 $this->command = $process->think('xadmin:queue start');

+ 16 - 0
app/admin/controller/User.php

@@ -33,6 +33,21 @@ class User extends Controller
     private $table = 'SystemUser';
 
     /**
+     * 超级用户名称
+     * @var string
+     */
+    protected $superName;
+
+    /**
+     * 控制器初始化
+     */
+    protected function initialize()
+    {
+        // 超级用户名称
+        $this->superName = $this->app->config->get('app.super_user', 'admin');
+    }
+
+    /**
      * 系统用户管理
      * @auth true
      * @menu true
@@ -43,6 +58,7 @@ class User extends Controller
     public function index()
     {
         $this->title = '系统用户管理';
+
         $query = $this->_query($this->table);
         $query->equal('status')->dateBetween('login_at,create_at');
         $query->like('username,contact_phone#phone,contact_mail#mail');

+ 1 - 1
app/admin/view/config/index.html

@@ -1,7 +1,7 @@
 {extend name="main"}
 
 {block name="button"}
-<!--{if session('user.username') eq 'admin'}-->
+<!--{if isset($isSuper) and $isSuper}-->
 <a class="layui-btn layui-btn-sm layui-btn-primary" data-load="{:url('admin/api.runtime/config')}">清理无效配置</a>
 <!--{/if}-->
 

+ 1 - 1
app/admin/view/index/index-top.html

@@ -26,7 +26,7 @@
             <dl class="layui-nav-child">
                 <dd lay-unselect><a data-modal="{:url('admin/index/info',['id'=>session('user.id')])}"><i class="layui-icon layui-icon-set-fill"></i> 基本资料</a></dd>
                 <dd lay-unselect><a data-modal="{:url('admin/index/pass',['id'=>session('user.id')])}"><i class="layui-icon layui-icon-component"></i> 安全设置</a></dd>
-                {if session('user.username') eq 'admin'}
+                {if isset($isSuper) and $isSuper}
                 <dd lay-unselect><a data-load="{:url('admin/api.runtime/push')}"><i class="layui-icon layui-icon-template-1"></i> 缓存加速</a></dd>
                 <dd lay-unselect><a data-load="{:url('admin/api.runtime/clear')}"><i class="layui-icon layui-icon-fonts-clear"></i> 清理缓存</a></dd>
                 {/if}

+ 1 - 1
app/admin/view/queue/index.html

@@ -1,7 +1,7 @@
 {extend name='main'}
 
 {block name="button"}
-<!--{if session('user.username') eq 'admin'}-->
+<!--{if isset($isSuper) and $isSuper}-->
 <a class="layui-btn layui-btn-sm layui-btn-primary" data-queue="{:url('admin/api.plugs/optimize')}">优化数据库</a>
 <!--{if $iswin}-->
 <button data-load='{:url("admin/api.queue/start")}' class='layui-btn layui-btn-sm layui-btn-primary'>开启后台服务</button>

+ 2 - 2
app/admin/view/queue/index_search.html

@@ -1,4 +1,4 @@
-{if session('user.username') eq 'admin'}
+<!--{if isset($isSuper) and $isSuper}-->
 <fieldset class="margin-bottom-15">
     <legend class="notselect">服务状态</legend>
     <div class="layui-code border-0 margin-top-0">
@@ -9,7 +9,7 @@
     </div>
     <script>$('[data-queue-message]').load('{:url("admin/api.queue/status")}')</script>
 </fieldset>
-{/if}
+<!--{/if}-->
 
 <fieldset>
     <legend>条件搜索</legend>

+ 1 - 1
app/admin/view/user/form.html

@@ -58,7 +58,7 @@
             <span class="color-green font-w7">访问权限</span>
             <span class="color-desc margin-left-5">Authorize</span>
             <div class="layui-textarea">
-                {if isset($vo.username) and $vo.username eq 'admin'}
+                {if isset($vo.username) and $vo.username eq $superName}
                 <span class="color-desc">超级用户不需要配置权限</span>
                 {elseif empty($authorizes)}
                 <span class="color-desc">未配置权限</span>

+ 2 - 0
config/app.php

@@ -19,6 +19,8 @@ return [
     'app_namespace'    => '',
     // 是否启用路由
     'with_route'       => true,
+    // 超级用户账号
+    'super_user'       => 'admin',
     // 应用快速访问
     'app_express'      => true,
     // 默认应用

+ 1 - 1
config/view.php

@@ -26,7 +26,7 @@ return [
     // 模板文件名分隔符
     'view_depr'          => DIRECTORY_SEPARATOR,
     // 去除HTML空格换行
-    'strip_space'        => true,
+    'strip_space'        => false,
     // 模板缓存配置
     'tpl_cache'          => !app()->isDebug(),
     // 模板引擎普通标签开始标记

+ 3 - 3
vendor/composer/InstalledVersions.php

@@ -32,7 +32,7 @@ private static $installed = array (
     'aliases' => 
     array (
     ),
-    'reference' => 'ba13afacdba9747fab47a87d5b67ec177dc398fa',
+    'reference' => '3cc374d1349454a0a8410869d7a9452461017e24',
     'name' => 'zoujingli/thinkadmin',
   ),
   'versions' => 
@@ -171,7 +171,7 @@ private static $installed = array (
       array (
         0 => '9999999-dev',
       ),
-      'reference' => '0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1',
+      'reference' => 'cdf95212d42ba02af227e02395259dc4bee9e610',
     ),
     'zoujingli/thinkadmin' => 
     array (
@@ -180,7 +180,7 @@ private static $installed = array (
       'aliases' => 
       array (
       ),
-      'reference' => 'ba13afacdba9747fab47a87d5b67ec177dc398fa',
+      'reference' => '3cc374d1349454a0a8410869d7a9452461017e24',
     ),
     'zoujingli/wechat-developer' => 
     array (

+ 12 - 4
vendor/composer/installed.json

@@ -849,12 +849,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/zoujingli/ThinkLibrary.git",
-                "reference": "0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1"
+                "reference": "cdf95212d42ba02af227e02395259dc4bee9e610"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1",
-                "reference": "0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1",
+                "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cdf95212d42ba02af227e02395259dc4bee9e610",
+                "reference": "cdf95212d42ba02af227e02395259dc4bee9e610",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -871,7 +871,8 @@
                 "ext-mbstring": "*",
                 "topthink/framework": "^6.0"
             },
-            "time": "2021-05-19T04:39:49+00:00",
+            "time": "2021-05-27T01:59:28+00:00",
+            "default-branch": true,
             "type": "library",
             "extra": {
                 "think": {
@@ -901,6 +902,13 @@
             ],
             "description": "ThinkPHP v6.0 Development Library",
             "homepage": "http://thinkadmin.top",
+            "support": {
+                "email": "zoujingli@qq.com",
+                "forum": "https://thinkadmin.top",
+                "issues": "https://gitee.com/zoujingli/ThinkLibrary/issues",
+                "source": "https://gitee.com/zoujingli/ThinkLibrary",
+                "wiki": "https://thinkadmin.top"
+            },
             "install-path": "../zoujingli/think-library"
         },
         {

+ 3 - 3
vendor/composer/installed.php

@@ -6,7 +6,7 @@
     'aliases' => 
     array (
     ),
-    'reference' => 'ba13afacdba9747fab47a87d5b67ec177dc398fa',
+    'reference' => '3cc374d1349454a0a8410869d7a9452461017e24',
     'name' => 'zoujingli/thinkadmin',
   ),
   'versions' => 
@@ -145,7 +145,7 @@
       array (
         0 => '9999999-dev',
       ),
-      'reference' => '0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1',
+      'reference' => 'cdf95212d42ba02af227e02395259dc4bee9e610',
     ),
     'zoujingli/thinkadmin' => 
     array (
@@ -154,7 +154,7 @@
       'aliases' => 
       array (
       ),
-      'reference' => 'ba13afacdba9747fab47a87d5b67ec177dc398fa',
+      'reference' => '3cc374d1349454a0a8410869d7a9452461017e24',
     ),
     'zoujingli/wechat-developer' => 
     array (

+ 1 - 1
vendor/services.php

@@ -1,5 +1,5 @@
 <?php 
-// This file is automatically generated at:2021-05-25 14:12:37
+// This file is automatically generated at:2021-05-27 10:10:34
 declare (strict_types = 1);
 return array (
   0 => 'think\\admin\\Library',

+ 0 - 1
vendor/zoujingli/think-library/src/Library.php

@@ -23,7 +23,6 @@ use think\admin\command\Replace;
 use think\admin\command\Version;
 use think\admin\multiple\BuildUrl;
 use think\admin\multiple\command\Build;
-use think\admin\multiple\command\Clear;
 use think\admin\multiple\Multiple;
 use think\admin\service\AdminService;
 use think\admin\service\SystemService;

+ 13 - 0
vendor/zoujingli/think-library/src/Queue.php

@@ -1,5 +1,18 @@
 <?php
 
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkLibrary
+// | github 代码仓库:https://github.com/zoujingli/ThinkLibrary
+// +----------------------------------------------------------------------
+
 declare (strict_types=1);
 
 namespace think\admin;

+ 1 - 1
vendor/zoujingli/think-library/src/service/AdminService.php

@@ -47,7 +47,7 @@ class AdminService extends Service
      */
     public function isSuper(): bool
     {
-        return $this->getUserName() === 'admin';
+        return $this->getUserName() === $this->app->config->get('app.super_user', 'admin');
     }
 
     /**