ComposerUpdate

This commit is contained in:
Anyon 2020-10-22 14:44:34 +08:00
parent 210f962fc8
commit d34bf96378
4 changed files with 29 additions and 35 deletions

View File

@ -44,18 +44,16 @@ class Plugs extends Controller
*/ */
public function push() public function push()
{ {
try { if (AdminService::instance()->isSuper()) try {
if (AdminService::instance()->isSuper()) { AdminService::instance()->clearCache();
AdminService::instance()->clearCache(); SystemService::instance()->pushRuntime();
SystemService::instance()->pushRuntime(); $this->success('网站缓存加速成功!');
$this->success('网站缓存加速成功!');
} else {
$this->error('只有超级管理员才能操作!');
}
} catch (HttpResponseException $exception) { } catch (HttpResponseException $exception) {
throw $exception; throw $exception;
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->error($exception->getMessage()); $this->error($exception->getMessage());
} else {
$this->error('只有超级管理员才能操作!');
} }
} }
@ -65,18 +63,16 @@ class Plugs extends Controller
*/ */
public function clear() public function clear()
{ {
try { if (AdminService::instance()->isSuper()) try {
if (AdminService::instance()->isSuper()) { AdminService::instance()->clearCache();
AdminService::instance()->clearCache(); SystemService::instance()->clearRuntime();
SystemService::instance()->clearRuntime(); $this->success('清理网站缓存成功!');
$this->success('清理网站缓存成功!');
} else {
$this->error('只有超级管理员才能操作!');
}
} catch (HttpResponseException $exception) { } catch (HttpResponseException $exception) {
throw $exception; throw $exception;
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->error($exception->getMessage()); $this->error($exception->getMessage());
} else {
$this->error('只有超级管理员才能操作!');
} }
} }
@ -86,14 +82,12 @@ class Plugs extends Controller
*/ */
public function debug() public function debug()
{ {
if (AdminService::instance()->isSuper()) { if (AdminService::instance()->isSuper()) if (input('state')) {
if (input('state')) { SystemService::instance()->setRuntime([], 'product');
SystemService::instance()->productMode(true); $this->success('已切换为生产模式!');
$this->success('已切换为生产模式!'); } else {
} else { SystemService::instance()->setRuntime([], 'debug');
SystemService::instance()->productMode(false); $this->success('已切换为开发模式!');
$this->success('已切换为开发模式!');
}
} else { } else {
$this->error('只有超级管理员才能操作!'); $this->error('只有超级管理员才能操作!');
} }

View File

@ -893,12 +893,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "fffe4896577d523c165f3730d6112d4d0aff11d5" "reference": "ccf77d245ae379dca22241568abbb19c56676d65"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/fffe4896577d523c165f3730d6112d4d0aff11d5", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ccf77d245ae379dca22241568abbb19c56676d65",
"reference": "fffe4896577d523c165f3730d6112d4d0aff11d5", "reference": "ccf77d245ae379dca22241568abbb19c56676d65",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -915,7 +915,7 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-10-15T06:12:17+00:00", "time": "2020-10-22T06:22:40+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-10-21 17:44:27 // This file is automatically generated at:2020-10-22 14:44:09
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\admin\\Library', 0 => 'think\\admin\\Library',

View File

@ -249,7 +249,7 @@ class SystemService extends Service
* @param null|boolean $state * @param null|boolean $state
* @return boolean * @return boolean
*/ */
public function productMode($state = null): bool public function productMode(?bool $state = null): bool
{ {
if (is_null($state)) { if (is_null($state)) {
return $this->bindRuntime(); return $this->bindRuntime();
@ -264,7 +264,7 @@ class SystemService extends Service
* @param array $default 配置内容 * @param array $default 配置内容
* @return array|string * @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"; $filename = "{$this->app->getRootPath()}runtime/config.json";
if (file_exists($filename) && is_file($filename)) { if (file_exists($filename) && is_file($filename)) {
@ -280,11 +280,11 @@ class SystemService extends Service
/** /**
* 设置实时运行配置 * 设置实时运行配置
* @param null|array $map 应用映射 * @param null|array $map 应用映射
* @param null|string $run 支持模式 * @param null|mixed $run 支持模式
* @param null|array $uri 域名映射 * @param null|array $uri 域名映射
* @return boolean 是否调试模式 * @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 = $this->getRuntime();
$data['run'] = is_string($run) ? $run : $data['run']; $data['run'] = is_string($run) ? $run : $data['run'];
@ -326,8 +326,8 @@ class SystemService extends Service
*/ */
public function pushRuntime(): void public function pushRuntime(): void
{ {
$type = $this->app->db->getConfig('default'); $connection = $this->app->db->getConfig('default');
$this->app->console->call("optimize:schema", ["--connection={$type}"]); $this->app->console->call("optimize:schema", ["--connection={$connection}"]);
foreach (NodeService::instance()->getModules() as $module) { foreach (NodeService::instance()->getModules() as $module) {
$path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $module; $path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $module;
file_exists($path) && is_dir($path) or mkdir($path, 0755, true); file_exists($path) && is_dir($path) or mkdir($path, 0755, true);