瀏覽代碼

增加网站缓存处理

Anyon 5 年之前
父節點
當前提交
4b5c6d3316
共有 3 個文件被更改,包括 40 次插入2 次删除
  1. 34 0
      app/admin/controller/Index.php
  2. 6 0
      app/admin/view/index/index.html
  3. 0 2
      public/static/admin.js

+ 34 - 0
app/admin/controller/Index.php

@@ -18,6 +18,7 @@ namespace app\admin\controller;
 use think\admin\Controller;
 use think\admin\service\AdminService;
 use think\admin\service\MenuService;
+use think\exception\HttpResponseException;
 
 /**
  * 后台界面入口
@@ -110,4 +111,37 @@ class Index extends Controller
         }
     }
 
+    /**
+     * 网站压缩发布
+     * @login true
+     */
+    public function optimize()
+    {
+        try {
+            $this->app->console->call('optimize:route');
+            $this->app->console->call('optimize:schema');
+            $this->success('网站压缩加速成功!');
+        } catch (HttpResponseException $exception) {
+            throw $exception;
+        } catch (\Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
+     * 清理运行缓存
+     * @login true
+     */
+    public function clear()
+    {
+        try {
+            $this->app->console->call('clear');
+            $this->success('清理网站缓存成功!');
+        } catch (HttpResponseException $exception) {
+            throw $exception;
+        } catch (\Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
 }

+ 6 - 0
app/admin/view/index/index.html

@@ -59,6 +59,12 @@
                         </a>
                     </dd>
                     <dd lay-unselect>
+                        <a data-modal="{:url('admin/index/optimize')}"><i class="layui-icon layui-icon-template-1 margin-right-5"></i>缓存加速</a>
+                    </dd>
+                    <dd lay-unselect>
+                        <a data-modal="{:url('admin/index/clear')}"><i class="layui-icon layui-icon-fonts-clear margin-right-5"></i>清理缓存</a>
+                    </dd>
+                    <dd lay-unselect>
                         <a data-load="{:url('admin/login/out')}" data-confirm="确定要退出登录吗?">
                             <i class="layui-icon layui-icon-release margin-right-5"></i> 退出登录
                         </a>

+ 0 - 2
public/static/admin.js

@@ -746,8 +746,6 @@ $(function () {
         this.value = (parseFloat(this.value) || 0).toFixed(fiexd);
     });
 
-   
-
     /*! 图片加载异常处理 */
     document.addEventListener('error', function (e, elem) {
         elem = e.target;