修改后台超用户配置

This commit is contained in:
邹景立 2021-05-27 10:14:59 +08:00
parent 3cc374d134
commit d53fed33e1
17 changed files with 60 additions and 21 deletions

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{extend name="main"} {extend name="main"}
{block name="button"} {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> <a class="layui-btn layui-btn-sm layui-btn-primary" data-load="{:url('admin/api.runtime/config')}">清理无效配置</a>
<!--{/if}--> <!--{/if}-->

View File

@ -26,7 +26,7 @@
<dl class="layui-nav-child"> <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/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> <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/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> <dd lay-unselect><a data-load="{:url('admin/api.runtime/clear')}"><i class="layui-icon layui-icon-fonts-clear"></i> 清理缓存</a></dd>
{/if} {/if}

View File

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

View File

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

View File

@ -58,7 +58,7 @@
<span class="color-green font-w7">访问权限</span> <span class="color-green font-w7">访问权限</span>
<span class="color-desc margin-left-5">Authorize</span> <span class="color-desc margin-left-5">Authorize</span>
<div class="layui-textarea"> <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> <span class="color-desc">超级用户不需要配置权限</span>
{elseif empty($authorizes)} {elseif empty($authorizes)}
<span class="color-desc">未配置权限</span> <span class="color-desc">未配置权限</span>

View File

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

View File

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

View File

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

View File

@ -849,12 +849,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1" "reference": "cdf95212d42ba02af227e02395259dc4bee9e610"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cdf95212d42ba02af227e02395259dc4bee9e610",
"reference": "0c3fd320b8056d6a73d9b0db4ca8e97cf7bbf5e1", "reference": "cdf95212d42ba02af227e02395259dc4bee9e610",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -871,7 +871,8 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"topthink/framework": "^6.0" "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", "type": "library",
"extra": { "extra": {
"think": { "think": {
@ -901,6 +902,13 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://thinkadmin.top", "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" "install-path": "../zoujingli/think-library"
}, },
{ {

View File

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

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?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); declare (strict_types = 1);
return array ( return array (
0 => 'think\\admin\\Library', 0 => 'think\\admin\\Library',

View File

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

View File

@ -1,5 +1,18 @@
<?php <?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); declare (strict_types=1);
namespace think\admin; namespace think\admin;

View File

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