环境变量
This commit is contained in:
1
.env.production
Normal file
1
.env.production
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VITE_JUDGE0_URL=https://judge0.xuyue.cc
|
||||||
1
.env.staging
Normal file
1
.env.staging
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VITE_JUDGE0_URL=http://10.13.114.214:8082
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import { inBrowser } from 'vitepress'
|
import { inBrowser } from "vitepress"
|
||||||
|
|
||||||
interface Code {
|
interface Code {
|
||||||
language: "c" | "python"
|
language: "c" | "python"
|
||||||
@@ -24,17 +24,8 @@ const DEAD_RESULTS = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChromeVersion() {
|
//@ts-ignore
|
||||||
if (!inBrowser) return 0
|
const http = axios.create({ baseURL: import.meta.env.VITE_JUDGE0_URL })
|
||||||
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` })
|
|
||||||
|
|
||||||
function encode(string?: string) {
|
function encode(string?: string) {
|
||||||
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vitepress dev",
|
"start": "vitepress dev",
|
||||||
"build": "vitepress build"
|
"build": "vitepress build",
|
||||||
|
"build:staging": "vitepress build --mode=staging"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user