From 4b1cd997eaca99e9079e18bed59ef4530cc950ea Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Tue, 18 Feb 2025 19:57:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=90=88=E5=B9=B6app?= =?UTF-8?q?=E5=90=8E=E6=89=93=E5=BC=80=E4=B9=B1=E7=A0=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E5=AE=9E=E7=8E=B0jwt=E6=8B=A6=E6=88=AAtoken=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/IndexController.php | 7 +------ app/middleware/JwtAuthMiddleware.php | 6 ++++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index a892a42..4e56544 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -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) diff --git a/app/middleware/JwtAuthMiddleware.php b/app/middleware/JwtAuthMiddleware.php index 0f0d0a0..8120b65 100644 --- a/app/middleware/JwtAuthMiddleware.php +++ b/app/middleware/JwtAuthMiddleware.php @@ -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 属性中