From 72f63a9aca5179976bcc38d7603fd5a0307fd3fb Mon Sep 17 00:00:00 2001 From: slhmy <1484836413@qq.com> Date: Mon, 2 Oct 2023 07:49:49 +0800 Subject: [PATCH] Fix mock worker for gh-pages --- src/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index da1166551..7a7cc401d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -8,9 +8,16 @@ import "./i18n/i18n"; import "./index.css"; console.log("Running in:", import.meta.env.MODE); -if (import.meta.env.MODE === "mock" || import.meta.env.MODE === "gh-pages") { +if (import.meta.env.MODE === "mock") { worker.start(); } +if (import.meta.env.MODE === "gh-pages") { + worker.start({ + serviceWorker: { + url: "/oj-lab-front/mockServiceWorker.js", + }, + }); +} const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement,