fix: 修复session、模板页脚页头初始化
This commit is contained in:
@@ -17,6 +17,7 @@ use app\common\library\Email;
|
|||||||
use app\common\library\Ftp;
|
use app\common\library\Ftp;
|
||||||
use think\cache\driver\Memcached;
|
use think\cache\driver\Memcached;
|
||||||
use think\cache\driver\Redis;
|
use think\cache\driver\Redis;
|
||||||
|
use think\facade\Cache;
|
||||||
use Webman\Event\Event;
|
use Webman\Event\Event;
|
||||||
use app\common\model\system\Attachment;
|
use app\common\model\system\Attachment;
|
||||||
use app\common\model\system\Config;
|
use app\common\model\system\Config;
|
||||||
@@ -279,6 +280,7 @@ class Index extends AdminController
|
|||||||
$config[$key] = $option;
|
$config[$key] = $option;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(new Config())->saveAll($config);
|
(new Config())->saveAll($config);
|
||||||
$env = base_path() . '/.env';
|
$env = base_path() . '/.env';
|
||||||
@@ -293,6 +295,12 @@ class Index extends AdminController
|
|||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
return $this->error($th->getMessage());
|
return $this->error($th->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清理系统缓存
|
||||||
|
$configList = Cache::get('config_list');
|
||||||
|
foreach ($configList as $item) {
|
||||||
|
Cache::delete($item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->success('保存成功!');
|
return $this->success('保存成功!');
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ use app\common\model\system\AdminAccess as AdminAccessModel;
|
|||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
use think\db\exception\ModelNotFoundException;
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
use think\facade\Cache;
|
||||||
use Webman\Http\Request;
|
use Webman\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -541,7 +542,6 @@ class Admin extends AdminController
|
|||||||
/**
|
/**
|
||||||
* 清理系统缓存
|
* 清理系统缓存
|
||||||
* @return \support\Response
|
* @return \support\Response
|
||||||
* @throws \think\Exception
|
|
||||||
*/
|
*/
|
||||||
public function clear(): \support\Response
|
public function clear(): \support\Response
|
||||||
{
|
{
|
||||||
@@ -553,7 +553,9 @@ class Admin extends AdminController
|
|||||||
|
|
||||||
// 清理内容
|
// 清理内容
|
||||||
if ($type == 'all' || $type == 'content') {
|
if ($type == 'all' || $type == 'content') {
|
||||||
|
$session = session(AdminSession);
|
||||||
\think\facade\Cache::clear();
|
\think\facade\Cache::clear();
|
||||||
|
request()->session()->set(AdminSession, $session);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理模板
|
// 清理模板
|
||||||
|
|||||||
@@ -17,6 +17,15 @@
|
|||||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
</head>
|
</head>
|
||||||
|
<style>
|
||||||
|
.lay-fix-top {
|
||||||
|
top: 0!important;
|
||||||
|
margin-top:0!important;
|
||||||
|
}
|
||||||
|
.lay-fix-bottom {
|
||||||
|
bottom: 0!important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
var _global_ = {
|
var _global_ = {
|
||||||
app: "{$app|default='admin.php'}",
|
app: "{$app|default='admin.php'}",
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ declare(strict_types=1);
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace app\common\library;
|
namespace app\common\library;
|
||||||
|
|
||||||
|
use Psr\SimpleCache\InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局模型数据处理类
|
* 全局模型数据处理类
|
||||||
* 1、自动设置字段属性
|
* 1、自动设置字段属性
|
||||||
@@ -162,14 +164,13 @@ class ParseData
|
|||||||
* @param string $image 图片地址
|
* @param string $image 图片地址
|
||||||
* @param bool $bool 链接OR替换
|
* @param bool $bool 链接OR替换
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
*/
|
*/
|
||||||
protected static function changeImages(string $image, bool $bool = true): string
|
protected static function changeImages(string $image, bool $bool = true): string
|
||||||
{
|
{
|
||||||
$prefix = cdn_Prefix();
|
$prefix = cdn_Prefix();
|
||||||
|
var_dump($prefix);
|
||||||
if (!empty($prefix) && $image) {
|
if (!empty($prefix) && $image) {
|
||||||
// 过滤base64
|
if (!strpos($image, 'data:image')) {
|
||||||
if (!stristr($image, 'data:image')) {
|
|
||||||
return $bool ? $prefix . $image : str_replace($prefix, '', $image);
|
return $bool ? $prefix . $image : str_replace($prefix, '', $image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -574,32 +574,25 @@ if (!function_exists('saenv')) {
|
|||||||
* @param bool $group
|
* @param bool $group
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
function saenv(string $name, bool $group = false)
|
function saenv(string $name, bool $group = false)
|
||||||
{
|
{
|
||||||
|
$redis = 'config_' . $name;
|
||||||
$redis = 'sys_' . $name;
|
|
||||||
try {
|
|
||||||
|
|
||||||
$config = Cache::get($redis);
|
$config = Cache::get($redis);
|
||||||
if (empty($config) || getenv('APP_DEBUG')) {
|
$configList = Cache::get('config_list') ?? [];
|
||||||
$config = Config::all($name, $group);
|
if (empty($config)) {
|
||||||
|
$config = $group ? Config::all($name, true) : Config::where('name', $name)->value('value');
|
||||||
|
if (!empty($config)) {
|
||||||
|
$configList[$name] = $redis;
|
||||||
Cache::set($redis, $config);
|
Cache::set($redis, $config);
|
||||||
}
|
Cache::set('config_list', $configList);
|
||||||
} catch (\Throwable $th) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 优先返回组配置
|
|
||||||
if (!empty($group)) {
|
|
||||||
return $config;
|
|
||||||
} else {
|
|
||||||
if (isset($config[$name]) && $config[$name]) {
|
|
||||||
return $config[$name];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $config ?: false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ use function root_path;
|
|||||||
|
|
||||||
class IndexInitialize implements MiddlewareInterface
|
class IndexInitialize implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param callable $handler
|
||||||
|
* @return Response
|
||||||
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
public function process(Request $request, callable $handler): Response
|
public function process(Request $request, callable $handler): Response
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ return [
|
|||||||
'auth' => '',
|
'auth' => '',
|
||||||
'timeout' => 2,
|
'timeout' => 2,
|
||||||
'database' => getenv('CACHE_SELECT') ?? 0,
|
'database' => getenv('CACHE_SELECT') ?? 0,
|
||||||
'prefix' => 'redis_',
|
'prefix' => '',
|
||||||
],
|
],
|
||||||
'redis_cluster' => [
|
'redis_cluster' => [
|
||||||
'host' => ['127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7001'],
|
'host' => ['127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7001'],
|
||||||
'timeout' => 2,
|
'timeout' => 2,
|
||||||
'auth' => '',
|
'auth' => '',
|
||||||
'prefix' => 'redis_',
|
'prefix' => '',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'session_name' => 'SAPHPID',
|
'session_name' => 'SAPHPID',
|
||||||
|
|||||||
@@ -317,26 +317,24 @@ layui.define(['jquery', 'i18n', 'element', 'layer', 'form', 'rate', 'table', 'sl
|
|||||||
, setPageHeaderFooter: function (type = 'header') {
|
, setPageHeaderFooter: function (type = 'header') {
|
||||||
|
|
||||||
if (type === 'header') {
|
if (type === 'header') {
|
||||||
|
|
||||||
var openHeader = admin.getStorage('openHeader');
|
var openHeader = admin.getStorage('openHeader');
|
||||||
if (openHeader === false) { // 移除
|
if (!openHeader) {
|
||||||
|
console.log('移除');
|
||||||
top.layui.$('.layui-header,.layui-logo').hide();
|
top.layui.$('.layui-header,.layui-logo').hide();
|
||||||
top.layui.$('.layui-nav-tree,.layui-body').css({
|
top.layui.$('.layui-nav-tree,.layui-body').addClass('lay-fix-top');
|
||||||
"top": "0px",
|
} else {
|
||||||
"margin-top": "0px"
|
|
||||||
});
|
|
||||||
} else if (openHeader === true) { // 还原回来
|
|
||||||
top.layui.$('.layui-header,.layui-logo').show();
|
top.layui.$('.layui-header,.layui-logo').show();
|
||||||
top.layui.$('.layui-nav-tree').css("margin-top", "60px");
|
top.layui.$('.layui-nav-tree,.layui-body').removeClass('lay-fix-top');
|
||||||
top.layui.$('.layui-body').css("top", "50px");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var openFooter = admin.getStorage('openFooter');
|
var openFooter = admin.getStorage('openFooter');
|
||||||
if (openFooter === false) { // 移除
|
if (!openFooter) {
|
||||||
top.layui.$('.layui-footer').hide();
|
top.layui.$('.layui-footer').addClass('layui-hide');
|
||||||
} else if (openFooter === true) { // 显示
|
top.layui.$('.layui-layout-admin>.layui-body').addClass('lay-fix-bottom');
|
||||||
top.layui.$('.layui-footer').show();
|
} else { // 显示
|
||||||
|
top.layui.$('.layui-footer').removeClass('layui-hide');
|
||||||
|
top.layui.$('.layui-layout-admin>.layui-body').removeClass('lay-fix-bottom');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2607,6 +2605,7 @@ layui.define(['jquery', 'i18n', 'element', 'layer', 'form', 'rate', 'table', 'sl
|
|||||||
let othis = this;
|
let othis = this;
|
||||||
this.options = $.extend(this.options, options);
|
this.options = $.extend(this.options, options);
|
||||||
this.options.layout = this.getStorage('layout') || this.options.layout;
|
this.options.layout = this.getStorage('layout') || this.options.layout;
|
||||||
|
othis.setPageHeaderFooter() || othis.setPageHeaderFooter('footer');
|
||||||
|
|
||||||
// 初始化Load效果
|
// 初始化Load效果
|
||||||
if (!$(LAYOUTBODY).children('#loading').length) {
|
if (!$(LAYOUTBODY).children('#loading').length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user