环境变量

This commit is contained in:
2025-05-09 08:15:00 +08:00
parent dbd9486d8e
commit 69a62ece22
10 changed files with 38 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import { addAPIProvider } from "@iconify/vue"
import { createPinia } from "pinia"
import { createRouter, createWebHistory } from "vue-router"
@@ -32,3 +33,9 @@ const app = createApp(App)
app.use(router)
app.use(pinia)
app.mount("#app")
if (!!import.meta.env.VITE_ICONIFY_URL) {
addAPIProvider("", {
resources: [import.meta.env.VITE_ICONIFY_URL],
})
}

View File

@@ -92,7 +92,7 @@ async function select(key: string) {
copy()
break
case "test":
window.open("https://code.xuyue.cc", "_blank")
window.open(import.meta.env.VITE_CODE_URL, "_blank")
break
}
}

View File

@@ -2,7 +2,7 @@ import axios from "axios"
import { decode, encode } from "./functions"
import { Code } from "./types"
const http = axios.create({ baseURL: `https://judge0api.xuyue.cc` })
const http = axios.create({ baseURL: import.meta.env.VITE_JUDGE0_URL })
export async function createTestSubmission(code: Code, input: string) {
const encodedCode = encode(code.value)

12
src/vite-env.d.ts vendored
View File

@@ -1 +1,13 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_MAXKB_URL: string
readonly VITE_OJ_URL: string
readonly VITE_CODE_URL: string
readonly VITE_JUDGE0_URL: string
readonly VITE_ICONIFY_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}