From 0a8baab073204a8ffcea7826d9890e96ff6cff61 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 3 Aug 2020 18:05:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B3=BB=E7=BB=9F=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Module.php | 19 +++++++ app/admin/ver.php | 2 +- app/admin/view/module/change.html | 30 ++++++++++++ app/admin/view/module/index.html | 2 +- composer.lock | 8 +-- vendor/composer/installed.json | 8 +-- vendor/services.php | 2 +- .../src/service/ModuleService.php | 49 ++++++++++--------- 8 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 app/admin/view/module/change.html diff --git a/app/admin/controller/Module.php b/app/admin/controller/Module.php index 9fc2ef6b2..c403ed675 100644 --- a/app/admin/controller/Module.php +++ b/app/admin/controller/Module.php @@ -47,4 +47,23 @@ class Module extends Controller [$state, $message] = ModuleService::instance()->install($data['name']); $state ? $this->success($message) : $this->error($message); } + + /** + * 查看模块更新 + * @auth true + */ + public function change() + { + $data = $this->_vali(['name.require' => '模块名称不能为空!']); + $modules = ModuleService::instance()->online(); + if (isset($modules[$data['name']])) { + $this->module = $modules[$data['name']]; + foreach ($this->module['changes'] as $key => &$change) { + $change['datetime'] = preg_replace("|^(\d{4})\.(\d{2})\.(\d{2}).*?$|", '$1年$2月$3日', $key); + } + $this->fetch(); + } else { + $this->error('未查询到模块更新记录!'); + } + } } \ No newline at end of file diff --git a/app/admin/ver.php b/app/admin/ver.php index 962b7b90d..2be6eb31e 100644 --- a/app/admin/ver.php +++ b/app/admin/ver.php @@ -17,7 +17,7 @@ return [ 'name' => 'admin', 'author' => 'Anyon', - 'version' => '2020.08.03.00', + 'version' => '2020.08.01.00', 'content' => 'ThinkAdmin 系统基础模块', 'changes' => [ '2020.08.03.00' => [ diff --git a/app/admin/view/module/change.html b/app/admin/view/module/change.html new file mode 100644 index 000000000..2312c7369 --- /dev/null +++ b/app/admin/view/module/change.html @@ -0,0 +1,30 @@ +
+
+ + + + + + + + + + + + + +
模块名称{$module.name}
模块描述{$module.content}
最新版本{$module.version}
+
    + {foreach $module.changes as $key=>$vo} +
  • + +
    +

    {$vo.datetime|default=''}

    +

    模块版本:{$key|default=''}

    +

    更新描述:{$vo.content|default=''}

    +
    +
  • + {/foreach} +
+
+
\ No newline at end of file diff --git a/app/admin/view/module/index.html b/app/admin/view/module/index.html index 0130cd84f..d987247b4 100644 --- a/app/admin/view/module/index.html +++ b/app/admin/view/module/index.html @@ -22,7 +22,7 @@ {if isset($vo.local)} {$vo.local.version} {if $vo.version > $vo.local.version} - {$vo.local.version} + {$vo.version} {else} {$vo.type_desc} {/if} diff --git a/composer.lock b/composer.lock index 1d0ecc574..02ea75ba2 100644 --- a/composer.lock +++ b/composer.lock @@ -879,12 +879,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "0cf2b63422aff3efe9ad200b21af1ef88339726a" + "reference": "d799064954094a3ca5d548d2b6e1e575a4dbeac5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0cf2b63422aff3efe9ad200b21af1ef88339726a", - "reference": "0cf2b63422aff3efe9ad200b21af1ef88339726a", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/d799064954094a3ca5d548d2b6e1e575a4dbeac5", + "reference": "d799064954094a3ca5d548d2b6e1e575a4dbeac5", "shasum": "", "mirrors": [ { @@ -928,7 +928,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://thinkadmin.top", - "time": "2020-08-03T09:30:04+00:00" + "time": "2020-08-03T09:33:56+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9009bf0a3..fa427f55a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -903,12 +903,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "0cf2b63422aff3efe9ad200b21af1ef88339726a" + "reference": "d799064954094a3ca5d548d2b6e1e575a4dbeac5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0cf2b63422aff3efe9ad200b21af1ef88339726a", - "reference": "0cf2b63422aff3efe9ad200b21af1ef88339726a", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/d799064954094a3ca5d548d2b6e1e575a4dbeac5", + "reference": "d799064954094a3ca5d548d2b6e1e575a4dbeac5", "shasum": "", "mirrors": [ { @@ -924,7 +924,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-08-03T09:30:04+00:00", + "time": "2020-08-03T09:33:56+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 0f19fc41f..07e65285b 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/service/ModuleService.php b/vendor/zoujingli/think-library/src/service/ModuleService.php index 64f33d71d..def9c7de2 100644 --- a/vendor/zoujingli/think-library/src/service/ModuleService.php +++ b/vendor/zoujingli/think-library/src/service/ModuleService.php @@ -48,6 +48,25 @@ class ModuleService extends Service return $online; } + + /** + * 获取线上模块数据 + * @return array + */ + public function online(): array + { + $data = $this->app->cache->get('moduleOnlineData', []); + if (!empty($data)) return $data; + $server = InstallService::instance()->getServer(); + $result = json_decode(HttpExtend::get("{$server}/admin/api.update/version"), true); + if (isset($result['code']) && $result['code'] > 0 && isset($result['data']) && is_array($result['data'])) { + $this->app->cache->set('moduleOnlineData', $result['data'], 1800); + return $result['data']; + } else { + return []; + } + } + /** * 安装或更新模块 * @param string $name 模块名称 @@ -55,7 +74,7 @@ class ModuleService extends Service */ public function install($name): array { - $this->app->cache->set('module-online-data', []); + $this->app->cache->set('moduleOnlineData', []); $data = InstallService::instance()->grenerateDifference(["app/{$name}"]); if (empty($data)) { return [0, '没有需要安装的文件', []]; @@ -77,35 +96,17 @@ class ModuleService extends Service } } - /** - * 获取线上模块数据 - * @return array - */ - public function online(): array - { - $data = $this->app->cache->get('module-online-data', []); - if (!empty($data)) return $data; - $server = InstallService::instance()->getServer(); - $result = json_decode(HttpExtend::get("{$server}/admin/api.update/version"), true); - if (isset($result['code']) && $result['code'] > 0 && isset($result['data']) && is_array($result['data'])) { - $this->app->cache->set('module-online-data', $result['data'], 1800); - return $result['data']; - } else { - return []; - } - } - /** * 获取系统模块信息 + * @param array $data * @return array */ - public function getModules(): array + public function getModules(array $data = []): array { - $data = []; foreach (NodeService::instance()->getModules() as $name) { - if (is_array($ver = $this->getModuleVersion($name))) { - if (preg_match('|^\d{4}\.\d{2}\.\d{2}\.\d{2}$|', $ver['version'])) { - $data[$name] = $ver; + if (is_array($version = $this->getModuleVersion($name))) { + if (preg_match('|^\d{4}\.\d{2}\.\d{2}\.\d{2}$|', $version['version'])) { + $data[$name] = $version; } } }