Add server navigation controls across modes

This commit is contained in:
illusia committed 2026-10-12 12:01:51 +08:00
1 parent c6eeb49f44
commit 319a16f384
18 files changed
+372 -63

No files matched your search

+40 -9
View File
@@ -55,11 +55,13 @@ export default defineComponent({
extensionPermissions: { type: Array as PropType<readonly SkinPluginPermission[]>, default: () => [] },
componentNamespace: { type: String, default: "" },
manageSurfaceRecovery: { type: Boolean, default: true },
page: { type: String as PropType<"home" | "voice" | "demo">, required: true },
data: { type: Object as PropType<SafeContext>, required: true },
assets: { type: Object as PropType<Record<string, Blob>>, required: true },
actions: { type: Object as PropType<Record<string, HostAction>>, required: true },
widgets: { type: Object as PropType<Partial<Record<SkinPluginHostWidget, HostWidget>>>, default: () => ({}) },
page: { type: String as PropType<"home" | "voice" | "demo">, required: true },
data: { type: Object as PropType<SafeContext>, required: true },
assets: { type: Object as PropType<Record<string, Blob>>, required: true },
actions: { type: Object as PropType<Record<string, HostAction>>, required: true },
serverAddLabel: { type: String, default: "添加服务器 / Add server" },
onAddServer: { type: Function as PropType<() => void>, default: () => undefined },
widgets: { type: Object as PropType<Partial<Record<SkinPluginHostWidget, HostWidget>>>, default: () => ({}) },
},
emits: {
"surface-change": (_active: boolean) => typeof _active === "boolean",
@@ -311,12 +313,22 @@ export default defineComponent({
} else if (expected !== undefined ? value !== expected : !value) return null;
}
const attrs: Record<string, unknown> = {};
for (const [key, value] of Object.entries(node.attributes ?? {})) {
for (const [key, value] of Object.entries(node.attributes ?? {})) {
// data-ws-* belongs to host layout, page, and recovery machinery. Older
// packages remain loadable, but their nodes cannot impersonate host hooks.
if (key.startsWith("data-ws-")) continue;
attrs[svgAttributeNames[key] ?? key] = typeof value === "string" ? interpolate(value, context, state) : value;
}
attrs[svgAttributeNames[key] ?? key] = typeof value === "string" ? interpolate(value, context, state) : value;
}
if (node.tag === "button" && node.part === "quick-server") {
const server = context.server;
if (server && typeof server === "object" && !Array.isArray(server)) {
const restricted = (server as Record<string, unknown>).switchRestricted === true;
if (restricted) delete attrs.disabled;
attrs["aria-disabled"] = String(restricted);
const switchTitle = (server as Record<string, unknown>).switchTitle;
if (typeof switchTitle === "string") attrs.title = switchTitle;
}
}
if (node.asset) {
const url = assetUrl(node.asset);
if (url) attrs.src = url;
@@ -357,7 +369,26 @@ export default defineComponent({
};
}
if (node.tag === "form" && !node.events?.submit) attrs.onSubmit = (event: Event) => event.preventDefault();
const children = (node.children ?? []).map((child, index) => renderNode(component, child, context, state, budget, false, `${nodePath}-${index}`));
const children = (node.children ?? []).map((child, index) => renderNode(component, child, context, state, budget, false, `${nodePath}-${index}`));
if (props.page === "voice" && node.tag === "nav" && ["server-rail", "quick-rail"].includes(node.part ?? "")) {
children.push(h("span", {
class: "ws-plugin-server-add-divider",
"data-ws-part": "voice.favorite-servers.skin-add-divider",
"aria-hidden": "true",
}));
children.push(h("button", {
type: "button",
class: "ws-plugin-server-add",
"data-ws-plugin-part": `${component.id}.server-add`,
"data-ws-part": `skin.voice.${component.id}.control-part-server-add`,
"aria-label": props.serverAddLabel,
title: props.serverAddLabel,
onClick: (event: Event) => {
if (!event.isTrusted) return;
props.onAddServer?.();
},
}, [h("span", { "aria-hidden": "true" }, "+")]));
}
// Custom element names are inert host-rendered placeholders. Never instantiate a page-registered
// custom element from generated output, since its connectedCallback would run with page privileges.
const tag = node.tag.includes("-") ? "div" : node.tag;
+11 -7
View File
@@ -101,9 +101,11 @@ export default defineComponent({
styles: { type: Object as PropType<Record<string, string>>, default: () => ({}) },
assets: { type: Object as PropType<Record<string, Blob>>, default: () => ({}) },
page: { type: String as PropType<SkinRuntimePluginPage>, required: true },
mountRevision: { type: String, default: "" },
context: { type: Object as PropType<Record<string, unknown>>, default: () => ({}) },
actions: { type: Object as PropType<Partial<Record<SkinPluginAction, HostActionHandler>>>, default: () => ({}) },
mountRevision: { type: String, default: "" },
context: { type: Object as PropType<Record<string, unknown>>, default: () => ({}) },
actions: { type: Object as PropType<Partial<Record<SkinPluginAction, HostActionHandler>>>, default: () => ({}) },
serverAddLabel: { type: String, default: "添加服务器 / Add server" },
onAddServer: { type: Function as PropType<() => void>, default: () => undefined },
widgets: { type: Object as PropType<Partial<Record<SkinPluginHostWidget, (options?: SkinPluginWidgetOptions) => VNodeChild>>>, default: () => ({}) },
readSessionStatus: { type: Function as PropType<(signal: AbortSignal) => SkinExtensionSessionStatus | Promise<SkinExtensionSessionStatus>>, required: true },
},
@@ -379,10 +381,12 @@ export default defineComponent({
componentNamespace: plugin.id,
manageSurfaceRecovery: false,
page: props.page,
data: {},
assets: pluginAssets,
actions: {},
extensionPermissions: plugin.permissions,
data: {},
assets: pluginAssets,
actions: {},
serverAddLabel: props.serverAddLabel,
onAddServer: props.onAddServer,
extensionPermissions: plugin.permissions,
widgets: props.widgets,
onExtensionEvent: (event: unknown) => dispatch(plugin.id, event),
onSurfaceChange: (active: boolean) => surfaceChanged(plugin.id, active),
@@ -31,6 +31,8 @@
data-ws-part="voice.server-switcher.item"
:class="{ 'is-current': server.current }"
:aria-current="server.current ? 'true' : undefined"
:aria-disabled="server.current || server.switchRestricted"
:title="server.switchTitle"
:disabled="server.current"
@click="switchServer(server)"
>
+10
View File
@@ -84,6 +84,8 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
favoriteServers: "常用服务器",
quickServers: "快速连接",
addFavoriteServer: "添加服务器",
serverFeatureAdminDisabled: "该功能已被管理员关闭",
serverSwitchRestricted: "管理员不允许切换TS服务器",
quickConnectTitle: "添加服务器收藏",
favoriteDisplayName: "显示名称",
favoriteDisplayNamePlaceholder: "例如:游戏、朋友或社区",
@@ -495,6 +497,8 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
favoriteServers: "Favorites",
quickServers: "Quick servers",
addFavoriteServer: "Add server",
serverFeatureAdminDisabled: "This feature has been disabled by the administrator.",
serverSwitchRestricted: "The administrator does not allow switching TS servers.",
quickConnectTitle: "Add a server favorite",
favoriteDisplayName: "Display name",
favoriteDisplayNamePlaceholder: "For example: gaming, friends, or community",
@@ -909,6 +913,8 @@ webClientTranslations.de = {
favoriteServers: "Favoriten",
quickServers: "Schnellverbindungen",
addFavoriteServer: "Server hinzufügen",
serverFeatureAdminDisabled: "Diese Funktion wurde vom Administrator deaktiviert.",
serverSwitchRestricted: "Der Administrator erlaubt keinen Wechsel des TeamSpeak-Servers.",
quickConnectTitle: "Server zu Favoriten hinzufügen",
favoriteDisplayName: "Anzeigename",
favoriteDisplayNamePlaceholder: "Zum Beispiel: Gaming, Freunde oder Community",
@@ -1354,6 +1360,8 @@ webClientTranslations.ru = {
favoriteServers: "Избранное",
quickServers: "Быстрый доступ",
addFavoriteServer: "Добавить сервер",
serverFeatureAdminDisabled: "Эта функция отключена администратором.",
serverSwitchRestricted: "Администратор запретил переключение серверов TeamSpeak.",
quickConnectTitle: "Добавить сервер в избранное",
favoriteDisplayName: "Отображаемое имя",
favoriteDisplayNamePlaceholder: "Например: игра, друзья или сообщество",
@@ -1552,6 +1560,8 @@ webClientTranslations.ja = {
favoriteServers: "お気に入り",
quickServers: "クイック接続",
addFavoriteServer: "サーバーを追加",
serverFeatureAdminDisabled: "この機能は管理者によって無効にされています。",
serverSwitchRestricted: "管理者はTeamSpeakサーバーの切り替えを許可していません。",
quickConnectTitle: "サーバーをお気に入りに追加",
favoriteDisplayName: "表示名",
favoriteDisplayNamePlaceholder: "例:ゲーム、友人、コミュニティ",
+1 -1
View File
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.78",
version: "3.1.79",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired voice-room workspace with a searchable server header, TeamSpeak banner and welcome message, nested channel members, attached channel chat, and a compact WebSpeak audio dock.",
+103
View File
@@ -217,6 +217,109 @@ test("generated SVG restores case-sensitive standard attribute names in host-ren
assert.match(html, /gradientUnits="userSpaceOnUse"/);
});
test("host adds a trusted server-add control to custom server rails in every skin", async () => {
for (const part of ["server-rail", "quick-rail"]) {
const html = await renderToString(createSSRApp(SkinPluginOutlet, {
skinId: "community.server-add-test",
skinVersion: "1.0.0",
document: { schemaVersion: 3, components: [] },
extensionOutput: generatedOutput("voice-workspace", { tag: "nav", part, children: [] }),
page: "voice",
data: {},
assets: {},
actions: {},
serverAddLabel: "Add server",
}));
assert.match(html, /data-ws-plugin-part="voice-workspace\.server-add"/);
assert.match(html, /aria-label="Add server"/);
}
const homeHtml = await renderToString(createSSRApp(SkinPluginOutlet, {
skinId: "community.server-add-test",
skinVersion: "1.0.0",
document: { schemaVersion: 3, components: [] },
extensionOutput: generatedOutput("home-workspace", { tag: "nav", part: "server-rail", children: [] }),
page: "home",
data: {},
assets: {},
actions: {},
}));
assert.doesNotMatch(homeHtml, /\.server-add/);
const restrictedQuickServerHtml = await renderToString(createSSRApp(SkinPluginOutlet, {
skinId: "community.server-add-test",
skinVersion: "1.0.0",
document: { schemaVersion: 3, components: [] },
extensionOutput: generatedOutput("voice-workspace", {
tag: "nav",
part: "server-rail",
children: [{ tag: "button", part: "quick-server", attributes: { type: "button", disabled: true } }],
}),
page: "voice",
data: { server: { switchRestricted: true, switchTitle: "管理员不允许切换TS服务器" } },
assets: {},
actions: {},
}));
assert.match(restrictedQuickServerHtml, /aria-disabled="true"/);
assert.match(restrictedQuickServerHtml, /title="管理员不允许切换TS服务器"/);
assert.doesNotMatch(restrictedQuickServerHtml, /\sdisabled(?:="(?:true|disabled)?")?(?:\s|>)/);
type HostNode = { type: string; props: Record<string, unknown>; text: string; children: HostNode[]; parent?: HostNode };
const createHostNode = (type: string, text = ""): HostNode => ({ type, props: {}, text, children: [] });
const renderer = createRenderer<HostNode, HostNode>({
patchProp(node, key, _previous, next) { node.props[key] = next; },
insert(node, parent, anchor) {
node.parent = parent;
const oldIndex = parent.children.indexOf(node);
if (oldIndex >= 0) parent.children.splice(oldIndex, 1);
const anchorIndex = anchor ? parent.children.indexOf(anchor) : -1;
parent.children.splice(anchorIndex >= 0 ? anchorIndex : parent.children.length, 0, node);
},
remove(node) {
if (!node.parent) return;
const index = node.parent.children.indexOf(node);
if (index >= 0) node.parent.children.splice(index, 1);
node.parent = undefined;
},
createElement: (type) => createHostNode(type),
createText: (text) => createHostNode("#text", text),
createComment: (text) => createHostNode("#comment", text),
setText(node, text) { node.text = text; },
setElementText(node, text) { node.children = []; node.text = text; },
parentNode: (node) => node.parent ?? null,
nextSibling(node) {
if (!node.parent) return null;
return node.parent.children[node.parent.children.indexOf(node) + 1] ?? null;
},
});
let addCount = 0;
const app = renderer.createApp(SkinPluginOutlet, {
skinId: "community.server-add-test",
skinVersion: "1.0.0",
document: { schemaVersion: 3, components: [] },
extensionOutput: generatedOutput("voice-workspace", { tag: "nav", part: "server-rail", children: [] }),
page: "voice",
data: {},
assets: {},
actions: {},
onAddServer: () => { addCount += 1; },
});
const host = createHostNode("root");
app.mount(host);
await nextTick();
const findAddButton = (node: HostNode): HostNode | undefined => {
if (node.type === "button" && node.props["data-ws-plugin-part"] === "voice-workspace.server-add") return node;
return node.children.map(findAddButton).find(Boolean);
};
const addButton = findAddButton(host);
assert.ok(addButton);
(addButton.props.onClick as (event: Event) => void)({ isTrusted: false } as Event);
assert.equal(addCount, 0, "synthetic events cannot open the host dialog");
(addButton.props.onClick as (event: Event) => void)({ isTrusted: true } as Event);
assert.equal(addCount, 1, "a trusted click opens the existing host add-server flow");
app.unmount();
});
test("generated UI can exceed the former 16 KiB output ceiling while staying within the new package-sized limit", () => {
const source = JSON.stringify({
schemaVersion: 4,
+2 -1
View File
@@ -479,7 +479,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.kaak-voice");
assert.equal(skin.version, "3.1.78");
assert.equal(skin.version, "3.1.79");
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
assert.equal(skin.schemaVersion, 3);
const home = skin.pluginData?.components.find((component) => component.page === "home");
@@ -670,6 +670,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.match(skin.css, /minmax\(340px, min\(38vw, 520px\)\)/);
assert.match(skin.css, /grid-template-rows: 40px/);
assert.match(skin.css, /kaak-workspace\.server-rail"\]\s*\{[\s\S]*?--skin-kaak-rail-bg: #191a1d;[\s\S]*?--skin-kaak-rail-item-bg: #2b2d32;[\s\S]*?--skin-kaak-rail-accent: #75c900;[\s\S]*?gap: 18px;[\s\S]*?padding: 14px 0 96px;[\s\S]*?background: var\(--skin-kaak-rail-bg\);/);
assert.match(skin.css, /kaak-workspace\.server-add"\]\s*\{[\s\S]*?width: 58px;[\s\S]*?height: 58px;[\s\S]*?border-radius: 18px;/);
assert.match(skin.css, /kaak-workspace\.quick-server-item"\]\s*\{[\s\S]*?width: 58px;[\s\S]*?height: 58px;/);
assert.match(skin.css, /kaak-workspace\.quick-server"\]\s*\{[\s\S]*?width: 58px;[\s\S]*?height: 58px;[\s\S]*?border: 2px solid transparent;[\s\S]*?border-radius: 18px;/);
assert.match(skin.css, /quick-server\"\]\:hover[\s\S]*?background: #383a40;/);
+10 -1
View File
@@ -8,6 +8,8 @@ export interface SkinPluginQuickServer {
icon: string;
tone: number;
current: boolean;
switchRestricted: boolean;
switchTitle: string;
kind: "favorite" | "recent";
favorite: boolean;
}
@@ -44,7 +46,12 @@ export function createSkinPluginQuickServerProjection(createId: () => string = r
const targetByOpaqueId = new Map<string, QuickServer>();
return {
project(servers: readonly QuickServer[], isCurrent: (server: QuickServer) => boolean): SkinPluginQuickServer[] {
project(
servers: readonly QuickServer[],
isCurrent: (server: QuickServer) => boolean,
switchRestricted = false,
switchRestrictedLabel = "Server switching is restricted by the administrator",
): SkinPluginQuickServer[] {
const activeServerIds = new Set(servers.map((server) => server.id));
for (const id of opaqueIdByServerId.keys()) if (!activeServerIds.has(id)) opaqueIdByServerId.delete(id);
targetByOpaqueId.clear();
@@ -70,6 +77,8 @@ export function createSkinPluginQuickServerProjection(createId: () => string = r
icon: isSafeQuickServerIcon(server.serverIcon) ? server.serverIcon : "",
tone: safeLabelTone(safeLabel),
current: isCurrent(server),
switchRestricted,
switchTitle: switchRestricted ? switchRestrictedLabel : safeLabel,
kind: server.isFavorite ? "favorite" : "recent",
favorite: server.isFavorite,
};
@@ -8,6 +8,7 @@ import {
revokeSkinPluginApprovals,
} from "./skin-plugin-approval.js";
import { createSkinPluginQuickServerProjection } from "./skin-plugin-context.js";
import { webClientTranslations } from "../i18n/web-client.js";
import "./skin-plugin-asset-urls.test.js";
function surfaceDocument(): SkinPluginDocument {
@@ -74,6 +75,7 @@ test("skin quick-server data redacts connection targets and resolves only host-g
["Recent 2", "recent", false, false],
["Friends", "favorite", true, true],
]);
assert.ok(rows.every(({ switchRestricted, switchTitle }) => !switchRestricted && typeof switchTitle === "string"));
assert.equal(JSON.stringify(rows).includes("192.0.2.10"), false);
assert.equal(JSON.stringify(rows).includes("voice.example"), false);
const friendsTone = rows.find(({ label }) => label === "Friends")?.tone;
@@ -82,6 +84,10 @@ test("skin quick-server data redacts connection targets and resolves only host-g
assert.equal(reorderedTone, friendsTone, "a server keeps its color tone when its saved-list position changes");
assert.equal(projection.resolve("opaque-1")?.address, "192.0.2.10:9987");
assert.equal(projection.resolve("192.0.2.10:9987"), undefined);
const restricted = projection.project(servers, () => false, true, "管理员不允许切换TS服务器");
assert.ok(restricted.every(({ switchRestricted, switchTitle }) => switchRestricted && switchTitle === "管理员不允许切换TS服务器"));
assert.equal(JSON.stringify(restricted).includes("192.0.2.10"), false);
});
test("skin quick-server projection uses the TeamSpeak name and public icon while keeping its target private", () => {
@@ -116,3 +122,8 @@ test("skin quick-server projection does not expose a network target used as the
assert.equal(server.monogram, "F");
assert.equal(JSON.stringify(server).includes("server.example.invalid"), false);
});
test("fixed-mode server controls use the requested Chinese restriction messages", () => {
assert.equal(webClientTranslations.zh.serverFeatureAdminDisabled, "该功能已被管理员关闭");
assert.equal(webClientTranslations.zh.serverSwitchRestricted, "管理员不允许切换TS服务器");
});
+57
View File
@@ -7890,11 +7890,68 @@
border-radius: 0 4px 4px 0;
}
[data-ws-plugin-part$=".quick-server"][aria-disabled="true"] {
cursor: not-allowed;
opacity: .48;
}
.ws-plugin-server-add {
position: sticky;
bottom: 0;
z-index: 1;
display: grid;
width: 42px;
height: 42px;
flex: 0 0 42px;
place-items: center;
padding: 0;
border: 1px solid var(--border);
border-radius: 14px;
color: var(--text-muted);
background: var(--surface-2);
font: inherit;
font-size: 22px;
line-height: 1;
cursor: pointer;
transition: color .14s ease, background .14s ease, border-color .14s ease;
}
.ws-plugin-server-add-divider {
display: block;
width: 34px;
height: 1px;
flex: 0 0 1px;
background: color-mix(in srgb, currentColor 18%, transparent);
}
.ws-plugin-server-add:hover,
.ws-plugin-server-add:focus-visible {
color: var(--text-primary);
border-color: var(--accent);
background: var(--surface-2);
}
.ws-plugin-server-add:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 3px;
}
.favorite-server-button:disabled {
cursor: wait;
opacity: .65;
}
.favorite-server-button[aria-disabled="true"],
.favorite-server-strip-button[aria-disabled="true"] {
cursor: not-allowed;
opacity: .48;
}
.ws-voice-server-switcher-item[aria-disabled="true"]:not(.is-current) {
cursor: not-allowed;
opacity: .55;
}
.favorite-server-avatar {
display: grid;
width: 40px;
+66 -36
View File
@@ -17,10 +17,12 @@
:skin-version="activeSkin.version"
:document="skinPluginDocument"
:page="showVoiceShell ? 'voice' : 'home'"
:data="skinPluginContext"
:assets="activeSkin.assets"
:actions="skinPluginActions"
:widgets="skinPluginWidgets"
:data="skinPluginContext"
:assets="activeSkin.assets"
:actions="skinPluginActions"
:server-add-label="t('addFavoriteServer')"
:on-add-server="openFavoriteServerDialog"
:widgets="skinPluginWidgets"
@surface-change="skinPluginSurfaceActive = $event"
@restore-skin="switchToBuiltIn"
/>
@@ -42,10 +44,12 @@
:styles="activeSkin.runtimePluginStyles ?? {}"
:assets="activeSkin.assets"
:page="showVoiceShell ? 'voice' : 'home'"
:mount-revision="accessMode"
:context="skinPluginContext"
:actions="skinPluginActions"
:widgets="skinPluginWidgets"
:mount-revision="accessMode"
:context="skinPluginContext"
:actions="skinPluginActions"
:server-add-label="t('addFavoriteServer')"
:on-add-server="openFavoriteServerDialog"
:widgets="skinPluginWidgets"
:read-session-status="readSkinRuntimeSessionStatus"
@surface-change="skinRuntimePluginSurfaceActive = $event"
@restore-skin="switchToBuiltIn"
@@ -334,13 +338,12 @@
v-else-if="showVoiceShell && !skinPluginSurfaceActive && !skinRuntimePluginSurfaceActive"
:class="['app-shell', `mobile-view-${mobileSection}`]"
:data-performance-open="performancePanelOpen ? 'true' : 'false'"
:data-favorite-rail="accessMode === 'open' ? 'true' : 'false'"
:data-favorite-rail="'true'"
data-ws-part="voice.shell"
@click="memberMenu = null"
>
<aside
v-if="accessMode === 'open'"
class="favorite-server-rail"
class="favorite-server-rail"
data-ws-part="voice.favorite-servers.rail"
:aria-label="t('quickServers')"
>
@@ -356,13 +359,14 @@
<button
type="button"
:class="['favorite-server-button', { active: isQuickServerTarget(server) }]"
data-ws-part="voice.favorite-servers.server"
:data-ws-state="isQuickServerTarget(server) ? 'current' : 'idle'"
:data-ws-server-kind="server.isFavorite ? 'favorite' : 'recent'"
:title="server.label + '\n' + server.address"
:aria-label="t('switchToServer', { server: server.label })"
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
data-ws-part="voice.favorite-servers.server"
:data-ws-state="isQuickServerTarget(server) ? 'current' : 'idle'"
:data-ws-server-kind="server.isFavorite ? 'favorite' : 'recent'"
:aria-label="t('switchToServer', { server: server.label })"
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
:aria-disabled="!serverCanSwitch(server)"
:title="serverCanSwitch(server) ? server.label + '\n' + server.address : t('serverSwitchRestricted')"
@click.stop="connectQuickServer(server)"
>
<span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(server.label)"><img v-if="server.serverIcon" :src="server.serverIcon" alt="" aria-hidden="true" /><template v-else>{{ avatarInitial(server.serverName || server.label) }}</template></span>
@@ -388,14 +392,13 @@
data-ws-part="voice.favorite-servers.add"
:aria-label="t('addFavoriteServer')"
:title="t('addFavoriteServer')"
@click.stop="favoriteServerDialogOpen = true"
@click.stop="openFavoriteServerDialog"
><Icon name="plus" :size="20" /></button>
<div class="ws-skin-mount-slot" data-ws-skin-mount="voice.server-rail.after"></div>
</aside>
<nav
v-if="accessMode === 'open'"
class="favorite-server-strip"
class="favorite-server-strip"
data-ws-part="voice.favorite-servers.strip"
:aria-label="t('quickServers')"
>
@@ -410,10 +413,12 @@
:class="['favorite-server-strip-button', { active: isQuickServerTarget(server) }]"
data-ws-part="voice.favorite-servers.strip.server"
:data-ws-state="isQuickServerTarget(server) ? 'current' : 'idle'"
:data-ws-server-kind="server.isFavorite ? 'favorite' : 'recent'"
:aria-label="t('switchToServer', { server: server.label })"
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
:data-ws-server-kind="server.isFavorite ? 'favorite' : 'recent'"
:aria-label="t('switchToServer', { server: server.label })"
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
:aria-disabled="!serverCanSwitch(server)"
:title="serverCanSwitch(server) ? server.label : t('serverSwitchRestricted')"
@click="connectQuickServer(server)"
><span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(server.label)"><img v-if="server.serverIcon" :src="server.serverIcon" alt="" aria-hidden="true" /><template v-else>{{ avatarInitial(server.serverName || server.label) }}</template></span><span>{{ server.label }}</span></button
><button
@@ -433,7 +438,7 @@
data-ws-part="voice.favorite-servers.strip.add"
:aria-label="t('addFavoriteServer')"
:title="t('addFavoriteServer')"
@click="favoriteServerDialogOpen = true"
@click="openFavoriteServerDialog"
><Icon name="plus" :size="18" /></button>
</nav>
@@ -1451,9 +1456,13 @@ const favoriteSwitchLabel = computed(() => quickServers.value.find((server) =>
server.id === currentServerTarget().toLocaleLowerCase(),
)?.label ?? currentServerTarget());
function isQuickServerTarget(server: QuickServer): boolean {
return server.id === currentServerTarget().toLocaleLowerCase();
}
function isQuickServerTarget(server: QuickServer): boolean {
return server.id === currentServerTarget().toLocaleLowerCase();
}
function serverCanSwitch(_server: QuickServer): boolean {
return accessMode.value === "open";
}
const quickServersForDisplay = computed(() => quickServers.value.map((server) => {
const liveInfo = isQuickServerTarget(server) ? voiceServerInfo.value : null;
@@ -1469,8 +1478,12 @@ const quickServersForDisplay = computed(() => quickServers.value.map((server) =>
};
}));
function connectQuickServer(server: QuickServer): void {
if (accessMode.value !== "open" || voiceState.connecting || (voiceState.connected && isQuickServerTarget(server))) return;
function connectQuickServer(server: QuickServer): void {
if (voiceState.connecting || (voiceState.connected && isQuickServerTarget(server))) return;
if (accessMode.value !== "open") {
showToast(t("serverSwitchRestricted"));
return;
}
const target = splitTeamSpeakTarget(server.address);
serverHost.value = target.address;
serverPort.value = target.port || DEFAULT_TEAM_SPEAK_PORT;
@@ -1513,9 +1526,18 @@ function leaveVoiceWorkspace(): void {
doDisconnect();
}
function toggleQuickFavorite(server: QuickServer): void {
void toggleQuickServerFavorite(server);
}
function toggleQuickFavorite(server: QuickServer): void {
void toggleQuickServerFavorite(server);
}
function openFavoriteServerDialog(): void {
if (accessMode.value !== "open") {
showToast(t("serverFeatureAdminDisabled"));
return;
}
if (!showVoiceShell.value || voiceState.connecting || favoriteDialogBusy.value) return;
favoriteServerDialogOpen.value = true;
}
async function submitFavoriteServerDraft(draft: FavoriteServerDraft): Promise<void> {
if (favoriteDialogBusy.value || voiceState.connecting || accessMode.value !== "open") return;
@@ -1552,7 +1574,12 @@ async function submitFavoriteServerDraft(draft: FavoriteServerDraft): Promise<vo
const visiblePokes = computed(() => pokeNotifications.slice(-3));
const skinPluginQuickServers = createSkinPluginQuickServerProjection();
const skinPluginQuickList = computed(() => skinPluginQuickServers.project(quickServersForDisplay.value, isQuickServerTarget));
const skinPluginQuickList = computed(() => skinPluginQuickServers.project(
quickServersForDisplay.value,
isQuickServerTarget,
accessMode.value !== "open",
t("serverSwitchRestricted"),
));
const currentServerDisplayName = computed(() => {
const target = currentServerTarget();
const liveName = safeSkinServerDisplayName(voiceServerInfo.value?.name ?? "", target);
@@ -1657,7 +1684,10 @@ const readSkinRuntimeSessionStatus = (_signal: AbortSignal) => ({
});
function switchQuickServerByOpaqueId(quickServerId: string): void {
if (accessMode.value !== "open") return;
if (accessMode.value !== "open") {
showToast(t("serverSwitchRestricted"));
return;
}
const target = skinPluginQuickServers.resolve(quickServerId);
if (target && quickServers.value.some((server) => server.id === target.id)) connectQuickServer(target);
}