From 5ad3d5125a118ede50521022302e300c9ea7c912 Mon Sep 17 00:00:00 2001 From: Karson Date: Mon, 29 Mar 2021 16:44:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=85=E9=99=A4=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BC=98=E5=8C=96=E4=B8=8B=E6=8B=89=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E5=92=8C?= =?UTF-8?q?=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 71 +++++++++++++------ .../admin/controller/general/Config.php | 28 +------- application/admin/lang/zh-cn/index.php | 3 +- application/admin/view/common/header.html | 1 + application/common/model/Config.php | 28 ++++++++ public/assets/css/backend.css | 10 +++ public/assets/css/frontend.css | 4 +- public/assets/less/backend.less | 15 ++++ public/assets/less/frontend.less | 8 ++- 9 files changed, 118 insertions(+), 50 deletions(-) diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index dd58cf11..7a3d6e77 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -112,7 +112,6 @@ class Ajax extends Backend $this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); } - } /** @@ -187,25 +186,57 @@ class Ajax extends Backend */ public function wipecache() { - $type = $this->request->request("type"); - switch ($type) { - case 'all': - case 'content': - rmdirs(CACHE_PATH, false); - Cache::clear(); - if ($type == 'content') { - break; - } - case 'template': - rmdirs(TEMP_PATH, false); - if ($type == 'template') { - break; - } - case 'addons': - Service::refresh(); - if ($type == 'addons') { - break; - } + try { + $type = $this->request->request("type"); + switch ($type) { + case 'all': + // no break + case 'content': + //内容缓存 + rmdirs(CACHE_PATH, false); + Cache::clear(); + if ($type == 'content') { + break; + } + case 'template': + // 模板缓存 + rmdirs(TEMP_PATH, false); + if ($type == 'template') { + break; + } + case 'addons': + // 插件缓存 + Service::refresh(); + if ($type == 'addons') { + break; + } + case 'browser': + // 浏览器缓存 + // 只有生产环境下才修改 + if (1 || !config('app_debug')) { + $version = config('site.name'); + $version = '1.0.1'; + $newversion = preg_replace_callback("/(.*)\.([0-9]+)\$/", function ($match) { + return $match[1] . '.' . ($match[2] + 1); + }, $version); + if ($newversion && $newversion != $version) { + Db::startTrans(); + try { + \app\common\model\Config::where('name', 'version')->update(['value' => $newversion]); + \app\common\model\Config::refreshFile(); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + exception($e->getMessage()); + } + } + } + if ($type == 'browser') { + break; + } + } + } catch (\Exception $e) { + $this->error($e->getMessage()); } \think\Hook::listen("wipecache_after"); diff --git a/application/admin/controller/general/Config.php b/application/admin/controller/general/Config.php index 8fd89441..f4b93e2a 100644 --- a/application/admin/controller/general/Config.php +++ b/application/admin/controller/general/Config.php @@ -99,7 +99,7 @@ class Config extends Backend } if ($result !== false) { try { - $this->refreshFile(); + ConfigModel::refreshFile(); } catch (Exception $e) { $this->error($e->getMessage()); } @@ -142,7 +142,7 @@ class Config extends Backend $this->error($e->getMessage()); } try { - $this->refreshFile(); + ConfigModel::refreshFile(); } catch (Exception $e) { $this->error($e->getMessage()); } @@ -163,7 +163,7 @@ class Config extends Backend if ($name && $config) { try { $config->delete(); - $this->refreshFile(); + ConfigModel::refreshFile(); } catch (Exception $e) { $this->error($e->getMessage()); } @@ -173,28 +173,6 @@ class Config extends Backend } } - /** - * 刷新配置文件 - */ - protected function refreshFile() - { - $config = []; - foreach ($this->model->all() as $k => $v) { - $value = $v->toArray(); - if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) { - $value['value'] = explode(',', $value['value']); - } - if ($value['type'] == 'array') { - $value['value'] = (array)json_decode($value['value'], true); - } - $config[$value['name']] = $value['value']; - } - file_put_contents( - CONF_PATH . 'extra' . DS . 'site.php', - ' '清除缓存失败', 'Wipe cache' => '清空缓存', 'Wipe all cache' => '一键清除缓存', - 'Wipe content cache' => '清空内容缓存', + 'Wipe content cache' => '清除内容缓存', 'Wipe template cache' => '清除模板缓存', 'Wipe addons cache' => '清除插件缓存', + 'Wipe browser cache' => '清除浏览器缓存', 'Check for updates' => '检测更新', 'Discover new version' => '发现新版本', 'Go to download' => '去下载更新', diff --git a/application/admin/view/common/header.html b/application/admin/view/common/header.html index a0ca7d66..aa3b3e33 100755 --- a/application/admin/view/common/header.html +++ b/application/admin/view/common/header.html @@ -39,6 +39,7 @@
  • {:__('Wipe content cache')}
  • {:__('Wipe template cache')}
  • {:__('Wipe addons cache')}
  • +
  • {:__('Wipe browser cache')}
  • diff --git a/application/common/model/Config.php b/application/common/model/Config.php index e53ba701..050a6ad7 100644 --- a/application/common/model/Config.php +++ b/application/common/model/Config.php @@ -191,4 +191,32 @@ class Config extends Model return $upload; } + /** + * 刷新配置文件 + */ + public static function refreshFile() + { + //如果没有配置权限无法进行修改 + if (!\app\admin\library\Auth::instance()->check('general/config/edit')) { + return false; + } + $config = []; + $configList = self::all(); + foreach ($configList as $k => $v) { + $value = $v->toArray(); + if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) { + $value['value'] = explode(',', $value['value']); + } + if ($value['type'] == 'array') { + $value['value'] = (array)json_decode($value['value'], true); + } + $config[$value['name']] = $value['value']; + } + file_put_contents( + CONF_PATH . 'extra' . DS . 'site.php', + ' li > a { + font-size: 13px; + padding: 5px 12px; +} .selection { position: absolute; border: 1px solid #8B9; @@ -31,6 +35,12 @@ body.is-dialog { .main-header .navbar { position: relative; } +.main-header .navbar .dropdown-menu { + font-size: 13px; +} +.main-header .navbar .dropdown-menu > li > a { + padding: 5px 20px; +} .bootstrap-dialog .modal-dialog { /*width: 70%;*/ max-width: 885px; diff --git a/public/assets/css/frontend.css b/public/assets/css/frontend.css index 43c2d554..c6f42f0c 100644 --- a/public/assets/css/frontend.css +++ b/public/assets/css/frontend.css @@ -30,9 +30,9 @@ body { .navbar-nav > li > a { font-size: 14px; } -.navbar-nav ul.dropdown-menu > li > a { - padding: 5px 20px; +.dropdown-menu > li > a { font-size: 13px; + padding: 5px 20px; } .toast-top-center { top: 50px; diff --git a/public/assets/less/backend.less b/public/assets/less/backend.less index 073536f3..48835a22 100644 --- a/public/assets/less/backend.less +++ b/public/assets/less/backend.less @@ -36,6 +36,13 @@ body.is-dialog { background: #fff; } +.dropdown-menu { + > li > a { + font-size: 13px; + padding: 5px 12px; + } +} + .selection { position: absolute; border: 1px solid #8B9; @@ -46,6 +53,14 @@ body.is-dialog { .navbar { position: relative; + + .dropdown-menu { + font-size: 13px; + + > li > a { + padding: 5px 20px; + } + } } } diff --git a/public/assets/less/frontend.less b/public/assets/less/frontend.less index f9c23fff..b28c3239 100644 --- a/public/assets/less/frontend.less +++ b/public/assets/less/frontend.less @@ -49,11 +49,15 @@ body { > li > a { font-size:14px; } - ul.dropdown-menu > li > a { - padding: 5px 20px; +} + +.dropdown-menu { + > li > a { font-size: 13px; + padding: 5px 20px; } } + .toast-top-center{ top:50px; }