解决合并app后打开乱码问题 实现jwt拦截token过期需要重新登录

This commit is contained in:
lingling 2025-02-18 19:57:55 +08:00
parent 2865ee97c5
commit 4b1cd997ea
2 changed files with 5 additions and 8 deletions

View File

@ -12,12 +12,7 @@ class IndexController
public function index(Request $request)
{
Log::channel('plugin.admin.default')->info('test');
static $readme;
if (!$readme) {
$readme = file_get_contents(base_path('README.md'));
}
return $readme;
return response()->file(public_path() . '/index.html');
}
public function view(Request $request)

View File

@ -50,7 +50,8 @@ class JwtAuthMiddleware implements MiddlewareInterface
}
// 检查 token 是否为空
if (empty($token)) {
return ApiResponse::error(401, ['error' => '缺少令牌'], '未授权');
// return ApiResponse::error(401, ['error' => '缺少令牌'], '未授权');
return response('',401,['error' => '缺少令牌']);
}
// var_dump($token);
@ -66,7 +67,8 @@ class JwtAuthMiddleware implements MiddlewareInterface
} catch (\Exception $e) {
var_dump($e);
// 解码失败,返回无效令牌错误
return ApiResponse::error(401, ['error' => '无效的令牌'], '无效的令牌');
// return ApiResponse::error(401, ['error' => '无效的令牌'], '无效的令牌');
return response('',401,['error' => '无效的令牌']);
}
// 将解码后的用户信息存储到请求对象的 user 属性中