isAjax()) { return json([ 'code' => 0, 'msg' => '请先登录', ]); } // 否则跳转到登录页 return redirect('/login'); } return $next($request); } }