From d14931bf1b510b27c3df55459bb7cd4d97eb31d4 Mon Sep 17 00:00:00 2001 From: digua Date: Wed, 13 May 2026 20:39:46 +0800 Subject: [PATCH] fix: guard Electron-specific calls in BasicSettingsTab for web mode Add IS_ELECTRON guards around window.api.setThemeSource, window.api.app.getOpenAtLogin, and window.api.app.setOpenAtLogin to prevent crashes when opening settings in web mode. --- src/components/common/Settings/BasicSettingsTab.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/common/Settings/BasicSettingsTab.vue b/src/components/common/Settings/BasicSettingsTab.vue index 173705e1..aa8c317e 100644 --- a/src/components/common/Settings/BasicSettingsTab.vue +++ b/src/components/common/Settings/BasicSettingsTab.vue @@ -8,6 +8,7 @@ import { useColorMode } from '@vueuse/core' import { availableLocales, type LocaleType } from '@/i18n' import NetworkSettingsSection from './NetworkSettingsSection.vue' import UITabs from '@/components/UI/Tabs.vue' +import { IS_ELECTRON } from '@/utils/platform' const { t } = useI18n() @@ -22,6 +23,10 @@ const openAtLogin = ref(false) const isPackaged = ref(true) onMounted(async () => { + if (!IS_ELECTRON) { + isPackaged.value = false + return + } try { const enabled = await window.api.app.getOpenAtLogin() openAtLogin.value = enabled @@ -31,6 +36,7 @@ onMounted(async () => { }) async function handleAutoLaunchChange(enabled: boolean) { + if (!IS_ELECTRON) return const { success } = await window.api.app.setOpenAtLogin(enabled) if (!success) { openAtLogin.value = !enabled @@ -77,11 +83,12 @@ const toolsPanelPositionOptions = computed(() => [ { label: t('settings.basic.toolsPanel.positionSide'), value: 'side' }, ]) -// Sync theme with main process +// Sync theme with main process (Electron only) import { watch } from 'vue' watch( colorMode, (val) => { + if (!IS_ELECTRON) return const mode = val === 'auto' ? 'system' : (val as 'light' | 'dark') window.api.setThemeSource(mode) },