调整后台模板功能

This commit is contained in:
Anyon 2020-12-16 14:34:45 +08:00
parent a45f89622c
commit c630fd4274
13 changed files with 116 additions and 102 deletions

View File

@ -98,49 +98,6 @@ class Queue extends Controller
}
}
/**
* WIN创建监听进程
* @auth true
*/
public function start()
{
try {
$message = nl2br($this->app->console->call('xadmin:queue', ['start'])->fetch());
if (stripos($message, 'daemons started successfully for pid')) {
$this->success('任务监听主进程启动成功!');
} elseif (stripos($message, 'daemons already exist for pid')) {
$this->success('任务监听主进程已经存在!');
} else {
$this->error($message);
}
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}
/**
* WIN停止监听进程
* @auth true
*/
public function stop()
{
try {
$message = nl2br($this->app->console->call('xadmin:queue', ['stop'])->fetch());
if (stripos($message, 'sent end signal to process')) {
$this->success('停止任务监听主进程成功!');
} elseif (stripos($message, 'processes to stop')) {
$this->success('没有找到需要停止的进程!');
} else {
$this->error($message);
}
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}
/**
* 创建记录清理任务

View File

@ -58,26 +58,6 @@ class Plugs extends Controller
}
}
/**
* 检查任务状态
* @login true
*/
public function queue()
{
if (AdminService::instance()->isSuper()) try {
$message = $this->app->console->call('xadmin:queue', ['status'])->fetch();
if (preg_match('/process.*?\d+.*?running/', $message, $attrs)) {
echo '<span class="color-green">' . $message . '</span>';
} else {
echo '<span class="color-red">' . $message . '</span>';
}
} catch (\Exception $exception) {
echo '<span class="color-red">' . $exception->getMessage() . '</span>';
} else {
echo '<span class="color-red">只有超级管理员才能操作!</span>';
}
}
/**
* 优化数据库
* @login true

View File

@ -16,7 +16,9 @@
namespace app\admin\controller\api;
use think\admin\Controller;
use think\admin\service\AdminService;
use think\admin\service\QueueService;
use think\exception\HttpResponseException;
/**
* 后台任务通用接口
@ -40,4 +42,67 @@ class Queue extends Controller
$this->success('获取任务进度成功!', $queue->progress());
}
/**
* WIN停止监听进程
* @login true
*/
public function stop()
{
try {
$message = nl2br($this->app->console->call('xadmin:queue', ['stop'])->fetch());
if (stripos($message, 'sent end signal to process')) {
$this->success('停止后台服务主进程成功!');
} elseif (stripos($message, 'processes to stop')) {
$this->success('没有找到需要停止的进程!');
} else {
$this->error($message);
}
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}
/**
* WIN创建监听进程
* @login true
*/
public function start()
{
try {
$message = nl2br($this->app->console->call('xadmin:queue', ['start'])->fetch());
if (stripos($message, 'daemons started successfully for pid')) {
$this->success('后台服务主进程启动成功!');
} elseif (stripos($message, 'daemons already exist for pid')) {
$this->success('后台服务主进程已经存在!');
} else {
$this->error($message);
}
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}
/**
* 检查任务状态
* @login true
*/
public function status()
{
if (AdminService::instance()->isSuper()) try {
$message = $this->app->console->call('xadmin:queue', ['status'])->fetch();
if (preg_match('/process.*?\d+.*?running/', $message, $attrs)) {
echo '<span class="color-green">' . $message . '</span>';
} else {
echo '<span class="color-red">' . $message . '</span>';
}
} catch (\Exception $exception) {
echo '<span class="color-red">' . $exception->getMessage() . '</span>';
} else {
echo '<span class="color-red">只有超级管理员才能操作!</span>';
}
}
}

View File

@ -9,7 +9,7 @@
</label>
<label class="layui-form-item relative block">
<span class="color-green font-w7">访问权限描述</span><span class="color-desc margin-left-5">PermissionDescription</span>
<span class="color-green font-w7">访问权限描述</span><span class="color-desc margin-left-5">Permission Remark</span>
<textarea placeholder="请输入访问权限描述" class="layui-textarea" name="desc">{$vo.desc|default=""}</textarea>
</label>

View File

@ -4,6 +4,7 @@
<!--{if auth("add")}-->
<button data-modal='{:url("add")}' data-title="添加权限" class='layui-btn layui-btn-sm layui-btn-primary'>添加权限</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除这些权限吗?" class='layui-btn layui-btn-sm layui-btn-primary'>删除权限</button>
<!--{/if}-->
@ -36,22 +37,22 @@
<td class='text-left'>{$vo.title|default='-'}</td>
<td class='text-left'>{$vo.desc|default="没有写描述哦!"}</td>
<td class="text-left nowrap">{$vo.create_at|format_datetime}</td>
<td class='text-center nowrap'>{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{else}<span class="color-green">已激活</span>{/eq}</td>
<td class='text-left nowrap'>{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{else}<span class="color-green">已激活</span>{/eq}</td>
<td class='text-center nowrap'>
<!--{if auth("edit")}-->
<a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑权限" data-modal='{:url("edit")}?id={$vo.id}'> </a>
<a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑权限" data-modal='{:url("edit")}?id={$vo.id}'> </a>
<!--{/if}-->
<!--{if auth("apply")}-->
<a class="layui-btn layui-btn-normal layui-btn-xs" data-open='{:url("apply")}?id={$vo.id}'> </a>
<a class="layui-btn layui-btn-normal layui-btn-sm" data-open='{:url("apply")}?id={$vo.id}'> </a>
<!--{/if}-->
<!--{if $vo.status eq 1 and auth("state")}-->
<a class="layui-btn layui-btn-warm layui-btn-xs" data-confirm="确定禁用该权限吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}"> </a>
<a class="layui-btn layui-btn-warm layui-btn-sm" data-confirm="确定禁用该权限吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}"> </a>
<!--{/if}-->
<!--{if $vo.status eq 0 and auth("state")}-->
<a class="layui-btn layui-btn-warm layui-btn-xs" data-confirm="确定启用该权限吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}"> </a>
<a class="layui-btn layui-btn-warm layui-btn-sm" data-confirm="确定启用该权限吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}"> </a>
<!--{/if}-->
<!--{if auth("remove")}-->
<a class="layui-btn layui-btn-danger layui-btn-xs" data-confirm="确定要删除权限吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}"> </a>
<a class="layui-btn layui-btn-danger layui-btn-sm" data-confirm="确定要删除权限吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}"> </a>
<!--{/if}-->
</td>
</tr>

View File

@ -2,7 +2,6 @@
{block name="button"}
<!--{if session('user.username') eq 'admin'}-->
<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-load="{:url('admin/api.plugs/clearConfig')}">清理无效配置</a>
<!--{/if}-->
<!--{if auth('system')}-->

View File

@ -1,5 +1,6 @@
<form onsubmit="return false" data-auto="true" action="{:request()->url()}" method="post" class='layui-form layui-card' autocomplete="off">
<div class="layui-card-body padding-left-40">
<div class="layui-form-item">
<span class="color-green font-w7 label-required-prev">后台登录入口</span>
<span class="color-desc margin-left-5">Login</span>
@ -9,6 +10,7 @@
</label>
<span class="help-block">名称由英文字母开头且不能存在相同名称的应用,设置之后原地址不能继续访问!</span>
</div>
<label class="layui-form-item relative block">
<span class="color-green font-w7">浏览器小图标</span>
<span class="color-desc margin-left-5">Icon</span>
@ -16,6 +18,7 @@
<a class="input-right-icon layui-icon layui-icon-upload-drag" style="top:25px" data-file="btn" data-type="ico,png" data-field="site_icon"></a>
<span class="help-block">建议上传 <span class="color-blue">128x128</span> ico png 图片,可以通过 <a href="http://www.favicon-icon-generator.com" target="_blank">ICON </a>在线制作 ico 文件!</span>
</label>
<div class="layui-form-item layui-row layui-col-space15">
<div class="layui-col-xs4 padding-bottom-0">
<label class="relative block">
@ -42,24 +45,28 @@
</label>
</div>
</div>
<label class="layui-form-item relative block">
<span class="color-green font-w7">公网安备号</span>
<span class="color-desc margin-left-5">Baian</span>
<input name="beian" placeholder="请输入公网安备号" value="{:sysconf('beian')}" class="layui-input">
<span class="help-block">公网安备号,可以在<a target="_blank" href="http://beian.miit.gov.cn">备案管理中心</a>查询获取,将在登录页面下面显示!</span>
</label>
<label class="layui-form-item relative block">
<span class="color-green font-w7">网站备案号</span>
<span class="color-desc margin-left-5">Miitbeian</span>
<input name="miitbeian" placeholder="请输入网站备案号" value="{:sysconf('miitbeian')}" class="layui-input">
<span class="help-block">网站备案号,可以在<a target="_blank" href="http://beian.miit.gov.cn">备案管理中心</a>查询获取,将在登录页面下面显示!</span>
</label>
<label class="layui-form-item relative block">
<span class="color-green font-w7">网站版权信息</span>
<span class="color-desc margin-left-5">Copyright</span>
<input name="site_copy" required placeholder="请输入版权信息" value="{:sysconf('site_copy')}" class="layui-input">
<span class="help-block">网站版权信息,在后台登录页面显示版本信息并链接到备案到信息备案管理系统!</span>
</label>
<div class="hr-line-dashed "></div>
<div class="layui-form-item text-center">
<button class="layui-btn" type="submit">保存配置</button>

View File

@ -4,6 +4,7 @@
<!--{if auth("add")}-->
<button data-modal='{:url("add")}' data-title="添加菜单" class='layui-btn layui-btn-sm layui-btn-primary'>添加菜单</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-csrf="{:systoken('remove')}" data-rule="id#{key}" class='layui-btn layui-btn-sm layui-btn-primary'>删除菜单</button>
<!--{/if}-->

View File

@ -2,10 +2,11 @@
{block name="button"}
<!--{if auth("clear")}-->
<button data-load='{:url("clear")}' data-confirm="确定要消除所有日志吗?" class='layui-btn layui-btn-sm layui-btn-primary'>清理日志</button>
<button data-load='{:url("clear")}' data-confirm="确定要清理所有记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>清理所有日志</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除日志吗?" class='layui-btn layui-btn-sm layui-btn-primary'>删除日志</button>
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除这些记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除日志</button>
<!--{/if}-->
{/block}
@ -55,7 +56,7 @@
</td>
<td class='text-left nowrap'>
<!--{if auth("remove")}-->
<a class="layui-btn layui-btn-xs layui-btn-danger" data-confirm="确定要删除该日志吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}"> </a>
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该日志吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}"> </a>
<!--{/if}-->
</td>
</tr>

View File

@ -1,17 +1,20 @@
{extend name='main'}
{block name="button"}
<!--{if auth("start") && $iswin}-->
<button data-load='{:url("start")}' class='layui-btn layui-btn-sm layui-btn-primary'>开始监听</button>
<!--{if session('user.username') eq 'admin'}-->
<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>
<button data-load='{:url("admin/api.queue/stop")}' class='layui-btn layui-btn-sm layui-btn-primary'>关闭后台服务</button>
<!--{/if}-->
<!--{if auth("stop") && $iswin}-->
<button data-load='{:url("stop")}' data-confirm="确定要停止主进程监听吗?" class='layui-btn layui-btn-sm layui-btn-primary'>停止监听</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{key}" data-confirm="确定批量删除任务吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
<!--{/if}-->
<!--{if auth("clear")}-->
<button data-load='{:url("clear")}' data-confirm="确定要创建定时清理任务吗?" class='layui-btn layui-btn-sm layui-btn-primary'>定时清理</button>
<button data-load='{:url("clear")}' data-confirm="确定要创建定时清理任务吗?" class='layui-btn layui-btn-sm layui-btn-primary'>定时维护清理</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{key}" data-confirm="确定批量删除记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除记录</button>
<!--{/if}-->
{/block}
@ -20,7 +23,7 @@
<div class="layui-row layui-col-space20 portal-block-container notselect">
<div class="layui-col-sm6 layui-col-md6 layui-col-lg3">
<div class="portal-block-item nowrap" style="background:linear-gradient(-125deg,#57bdbf,#2f9de2)">
<div>待处理</div>
<div>待处理</div>
<div>{$total.pre|default=0}</div>
<div>待处理的任务数量</div>
</div>
@ -28,7 +31,7 @@
</div>
<div class="layui-col-sm6 layui-col-md6 layui-col-lg3">
<div class="portal-block-item nowrap" style="background:linear-gradient(-125deg,#ff7d7d,#fb2c95)">
<div>处理</div>
<div>正在处理</div>
<div>{$total.dos|default=0}</div>
<div>处理中的任务数量</div>
</div>

View File

@ -1,13 +1,13 @@
{if session('user.username') eq 'admin'}
<fieldset class="margin-bottom-15">
<legend class="notselect">守护状态</legend>
<legend class="notselect">服务状态</legend>
<div class="layui-code border-0 margin-top-0">
<h4 class="color-desc margin-top-10 notselect">守护进程运行状态</h4>
<h4 class="color-desc margin-top-10 notselect">后台服务主进程运行状态</h4>
<div data-queue-message>Checking task process running status ...</div>
<h4 class="color-desc margin-top-10 notselect">配置定时任务来检查并启动进程(建议每分钟执行)</h4>
<p>{$command|default='--'}</p>
<div>{$command|default='--'}</div>
</div>
<script>$('[data-queue-message]').load('{:url("@admin/api.plugs/queue")}')</script>
<script>$('[data-queue-message]').load('{:url("@admin/api.queue/status")}')</script>
</fieldset>
{/if}

View File

@ -8,11 +8,11 @@
<div class="layui-col-xs5">
<label class="block relative">
<span class="color-green font-w7">登录账号</span>
<span class="color-desc margin-left-5">Username</span>
<span class="color-desc margin-left-5">User Name</span>
{if isset($vo) and isset($vo.username)}
<input disabled value='{$vo.username|default=""}' class="layui-input layui-bg-gray">
{else}
<input name="username" value='{$vo.username|default=""}' required pattern="^.{4,}$" placeholder="请输入登录用户账号" class="layui-input">
<input name="username" value='{$vo.username|default=""}' required pattern="^.{4,}$" placeholder="请输入登录账号" class="layui-input">
{/if}
<span class="help-block">登录账号不能重复,账号创建后不能再次修改</span>
</label>
@ -20,8 +20,8 @@
<div class="layui-col-xs5">
<label class="block relative">
<span class="color-green font-w7">用户昵称</span>
<span class="color-desc margin-left-5">Nickname</span>
<input name="nickname" value='{$vo.nickname|default=""}' required placeholder="请输入用户昵称" class="layui-input">
<span class="color-desc margin-left-5">Nick Name</span>
<input name="nickname" value='{$vo.nickname|default=""}' required placeholder="请输入用户昵称" class="layui-input">
<span class="help-block">用户显示的账号别名,请尽量保持不要重复</span>
</label>
</div>
@ -76,7 +76,7 @@
{/notempty}
<div class="hr-line-dashed margin-top-10 margin-bottom-10"></div>
<label class="layui-form-item block relative">
<span class="color-green font-w7">用户描述</span><span class="color-desc margin-left-5">Description</span>
<span class="color-green font-w7">用户描述</span><span class="color-desc margin-left-5">User Remark</span>
<textarea placeholder="请输入用户描述" class="layui-textarea" name="describe">{$vo.describe|default=""}</textarea>
</label>
<div class="hr-line-dashed"></div>

View File

@ -40,8 +40,8 @@
<th class='list-table-sort-td'>
<button type="button" data-reload class="layui-btn layui-btn-xs"> </button>
</th>
<th class='text-left nowrap' width="180px"></th>
<th class='text-left nowrap' width="150px"></th>
<th class='text-left nowrap'></th>
<th class='text-left nowrap'></th>
<th class='text-left nowrap'></th>
<th></th>
</tr>
@ -78,23 +78,23 @@
<td class='text-left nowrap'>
{if isset($type) and $type eq 'all'}
<!--{if auth("pass")}-->
<a class="layui-btn layui-btn-xs layui-btn-normal" data-title="设置密码" data-modal='{:url("pass")}?id={$vo.id}'> </a>
<a class="layui-btn layui-btn-sm layui-btn-normal" data-title="设置密码" data-modal='{:url("pass")}?id={$vo.id}'> </a>
<!--{/if}-->
<!--{if auth("edit")}-->
<a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'> </a>
<a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'> </a>
<!--{/if}-->
<!--{if auth("state") and $vo.status eq 1}-->
<a class="layui-btn layui-btn-xs layui-btn-warm" data-confirm="确定要禁用该禁用账号吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}"> </a>
<a class="layui-btn layui-btn-sm layui-btn-warm" data-confirm="确定要禁用该禁用账号吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}"> </a>
<!--{/if}-->
{else}
<!--{if auth("edit")}-->
<a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'> </a>
<a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'> </a>
<!--{/if}-->
<!--{if auth("state") and $vo.status eq 0}-->
<a class="layui-btn layui-btn-xs layui-btn-warm" data-confirm="确定要恢复该账号吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}"> </a>
<a class="layui-btn layui-btn-sm layui-btn-warm" data-confirm="确定要恢复该账号吗?" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}"> </a>
<!--{/if}-->
<!--{if auth("remove")}-->
<a class="layui-btn layui-btn-xs layui-btn-danger" data-confirm="确定要永久删除此账号吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}"> </a>
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要永久删除此账号吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}"> </a>
<!--{/if}-->
{/if}
</td>