mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
fix: improve voice playback, diagnostics and workspace controls
This commit is contained in:
1 parent
72d7e6e013
commit
e82116239a
34 files changed
+502
-147
No files matched your search
@@ -1,10 +1,14 @@
|
||||
<template>
|
||||
<Teleport to="#webspeak-plugin-toolbar">
|
||||
<div v-if="thirdPartyAllowed && connected && sessionToken" class="ws-plugin-toolbar">
|
||||
<button ref="launcher" class="header-action ws-plugin-toolbar-trigger" type="button" :title="tr('title')" :aria-label="tr('title')" :aria-expanded="visible" @click="toggle">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z" /></svg>
|
||||
</button>
|
||||
<button v-for="entry in pinnedApps" :key="entry.manifest.id" class="header-action ws-plugin-toolbar-shortcut" type="button" :title="entry.manifest.name" :aria-label="entry.manifest.name" :disabled="busy || entry.runtime.state === 'failed'" @click="launch(entry.manifest.id)">{{ entry.manifest.name.slice(0, 1).toUpperCase() }}</button>
|
||||
</div>
|
||||
</Teleport>
|
||||
<Teleport to="body">
|
||||
<div v-if="thirdPartyAllowed && connected && sessionToken" class="ws-plugin-overlay" :data-plugin-theme="theme">
|
||||
<button ref="launcher" class="ws-plugin-launcher" :style="launcherPosition" type="button" :title="tr('title')" :aria-label="tr('title')" :aria-expanded="visible" @pointerdown="startLauncherDrag" @lostpointercapture="endDrag" @click="toggle">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z" /></svg>
|
||||
<span>{{ tr('title') }}</span><i v-if="current" />
|
||||
</button>
|
||||
<section v-show="visible" ref="windowElement" class="ws-plugin-window" :class="{ 'is-maximized': maximized, 'is-dragging': dragging }" :style="position" role="dialog" :aria-label="current && appView ? current.manifest.name : tr('title')" tabindex="-1" @keydown.esc.stop="minimize">
|
||||
<header class="ws-plugin-titlebar" @pointerdown="startDrag" @lostpointercapture="endDrag" @dblclick="toggleMaximize">
|
||||
<span class="ws-plugin-mark" aria-hidden="true">◈</span>
|
||||
@@ -55,14 +59,14 @@ const tr = (key: PluginTextKey) => pluginTranslations[props.language][key];
|
||||
const ui = computed(() => pluginWindowTranslations[props.language]);
|
||||
const windowElement = ref<HTMLElement | null>(null), launcher = ref<HTMLButtonElement | null>(null), frame = ref<HTMLIFrameElement | null>(null);
|
||||
const available = shallowRef<AvailablePluginApp[]>([]), current = shallowRef<PluginAppLaunch | null>(null);
|
||||
const pinnedApps = computed(() => available.value.filter(entry => entry.toolbarPinned));
|
||||
const busy = ref(false), error = ref(''), theme = ref<'light' | 'dark'>('light');
|
||||
const visible = ref(false), maximized = ref(false), appView = ref(false), dragging = ref(false), search = ref('');
|
||||
const position = ref<Record<string, string>>({});
|
||||
const launcherPosition = ref<Record<string, string>>({});
|
||||
const filtered = computed(() => available.value.filter(entry => `${entry.manifest.name} ${entry.manifest.description}`.toLocaleLowerCase().includes(search.value.trim().toLocaleLowerCase())));
|
||||
let epoch = 0, pending: AbortController | undefined, opening: { client: PluginAppClient; key: string } | undefined, observer: MutationObserver | undefined;
|
||||
let drag: { id: number; x: number; y: number; left: number; top: number; handle: HTMLElement; kind: 'window' | 'launcher'; moved: boolean } | undefined;
|
||||
let suppressLauncherClick = false, resizeObserver: ResizeObserver | undefined;
|
||||
let drag: { id: number; x: number; y: number; left: number; top: number; handle: HTMLElement; moved: boolean } | undefined;
|
||||
let resizeObserver: ResizeObserver | undefined;
|
||||
const browserFeatures = computed(() => {
|
||||
const policy = (document as Document & { featurePolicy?: { features(): string[] } }).featurePolicy;
|
||||
const features = policy?.features() ?? ['fullscreen', 'autoplay', 'camera', 'microphone', 'display-capture', 'clipboard-read', 'clipboard-write', 'geolocation', 'screen-wake-lock'];
|
||||
@@ -84,7 +88,6 @@ async function refresh() {
|
||||
finally { if (owner === epoch) { busy.value = false; pending = undefined; } }
|
||||
}
|
||||
function toggle() {
|
||||
if (suppressLauncherClick) { suppressLauncherClick = false; return; }
|
||||
if (visible.value) { minimize(); return; }
|
||||
detectTheme(); visible.value = true;
|
||||
if (!current.value) { appView.value = false; void refresh(); }
|
||||
@@ -98,6 +101,7 @@ function stop() {
|
||||
}
|
||||
async function launch(id: string) {
|
||||
if (!thirdPartyAllowed.value) return;
|
||||
detectTheme(); visible.value = true;
|
||||
if (current.value?.manifest.id === id) { appView.value = true; return; }
|
||||
stop(); const owner = ++epoch, controller = new AbortController(), service = client(), key = crypto.randomUUID(); pending = controller; opening = { client: service, key }; busy.value = true; error.value = '';
|
||||
try {
|
||||
@@ -115,10 +119,6 @@ function message(event: MessageEvent) {
|
||||
}
|
||||
function appearance() { if (current.value && opening) void opening.client.appearance(current.value.id, theme.value, props.language).catch(() => undefined); }
|
||||
function fitWindow() {
|
||||
if (launcher.value && launcherPosition.value.left) {
|
||||
const box = launcher.value.getBoundingClientRect();
|
||||
launcherPosition.value = { left: `${Math.max(8, Math.min(box.left, innerWidth - box.width - 8))}px`, top: `${Math.max(8, Math.min(box.top, innerHeight - box.height - 8))}px`, right: 'auto', bottom: 'auto' };
|
||||
}
|
||||
if (!visible.value || maximized.value || !windowElement.value) return;
|
||||
const box = windowElement.value.getBoundingClientRect();
|
||||
position.value = { left: `${Math.max(8, Math.min(box.left, innerWidth - box.width - 8))}px`, top: `${Math.max(8, Math.min(box.top, innerHeight - box.height - 8))}px`, transform: 'none' };
|
||||
@@ -128,34 +128,34 @@ function startDrag(event: PointerEvent) {
|
||||
if (event.button !== 0 || maximized.value || (event.target as HTMLElement).closest('button')) return;
|
||||
const box = windowElement.value?.getBoundingClientRect(); if (!box) return;
|
||||
event.preventDefault(); const handle = event.currentTarget as HTMLElement;
|
||||
drag = { id: event.pointerId, x: event.clientX, y: event.clientY, left: box.left, top: box.top, handle, kind: 'window', moved: false }; dragging.value = true;
|
||||
drag = { id: event.pointerId, x: event.clientX, y: event.clientY, left: box.left, top: box.top, handle, moved: false }; dragging.value = true;
|
||||
handle.setPointerCapture(event.pointerId);
|
||||
}
|
||||
function startLauncherDrag(event: PointerEvent) {
|
||||
if (event.button !== 0 || !launcher.value) return;
|
||||
const box = launcher.value.getBoundingClientRect(); suppressLauncherClick = false;
|
||||
drag = { id: event.pointerId, x: event.clientX, y: event.clientY, left: box.left, top: box.top, handle: launcher.value, kind: 'launcher', moved: false };
|
||||
launcher.value.setPointerCapture(event.pointerId);
|
||||
}
|
||||
function moveDrag(event: PointerEvent) {
|
||||
if (!drag || drag.id !== event.pointerId) return;
|
||||
const target = drag.kind === 'launcher' ? launcher.value : windowElement.value; if (!target) return;
|
||||
const target = windowElement.value; if (!target) return;
|
||||
if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) < 5 && !drag.moved) return;
|
||||
drag.moved = true; const box = target.getBoundingClientRect();
|
||||
const next = { left: `${Math.max(8, Math.min(drag.left + event.clientX - drag.x, innerWidth - box.width - 8))}px`, top: `${Math.max(8, Math.min(drag.top + event.clientY - drag.y, innerHeight - box.height - 8))}px`, transform: 'none' };
|
||||
if (drag.kind === 'launcher') launcherPosition.value = { ...next, right: 'auto', bottom: 'auto' }; else position.value = next;
|
||||
position.value = next;
|
||||
}
|
||||
function endDrag() {
|
||||
const old = drag; drag = undefined; dragging.value = false;
|
||||
if (old?.kind === 'launcher' && old.moved) suppressLauncherClick = true;
|
||||
if (old?.handle.hasPointerCapture(old.id)) old.handle.releasePointerCapture(old.id);
|
||||
}
|
||||
watch(windowElement, element => { resizeObserver?.disconnect(); if (element) { resizeObserver = new ResizeObserver(fitWindow); resizeObserver.observe(element); } });
|
||||
watch(() => [props.sessionToken, props.gatewayUrl, props.connected] as const, close);
|
||||
watch(thirdPartyAllowed, allowed => { if (!allowed) close(); }, { flush: 'sync' });
|
||||
watch(() => [props.sessionToken, props.gatewayUrl, props.connected] as const, () => {
|
||||
close();
|
||||
if (props.connected && thirdPartyAllowed.value) void refresh();
|
||||
});
|
||||
watch(thirdPartyAllowed, allowed => {
|
||||
if (!allowed) close();
|
||||
else if (props.connected) void refresh();
|
||||
}, { flush: 'sync' });
|
||||
watch(() => props.language, appearance); watch(theme, appearance);
|
||||
onMounted(() => {
|
||||
detectTheme(); window.addEventListener('message', message); window.addEventListener('resize', fitWindow); window.addEventListener('pointermove', moveDrag); window.addEventListener('pointerup', endDrag); window.addEventListener('pointercancel', endDrag); window.addEventListener('blur', endDrag);
|
||||
if (props.connected && thirdPartyAllowed.value) void refresh();
|
||||
observer = new MutationObserver(detectTheme); observer.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: ['data-ws-skin', 'data-theme'] });
|
||||
});
|
||||
onBeforeUnmount(() => { stop(); endDrag(); observer?.disconnect(); resizeObserver?.disconnect(); window.removeEventListener('message', message); window.removeEventListener('resize', fitWindow); window.removeEventListener('pointermove', moveDrag); window.removeEventListener('pointerup', endDrag); window.removeEventListener('pointercancel', endDrag); window.removeEventListener('blur', endDrag); });
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<details :open="expanded===plugin.manifest.id" @toggle="onToggle($event,plugin.manifest.id)"><summary><Icon name="settings" :size="16" />{{ text('configure') }}<Icon class="plugin-chevron" name="chevron-down" :size="15" /></summary><fieldset :disabled="model.busy.value">
|
||||
<div class="plugin-enable-row"><div><strong>{{ tr('enabled') }}</strong><p>{{ text('review') }}</p></div><label class="plugin-switch"><input v-model="model.drafts[plugin.manifest.id].enabled" type="checkbox" :aria-label="tr('enabled')" /><span></span></label></div>
|
||||
<label class="plugin-trust"><input v-model="model.drafts[plugin.manifest.id].trusted" type="checkbox" />{{ tr('trust') }}</label><p class="plugin-trust-note">{{ tr('enableNote') }}</p>
|
||||
<label class="plugin-trust"><input v-model="model.drafts[plugin.manifest.id].toolbarPinned" type="checkbox" />{{ tr('toolbarPin') }}</label>
|
||||
<label>{{ tr('scope') }}<select v-model="model.drafts[plugin.manifest.id].scope"><option v-for="scope in plugin.manifest.scopes" :key="scope" :value="scope">{{ tr(scope) }}</option></select></label>
|
||||
<label v-if="model.drafts[plugin.manifest.id].scope==='server'">{{ tr('targets') }}<textarea v-model="model.drafts[plugin.manifest.id].targets" rows="3" maxlength="15000" placeholder="voice.example.com:9987"></textarea></label>
|
||||
<details class="plugin-advanced"><summary>{{ text('advanced') }}<Icon name="chevron-down" :size="14" /></summary><label>{{ tr('config') }}<textarea v-model="model.drafts[plugin.manifest.id].config" rows="5" maxlength="65536" spellcheck="false"></textarea></label><template v-if="plugin.manifest.server"><label>{{ tr('privateConfig') }}<small>{{ tr(plugin.settings.hasServerConfig?'secretSaved':'secretEmpty') }}</small><select v-model="model.drafts[plugin.manifest.id].serverConfigAction"><option value="keep">{{ tr('keep') }}</option><option value="replace">{{ tr('replace') }}</option><option value="remove">{{ tr('erase') }}</option></select><textarea v-if="model.drafts[plugin.manifest.id].serverConfigAction==='replace'" v-model="model.drafts[plugin.manifest.id].serverConfig" rows="5" maxlength="65536" spellcheck="false" autocomplete="off" autocapitalize="off" autocorrect="off"></textarea></label></template></details>
|
||||
|
||||
@@ -50,15 +50,14 @@
|
||||
@input="onInputVolume"
|
||||
/>
|
||||
<div class="dock-panel-divider"></div>
|
||||
<label class="dock-switch-row"
|
||||
><span
|
||||
><strong>{{ t("noiseSuppression") }}</strong></span
|
||||
><input
|
||||
type="checkbox"
|
||||
:checked="noiseSuppressionEnabled"
|
||||
:aria-label="t('noiseSuppression')"
|
||||
@change="onNoiseSuppressionToggle"
|
||||
/></label>
|
||||
<label class="dock-switch-row">
|
||||
<span><strong>{{ t("noiseSuppression") }}</strong></span>
|
||||
<select class="noise-suppression-level" :value="noiseSuppressionLevel" :aria-label="t('noiseSuppression')" @change="onNoiseSuppressionChange">
|
||||
<option value="off">{{ t("noiseSuppressionOff") }}</option>
|
||||
<option value="standard">{{ t("noiseSuppressionStandard") }}</option>
|
||||
<option value="strong">{{ t("noiseSuppressionStrong") }}</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@@ -132,12 +131,12 @@ import type { useVoiceWebSocket } from "../../composables/useVoiceWebSocket.js";
|
||||
import type { useWebClientAudioControls } from "../../composables/useWebClientAudioControls.js";
|
||||
|
||||
const props = defineProps<{
|
||||
model: Pick<ReturnType<typeof useVoiceWebSocket>, "microphoneMuted" | "inputVolume" | "outputVolume" | "outputMuted" | "noiseSuppressionEnabled" | "accompanimentActive">;
|
||||
controls: Pick<ReturnType<typeof useWebClientAudioControls>, "toggleMicrophone" | "toggleNoiseSuppression" | "onInputVolume" | "onOutputVolume" | "onNoiseSuppressionToggle" | "toggleAccompaniment">;
|
||||
model: Pick<ReturnType<typeof useVoiceWebSocket>, "microphoneMuted" | "inputVolume" | "outputVolume" | "outputMuted" | "noiseSuppressionLevel" | "accompanimentActive">;
|
||||
controls: Pick<ReturnType<typeof useWebClientAudioControls>, "toggleMicrophone" | "toggleNoiseSuppression" | "onInputVolume" | "onOutputVolume" | "onNoiseSuppressionChange" | "toggleAccompaniment">;
|
||||
t: (key: string) => string;
|
||||
rangeStyle: (value: number, max: number) => Record<string, string>;
|
||||
}>();
|
||||
const { microphoneMuted, inputVolume, outputVolume, outputMuted, noiseSuppressionEnabled, accompanimentActive } = props.model;
|
||||
const { toggleMicrophone, onInputVolume, onOutputVolume, onNoiseSuppressionToggle, toggleAccompaniment } = props.controls;
|
||||
const { microphoneMuted, inputVolume, outputVolume, outputMuted, noiseSuppressionLevel, accompanimentActive } = props.model;
|
||||
const { toggleMicrophone, onInputVolume, onOutputVolume, onNoiseSuppressionChange, toggleAccompaniment } = props.controls;
|
||||
const emit = defineEmits<{ settings: []; outputMute: [] }>();
|
||||
</script>
|
||||
@@ -76,16 +76,14 @@
|
||||
/>
|
||||
{{ microphoneMuted ? t("unmuteMic") : t("muteMic") }}</button
|
||||
></div
|
||||
><label
|
||||
class="noise-suppression-toggle settings-form-row"
|
||||
><span
|
||||
><strong>{{ t("noiseSuppression") }}</strong
|
||||
><small>{{ t("noiseSuppressionHint") }}</small></span
|
||||
><input
|
||||
type="checkbox"
|
||||
:checked="noiseSuppressionEnabled"
|
||||
:aria-label="t('noiseSuppression')"
|
||||
@change="onNoiseSuppressionToggle" /></label
|
||||
><label class="settings-form-row">
|
||||
<span><strong>{{ t("noiseSuppression") }}</strong><small>{{ t("noiseSuppressionHint") }}</small></span>
|
||||
<select class="noise-suppression-level" :value="noiseSuppressionLevel" :aria-label="t('noiseSuppression')" @change="onNoiseSuppressionChange">
|
||||
<option value="off">{{ t("noiseSuppressionOff") }}</option>
|
||||
<option value="standard">{{ t("noiseSuppressionStandard") }}</option>
|
||||
<option value="strong">{{ t("noiseSuppressionStrong") }}</option>
|
||||
</select>
|
||||
</label
|
||||
><div class="settings-form-row settings-range-form-row"
|
||||
><label class="settings-label">{{ t("inputVolume") }}</label
|
||||
><div class="settings-form-control"
|
||||
@@ -265,7 +263,7 @@ type AudioSettingsState = Pick<ReturnType<typeof useVoiceWebSocket>,
|
||||
| "audioPermission"
|
||||
| "audioContextState"
|
||||
| "microphoneMuted"
|
||||
| "noiseSuppressionEnabled"
|
||||
| "noiseSuppressionLevel"
|
||||
| "inputVolume"
|
||||
| "outputVolume"
|
||||
| "voxThreshold"
|
||||
@@ -277,7 +275,7 @@ type AudioSettingsState = Pick<ReturnType<typeof useVoiceWebSocket>,
|
||||
type AudioSettingsControls = Pick<ReturnType<typeof useWebClientAudioControls>,
|
||||
| "settingsError"
|
||||
| "onInputVolume"
|
||||
| "onNoiseSuppressionToggle"
|
||||
| "onNoiseSuppressionChange"
|
||||
| "onOutputVolume"
|
||||
| "onVoxThreshold"
|
||||
| "onNotificationVolume"
|
||||
@@ -310,7 +308,7 @@ const {
|
||||
audioPermission,
|
||||
audioContextState,
|
||||
microphoneMuted,
|
||||
noiseSuppressionEnabled,
|
||||
noiseSuppressionLevel,
|
||||
inputVolume,
|
||||
outputVolume,
|
||||
voxThreshold,
|
||||
@@ -322,7 +320,7 @@ const {
|
||||
const {
|
||||
settingsError: audioSettingsError,
|
||||
onInputVolume,
|
||||
onNoiseSuppressionToggle,
|
||||
onNoiseSuppressionChange,
|
||||
onOutputVolume,
|
||||
onVoxThreshold,
|
||||
onNotificationVolume,
|
||||
|
||||
@@ -33,15 +33,21 @@
|
||||
><div
|
||||
><strong>{{ t("voiceStatus") }}</strong
|
||||
><small>{{ t("voiceStatusHint") }}</small></div
|
||||
><button
|
||||
><div class="performance-panel-tools"><button
|
||||
type="button"
|
||||
class="performance-refresh"
|
||||
:title="t('exportAudioTrace')"
|
||||
:aria-label="t('exportAudioTrace')"
|
||||
:disabled="!traceEvents.length"
|
||||
@click="exportTrace"
|
||||
><Icon name="download" :size="15" /></button><button
|
||||
type="button"
|
||||
class="performance-refresh"
|
||||
:title="t('measureNow')"
|
||||
:aria-label="t('measureNow')"
|
||||
:disabled="performanceRunning"
|
||||
@click="refreshPerformanceProbe"
|
||||
><Icon
|
||||
name="refresh"
|
||||
:size="15" /></button
|
||||
><Icon name="refresh" :size="15" /></button></div
|
||||
></header>
|
||||
<div
|
||||
class="voice-status-summary"
|
||||
@@ -147,6 +153,7 @@
|
||||
: t("voiceStatusWaiting")
|
||||
}}</p
|
||||
>
|
||||
<p class="performance-status">{{ t("backgroundVoiceHint") }} · {{ t("audioTraceHint") }}</p>
|
||||
<section
|
||||
v-if="showScreenShare && screenShareWebRtcStats.peers.length"
|
||||
class="webrtc-stats"
|
||||
@@ -224,7 +231,7 @@ import type { useWebClientPerformance } from "../../composables/useWebClientPerf
|
||||
import type { ScreenShareWebRtcStats } from "../../composables/useVoiceWebSocket.js";
|
||||
const props = defineProps<{ model: ReturnType<typeof useWebClientPerformance>; screenShareWebRtcStats: ScreenShareWebRtcStats; showScreenShare?: boolean; t: (key: string) => string }>();
|
||||
const showScreenShare = props.showScreenShare !== false;
|
||||
const { panelOpen: performancePanelOpen, running: performanceRunning, stats: performanceStats, togglePanel: togglePerformancePanel, refresh: refreshPerformanceProbe } = props.model;
|
||||
const { panelOpen: performancePanelOpen, running: performanceRunning, stats: performanceStats, traceEvents, togglePanel: togglePerformancePanel, refresh: refreshPerformanceProbe, exportTrace } = props.model;
|
||||
const root = ref<HTMLElement | null>(null);
|
||||
const trigger = ref<HTMLButtonElement | null>(null);
|
||||
const t = props.t;
|
||||
|
||||
Reference in new issue
Block a user