From d34bf96378247b0ad0461d0badc9f4b73b95c2f5 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 22 Oct 2020 14:44:34 +0800 Subject: [PATCH] ComposerUpdate --- app/admin/controller/api/Plugs.php | 42 ++++++++----------- vendor/composer/installed.json | 8 ++-- vendor/services.php | 2 +- .../src/service/SystemService.php | 12 +++--- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/app/admin/controller/api/Plugs.php b/app/admin/controller/api/Plugs.php index 23502da44..0006c0f5a 100644 --- a/app/admin/controller/api/Plugs.php +++ b/app/admin/controller/api/Plugs.php @@ -44,18 +44,16 @@ class Plugs extends Controller */ public function push() { - try { - if (AdminService::instance()->isSuper()) { - AdminService::instance()->clearCache(); - SystemService::instance()->pushRuntime(); - $this->success('网站缓存加速成功!'); - } else { - $this->error('只有超级管理员才能操作!'); - } + if (AdminService::instance()->isSuper()) try { + AdminService::instance()->clearCache(); + SystemService::instance()->pushRuntime(); + $this->success('网站缓存加速成功!'); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); + } else { + $this->error('只有超级管理员才能操作!'); } } @@ -65,18 +63,16 @@ class Plugs extends Controller */ public function clear() { - try { - if (AdminService::instance()->isSuper()) { - AdminService::instance()->clearCache(); - SystemService::instance()->clearRuntime(); - $this->success('清理网站缓存成功!'); - } else { - $this->error('只有超级管理员才能操作!'); - } + if (AdminService::instance()->isSuper()) try { + AdminService::instance()->clearCache(); + SystemService::instance()->clearRuntime(); + $this->success('清理网站缓存成功!'); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); + } else { + $this->error('只有超级管理员才能操作!'); } } @@ -86,14 +82,12 @@ class Plugs extends Controller */ public function debug() { - if (AdminService::instance()->isSuper()) { - if (input('state')) { - SystemService::instance()->productMode(true); - $this->success('已切换为生产模式!'); - } else { - SystemService::instance()->productMode(false); - $this->success('已切换为开发模式!'); - } + if (AdminService::instance()->isSuper()) if (input('state')) { + SystemService::instance()->setRuntime([], 'product'); + $this->success('已切换为生产模式!'); + } else { + SystemService::instance()->setRuntime([], 'debug'); + $this->success('已切换为开发模式!'); } else { $this->error('只有超级管理员才能操作!'); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 5d4e90090..b769c69be 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -893,12 +893,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "fffe4896577d523c165f3730d6112d4d0aff11d5" + "reference": "ccf77d245ae379dca22241568abbb19c56676d65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/fffe4896577d523c165f3730d6112d4d0aff11d5", - "reference": "fffe4896577d523c165f3730d6112d4d0aff11d5", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ccf77d245ae379dca22241568abbb19c56676d65", + "reference": "ccf77d245ae379dca22241568abbb19c56676d65", "shasum": "", "mirrors": [ { @@ -915,7 +915,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-10-15T06:12:17+00:00", + "time": "2020-10-22T06:22:40+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index a4454d1bf..5f03e9957 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/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index 637c55248..2f2e88ebf 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -249,7 +249,7 @@ class SystemService extends Service * @param null|boolean $state * @return boolean */ - public function productMode($state = null): bool + public function productMode(?bool $state = null): bool { if (is_null($state)) { return $this->bindRuntime(); @@ -264,7 +264,7 @@ class SystemService extends Service * @param array $default 配置内容 * @return array|string */ - public function getRuntime($name = null, array $default = []) + public function getRuntime(?string $name = null, array $default = []) { $filename = "{$this->app->getRootPath()}runtime/config.json"; if (file_exists($filename) && is_file($filename)) { @@ -280,11 +280,11 @@ class SystemService extends Service /** * 设置实时运行配置 * @param null|array $map 应用映射 - * @param null|string $run 支持模式 + * @param null|mixed $run 支持模式 * @param null|array $uri 域名映射 * @return boolean 是否调试模式 */ - public function setRuntime(array $map = [], $run = null, array $uri = []): bool + public function setRuntime(?array $map = [], ?string $run = null, ?array $uri = []): bool { $data = $this->getRuntime(); $data['run'] = is_string($run) ? $run : $data['run']; @@ -326,8 +326,8 @@ class SystemService extends Service */ public function pushRuntime(): void { - $type = $this->app->db->getConfig('default'); - $this->app->console->call("optimize:schema", ["--connection={$type}"]); + $connection = $this->app->db->getConfig('default'); + $this->app->console->call("optimize:schema", ["--connection={$connection}"]); foreach (NodeService::instance()->getModules() as $module) { $path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $module; file_exists($path) && is_dir($path) or mkdir($path, 0755, true);