mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate
This commit is contained in:
parent
9c9e1f69a4
commit
468f8bd0e2
12
vendor/composer/installed.json
vendored
12
vendor/composer/installed.json
vendored
@ -958,17 +958,17 @@
|
||||
},
|
||||
{
|
||||
"name": "zoujingli/think-library",
|
||||
"version": "v6.0.12",
|
||||
"version_normalized": "6.0.12.0",
|
||||
"version": "v6.0.13",
|
||||
"version_normalized": "6.0.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "a25e52f4f8af59ee55e33d00fff42ee919abba46"
|
||||
"reference": "4f492966b363a613ec7e89af47db0c59fe322350"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a25e52f4f8af59ee55e33d00fff42ee919abba46",
|
||||
"reference": "a25e52f4f8af59ee55e33d00fff42ee919abba46",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/4f492966b363a613ec7e89af47db0c59fe322350",
|
||||
"reference": "4f492966b363a613ec7e89af47db0c59fe322350",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -985,7 +985,7 @@
|
||||
"ext-mbstring": "*",
|
||||
"topthink/framework": "^6.0"
|
||||
},
|
||||
"time": "2020-09-24T02:44:19+00:00",
|
||||
"time": "2020-09-24T03:26:07+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
|
@ -41,7 +41,7 @@ class Library extends Service
|
||||
/**
|
||||
* 扩展库版本号
|
||||
*/
|
||||
const VERSION = '6.0.12';
|
||||
const VERSION = '6.0.13';
|
||||
|
||||
/**
|
||||
* 启动服务
|
||||
|
@ -64,7 +64,7 @@ class Database extends Command
|
||||
[$total, $used] = [count($tables = $this->getTables()), 0];
|
||||
$this->setQueueProgress("总共需要修复 {$total} 张数据表", 0);
|
||||
foreach ($tables as $table) {
|
||||
$stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}";
|
||||
$stridx = progress_prefix($total, ++$used);
|
||||
$this->setQueueProgress("[{$stridx}] 正在修复数据表 {$table}", $used / $total * 100);
|
||||
$this->app->db->query("REPAIR TABLE `{$table}`");
|
||||
}
|
||||
@ -83,7 +83,7 @@ class Database extends Command
|
||||
[$total, $used] = [count($tables = $this->getTables()), 0];
|
||||
$this->setQueueProgress("总共需要优化 {$total} 张数据表", 0);
|
||||
foreach ($tables as $table) {
|
||||
$stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}";
|
||||
$stridx = progress_prefix($total, ++$used);
|
||||
$this->setQueueProgress("[{$stridx}] 正在优化数据表 {$table}", $used / $total * 100);
|
||||
$this->app->db->query("OPTIMIZE TABLE `{$table}`");
|
||||
}
|
||||
|
@ -114,20 +114,26 @@ class Install extends Command
|
||||
}
|
||||
}
|
||||
|
||||
protected function installFile()
|
||||
private function installFile()
|
||||
{
|
||||
$data = ModuleService::instance()->grenerateDifference($this->rules, $this->ignore);
|
||||
if (empty($data)) $this->output->writeln('No need to update the file if the file comparison is consistent');
|
||||
else foreach ($data as $file) {
|
||||
[$state, $mode, $name] = ModuleService::instance()->updateFileByDownload($file);
|
||||
if ($state) {
|
||||
if ($mode === 'add') $this->output->writeln("--- {$name} add successfully");
|
||||
if ($mode === 'mod') $this->output->writeln("--- {$name} update successfully");
|
||||
if ($mode === 'del') $this->output->writeln("--- {$name} delete successfully");
|
||||
} else {
|
||||
if ($mode === 'add') $this->output->writeln("--- {$name} add failed");
|
||||
if ($mode === 'mod') $this->output->writeln("--- {$name} update failed");
|
||||
if ($mode === 'del') $this->output->writeln("--- {$name} delete failed");
|
||||
$module = ModuleService::instance();
|
||||
$data = $module->grenerateDifference($this->rules, $this->ignore);
|
||||
if (empty($data)) {
|
||||
$this->output->writeln('No need to update the file if the file comparison is consistent');
|
||||
} 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");
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,12 +189,12 @@ 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 = str_pad($timeout + $loops, strlen("{$total}"), 0, STR_PAD_LEFT);
|
||||
$prefix = progress_prefix($total, $timeout + $loops);
|
||||
if ($item['loops_time'] > 0) {
|
||||
$this->setQueueProgress("[{$prefix}/{$total}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total);
|
||||
$this->setQueueProgress("[{$prefix}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total);
|
||||
[$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!'];
|
||||
} else {
|
||||
$this->setQueueProgress("[{$prefix}/{$total}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total);
|
||||
$this->setQueueProgress("[{$prefix}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total);
|
||||
[$status, $message] = [4, '任务执行超时,已自动标识为失败!'];
|
||||
}
|
||||
$this->app->db->name($this->table)->where(['id' => $item['id']])->update(['status' => $status, 'exec_desc' => $message]);
|
||||
|
15
vendor/zoujingli/think-library/src/common.php
vendored
15
vendor/zoujingli/think-library/src/common.php
vendored
@ -141,6 +141,7 @@ if (!function_exists('sysoplog')) {
|
||||
return SystemService::instance()->setOplog($action, $content);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('encode')) {
|
||||
/**
|
||||
* 加密 UTF8 字符串
|
||||
@ -281,4 +282,18 @@ 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}";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user