From 33f00a1136c9f7e501b989d432b709d632905304 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 12 Jul 2026 02:09:04 +0800
Subject: [PATCH] chore(mas): initialize split project metadata
---
C1.source/privatevoice.src/frontend/src/App.svelte | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/C1.source/privatevoice.src/frontend/src/App.svelte b/C1.source/privatevoice.src/frontend/src/App.svelte
index 8406d60..58a1c89 100755
--- a/C1.source/privatevoice.src/frontend/src/App.svelte
+++ b/C1.source/privatevoice.src/frontend/src/App.svelte
@@ -19,38 +19,40 @@
let showOnboarding = $state(false)
onMount(() => {
+ const offEvents: Array<() => void> = []
+
Call.ByName('voicesnap/services.ConfigService.GetLanguageSettings').then((settings: any) => {
applyLanguageSettings(settings)
}).catch(() => {
languageReady = true
})
- Events.On('indicator:show', (ev: any) => {
+ offEvents.push(Events.On('indicator:show', (ev: any) => {
indicatorVisible.set(true)
if (ev?.data?.status) {
indicatorStatus.set(ev.data.status)
}
- })
+ }))
- Events.On('indicator:hide', () => {
+ offEvents.push(Events.On('indicator:hide', () => {
indicatorVisible.set(false)
- })
+ }))
- Events.On('indicator:status', (ev: any) => {
+ offEvents.push(Events.On('indicator:status', (ev: any) => {
const data = ev?.data
if (data?.status) {
indicatorStatus.set(data.status)
}
- if (data?.hotkeyName) {
+ if (typeof data?.hotkeyName === 'string') {
hotkeyName.set(data.hotkeyName)
}
- })
+ }))
- Events.On('indicator:volume', (ev: any) => {
+ offEvents.push(Events.On('indicator:volume', (ev: any) => {
indicatorVolume.set(ev?.data ?? 0)
- })
+ }))
- Events.On('engine:status', (ev: any) => {
+ offEvents.push(Events.On('engine:status', (ev: any) => {
const data = ev?.data
if (data?.status) {
engineStatus.set(data.status as any)
@@ -61,23 +63,24 @@
if (data?.hardwareInfo) {
engineHardwareInfo.set(data.hardwareInfo)
}
- })
+ }))
- Events.On('device:changed', (ev: any) => {
+ offEvents.push(Events.On('device:changed', (ev: any) => {
if (ev?.data?.name) {
deviceName.set(ev.data.name)
}
- })
+ }))
- Events.On('update:available', (ev: any) => {
+ offEvents.push(Events.On('update:available', (ev: any) => {
const data = ev?.data as UpdateInfo
updateAvailable.set(data)
showUpdateDialog = true
- })
+ }))
- window.addEventListener('hashchange', () => {
+ const onHashChange = () => {
isIndicatorRoute = window.location.hash === '#/indicator'
- })
+ }
+ window.addEventListener('hashchange', onHashChange)
// Query engine status on mount (events emitted before frontend load are lost)
Call.ByName('voicesnap/services.EngineService.GetStatus').then((data: any) => {
@@ -94,12 +97,17 @@
refreshCurrentModelAvailability()
- // Load actual hotkey name from backend (store default is generic "Ctrl")
+ // Load actual hotkey name from backend; an empty name means no trigger key is set yet.
Call.ByName('voicesnap/services.HotkeyService.GetHotkeyName').then((name: any) => {
- if (name) {
+ if (typeof name === 'string') {
hotkeyName.set(name)
}
})
+
+ return () => {
+ for (const off of offEvents) off()
+ window.removeEventListener('hashchange', onHashChange)
+ }
})
function applyLanguageSettings(settings: any) {
--
Gitblit v1.9.3