From d2c1d8a4f61f94fa5120e3a0b09db7d19c9fc93f Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Mon, 20 Apr 2026 11:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=E6=94=B6?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=8E=A8=E9=80=81=E6=8A=A5=E9=94=99404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin/webman/push/route.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/config/plugin/webman/push/route.php b/config/plugin/webman/push/route.php index ea54c37..0b09191 100644 --- a/config/plugin/webman/push/route.php +++ b/config/plugin/webman/push/route.php @@ -17,10 +17,21 @@ use Webman\Route; use Webman\Push\Api; /** - * 推送js客户端文件 + * 推送 js 客户端 + * - 生产环境 Nginx 常把 root 指到 public/:须存在 public/plugin/webman/push/push.js(与 vendor 同步) + * - 若请求进入 Webman,则优先读 public,其次 vendor */ Route::get('/plugin/webman/push/push.js', function (Request $request) { - return response()->file(base_path().'/vendor/webman/push/src/push.js'); + $publicFile = public_path() . DIRECTORY_SEPARATOR . 'plugin' . DIRECTORY_SEPARATOR . 'webman' . DIRECTORY_SEPARATOR . 'push' . DIRECTORY_SEPARATOR . 'push.js'; + if (is_file($publicFile)) { + return response()->file($publicFile); + } + $vendorFile = base_path() . '/vendor/webman/push/src/push.js'; + if (is_file($vendorFile)) { + return response()->file($vendorFile); + } + + return response('push.js not found. Run: copy vendor/webman/push/src/push.js to public/plugin/webman/push/push.js', 404); }); /**