refactor(Logs): use APP_TARGET to read target websocket addr

refactor(config): use APP_TARGET constant for backend URL configuration

Centralize backend URL configuration by introducing APP_TARGET constant in vite.config.js and using it for both WebSocket connection and API proxy. This improves maintainability by having a single source of truth for the backend address.
This commit is contained in:
2026-03-26 16:29:18 +08:00
parent f7a2f9fb3f
commit 34f0d9f6d5
2 changed files with 8 additions and 2 deletions

View File

@@ -61,7 +61,8 @@ export default {
const connectWebSocket = () => {
const token = getCookie('token');
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${wsProtocol}//localhost:8080/system/getLogs?token=${token}`;
const target = __APP_TARGET__;
const wsUrl = `${wsProtocol}//${target}/system/getLogs?token=${token}`;
socket.value = new WebSocket(wsUrl);