Jelajahi Sumber

文章静态化

huwhois 3 tahun lalu
induk
melakukan
dc2c77edb3

+ 13 - 2
app/common/model/Article.php

@@ -7,6 +7,7 @@ namespace app\common\model;
 use think\exception\HttpException;
 
 use app\common\model\Base;
+use think\facade\Config;
 
 class Article extends Base
 {
@@ -80,12 +81,22 @@ class Article extends Base
             $where[] = ['create_time','between', [$days['firstday'], $days['lastday']]];
         }
 
-        $limit = empty($params['limit']) ? 20 : (int)$params['limit'];
+        $limit = empty($params['limit']) ? Config::get('app.page_size', 20) : (int)$params['limit'];
+        
+        $order = ['id desc'];
+        if (!empty($params['order'])) {
+            if (is_array($params['order'])) {
+                $order = array_unique(array_merge($params['order']));
+            } else {
+                array_push($order, $params['order']);
+                $order = array_unique($order);
+            }
+        }
 
         $list = self::where($where)
             ->field('id,cid,title,titlepic,username,summary,content_type,hits,sort,status,create_time')
             ->with(['category'])
-            ->order('id desc')->paginate($limit, false, ['query' => $params]);
+            ->order($order)->paginate($limit, false, ['query' => $params]);
 
         return $list;
     }

+ 0 - 2
app/common/model/Category.php

@@ -24,8 +24,6 @@ class Category extends Base
         "update_time" => "int"
     ];
 
