This commit is contained in:
杨志
2026-01-21 09:15:50 +08:00
parent a7a6d466d0
commit a562c95b10
2 changed files with 56 additions and 33 deletions

View File

@@ -20,9 +20,16 @@ class Auth
// 检查是否已登录
$username = session('username');
// 获取路径信息
$pathinfo = $request->pathinfo();
// 判断是否为API请求非index页面
$isApiRequest = $pathinfo !== 'crawler' && strpos($pathinfo, 'crawler/') === 0;
if (empty($username)) {
// 如果是AJAX请求返回JSON
if ($request->isAjax()) {
// 如果是API请求返回JSON
if ($isApiRequest || $request->isAjax()) {
header('Content-Type: application/json; charset=utf-8');
return json([
'code' => 0,
'msg' => '请先登录',