update
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-10-07 21:26:54 +08:00
parent 389393b70d
commit 7938e02421
7 changed files with 14 additions and 15 deletions

1
.env
View File

@@ -4,3 +4,4 @@ PUBLIC_OJ_URL=http://localhost:8000
PUBLIC_CODE_URL=http://localhost:3000
PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc
PUBLIC_WS_URL=wss://oj.xuyue.cc/ws

View File

@@ -4,3 +4,4 @@ PUBLIC_OJ_URL=https://oj.xuyue.cc
PUBLIC_CODE_URL=https://code.xuyue.cc
PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc
PUBLIC_WS_URL=wss://oj.xuyue.cc/ws

View File

@@ -5,3 +5,4 @@ PUBLIC_CODE_URL=http://10.13.114.114:82
PUBLIC_JUDGE0_URL=http://10.13.114.114:8082
PUBLIC_ICONIFY_URL=http://10.13.114.114:8098
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc
PUBLIC_WS_URL=wss://oj.xuyue.cc/ws

View File

@@ -5,3 +5,4 @@ PUBLIC_CODE_URL=http://10.13.114.114:82
PUBLIC_JUDGE0_URL=http://10.13.114.114:8082
PUBLIC_ICONIFY_URL=http://10.13.114.114:8098
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc
PUBLIC_WS_URL=wss://oj.xuyue.cc/ws

View File

@@ -10,19 +10,15 @@ export default defineConfig(({ envMode }) => {
mode: envMode,
})
const url = rawPublicVars["PUBLIC_OJ_URL"]
const proxyConfig = {
target: url,
headers: { Referer: url },
target: rawPublicVars["PUBLIC_OJ_URL"],
changeOrigin: true,
}
// WebSocket 代理配置(开发环境 Daphne 在 8001 端口)
const wsProxyConfig = {
target: url.replace(':8000', ':8001').replace('http:', 'ws:'), // http://localhost:8001 → ws://localhost:8001
ws: true, // 启用 WebSocket 代理
target: rawPublicVars["PUBLIC_WS_URL"],
ws: true,
changeOrigin: true,
logLevel: 'debug' as const, // 显示代理日志
}
return {
plugins: [pluginVue()],
@@ -149,7 +145,7 @@ export default defineConfig(({ envMode }) => {
proxy: {
"/api": proxyConfig,
"/public": proxyConfig,
"/ws": wsProxyConfig, // WebSocket 使用单独的代理配置
"/ws": wsProxyConfig,
},
},
}

1
src/env.d.ts vendored
View File

@@ -8,6 +8,7 @@ interface ImportMetaEnv {
readonly PUBLIC_JUDGE0_URL: string
readonly PUBLIC_ICONIFY_URL: string
readonly PUBLIC_SIGNALING_URL: string
readonly PUBLIC_WS_URL: string
}
interface ImportMeta {

View File

@@ -62,9 +62,7 @@ export class BaseWebSocket<T extends WebSocketMessage = WebSocketMessage> {
public status: Ref<ConnectionStatus> = ref<ConnectionStatus>("disconnected")
constructor(config: WebSocketConfig) {
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"
const host = window.location.host
this.url = `${protocol}//${host}/ws/${config.path}/`
this.url = import.meta.env.PUBLIC_WS_URL
this.maxReconnectAttempts = config.maxReconnectAttempts ?? 5
this.reconnectDelay = config.reconnectDelay ?? 1000