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

3
.env
View File

@@ -3,4 +3,5 @@ PUBLIC_MAXKB_URL=https://maxkb.xuyue.cc/chat/api/embed?protocol=https&host=maxkb
PUBLIC_OJ_URL=http://localhost:8000 PUBLIC_OJ_URL=http://localhost:8000
PUBLIC_CODE_URL=http://localhost:3000 PUBLIC_CODE_URL=http://localhost:3000
PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc
PUBLIC_WS_URL=wss://oj.xuyue.cc/ws

View File

@@ -3,4 +3,5 @@ PUBLIC_MAXKB_URL=https://maxkb.xuyue.cc/chat/api/embed?protocol=https&host=maxkb
PUBLIC_OJ_URL=https://oj.xuyue.cc PUBLIC_OJ_URL=https://oj.xuyue.cc
PUBLIC_CODE_URL=https://code.xuyue.cc PUBLIC_CODE_URL=https://code.xuyue.cc
PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc
PUBLIC_WS_URL=wss://oj.xuyue.cc/ws

View File

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

View File

@@ -4,4 +4,5 @@ PUBLIC_OJ_URL=http://10.13.114.114:81
PUBLIC_CODE_URL=http://10.13.114.114:82 PUBLIC_CODE_URL=http://10.13.114.114:82
PUBLIC_JUDGE0_URL=http://10.13.114.114:8082 PUBLIC_JUDGE0_URL=http://10.13.114.114:8082
PUBLIC_ICONIFY_URL=http://10.13.114.114:8098 PUBLIC_ICONIFY_URL=http://10.13.114.114:8098
PUBLIC_SIGNALING_URL=wss://signaling.xuyue.cc 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, mode: envMode,
}) })
const url = rawPublicVars["PUBLIC_OJ_URL"]
const proxyConfig = { const proxyConfig = {
target: url, target: rawPublicVars["PUBLIC_OJ_URL"],
headers: { Referer: url },
changeOrigin: true, changeOrigin: true,
} }
// WebSocket 代理配置(开发环境 Daphne 在 8001 端口)
const wsProxyConfig = { const wsProxyConfig = {
target: url.replace(':8000', ':8001').replace('http:', 'ws:'), // http://localhost:8001 → ws://localhost:8001 target: rawPublicVars["PUBLIC_WS_URL"],
ws: true, // 启用 WebSocket 代理 ws: true,
changeOrigin: true, changeOrigin: true,
logLevel: 'debug' as const, // 显示代理日志
} }
return { return {
plugins: [pluginVue()], plugins: [pluginVue()],
@@ -149,7 +145,7 @@ export default defineConfig(({ envMode }) => {
proxy: { proxy: {
"/api": proxyConfig, "/api": proxyConfig,
"/public": 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_JUDGE0_URL: string
readonly PUBLIC_ICONIFY_URL: string readonly PUBLIC_ICONIFY_URL: string
readonly PUBLIC_SIGNALING_URL: string readonly PUBLIC_SIGNALING_URL: string
readonly PUBLIC_WS_URL: string
} }
interface ImportMeta { interface ImportMeta {

View File

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