mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
Add server navigation controls across modes
This commit is contained in:
1 parent
c6eeb49f44
commit
319a16f384
18 files changed
+372
-63
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user