环境变量
This commit is contained in:
4
.env
Normal file
4
.env
Normal file
@@ -0,0 +1,4 @@
|
||||
VITE_MAXKB_URL=https://maxkb.xuyue.cc/api/application/embed?protocol=https&host=maxkb.xuyue.cc&token=1b7cd529423b3f36
|
||||
VITE_OJ_URL=https://ojtest.xuyue.cc
|
||||
VITE_CODE_URL=https://code.xuyue.cc
|
||||
VITE_JUDGE0_URL=https://judge0api.xuyue.cc
|
||||
4
.env.production
Normal file
4
.env.production
Normal file
@@ -0,0 +1,4 @@
|
||||
VITE_MAXKB_URL=https://maxkb.xuyue.cc/api/application/embed?protocol=https&host=maxkb.xuyue.cc&token=1b7cd529423b3f36
|
||||
VITE_OJ_URL=https://oj.xuyue.cc
|
||||
VITE_CODE_URL=https://code.xuyue.cc
|
||||
VITE_JUDGE0_URL=https://judge0api.xuyue.cc
|
||||
5
.env.staging
Normal file
5
.env.staging
Normal file
@@ -0,0 +1,5 @@
|
||||
VITE_MAXKB_URL=https://maxkb.xuyue.cc/api/application/embed?protocol=https&host=maxkb.xuyue.cc&token=1b7cd529423b3f36
|
||||
VITE_OJ_URL=http://10.13.114.214:81
|
||||
VITE_CODE_URL=http://10.13.114.214:82
|
||||
VITE_JUDGE0_URL=http://10.13.114.214:8082
|
||||
VITE_ICONIFY_URL=http://10.13.114.214:8098
|
||||
@@ -12,7 +12,7 @@
|
||||
<script
|
||||
async
|
||||
defer
|
||||
src="https://maxkb.xuyue.cc/api/application/embed?protocol=https&host=maxkb.xuyue.cc&token=1b7cd529423b3f36"
|
||||
src="%VITE_MAXKB_URL%"
|
||||
></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"build": "vue-tsc && vite build",
|
||||
"build:staging": "vue-tsc && vite build --mode=staging",
|
||||
"preview": "vite preview",
|
||||
"fmt": "prettier --write src *.ts"
|
||||
},
|
||||
|
||||
@@ -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],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
12
src/vite-env.d.ts
vendored
@@ -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
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import Components from "unplugin-vue-components/vite"
|
||||
import Markdown from "unplugin-vue-markdown/vite"
|
||||
import { defineConfig } from "vite"
|
||||
|
||||
const dev = process.env.NODE_ENV === "development"
|
||||
const url = dev ? "https://ojtest.xuyue.cc" : "https://oj.xuyue.cc"
|
||||
const url = process.env.VITE_OJ_URL
|
||||
|
||||
const proxyConfig = {
|
||||
target: url,
|
||||
changeOrigin: true,
|
||||
|
||||
Reference in New Issue
Block a user