老师好
tp版本 version 6.0.9
<?php
declare (strict_types = 1);
namespace app\admin\controller;
use app\BaseController;
use think\exception\HttpResponseException;
use think\Request;
use think\facade\View;
class AdminBase extends BaseController
{
public function initialize()
{
//判断是否登录
if (empty($this->isLogin())) {
return $this->redirect((string) url("login/index"),302);
}
}
/**
* 判断是否登录
* @return bool
*/
public function isLogin(){
$adminUserSession = session(config('admin.admin_user'));
if(empty($adminUserSession)){
return false;
}
return true;
}
/**
* 跳转方法覆盖重写
* @param ...$args
*/
public function redirect(...$args){
throw new HttpResponseException(redirect(...$args));
}
}
未登录状态访问下 admin/index/index
已确认执行了 initialize方法,但是返回
{"status":null,"message":"","result":[]}
并没有跳转