新增清除浏览器缓存功能

调整优化下拉菜单的字体大小和间距
pull/261/MERGE
Karson 2021-03-29 16:44:00 +08:00
parent dc691dbe84
commit 5ad3d5125a
9 changed files with 118 additions and 50 deletions

View File

@ -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");

View File

@ -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',
'<?php' . "\n\nreturn " . var_export_short($config) . ";\n"
);
}
/**
* 检测配置项是否存在
* @internal

View File

@ -35,9 +35,10 @@ return [
'Wipe cache failed' => '清除缓存失败',
'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' => '去下载更新',

View File

@ -39,6 +39,7 @@
<li><a href="javascript:;" data-type="content"><i class="fa fa-file-text fa-fw"></i> {:__('Wipe content cache')}</a></li>
<li><a href="javascript:;" data-type="template"><i class="fa fa-file-image-o fa-fw"></i> {:__('Wipe template cache')}</a></li>
<li><a href="javascript:;" data-type="addons"><i class="fa fa-rocket fa-fw"></i> {:__('Wipe addons cache')}</a></li>
<li><a href="javascript:;" data-type="browser"><i class="fa fa-chrome fa-fw"></i> {:__('Wipe browser cache')}</a></li>
</ul>
</li>

View File

@ -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',
'<?php' . "\n\nreturn " . var_export_short($config) . ";\n"
);
return true;
}
}

View File

@ -23,6 +23,10 @@ body {
body.is-dialog {
background: #fff;
}
.dropdown-menu > 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;

View File

@ -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;

View File

@ -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;
}
}
}
}

View File

@ -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;
}