mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-05-24 22:09:41 +08:00
added 优化jump跳转页面样式
This commit is contained in:
parent
d4b1bd5745
commit
44e649084a
@ -6,12 +6,17 @@
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\admin\model\User;
|
||||
use think\Controller;
|
||||
|
||||
class Base extends Controller {
|
||||
|
||||
public $primaryKey;
|
||||
public $uid;
|
||||
public $userInfo;
|
||||
private $superUrl = [
|
||||
'User/login'
|
||||
];
|
||||
|
||||
public function _initialize(){
|
||||
$this->primaryKey = config('SQL_PRIMARY_KEY');
|
||||
@ -19,7 +24,7 @@ class Base extends Controller {
|
||||
//初始化系统
|
||||
$this->uid = session('uid');
|
||||
$this->assign('uid',$this->uid);
|
||||
// $this->iniSystem();
|
||||
$this->iniSystem();
|
||||
|
||||
//控制器初始化
|
||||
if(method_exists($this,'_myInitialize')){
|
||||
@ -33,4 +38,49 @@ class Base extends Controller {
|
||||
public function _empty(){
|
||||
return (new PublicShow())->show_404();
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统初始化函数(登陆状态检测,权限检测,初始化菜单)
|
||||
*/
|
||||
private function iniSystem(){
|
||||
$url = $this->request->controller().'/'.$this->request->action();
|
||||
if( !in_array($url, $this->superUrl) ){
|
||||
// $this->allMenu = D('Menu')->order('sort asc')->select();
|
||||
// $this->menuInfo = D('Menu')->where(['url' => $this->url])->find();
|
||||
// if( empty($this->menuInfo) ){
|
||||
// $this->error( 'Menu'.L('_SELECT_NOT_EXIST_') );
|
||||
// }
|
||||
$this->checkLogin();
|
||||
// $this->checkRule();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录状态检测
|
||||
*/
|
||||
private function checkLogin(){
|
||||
if( isset($this->uid) && !empty($this->uid) ){
|
||||
$sidNow = session_id();
|
||||
$sidOld = cache($this->uid);
|
||||
if( isset($sidOld) && !empty($sidOld) ){
|
||||
if( $sidOld != $sidNow ){
|
||||
$this->error("您的账号在别的地方登录了,请重新登录!", url('User/login'));
|
||||
}else{
|
||||
cache($this->uid, $sidNow, config('online_time'));
|
||||
$this->userInfo = User::get([ $this->primaryKey => $this->uid ]);
|
||||
if( $this->userInfo['updateTime'] === 0 ){
|
||||
$this->error('初次登录请重置用户密码!', url('User/changePassWord'));
|
||||
}else{
|
||||
if( empty($this->userInfo['nickName']) ){
|
||||
$this->error('初次登录请设置用户昵称!', url('User/changeNickname'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->error("登录超时,请重新登录!", url('User/login'));
|
||||
}
|
||||
}else{
|
||||
$this->redirect('Login/index');
|
||||
}
|
||||
}
|
||||
}
|
@ -21,13 +21,13 @@ class User extends Base {
|
||||
$username = $this->request->post('username');
|
||||
$password = $this->request->post('password');
|
||||
if( !$username || !$password ){
|
||||
return $this->error('缺少关键数据!');
|
||||
$this->error('缺少关键数据!','');
|
||||
}
|
||||
$userModel = new \app\admin\model\User();
|
||||
$password = $userModel->getPwdHash($password);
|
||||
$userInfo = $userModel->where(['username' => $username, 'password' => $password])->find();
|
||||
if( empty($userInfo) ){
|
||||
return $this->error('用户名或者密码错误!');
|
||||
$this->error('用户名或者密码错误!','');
|
||||
}else{
|
||||
if( $userInfo['status'] ){
|
||||
//保存用户信息和登录凭证
|
||||
@ -50,9 +50,9 @@ class User extends Base {
|
||||
$newUserData->uid = $userInfo[$this->primaryKey];
|
||||
$newUserData->save();
|
||||
}
|
||||
return $this->success('登录成功', $url);
|
||||
$this->success('登录成功', $url);
|
||||
}else{
|
||||
return $this->error('用户已被封禁,请联系管理员');
|
||||
$this->error('用户已被封禁,请联系管理员','');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
63
application/admin/view/public/jump.html
Normal file
63
application/admin/view/public/jump.html
Normal file
@ -0,0 +1,63 @@
|
||||
{__NOLAYOUT__}
|
||||
<!doctype html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>7D - 跳转提示</title>
|
||||
<script src="__STATIC__/jQuery/3.1.1/jquery.min.js"></script>
|
||||
<link href="//cdn.bootcss.com/semantic-ui/2.2.6/semantic.min.css" rel="stylesheet">
|
||||
<script src="//cdn.bootcss.com/semantic-ui/2.2.6/semantic.js"></script>
|
||||
<link rel="icon" href="__ADMIN__/dist/img/favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="ui card" style="text-align:center;width:40%;position: fixed;top: 20%;left: 30%">
|
||||
<?php switch ($code) {?>
|
||||
<?php case 1:?>
|
||||
<div class="ui green inverted segment" style="margin: 0px;">
|
||||
<i class="ui check circle icon massive"></i>
|
||||
</div>
|
||||
<?php break;?>
|
||||
<?php case 0:?>
|
||||
<div class="ui red inverted segment" style="margin: 0px;">
|
||||
<i class="ui remove circle icon massive"></i>
|
||||
</div>
|
||||
<?php break;?>
|
||||
<?php } ?>
|
||||
<div class="content" style="line-height: 2em">
|
||||
<?php if(isset($msg)) {?>
|
||||
<span class="header"><?php echo(strip_tags($msg));?></span>
|
||||
<?php }else{?>
|
||||
<span class="header"><?php echo($error); ?></span>
|
||||
<?php }?>
|
||||
<div class="meta">
|
||||
将在<span id="left"><?php echo($wait); ?></span>S后自动跳转
|
||||
</div>
|
||||
</div>
|
||||
<span style="display: none" id="href"><?php echo($url); ?></span>
|
||||
<div class="ui bottom attached indicating progress" id="amanege-bar">
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
var wait = 0,left = $('#left').text();
|
||||
var href = $('#href').text();
|
||||
var each = 100/left;
|
||||
var interval = setInterval(function(){
|
||||
wait = wait + each;
|
||||
left = left - 1;
|
||||
if(wait > 100) {
|
||||
location.href = href;
|
||||
clearInterval(interval);
|
||||
return ;
|
||||
}
|
||||
$('#left').text(left);
|
||||
$('#amanege-bar').progress({
|
||||
percent: wait
|
||||
});
|
||||
}, 1000);
|
||||
})();
|
||||
</script>
|
||||
</html>
|
@ -143,8 +143,8 @@ return [
|
||||
'__ADMIN__'=>'/static/admin',
|
||||
],
|
||||
// 默认跳转页面对应的模板文件
|
||||
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
'dispatch_success_tmpl' => 'public/jump',
|
||||
'dispatch_error_tmpl' => 'public/jump',
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 异常及错误设置
|
||||
|
Loading…
x
Reference in New Issue
Block a user