-    protected $disuse = [ 'route' ];
-
     // 获取列表
     public static function getList()
     {

+ 11 - 0
app/index/config/app.php

@@ -0,0 +1,11 @@
+<?php
+// +----------------------------------------------------------------------
+// | 应用设置
+// +----------------------------------------------------------------------
+
+return [
+    // html 静态化
+    'html'             =>  env('www.html',false),
+    // 默认分页显示数量
+    'page_size'        => env('www.page_size', 20),
+];

+ 21 - 0
app/index/config/route.php

@@ -0,0 +1,21 @@
+<?php
+// +----------------------------------------------------------------------
+// | 路由设置
+// +----------------------------------------------------------------------
+
+return [
+    // pathinfo分隔符
+    'pathinfo_depr'         => '/',
+    // URL伪静态后缀
+    'url_html_suffix'       => 'html',
+    // URL普通方式参数 用于自动生成
+    'url_common_param'      => true,
+    // 是否开启路由延迟解析
+    'url_lazy_route'        => false,
+    // 是否强制使用路由
+    'url_route_must'        => true,
+    // 合并路由规则
+    'route_rule_merge'      => false,
+    // 路由是否完全匹配
+    'route_complete_match'  => false,
+];

+ 61 - 22
app/index/controller/Article.php

@@ -1,5 +1,6 @@
 <?php
-declare (strict_types = 1);
+
+declare(strict_types=1);
 /**
  * +----------------------------------------------------------------------
  * 文章控制制器
@@ -26,12 +27,18 @@ class Article extends Base
     protected $modelName = "Article";
 
     public function index()
-    {   
+    {
         $params = $this->app->request->param();
 
         $list = ArticleModel::queryPage($params);
-        
-        $baseUrl = $this->request->baseUrl();
+
+        $category = CategoryModel::find($params['cid']);
+
+        if ($category) {
+            $baseUrl = $category->url;
+        } else {
+            $baseUrl = '/index/all';
+        }
 
         View::assign([
             'baseUrl'  => $baseUrl,
@@ -41,16 +48,21 @@ class Article extends Base
             'page' => $list->currentPage(),
             'lastPage' => $list->lastPage(),
             'pagelist' => $list->render(),
-            'cid' => $params['cid']
+            'cid' => $params['cid'],
         ]);
 
-        return View::fetch();
+        $html = View::fetch();
+        // if ($this->html) {
+        //     $this->makeHtmlFile($html);
+        // }
+
+        return $html;
     }
 
     /**
      * 阅读文章
      */
-    public function read($id=null)
+    public function read($id = null)
     {
         $data = ArticleModel::getOne($id);
 
@@ -64,7 +76,7 @@ class Article extends Base
 
         $prev_next = ArticleModel::getNextPrev($id, $data->cid);
 
-        if ($data->content_type==1) {
+        if ($data->content_type == 1) {
             $parsedownExtension = new \ParsedownExtension();
             // $parsedownExtension->setTocEnabled(true);
             $res = $parsedownExtension->text($data->content);
@@ -81,7 +93,12 @@ class Article extends Base
         $this->seo['des'] = $data->summary;
         View::assign('seo',  $this->seo);
 
-        return View::fetch();
+        $html = View::fetch();
+        if ($this->html) {
+            $this->makeHtmlFile($html);
+        }
+
+        return $html;
     }
 
     /**
@@ -96,7 +113,7 @@ class Article extends Base
         $log = ArticleDolikeLog::where('aid', $id)->where('ip', $ip)->find();
 
         if ($log) {
-            return ['code' => 1, 'msg'=>'多谢喜欢, 已经点过赞了'];
+            return ['code' => 1, 'msg' => '多谢喜欢, 已经点过赞了'];
         }
 
         $res = ArticleModel::where('id', $id)->inc('likes')->update();
@@ -107,8 +124,8 @@ class Article extends Base
             'ip' => $this->request->ip()
         ]);
 
-        if ($res===false) {
-            return ['code' => 2, 'msg'=>'未知错误'];
+        if ($res === false) {
+            return ['code' => 2, 'msg' => '未知错误'];
         } else {
             return ['code' => 0];
         }
@@ -117,7 +134,7 @@ class Article extends Base
     /**
      * 标签列表
      */
-    public function tags($name=null)
+    public function tags($name = null)
     {
         if (!$name) {
             throw new HttpException(404, '标签不可为空');
@@ -136,22 +153,32 @@ class Article extends Base
     /**
      * 归档页面(时间)
      */
-    public function archive($year=0, $month=0)
+    public function archive($year = 0, $month = 0)
     {
         $yearMonth = $year . '-' . $month;
 
-        if ($year==0 || $month==0) {
+        if ($year == 0 || $month == 0) {
             throw new HttpException(404, '日期格式不正确');
         }
 
-        $list = ArticleModel::queryPage(['yearMonth'=>$yearMonth]);
+        $list = ArticleModel::queryPage(['yearMonth' => $yearMonth]);
 
         View::assign([
-            'list' => $list,
+            'list' => $list->all(),
+            'total' => $list->total(),
+            'limit' => $list->listRows(),
+            'page' => $list->currentPage(),
+            'lastPage' => $list->lastPage(),
+            'pagelist' => $list->render(),
             'yearMonth'  => $yearMonth
         ]);
 
-        return View::fetch();
+        $html = View::fetch();
+        // if ($this->html) {
+        //     $this->makeHtmlFile($html);
+        // }
+
+        return $html;
     }
 
     /**
@@ -159,11 +186,23 @@ class Article extends Base
      */
     public function time()
     {
-        $list =ArticleModel::field('id,cid,title,titlepic,username,summary,hits,sort,status,create_time')->with(['category'])->order('update_time desc')->paginate();
+        $params = ['order' => 'update_time desc'];
+        $list = ArticleModel::queryPage($params);
+
+        View::assign([
+            'list' => $list->all(),
+            'total' => $list->total(),
+            'limit' => $list->listRows(),
+            'page' => $list->currentPage(),
+            'lastPage' => $list->lastPage(),
+            'pagelist' => $list->render(),
+        ]);
 
-        View::assign('list', $list);
+        $html = View::fetch();
+        if ($this->html) {
+            $this->makeHtmlFile($html);
+        }
 
-        return View::fetch();
+        return $html;
     }
-    
 }

+ 36 - 1
app/index/controller/Base.php

@@ -11,6 +11,7 @@ declare(strict_types=1);
 namespace app\index\controller;
 
 use think\facade\View;
+use think\facade\Config;
 use think\App;
 
 use app\common\model\Article;
@@ -36,6 +37,11 @@ abstract class Base
      */
     protected $seo = [];
 
+    /**
+     * makeHtmlFile
+     */
+    protected $html = false;
+
     /**
      * 构造方法
      * @access public
@@ -45,7 +51,7 @@ abstract class Base
     {
         $this->app     = $app;
         $this->request = $this->app->request;
-
+        $this->html    = Config::get('app.html', false);
         // 控制器初始化
         $this->initialize();
     }
@@ -97,4 +103,33 @@ abstract class Base
             'last_lists' => $last_lists,
         ]);
     }
+
+    protected  function makeHtmlFile($html)
+    {
+        $basepath = $this->app->getRootPath() . 'public';
+
+        $url = $this->request->baseUrl();
+
+        if (substr($url, -1) === '/') {
+            $url .= 'index.html';
+        }
+
+        if (empty(pathinfo($url, PATHINFO_EXTENSION))) {
+            $url .= '.html';
+        }
+        
+        $filename = $basepath . $url;
+        
+        $force = $this->request->has('force') ? (boolean) $this->request->param('force') : false;
+        
+        if (!file_exists($filename) || filectime($filename) <= time()-60*60*24*5 || $force == true) {
+            $dir = dirname($filename);
+            if (!file_exists($dir) ) {
+                mkdir($dir, 0755, true);
+                @file_put_contents($dir.'/index.html', "");  // 添加空html文件
+            }
+            
+            @file_put_contents($filename, $html);
+        }
+    }
 }

+ 14 - 3
app/index/controller/Index.php

@@ -14,6 +14,8 @@ use think\Request;
 use app\index\controller\Base;
 use app\common\model\Article;
 use app\common\model\GuestBook;
+use app\common\service\MakeHtmkFile;
+use think\facade\Config;
 
 class Index extends Base
 {
@@ -38,16 +40,25 @@ class Index extends Base
             'all_data' => $all_data,
         ]);
 
-        return View::fetch();
-    }
+        $html = View::fetch();
+        if ($this->html) {
+            $this->makeHtmlFile($html);
+        }
 
+        return $html;
+    }
 
     /**
      * 关于&留言
      */
     public function about()
     {
-        return View::fetch();
+        $html = View::fetch();
+        if ($this->html) {
+            $this->makeHtmlFile($html);
+        }
+
+        return $html;
     }
 
     public function guestBook()

+ 10 - 7
app/index/route/app.php

@@ -26,19 +26,22 @@ Route::get('think', function () {
     return 'hello,ThinkPHP6!';
 });
 
+Route::get('/index', 'index/index/index');
+Route::get('/', 'index/index/index');
 Route::view('/404', '404');
-Route::get('/all', 'index/article/index')->append(['cid' => 0]);
-Route::get('/:year/:month/:day/:id', 'index/article/read');
-Route::get('/:year/:month', 'index/article/archive');
-Route::post('/dolike', 'index/article/dolike');
-Route::get('/tags/:name', 'index/article/tags');
-Route::get('/time', 'index/article/time')->append(['_aside' => true]);
 Route::get('/about', 'index/index/about')->append(['_aside' => true]);
 
+Route::get('/tags/:name', 'index/article/tags');
+Route::get('/time-<page?>', 'index/article/time')->append(['_aside' => true]);
+Route::get('/all-<page?>', 'index/article/index')->append(['cid' => 0]);
+Route::post('/dolike', 'index/article/dolike');
+Route::get('/:year/<month>-<day>/:id', 'index/article/read');
+Route::get('/:year/<month>-<page?>', 'index/article/archive');
+
 $list = Category::getList();
 
 foreach ($list as $key => $value) {
     if ($value->template == 'article') {
-        Route::get('/'.$value->url, 'index/article/index')->append(['cid' => $value->id]);
+        Route::get($value->route . '-<page?>', 'index/article/index')->append(['cid' => $value->id]);
     }
 }

+ 1 - 1
app/sys/controller/Index.php

@@ -34,7 +34,7 @@ class Index  extends Base
             // 'messageCatUrl' => $messageCatUrl,
             'indexTips'     => $this->getIndexTips(),
         ]);
-        return View::fetch();
+        return View::fetch('index');
     }
 
     // 检查提示信息

+ 3 - 0
public/.gitignore

@@ -0,0 +1,3 @@
+# 静态文件
+/index
+index.html

+ 9 - 2
view/index/article/archive.html

@@ -6,10 +6,10 @@
   <div class="blogs">
     {foreach $list as $val}
     <div class="bloglist">
-      <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <h2><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
       <div class="bloginfo">
         <ul>
-          <li class="author"><a href="/index/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="author"><a href="{:url($val.category_url)}"> {$val.category_name} </a></li>
           <li class="timer">{$val.create_time}</li>
           <li class="view">{$val.hits} 已阅读</li>
           <li class="like">{$val.likes}</li>
@@ -18,6 +18,13 @@
       <p>{$val.summary}</p>
     </div>
     {/foreach}
+    <div class="pagelist">
+      {if $page > 1} <a href="/index/{:str_replace('-','/',$yearMonth)}-{$page-1}.html">«</a> {/if}
+      {for start="1" end="$lastPage+1"}
+      {if $page == $i} <b>{$i}</b>&nbsp; {else /} <a href="/index/{:str_replace('-','/',$yearMonth)}-{$i}.html">{$i}</a>&nbsp; {/if}
+      {/for}
+      {if $page < $lastPage} <a href="/index/{:str_replace('-','/',$yearMonth)}-{$page+1}.html">»</a> {/if}
+    </div>
   </div>
   {include file="aside"}
 </div>

+ 8 - 8
view/index/article/index.html

@@ -1,18 +1,18 @@
 <div class="box">
   <div class="place">
-    <a href="/index/all" class="{$cid==0 ? 'current_category': ''}">All</a>
+    <a href="/index/all.html" class="{$cid==0 ? 'current_category': ''}">All</a>
     {foreach $cate_lists as $value}
-    <a href="/index/{$value.url}" class="{$cid==$value.id ? 'current_category': ''}">{$value.name}</a>
+    <a href="{$value.url}.html" class="{$cid==$value.id ? 'current_category': ''}">{$value.name}</a>
     {/foreach}
   </div>
   <div class="blank"></div>
   <div class="blogs">
     {foreach $list as $val}
     <div class="bloglist">
-      <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <h2><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
       <div class="bloginfo">
         <ul>
-          <li class="author"><a href="/index/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="author"><a href="{$val.category_url}.html"> {$val.category_name} </a></li>
           <li class="timer">{$val.create_time}</li>
           <li class="view">{$val.hits} 已阅读</li>
           <li class="like">{$val.likes}</li>
@@ -28,12 +28,12 @@
       <a title="Total record">共&nbsp;<b>{$lastPage}</b>&nbsp;页</a>&nbsp;&nbsp;&nbsp;
       {neq name="page" value="1"}
       <a href="{$baseUrl}">首页</a>
-      <a href="{$baseUrl}?page={$page - 1}">上一页</a>&nbsp;
+      <a href="{$baseUrl}-{$page - 1}">上一页</a>&nbsp;
       {/neq}
       <b>{$page}</b>&nbsp;
       {if ( $lastPage != 0) && ( $lastPage != $page) }
-      <a href="{$baseUrl}?page={$page + 1}">下一页</a>&nbsp;
-      <a href="{$baseUrl}?page={$lastPage}">尾页</a>
+      <a href="{$baseUrl}-{$page + 1}">下一页</a>&nbsp;
+      <a href="{$baseUrl}-{$lastPage}">尾页</a>
       {/if}
       <input type="number" min="1" max="{$lastPage}" name="topage">
       <a href="javascript:goto()">转到</a>
@@ -45,6 +45,6 @@
 <script>
   function goto() {
     var page = $("input[name='topage']").val();
-    window.location.href = "{$baseUrl}?page=" + page;
+    window.location.href = "{$baseUrl}-" + page;
   }
 </script>

+ 1 - 1
view/index/article/tags.html

@@ -6,7 +6,7 @@
   <div class="blogs">
     {foreach $list as $val}
     <div class="bloglist">
-      <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <h2><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
       <div class="bloginfo">
         <ul>
           <li class="author"><a href="/index/{$val.category_url}"> {$val.category_name} </a></li>

+ 7 - 2
view/index/article/time.html

@@ -2,11 +2,16 @@
   <div class="timebox">
     <ul>
       {foreach $list as $val}
-      <li><span>{$val.create_time|date="Y-m-d"}</span><i><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></i></li>
+      <li><span>{$val.create_time|date="Y-m-d"}</span><i><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}"
+            title="{$val.title}">{$val.title}</a></i></li>
       {/foreach}
     </ul>
   </div>
   <div class="pagelist">
-    {$list->render()|raw}
+    {if $page > 1} <a href="/index/time-{$page-1}.html">«</a> {/if}
+    {for start="1" end="$lastPage+1"}
+    {if $page == $i} <b>{$i}</b>&nbsp; {else /} <a href="/index/time-{$i}.html">{$i}</a>&nbsp; {/if}
+    {/for}
+    {if $page < $lastPage} <a href="/index/time-{$page+1}.html">»</a> {/if}
   </div>
 </article>

+ 3 - 3
view/index/aside.html

@@ -8,7 +8,7 @@
     <h2>最近更新</h2>
     <ul>
       {foreach $last_lists as $value}
-      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
       {/foreach}
     </ul>
   </div>
@@ -16,7 +16,7 @@
     <h2>点击排行</h2>
     <ul>
       {foreach $hits_lists as $value}
-      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
       {/foreach}
     </ul>
   </div>
@@ -24,7 +24,7 @@
     <h2>博文推荐</h2>
     <ul>
       {foreach $top_lists as $value}
-      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
       {/foreach}
     </ul>
   </div>

+ 18 - 11
view/index/index/index.html

@@ -1,20 +1,19 @@
 <div class="box">
   <!-- PHP -->
   <div class="newsbox f_l ">
-    <div class="newstitle"><span><a href="/index/php">+</a></span><b>PHP</b></div>
+    <div class="newstitle"><span><a href="/index/php.html">+</a></span><b>PHP</b></div>
     <ul class="newsli">
       {foreach $php_data as $val}
-      <li><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
+      <li><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></li>
       {/foreach}
     </ul>
   </div>
   <!-- notes_data -->
   <div class="newsbox f_r ">
-    <div class="newstitle"><span><a href="/index/all">+</a></span><b>其他</b></div>
+    <div class="newstitle"><span><a href="/index/all.html">+</a></span><b>其他</b></div>
     <ul class="newsli">
       {foreach $other_data as $val}
-      <li><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
-
+      <li><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></li>
       {/foreach}
     </ul>
   </div>
@@ -22,7 +21,7 @@
   <!-- top -->
   {foreach $top_data as  $key=> $val}
   <div class="sbox  {switch name='key'}{case value='1'}f_l ml{/case}{case value='2'}f_r{/case}{default /}f_l{/switch}"> <span>{$val.category_name}</span>
-    <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+    <h2><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
     <p>{$val.summary}</p>
   </div>
   {/foreach}
@@ -31,10 +30,10 @@
   <div class="blogs">
     {foreach $all_data as $val}
     <div class="bloglist">
-      <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <h2><a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
       <div class="bloginfo">
         <ul>
-          <li class="author"><a href="/index/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="author"><a href="/{$val.category_url}.html"> {$val.category_name} </a></li>
           <li class="timer">{$val.create_time}</li>
           <li class="view">{$val.hits} 已阅读</li>
           <li class="like">{$val.likes}</li>
@@ -48,7 +47,7 @@
     <div class="ztbox">
       <ul>
         {foreach $cate_lists as $value}
-        <li><a href="/index/{$value.url}">{$value.name}</a></li>
+        <li><a href="{$value.url}.html">{$value.name}</a></li>
         {/foreach}
       </ul>
     </div>
@@ -56,7 +55,7 @@
       <h2>点击排行</h2>
       <ul>
         {foreach $hits_lists as $value}
-        <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+        <li><a href="/index/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
         {/foreach}
       </ul>
     </div>
@@ -64,7 +63,15 @@
       <h2>博文推荐</h2>
       <ul>
         {foreach $top_lists as $value}
-        <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+        <li><a href="/index/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
+        {/foreach}
+      </ul>
+    </div>
+    <div class="paihang">
+      <h2>归档</h2>
+      <ul>
+        {foreach $time_lists as $value}
+        <li><a href="/index/{:str_replace('-','/',$value)}" title="{$value}">{:str_replace('-','年',$value)}月</a></li>
         {/foreach}
       </ul>
     </div>

+ 2 - 2
view/index/layout.html

@@ -16,9 +16,9 @@
     <div class="logo"><a href="{:url('/index')}">huwhois个人博客</a></div>
     <nav>
       <ul id="starlist">
-        <li><a href="/index">网站首页</a></li>
+        <li><a href="{:url('/index')}">网站首页</a></li>
         {foreach $categories as $val}
-        <li><a href="/index/{$val.url}">{$val.name}</a></li>
+        <li><a href="{:url($val.url)}">{$val.name}</a></li>
         {/foreach}
       </ul>
     </nav>

+ 1 - 1
view/sys/article/index.html

@@ -56,7 +56,7 @@
                     </td>
                     <td>{$val.id}</td>
                     <td class="text-l">
-                        <a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" style="text-decoration:none" title="浏览"
+                        <a href="/index/{$val.create_time|date='Y/m-d'}/{$val.id}" style="text-decoration:none" title="浏览"
                             target="_blank">{$val.title}</a>
                     </td>
                     <td>{$val.category_name}</td>

+ 31 - 0
view/sys/index/index.html

@@ -179,6 +179,25 @@
                     <!-- /.card -->
                 </div>
             </div>
+            <div class="row">
+                <!--版本信息-->
+                <div class="col-12">
+                    <div class="card">
+                        <div class="card-header ui-sortable-handle">
+                            <h3 class="card-title"><i class="Hui-iconfont">&#xe6cd;</i>网页静态化</h3>
+                        </div>
+                        <!-- /.card-header -->
+                        <div class="card-body">
+                            <a class="btn btn-app" href="javascript:makeHtmlFile('index');">
+                                <i class="Hui-iconfont">&#xe681;</i>
+                                <span>刷新首页</span>
+                            </a>
+                        </div>
+                        <!-- /.card-body -->
+                    </div>
+                    <!-- /.card -->
+                </div>
+            </div>
         </div>
     </div>
 </article>
@@ -209,5 +228,17 @@
             }
         }, 'json');
     }
+
+    function makeHtmlFile(url) {
+        $.post('/sys/index/makehtmlfile',{'url': url}, function (res) {
+            console.log(res);
+            if (res.code == 0) {
+                layer.msg('清除成功', {
+                    icon: 1,
+                    time: 1000
+                });
+            }
+        }, 'json');
+    }
 </script>
 <!--请在上方写此页面业务相关的脚本-->