瀏覽代碼

ComposerUpdate

Anyon 4 年之前
父節點
當前提交
d34bf96378

+ 18 - 24
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('只有超级管理员才能操作!');
         }

+ 4 - 4
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": {

+ 1 - 1
vendor/services.php

@@ -1,5 +1,5 @@
 <?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);
 return array (
   0 => 'think\\admin\\Library',

+ 6 - 6
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);