diff --git a/app/admin/controller/Oplog.php b/app/admin/controller/Oplog.php
index 449139df3..b2729e318 100644
--- a/app/admin/controller/Oplog.php
+++ b/app/admin/controller/Oplog.php
@@ -63,6 +63,30 @@ class Oplog extends Controller
}
}
+ /**
+ * 日志行为配置
+ * @auth true
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\DbException
+ * @throws \think\db\exception\ModelNotFoundException
+ */
+ public function config()
+ {
+ if ($this->request->isGet()) {
+ $this->fetch();
+ } else {
+ $data = $this->_vali([
+ 'oplog_state.in:0,1' => '日志状态值异常!',
+ 'oplog_state.require' => '日志状态不能为空!',
+ 'oplog_days.require' => '保存天数不能为空!',
+ ]);
+ foreach ($data as $name => $value) {
+ sysconf($name, $value);
+ }
+ $this->success('日志配置成功!');
+ }
+ }
+
/**
* 清理系统日志
* @auth true
diff --git a/app/admin/controller/api/Plugs.php b/app/admin/controller/api/Plugs.php
index 2561a2c38..65cd0894f 100644
--- a/app/admin/controller/api/Plugs.php
+++ b/app/admin/controller/api/Plugs.php
@@ -78,27 +78,6 @@ class Plugs extends Controller
}
}
- /**
- * 数据变更日志
- * @login true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function oplog()
- {
- if (AdminService::instance()->isSuper()) {
- $data = $this->_vali([
- 'state.in:0,1' => '状态值范围错误!',
- 'state.require' => '状态值不能为空!',
- ]);
- sysconf('base.oplog_state', $data['state']);
- $this->success('数据变更日志切换成功!');
- } else {
- $this->error('只有超级管理员才能操作!');
- }
- }
-
/**
* 当前运行模式
* @login true
diff --git a/app/admin/sys.php b/app/admin/sys.php
index d45642956..4a1aa5412 100644
--- a/app/admin/sys.php
+++ b/app/admin/sys.php
@@ -21,7 +21,7 @@ try {
/*! 全局数据变更数据 */
$GLOBALS['oplogs'] = [];
/*! 数据变更日志开关状态 */
- if (sysconf('base.oplog_state')) {
+ if (sysconf('base.oplog_state') && ($days = floatval(sysoplog('base.oplog_days'))) > 0) {
/*! 数据变更批量写入 */
app()->event->listen('HttpEnd', function () {
if (is_array($GLOBALS['oplogs']) && count($GLOBALS['oplogs']) > 0) {
@@ -30,7 +30,7 @@ try {
}
$GLOBALS['oplogs'] = [];
if (rand(1, 100) <= 10) { /*! 清理一周前的日志记录 */
- $lastdate = date('Y-m-d H:i:s', strtotime('-7days'));
+ $lastdate = date('Y-m-d H:i:s', strtotime("-{$days}days"));
app()->db->name('SystemOplog')->where('create_at', '<', $lastdate)->delete();
}
}
diff --git a/app/admin/view/oplog/config.html b/app/admin/view/oplog/config.html
new file mode 100644
index 000000000..71db94de9
--- /dev/null
+++ b/app/admin/view/oplog/config.html
@@ -0,0 +1,29 @@
+
\ No newline at end of file
diff --git a/app/admin/view/oplog/index.html b/app/admin/view/oplog/index.html
index e66c2bceb..7c453a05e 100644
--- a/app/admin/view/oplog/index.html
+++ b/app/admin/view/oplog/index.html
@@ -1,19 +1,8 @@
{extend name='main'}
{block name="button"}
-
-
-
-
-
-
-
-
-
+
+日志配置
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 7fec3f8a1..58373baaa 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInit7ad2dfd941224dedfd9e69a3187017d8::getLoader();
+return ComposerAutoloaderInitc847eb2c7a922ed862fa0bfb18edd00b::getLoader();
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 5f5859490..80caa7bf9 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInit7ad2dfd941224dedfd9e69a3187017d8
+class ComposerAutoloaderInitc847eb2c7a922ed862fa0bfb18edd00b
{
private static $loader;
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit7ad2dfd941224dedfd9e69a3187017d8
return self::$loader;
}
- spl_autoload_register(array('ComposerAutoloaderInit7ad2dfd941224dedfd9e69a3187017d8', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInitc847eb2c7a922ed862fa0bfb18edd00b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
- spl_autoload_unregister(array('ComposerAutoloaderInit7ad2dfd941224dedfd9e69a3187017d8', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInitc847eb2c7a922ed862fa0bfb18edd00b', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
- call_user_func(\Composer\Autoload\ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8::getInitializer($loader));
+ call_user_func(\Composer\Autoload\ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@@ -51,19 +51,19 @@ class ComposerAutoloaderInit7ad2dfd941224dedfd9e69a3187017d8
$loader->register(true);
if ($useStaticLoader) {
- $includeFiles = Composer\Autoload\ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8::$files;
+ $includeFiles = Composer\Autoload\ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
- composerRequire7ad2dfd941224dedfd9e69a3187017d8($fileIdentifier, $file);
+ composerRequirec847eb2c7a922ed862fa0bfb18edd00b($fileIdentifier, $file);
}
return $loader;
}
}
-function composerRequire7ad2dfd941224dedfd9e69a3187017d8($fileIdentifier, $file)
+function composerRequirec847eb2c7a922ed862fa0bfb18edd00b($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index f7e64da2c..aeb3657e5 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
namespace Composer\Autoload;
-class ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8
+class ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b
{
public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@@ -669,10 +669,10 @@ class ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
- $loader->prefixLengthsPsr4 = ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8::$prefixLengthsPsr4;
- $loader->prefixDirsPsr4 = ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8::$prefixDirsPsr4;
- $loader->fallbackDirsPsr0 = ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8::$fallbackDirsPsr0;
- $loader->classMap = ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8::$classMap;
+ $loader->prefixLengthsPsr4 = ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b::$prefixDirsPsr4;
+ $loader->fallbackDirsPsr0 = ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b::$fallbackDirsPsr0;
+ $loader->classMap = ComposerStaticInitc847eb2c7a922ed862fa0bfb18edd00b::$classMap;
}, null, ClassLoader::class);
}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 3aedd9e13..88e670528 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -958,17 +958,17 @@
},
{
"name": "zoujingli/think-library",
- "version": "v6.0.13",
- "version_normalized": "6.0.13.0",
+ "version": "v6.0.14",
+ "version_normalized": "6.0.14.0",
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
- "reference": "4f492966b363a613ec7e89af47db0c59fe322350"
+ "reference": "fd4e99d0ed04c87778cc47a3ca911cd1ef84a38b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/4f492966b363a613ec7e89af47db0c59fe322350",
- "reference": "4f492966b363a613ec7e89af47db0c59fe322350",
+ "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/fd4e99d0ed04c87778cc47a3ca911cd1ef84a38b",
+ "reference": "fd4e99d0ed04c87778cc47a3ca911cd1ef84a38b",
"shasum": "",
"mirrors": [
{
@@ -985,7 +985,7 @@
"ext-mbstring": "*",
"topthink/framework": "^6.0"
},
- "time": "2020-09-24T03:26:07+00:00",
+ "time": "2020-09-24T08:15:19+00:00",
"type": "library",
"extra": {
"think": {
diff --git a/vendor/services.php b/vendor/services.php
index fc70f4370..3c73cb82a 100644
--- a/vendor/services.php
+++ b/vendor/services.php
@@ -1,5 +1,5 @@
'think\\admin\\Library',
diff --git a/vendor/zoujingli/think-library/src/Library.php b/vendor/zoujingli/think-library/src/Library.php
index e17f349bc..dfc48c420 100644
--- a/vendor/zoujingli/think-library/src/Library.php
+++ b/vendor/zoujingli/think-library/src/Library.php
@@ -41,7 +41,7 @@ class Library extends Service
/**
* 扩展库版本号
*/
- const VERSION = '6.0.13';
+ const VERSION = '6.0.14';
/**
* 启动服务
diff --git a/vendor/zoujingli/think-library/src/command/Database.php b/vendor/zoujingli/think-library/src/command/Database.php
index b0a95fcb8..662ce6128 100644
--- a/vendor/zoujingli/think-library/src/command/Database.php
+++ b/vendor/zoujingli/think-library/src/command/Database.php
@@ -64,8 +64,7 @@ class Database extends Command
[$total, $used] = [count($tables = $this->getTables()), 0];
$this->setQueueProgress("总共需要修复 {$total} 张数据表", 0);
foreach ($tables as $table) {
- $stridx = progress_prefix($total, ++$used);
- $this->setQueueProgress("[{$stridx}] 正在修复数据表 {$table}", $used / $total * 100);
+ $this->queue->message($total, ++$used, "正在修复数据表 {$table}");
$this->app->db->query("REPAIR TABLE `{$table}`");
}
}
@@ -83,8 +82,7 @@ class Database extends Command
[$total, $used] = [count($tables = $this->getTables()), 0];
$this->setQueueProgress("总共需要优化 {$total} 张数据表", 0);
foreach ($tables as $table) {
- $stridx = progress_prefix($total, ++$used);
- $this->setQueueProgress("[{$stridx}] 正在优化数据表 {$table}", $used / $total * 100);
+ $this->queue->message($total, ++$used, "正在优化数据表 {$table}");
$this->app->db->query("OPTIMIZE TABLE `{$table}`");
}
}
diff --git a/vendor/zoujingli/think-library/src/command/Install.php b/vendor/zoujingli/think-library/src/command/Install.php
index 9f5d5e83e..ddf0b583a 100644
--- a/vendor/zoujingli/think-library/src/command/Install.php
+++ b/vendor/zoujingli/think-library/src/command/Install.php
@@ -123,16 +123,15 @@ class Install extends Command
} else {
[$total, $used] = [count($data), 0];
foreach ($data as $file) {
- $prefix = progress_prefix($total, ++$used);
[$state, $mode, $name] = $module->updateFileByDownload($file);
if ($state) {
- if ($mode === 'add') $this->output->writeln("[{$prefix}] --- {$name} add successfully");
- if ($mode === 'mod') $this->output->writeln("[{$prefix}] --- {$name} update successfully");
- if ($mode === 'del') $this->output->writeln("[{$prefix}] --- {$name} delete successfully");
+ if ($mode === 'add') $this->queue->message($total, ++$used, "--- {$name} add successfully");
+ if ($mode === 'mod') $this->queue->message($total, ++$used, "--- {$name} update successfully");
+ if ($mode === 'del') $this->queue->message($total, ++$used, "--- {$name} delete successfully");
} else {
- if ($mode === 'add') $this->output->writeln("[{$prefix}] --- {$name} add failed");
- if ($mode === 'mod') $this->output->writeln("[{$prefix}] --- {$name} update failed");
- if ($mode === 'del') $this->output->writeln("[{$prefix}] --- {$name} delete failed");
+ if ($mode === 'add') $this->queue->message($total, ++$used, "--- {$name} add failed");
+ if ($mode === 'mod') $this->queue->message($total, ++$used, "--- {$name} update failed");
+ if ($mode === 'del') $this->queue->message($total, ++$used, "--- {$name} delete failed");
}
}
}
diff --git a/vendor/zoujingli/think-library/src/command/Queue.php b/vendor/zoujingli/think-library/src/command/Queue.php
index 0f1e3f99f..a16d88ece 100644
--- a/vendor/zoujingli/think-library/src/command/Queue.php
+++ b/vendor/zoujingli/think-library/src/command/Queue.php
@@ -51,12 +51,12 @@ class Queue extends Command
public function configure()
{
$this->setName('xadmin:queue');
- $this->addArgument('action', Argument::OPTIONAL, 'stop|start|status|query|listen|clean|dorun|webstop|webstart|webstatus', 'listen');
- $this->addArgument('code', Argument::OPTIONAL, 'Taskcode');
- $this->addArgument('spts', Argument::OPTIONAL, 'Separator');
$this->addOption('host', '-H', Option::VALUE_OPTIONAL, 'The host of WebServer.');
$this->addOption('port', '-p', Option::VALUE_OPTIONAL, 'The port of WebServer.');
$this->addOption('daemon', 'd', Option::VALUE_NONE, 'Run the queue listen in daemon mode');
+ $this->addArgument('action', Argument::OPTIONAL, 'stop|start|status|query|listen|clean|dorun|webstop|webstart|webstatus', 'listen');
+ $this->addArgument('code', Argument::OPTIONAL, 'Taskcode');
+ $this->addArgument('spts', Argument::OPTIONAL, 'Separator');
$this->setDescription('Asynchronous Command Queue Task for ThinkAdmin');
}
@@ -189,12 +189,11 @@ class Queue extends Command
$this->app->db->name($this->table)->whereOr([$map1, $map2])->chunk(100, function (Collection $result) use ($total, &$loops, &$timeout) {
foreach ($result->toArray() as $item) {
$item['loops_time'] > 0 ? $loops++ : $timeout++;
- $prefix = progress_prefix($total, $timeout + $loops);
if ($item['loops_time'] > 0) {
- $this->setQueueProgress("[{$prefix}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total);
+ $this->queue->message($total, $timeout + $loops, "正在重置任务 {$item['code']} 为运行");
[$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!'];
} else {
- $this->setQueueProgress("[{$prefix}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total);
+ $this->queue->message($total, $timeout + $loops, "正在标记任务 {$item['code']} 为超时");
[$status, $message] = [4, '任务执行超时,已自动标识为失败!'];
}
$this->app->db->name($this->table)->where(['id' => $item['id']])->update(['status' => $status, 'exec_desc' => $message]);
diff --git a/vendor/zoujingli/think-library/src/common.php b/vendor/zoujingli/think-library/src/common.php
index c393f3a99..bc6b4eb97 100644
--- a/vendor/zoujingli/think-library/src/common.php
+++ b/vendor/zoujingli/think-library/src/common.php
@@ -282,18 +282,4 @@ if (!function_exists('down_file')) {
$result = Storage::down($source, $force, $expire);
return $result['url'] ?? $source;
}
-}
-
-if (!function_exists('progress_prefix')) {
- /**
- * 生成进度前缀文字
- * @param integer $total
- * @param integer $used
- * @param string $char
- * @return string
- */
- function progress_prefix(int $total, int $used, string $char = '0'): string
- {
- return str_pad("{$used}", strlen("{$total}"), $char, STR_PAD_LEFT) . "/{$total}";
- }
}
\ No newline at end of file
diff --git a/vendor/zoujingli/think-library/src/service/QueueService.php b/vendor/zoujingli/think-library/src/service/QueueService.php
index ce70ee00e..3bac028a3 100644
--- a/vendor/zoujingli/think-library/src/service/QueueService.php
+++ b/vendor/zoujingli/think-library/src/service/QueueService.php
@@ -194,6 +194,24 @@ class QueueService extends Service
return $data;
}
+ /**
+ * 生成进度前缀数据
+ * @param integer $total 记录总和
+ * @param integer $used 当前记录
+ * @param string $message 文字描述
+ */
+ public function message(int $total, int $used, string $message = ''): void
+ {
+ $total = $total < 1 ? 1 : $total;
+ $prefix = str_pad("{$used}", strlen("{$total}"), '0', STR_PAD_LEFT);
+ $message = "[{$prefix}/{$total}] {$message}";
+ if (defined('WorkQueueCode')) {
+ $this->progress(2, $message, sprintf("%.2f", $used / $total * 100));
+ } else {
+ echo $message . PHP_EOL;
+ }
+ }
+
/**
* 执行任务处理
* @param array $data 任务参数