From 486ea309a2470d04001c0daf05c3ea7314b95baf Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Thu, 8 May 2025 19:20:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + .env.production | 1 + .env.staging | 1 + .vitepress/theme/judge.ts | 15 +++------------ package.json | 3 ++- 5 files changed, 8 insertions(+), 13 deletions(-) create mode 100644 .env create mode 100644 .env.production create mode 100644 .env.staging diff --git a/.env b/.env new file mode 100644 index 0000000..c7936c6 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_JUDGE0_URL=https://judge0.xuyue.cc \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..c7936c6 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_JUDGE0_URL=https://judge0.xuyue.cc \ No newline at end of file diff --git a/.env.staging b/.env.staging new file mode 100644 index 0000000..f6d92a6 --- /dev/null +++ b/.env.staging @@ -0,0 +1 @@ +VITE_JUDGE0_URL=http://10.13.114.214:8082 \ No newline at end of file diff --git a/.vitepress/theme/judge.ts b/.vitepress/theme/judge.ts index 49438b9..4bc84d8 100644 --- a/.vitepress/theme/judge.ts +++ b/.vitepress/theme/judge.ts @@ -1,5 +1,5 @@ import axios from "axios" -import { inBrowser } from 'vitepress' +import { inBrowser } from "vitepress" interface Code { language: "c" | "python" @@ -24,17 +24,8 @@ const DEAD_RESULTS = { }, } -function getChromeVersion() { - if (!inBrowser) return 0 - var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./) - return raw ? parseInt(raw[2], 10) : 0 -} - -const isLowVersion = getChromeVersion() < 80 - -const protocol = isLowVersion ? "http" : "https" - -const http = axios.create({ baseURL: `${protocol}://judge0api.xuyue.cc` }) +//@ts-ignore +const http = axios.create({ baseURL: import.meta.env.VITE_JUDGE0_URL }) function encode(string?: string) { return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? ""))) diff --git a/package.json b/package.json index c6741be..98c4f45 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "type": "module", "scripts": { "start": "vitepress dev", - "build": "vitepress build" + "build": "vitepress build", + "build:staging": "vitepress build --mode=staging" }, "keywords": [], "author": "",