mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate 修改系统模块
This commit is contained in:
parent
76e78af89b
commit
dcb5cd69de
@ -16,7 +16,9 @@
|
|||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
use library\Controller;
|
use library\Controller;
|
||||||
|
use library\service\ProcessService;
|
||||||
use think\Console;
|
use think\Console;
|
||||||
|
use think\Db;
|
||||||
use think\exception\HttpResponseException;
|
use think\exception\HttpResponseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,13 +47,14 @@ class Queue extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
if (session('user.username') === 'admin') try {
|
if (session('user.username') === 'admin') try {
|
||||||
$this->cmd = 'php ' . env('root_path') . 'think xtask:start';
|
|
||||||
$this->message = Console::call('xtask:state')->fetch();
|
$this->message = Console::call('xtask:state')->fetch();
|
||||||
|
$this->command = ProcessService::instance()->think('xtask:start');
|
||||||
|
$this->listen = preg_match('/process.*?\d+.*?running/', $this->message, $attr);
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$this->message = $exception->getMessage();
|
$this->message = $exception->getMessage();
|
||||||
}
|
}
|
||||||
$this->title = '系统任务管理';
|
$this->title = '系统任务管理';
|
||||||
$this->iswin = PATH_SEPARATOR === ';';
|
$this->iswin = ProcessService::instance()->iswin();
|
||||||
$query = $this->_query($this->table)->dateBetween('create_at,start_at,end_at');
|
$query = $this->_query($this->table)->dateBetween('create_at,start_at,end_at');
|
||||||
$query->like('title,preload')->equal('status')->order('id desc')->page();
|
$query->like('title,preload')->equal('status')->order('id desc')->page();
|
||||||
}
|
}
|
||||||
@ -71,10 +74,15 @@ class Queue extends Controller
|
|||||||
* WIN开始监听任务
|
* WIN开始监听任务
|
||||||
* @auth true
|
* @auth true
|
||||||
*/
|
*/
|
||||||
public function processStart()
|
public function start()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->success(nl2br(Console::call('xtask:start')->fetch()));
|
$message = nl2br(Console::call('xtask:start')->fetch());
|
||||||
|
if (preg_match('/process.*?\d+/', $message, $attr)) {
|
||||||
|
$this->success('任务监听主进程启动成功!');
|
||||||
|
} else {
|
||||||
|
$this->error($message);
|
||||||
|
}
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -86,10 +94,17 @@ class Queue extends Controller
|
|||||||
* WIN停止监听任务
|
* WIN停止监听任务
|
||||||
* @auth true
|
* @auth true
|
||||||
*/
|
*/
|
||||||
public function processStop()
|
public function stop()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->success(nl2br(Console::call('xtask:stop')->fetch()));
|
$message = nl2br(Console::call('xtask:stop')->fetch());
|
||||||
|
if (stripos($message, 'succeeded')) {
|
||||||
|
$this->success('停止任务监听主进程成功!');
|
||||||
|
} elseif (stripos($message, 'finish')) {
|
||||||
|
$this->success('没有找到需要停止的进程!');
|
||||||
|
} else {
|
||||||
|
$this->error($message);
|
||||||
|
}
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -97,6 +112,23 @@ class Queue extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理3天前的记录
|
||||||
|
* @auth true
|
||||||
|
* @throws \think\Exception
|
||||||
|
* @throws \think\exception\PDOException
|
||||||
|
*/
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
$map = [['time', '<', strtotime('-3days')]];
|
||||||
|
$result = Db::name($this->table)->where($map)->delete();
|
||||||
|
if ($result !== false) {
|
||||||
|
$this->success('成功清理3天前的任务记录!');
|
||||||
|
} else {
|
||||||
|
$this->error('清理3天前的任务记录失败!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除系统任务
|
* 删除系统任务
|
||||||
* @auth true
|
* @auth true
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
{extend name="main"}
|
{extend name="main"}
|
||||||
|
|
||||||
{block name="content"}
|
{block name="button"}
|
||||||
|
|
||||||
{if auth('config')}
|
{if auth('config')}
|
||||||
<div class="think-box-shadow margin-bottom-15">
|
<a class="layui-btn layui-btn-sm layui-btn-primary" data-modal="{:url('config')}">修改系统配置</a>
|
||||||
<span class="color-green font-w7 text-middle">系统参数配置:</span>
|
|
||||||
<a class="layui-btn layui-btn-sm" data-modal="{:url('config')}">修改系统配置</a>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block name="content"}
|
||||||
|
|
||||||
<div class="think-box-shadow margin-bottom-15">
|
<div class="think-box-shadow margin-bottom-15">
|
||||||
<span class="color-green font-w7 text-middle">文件存储引擎:</span>
|
<span class="color-green font-w7 text-middle">文件存储引擎:</span>
|
||||||
{foreach ['local'=>'本地服务器存储','qiniu'=>'七牛云对象存储','oss'=>'阿里云OSS存储'] as $k=>$v}
|
{foreach ['local'=>'本地服务器存储','qiniu'=>'七牛云对象存储','oss'=>'阿里云OSS存储'] as $k=>$v}
|
||||||
|
@ -2,16 +2,20 @@
|
|||||||
|
|
||||||
{block name="button"}
|
{block name="button"}
|
||||||
|
|
||||||
|
{if auth("start") && $iswin}
|
||||||
|
<button data-load='{:url("start")}' 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")}
|
{if auth("remove")}
|
||||||
<button data-action='{:url("remove")}' data-confirm="确定要批量删除任务吗?" data-rule="id#{key}" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
|
<button data-action='{:url("remove")}' data-rule="id#{key}" data-confirm="确定批量删除任务吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if auth("processstart") && $iswin}
|
{if auth("clear")}
|
||||||
<button data-load='{:url("processstart")}' class='layui-btn layui-btn-sm layui-btn-primary'>开始监听</button>
|
<button data-load='{:url("clear")}' data-confirm="确定要清理3天前的任务记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>清理记录</button>
|
||||||
{/if}
|
|
||||||
|
|
||||||
{if auth("processstop") && $iswin}
|
|
||||||
<button data-load='{:url("processstop")}' class='layui-btn layui-btn-sm layui-btn-primary'>停止监听</button>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
@ -44,35 +48,40 @@
|
|||||||
<span class="color-desc">任务指令:{$vo.preload}</span>
|
<span class="color-desc">任务指令:{$vo.preload}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class='text-left nowrap'>
|
<td class='text-left nowrap'>
|
||||||
创建时间:{$vo.create_at|format_datetime} / {$vo.time|format_datetime}<br>
|
计划时间:{$vo.time|format_datetime} {if isset($vo.exec_pid) and $vo.exec_pid>0}( 进程 <b class="color-blue">{$vo.exec_pid|default='-'}</b> ){/if}<br>
|
||||||
执行时间:{$vo.start_at|format_datetime} / {$vo.end_at|format_datetime}
|
{if $vo.status eq 3 or $vo.status eq 4}
|
||||||
|
执行时间:{$vo.start_at|format_datetime}( 耗时 <b class="color-blue">{:sprintf("%.4f",strtotime($vo.end_at)-strtotime($vo.start_at))}</b> 秒 )
|
||||||
|
{elseif $vo.status eq 2} 开始时间:{$vo.start_at|format_datetime}
|
||||||
|
{else} 创建时间:{$vo.create_at|format_datetime} {/if}
|
||||||
</td>
|
</td>
|
||||||
<td class='text-left nowrap'>
|
<td class='text-left nowrap'>
|
||||||
任务状态:{eq name='vo.double' value='1'}
|
<div>
|
||||||
<span class="layui-badge layui-bg-green margin-right-5">复</span>
|
{eq name='vo.double' value='1'}
|
||||||
{else}
|
<span class="layui-badge layui-bg-green margin-right-5">复</span>
|
||||||
<span class="layui-badge layui-bg-blue margin-right-5">单</span>
|
{else}
|
||||||
{/eq}
|
<span class="layui-badge layui-bg-blue margin-right-5">单</span>
|
||||||
|
{/eq}
|
||||||
|
|
||||||
{eq name='vo.status' value='1'}
|
{eq name='vo.status' value='1'}
|
||||||
<span class="layui-badge layui-bg-black">待处理</span>
|
<span class="layui-badge layui-bg-black">待处理</span>
|
||||||
{elseif $vo.status eq 2}
|
{elseif $vo.status eq 2}
|
||||||
<span class="layui-badge layui-bg-green">处理中</span>
|
<span class="layui-badge layui-bg-green">处理中</span>
|
||||||
{elseif $vo.status eq 3}
|
{elseif $vo.status eq 3}
|
||||||
<span class="layui-badge layui-bg-blue">处理完成</span>
|
<span class="layui-badge layui-bg-blue">处理完成</span>
|
||||||
{elseif $vo.status eq 4}
|
{elseif $vo.status eq 4}
|
||||||
<span class="layui-badge layui-bg-red margin-right-5">处理失败</span>
|
<span class="layui-badge layui-bg-red margin-right-5">处理失败</span>
|
||||||
<a class="layui-badge layui-bg-green" data-tips-text="重置该任务" data-action="{:url('redo')}" data-value="id#{$vo.id}">
|
<a class="layui-badge layui-bg-green" data-tips-text="重置该任务" data-action="{:url('redo')}" data-value="id#{$vo.id}">
|
||||||
<i class="layui-icon font-s12"></i>
|
<i class="layui-icon font-s12"></i>
|
||||||
</a>
|
</a>
|
||||||
{/eq}
|
{/eq}
|
||||||
{if auth("admin/queue/remove") and in_array($vo.status,[1,3,4])}
|
|
||||||
<a data-action='{:url("remove")}' data-confirm="确定要删除该任务吗?" data-value="id#{$vo.id}" data-tips-text="删除该任务" class='layui-badge layui-bg-red margin-left-5'>
|
{if auth("admin/queue/remove") and in_array($vo.status,[1,3,4])}
|
||||||
<i class="layui-icon"></i>
|
<a data-action='{:url("remove")}' data-confirm="确定要删除该任务吗?" data-value="id#{$vo.id}" data-tips-text="删除该任务" class='layui-badge layui-bg-red margin-left-5'>
|
||||||
</a>
|
<i class="layui-icon"></i>
|
||||||
{/if}
|
</a>
|
||||||
<br>
|
{/if}
|
||||||
状态描述:<span class="color-desc">{$vo.desc|raw|default="没有获取到状态描述"}</span>
|
</div>
|
||||||
|
<div class="color-desc">{$vo.desc|raw|default="没有获取到状态描述"}</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
{if session('user.username') eq 'admin'}
|
{if session('user.username') eq 'admin'}
|
||||||
<fieldset class="margin-bottom-10">
|
<fieldset class="margin-bottom-15">
|
||||||
<legend>进程守护</legend>
|
<legend class="notselect">守护状态</legend>
|
||||||
<div class="layui-code border-0 margin-top-0">
|
<div class="layui-code border-0 margin-top-0">
|
||||||
<p class="color-desc margin-top-10">当前消息队列守护进程运行状态</p>
|
<h4 class="color-desc margin-top-10 notselect">守护进程运行状态</h4>
|
||||||
{$message|raw|default='--'}
|
{if $listen}
|
||||||
<p class="color-desc margin-top-10">配置定时任务来检查并启动进程(建议每分钟执行)</p>
|
<span class="color-green">{$message|raw|default='--'}</span>
|
||||||
{$cmd|default='--'}
|
{else}
|
||||||
|
<span class="color-red">{$message|raw|default='--'}</span>
|
||||||
|
{/if}
|
||||||
|
<h4 class="color-desc margin-top-10 notselect">配置定时任务来检查并启动进程(建议每分钟执行)</h4>
|
||||||
|
<p>{$command|default='--'}</p>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>条件搜索</legend>
|
<legend>条件搜索</legend>
|
||||||
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
|
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
|
||||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -401,12 +401,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "bc77d2ff2e4ff7fb18a3a5bb6436633fe3f6b4ad"
|
"reference": "25ebb45be8d3c08c8abecd4620dbd857bdaf6f05"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/bc77d2ff2e4ff7fb18a3a5bb6436633fe3f6b4ad",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/25ebb45be8d3c08c8abecd4620dbd857bdaf6f05",
|
||||||
"reference": "bc77d2ff2e4ff7fb18a3a5bb6436633fe3f6b4ad",
|
"reference": "25ebb45be8d3c08c8abecd4620dbd857bdaf6f05",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -426,7 +426,7 @@
|
|||||||
"qiniu/php-sdk": "^7.2",
|
"qiniu/php-sdk": "^7.2",
|
||||||
"topthink/framework": "5.1.*"
|
"topthink/framework": "5.1.*"
|
||||||
},
|
},
|
||||||
"time": "2020-01-07T02:14:58+00:00",
|
"time": "2020-01-08T02:36:12+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -82,7 +82,7 @@ class Sync extends Command
|
|||||||
return $this->tree([
|
return $this->tree([
|
||||||
'think', 'config/log.php', 'config/cookie.php', 'config/template.php',
|
'think', 'config/log.php', 'config/cookie.php', 'config/template.php',
|
||||||
'application/admin', 'application/wechat', 'application/service',
|
'application/admin', 'application/wechat', 'application/service',
|
||||||
'public/static/plugs', 'public/static/theme', 'public/static/admin.js',
|
'public/static/plugs', 'public/static/theme', 'public/static/admin.js', 'public/static/login.js',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,22 +39,30 @@ class ValidateHelper extends Helper
|
|||||||
list($name, $alias) = explode('#', $name);
|
list($name, $alias) = explode('#', $name);
|
||||||
}
|
}
|
||||||
if (stripos($name, '.') === false) {
|
if (stripos($name, '.') === false) {
|
||||||
$data[$name] = empty($alias) ? $name : $alias;
|
if (is_numeric($name)) {
|
||||||
|
$keys = $message;
|
||||||
|
if (is_string($message) && stripos($message, '#') !== false) {
|
||||||
|
list($name, $alias) = explode('#', $message);
|
||||||
|
$keys = empty($alias) ? $name : $alias;
|
||||||
|
}
|
||||||
|
$data[$name] = input("{$type}{$keys}");
|
||||||
|
} else {
|
||||||
|
$data[$name] = $message;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
list($_rgx) = explode(':', $name);
|
list($_rgx) = explode(':', $name);
|
||||||
list($_key, $_rule) = explode('.', $name);
|
list($_key, $_rule) = explode('.', $name);
|
||||||
|
$keys = empty($alias) ? $_key : $alias;
|
||||||
$info[$_rgx] = $message;
|
$info[$_rgx] = $message;
|
||||||
$data[$_key] = empty($alias) ? $_key : $alias;
|
$data[$_key] = input("{$type}{$keys}");
|
||||||
$rule[$_key] = empty($rule[$_key]) ? $_rule : "{$rule[$_key]}|{$_rule}";
|
$rule[$_key] = empty($rule[$_key]) ? $_rule : "{$rule[$_key]}|{$_rule}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($data as $key => $name) $data[$key] = input("{$type}{$name}");
|
$validate = new Validate();
|
||||||
$validate = Validate::make($rule, $info);
|
if ($validate->rule($rule)->message($info)->check($data)) {
|
||||||
if ($validate->check($data)) {
|
|
||||||
return $data;
|
return $data;
|
||||||
} else {
|
} else {
|
||||||
$this->controller->error($validate->getError());
|
$this->controller->error($validate->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user