mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat: add managed invites and admin diagnostics backend
This commit is contained in:
1 parent
96ef77c789
commit
f5bd06fdaf
10 files changed
+562
-29
No files matched your search
@@ -552,7 +552,7 @@ export function useVoiceWebSocket() {
|
||||
}
|
||||
}
|
||||
|
||||
function connect(target: string, channel: string, nickname: string, serverPassword = "", identity = "", rememberIdentity = false): void {
|
||||
function connect(target: string, channel: string, nickname: string, serverPassword = "", identity = "", rememberIdentity = false, inviteToken = ""): void {
|
||||
disconnect(true);
|
||||
lastConnection = { target, channel, nickname, serverPassword, ...(identity ? { identity } : {}), rememberIdentity };
|
||||
identityMaterial.value = identity;
|
||||
@@ -563,15 +563,15 @@ export function useVoiceWebSocket() {
|
||||
state.reconnecting = false;
|
||||
state.reconnectAttempt = 0;
|
||||
state.reconnectFailed = false;
|
||||
void openTicketedConnection(sequence, target, channel, nickname, serverPassword);
|
||||
void openTicketedConnection(sequence, target, channel, nickname, serverPassword, inviteToken);
|
||||
}
|
||||
|
||||
async function openTicketedConnection(sequence: number, target: string, channel: string, nickname: string, serverPassword: string): Promise<void> {
|
||||
async function openTicketedConnection(sequence: number, target: string, channel: string, nickname: string, serverPassword: string, inviteToken: string): Promise<void> {
|
||||
try {
|
||||
const response = await fetch("/api/join-ticket", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", accept: "application/json" },
|
||||
body: JSON.stringify({ target, nickname, channel, serverPassword, ...(lastConnection?.rememberIdentity && lastConnection.identity ? { identity: lastConnection.identity } : {}), ...(lastConnection?.rememberIdentity ? { rememberIdentity: true } : {}) }),
|
||||
body: JSON.stringify({ target, nickname, channel, serverPassword, ...(inviteToken ? { invite: inviteToken } : {}), ...(lastConnection?.rememberIdentity && lastConnection.identity ? { identity: lastConnection.identity } : {}), ...(lastConnection?.rememberIdentity ? { rememberIdentity: true } : {}) }),
|
||||
});
|
||||
const result = await response.json().catch(() => ({})) as { ticket?: unknown; code?: unknown };
|
||||
if (!response.ok || typeof result.ticket !== "string") {
|
||||
@@ -631,6 +631,7 @@ export function useVoiceWebSocket() {
|
||||
if (code === "NOT_INITIALIZED") return "WebSpeak 尚未完成首次配置";
|
||||
if (code === "TARGET_NOT_ALLOWED") return "此 TeamSpeak 服务器地址不允许连接";
|
||||
if (code === "INVALID_NICKNAME") return "请输入有效的昵称";
|
||||
if (code === "INVITE_INVALID") return "邀请链接已失效或已被撤销";
|
||||
return "连接服务器失败,请检查邀请链接或服务器状态";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user