fix: 修复本地测试发现的若干问题 (#392)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-07-12 15:17:54 +08:00
committed by GitHub
parent c8f7a2267d
commit 87fb597ba4
14 changed files with 73 additions and 129 deletions

View File

@@ -65,8 +65,11 @@ export class WebSocketManager {
try {
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
this.socket = new WebSocket(`${protocol}${window.location.host}/api/ws`, [token]);
// 使用 base64URL no padding 编码 token 以避免特殊字符问题
this.socket = new WebSocket(
`${protocol}${window.location.host}/api/ws`,
btoa(token).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
);
this.socket.onopen = () => {
this.connected = true;
this.connecting = false;