增加登录跳转到指定页面;发布新版本

This commit is contained in:
2023-10-04 09:27:45 +08:00
parent daae12610e
commit 8abfdd5016
7 changed files with 30 additions and 17 deletions

View File

@@ -35,7 +35,7 @@
"psr/simple-cache": ">=1.0"
},
"require-dev": {
"symfony/var-dumper": "^4.2"
"symfony/var-dumper": "*"
},
"autoload": {
"psr-4": {

View File

@@ -5,7 +5,7 @@
// +----------------------------------------------------------------------
return [
// cookie 保存时间
'expire' => 0,
'expire' => 86400*30,
// cookie 保存路径
'path' => '/',
// cookie 有效域名

View File

@@ -1,19 +1,20 @@
<?php
// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
return [
// session name
'name' => 'PHPSESSID',
'name' => 'PHPSESSID',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// 驱动方式 支持file cache
'type' => 'file',
'type' => 'file',
// 存储连接标识 当type使用cache的时候有效
'store' => null,
'store' => null,
// 过期时间
'expire' => 86400,
'expire' => 86400 * 30,
// 前缀
'prefix' => '',
'prefix' => '',
];

View File

@@ -7,6 +7,7 @@ use app\common\controller\AdminController;
use think\captcha\facade\Captcha;
use think\facade\Env;
use think\facade\Event;
use think\facade\Session;
/**
* Class Login.
@@ -37,6 +38,18 @@ class LoginBase extends AdminController
'controller' => $this,
]);
$back_url = $this->request->param('back_url');
if (!empty($back_url)) {
Session::set('back-url', $back_url);
} else {
$back_url = Session::get('back-url');
}
if (empty($back_url)) {
$back_url = null;
}
$captcha = Env::get('adminsystem.captcha', 1);
if ($this->request->isPost()) {
$post = $this->request->post();
@@ -67,7 +80,8 @@ class LoginBase extends AdminController
$admin['expire_time'] = $post['keep_login'] == 1 ? true : time() + 7200;
session('admin', $admin);
$this->success('登录成功');
Session::delete('back-url');
$this->success('登录成功', '', $back_url);
}
$this->assign('captcha', $captcha);
$this->assign('demo', $this->isDemo);

View File

@@ -30,7 +30,7 @@ $(function () {
return data;
}, function (res) {
ua.msg.success(res.msg, function () {
window.location = ua.url('index');
window.location = res.url;
});
}, function (res) {
ua.msg.error(res.msg, function () {

View File

@@ -12,16 +12,12 @@ use think\console\Output;
class VersionBase extends Command
{
public const VERSION = 'v2.0.53';
public const VERSION = 'v2.0.54';
public const LAYUI_VERSION = '2.8.17';
public const COMMENT = [
'优化首页移动端兼容性',
'修改说明文件和版本信息',
'清理遗留技术代码',
'移除表格转卡片',
'新增手机端浏览模式和基本分页查询',
'增加登录跳转到指定页面',
'发布新版本',
];

View File

@@ -398,17 +398,19 @@ class AdminControllerBase extends BaseController
$currentController = parse_name(app()->request->controller());
$back_url = $this->request->url();
// 验证登录
if (
!in_array($currentController, $adminConfig['no_login_controller']) &&
!in_array($currentNode, $adminConfig['no_login_node'])
) {
empty($adminId) && $this->error('请先登录后台', [], __url('admin/login/index'));
empty($adminId) && $this->error('请先登录后台', [], __url('admin/login/index', ['back_url' => $back_url]));
// 判断是否登录过期
if ($expireTime !== true && time() > $expireTime) {
session('admin', null);
$this->error('登录已过期,请重新登录', [], __url('admin/login/index'));
$this->error('登录已过期,请重新登录', [], __url('admin/login/index', ['back_url' => $back_url]));
}
}