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

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" "psr/simple-cache": ">=1.0"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "^4.2" "symfony/var-dumper": "*"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

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

View File

@@ -1,19 +1,20 @@
<?php <?php
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 会话设置 // | 会话设置
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
return [ return [
// session name // session name
'name' => 'PHPSESSID', 'name' => 'PHPSESSID',
// SESSION_ID的提交变量,解决flash上传跨域 // SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '', 'var_session_id' => '',
// 驱动方式 支持file cache // 驱动方式 支持file cache
'type' => 'file', 'type' => 'file',
// 存储连接标识 当type使用cache的时候有效 // 存储连接标识 当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\captcha\facade\Captcha;
use think\facade\Env; use think\facade\Env;
use think\facade\Event; use think\facade\Event;
use think\facade\Session;
/** /**
* Class Login. * Class Login.
@@ -37,6 +38,18 @@ class LoginBase extends AdminController
'controller' => $this, '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); $captcha = Env::get('adminsystem.captcha', 1);
if ($this->request->isPost()) { if ($this->request->isPost()) {
$post = $this->request->post(); $post = $this->request->post();
@@ -67,7 +80,8 @@ class LoginBase extends AdminController
$admin['expire_time'] = $post['keep_login'] == 1 ? true : time() + 7200; $admin['expire_time'] = $post['keep_login'] == 1 ? true : time() + 7200;
session('admin', $admin); session('admin', $admin);
$this->success('登录成功'); Session::delete('back-url');
$this->success('登录成功', '', $back_url);
} }
$this->assign('captcha', $captcha); $this->assign('captcha', $captcha);
$this->assign('demo', $this->isDemo); $this->assign('demo', $this->isDemo);

View File

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

View File

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

View File

@@ -398,17 +398,19 @@ class AdminControllerBase extends BaseController
$currentController = parse_name(app()->request->controller()); $currentController = parse_name(app()->request->controller());
$back_url = $this->request->url();
// 验证登录 // 验证登录
if ( if (
!in_array($currentController, $adminConfig['no_login_controller']) && !in_array($currentController, $adminConfig['no_login_controller']) &&
!in_array($currentNode, $adminConfig['no_login_node']) !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) { if ($expireTime !== true && time() > $expireTime) {
session('admin', null); session('admin', null);
$this->error('登录已过期,请重新登录', [], __url('admin/login/index')); $this->error('登录已过期,请重新登录', [], __url('admin/login/index', ['back_url' => $back_url]));
} }
} }