From 115e3fb3bde3777ef9dec32e9e802f0c2790f5e0 Mon Sep 17 00:00:00 2001 From: SWangHash <88996709+SWangHash@users.noreply.github.com> Date: Thu, 18 Jun 2026 15:48:13 +0800 Subject: [PATCH] feat(settings): remove launch-at-login setting --- src/web-ui/package.json | 1 - .../api/service-api/SystemAPI.ts | 31 ------ .../config/components/BasicsConfig.tsx | 99 ------------------- .../src/locales/en-US/settings/basics.json | 13 --- .../src/locales/zh-CN/settings/basics.json | 13 --- .../src/locales/zh-TW/settings/basics.json | 13 --- 6 files changed, 170 deletions(-) diff --git a/src/web-ui/package.json b/src/web-ui/package.json index eaec6ccf42..4d5d1df67d 100644 --- a/src/web-ui/package.json +++ b/src/web-ui/package.json @@ -21,7 +21,6 @@ "@monaco-editor/react": "^4.6.0", "@tanstack/react-virtual": "^3.13.23", "@tauri-apps/api": "^2.10.1", - "@tauri-apps/plugin-autostart": "^2.0.0", "@tauri-apps/plugin-dialog": "^2.6.0", "@tauri-apps/plugin-fs": "^2.0.0", "@tauri-apps/plugin-log": "^2.8.0", diff --git a/src/web-ui/src/infrastructure/api/service-api/SystemAPI.ts b/src/web-ui/src/infrastructure/api/service-api/SystemAPI.ts index 41d7d8bc0e..c0b2d73421 100644 --- a/src/web-ui/src/infrastructure/api/service-api/SystemAPI.ts +++ b/src/web-ui/src/infrastructure/api/service-api/SystemAPI.ts @@ -3,7 +3,6 @@ import { api } from './ApiClient'; import { createTauriCommandError } from '../errors/TauriCommandError'; import { openUrl } from '@tauri-apps/plugin-opener'; -import { disable as autostartDisable, enable as autostartEnable, isEnabled as autostartIsEnabled } from '@tauri-apps/plugin-autostart'; import { createLogger } from '@/shared/utils/logger'; @@ -172,19 +171,6 @@ export class SystemAPI { } } - /** Desktop only: whether the app is registered to launch at OS login. */ - async getLaunchAtLoginEnabled(): Promise { - if (typeof window === 'undefined' || !('__TAURI__' in window)) { - return false; - } - try { - return await autostartIsEnabled(); - } catch (error) { - log.error('Failed to read launch-at-login state', error); - throw createTauriCommandError('autostart_is_enabled', error); - } - } - /** Desktop only: send an OS-level desktop notification. */ async sendSystemNotification(title: string, body?: string): Promise { if (typeof window === 'undefined' || !('__TAURI__' in window)) { @@ -199,23 +185,6 @@ export class SystemAPI { } } - /** Desktop only: register or unregister launch at OS login. */ - async setLaunchAtLoginEnabled(enabled: boolean): Promise { - if (typeof window === 'undefined' || !('__TAURI__' in window)) { - return; - } - try { - if (enabled) { - await autostartEnable(); - } else { - await autostartDisable(); - } - } catch (error) { - log.error('Failed to set launch-at-login', { enabled, error }); - throw createTauriCommandError('autostart_set', error, { enabled }); - } - } - // ─── Window / Tray behavior ──────────────────────────────────────────────── /** Desktop only: immediately quit the application. */ diff --git a/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx b/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx index 73aac14764..5e9a55e15e 100644 --- a/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx +++ b/src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx @@ -11,7 +11,6 @@ import { ConfigPageMessage, } from '@/component-library'; import { configAPI, workspaceAPI } from '@/infrastructure/api'; -import { systemAPI } from '@/infrastructure/api/service-api/SystemAPI'; import type { CloseBehavior } from '@/infrastructure/api/service-api/SystemAPI'; import { getTerminalService, @@ -38,103 +37,6 @@ import './BasicsConfig.scss'; const log = createLogger('BasicsConfig'); -function BasicsLaunchAtLoginSection() { - const { t } = useTranslation('settings/basics'); - const isTauri = typeof window !== 'undefined' && '__TAURI__' in window; - const [enabled, setEnabled] = useState(false); - const [loading, setLoading] = useState(true); - const [saving, setSaving] = useState(false); - const [message, setMessage] = useState<{ type: 'success' | 'error' | 'info'; text: string } | null>(null); - - const showMessage = useCallback((type: 'success' | 'error' | 'info', text: string) => { - setMessage({ type, text }); - setTimeout(() => setMessage(null), 3000); - }, []); - - useEffect(() => { - if (!isTauri) { - setLoading(false); - return; - } - - let cancelled = false; - void (async () => { - try { - setLoading(true); - const v = await systemAPI.getLaunchAtLoginEnabled(); - if (!cancelled) { - setEnabled(v); - } - } catch (error) { - log.error('Failed to load launch-at-login state', error); - if (!cancelled) { - showMessage('error', t('launchAtLogin.messages.loadFailed')); - } - } finally { - if (!cancelled) { - setLoading(false); - } - } - })(); - - return () => { - cancelled = true; - }; - }, [isTauri, showMessage, t]); - - const handleToggle = useCallback( - async (next: boolean) => { - const previous = enabled; - setEnabled(next); - setSaving(true); - try { - await systemAPI.setLaunchAtLoginEnabled(next); - } catch (error) { - setEnabled(previous); - log.error('Failed to set launch-at-login', { next, error }); - showMessage('error', t('launchAtLogin.messages.saveFailed')); - } finally { - setSaving(false); - } - }, - [enabled, showMessage, t] - ); - - if (!isTauri) { - return null; - } - - if (loading) { - return ; - } - - return ( -
-
- - - - { - void handleToggle(e.target.checked); - }} - disabled={saving} - /> - - -
-
- ); -} - function BasicsAutoUpdateSection() { const { t } = useTranslation('settings/basics'); const isTauri = typeof window !== 'undefined' && '__TAURI__' in window; @@ -813,7 +715,6 @@ const BasicsConfig: React.FC = () => { - diff --git a/src/web-ui/src/locales/en-US/settings/basics.json b/src/web-ui/src/locales/en-US/settings/basics.json index ff962479a5..2dae0332bc 100644 --- a/src/web-ui/src/locales/en-US/settings/basics.json +++ b/src/web-ui/src/locales/en-US/settings/basics.json @@ -87,19 +87,6 @@ "saved": "Update preference saved" } }, - "launchAtLogin": { - "sections": { - "title": "Login", - "hint": "Start BitFun when you sign in to this account" - }, - "toggleLabel": "Launch at login", - "toggleDescription": "Automatically start BitFun after you log in. Exact behavior depends on your operating system.", - "messages": { - "loading": "Loading...", - "loadFailed": "Failed to read launch-at-login setting", - "saveFailed": "Failed to update launch-at-login setting" - } - }, "logging": { "sections": { "logging": "Logging", diff --git a/src/web-ui/src/locales/zh-CN/settings/basics.json b/src/web-ui/src/locales/zh-CN/settings/basics.json index b0e1d937f9..6d0fe7c4eb 100644 --- a/src/web-ui/src/locales/zh-CN/settings/basics.json +++ b/src/web-ui/src/locales/zh-CN/settings/basics.json @@ -87,19 +87,6 @@ "saved": "已保存更新偏好" } }, - "launchAtLogin": { - "sections": { - "title": "登录时启动", - "hint": "登录本用户后是否自动运行 BitFun" - }, - "toggleLabel": "开机自动启动", - "toggleDescription": "登录系统后自动启动 BitFun;具体表现因操作系统而异。", - "messages": { - "loading": "加载中…", - "loadFailed": "无法读取开机启动设置", - "saveFailed": "无法更新开机启动设置" - } - }, "logging": { "sections": { "logging": "日志", diff --git a/src/web-ui/src/locales/zh-TW/settings/basics.json b/src/web-ui/src/locales/zh-TW/settings/basics.json index 12af5df84e..7aec1194d9 100644 --- a/src/web-ui/src/locales/zh-TW/settings/basics.json +++ b/src/web-ui/src/locales/zh-TW/settings/basics.json @@ -73,19 +73,6 @@ "flowChatPxOption": "{{n}} px" } }, - "launchAtLogin": { - "sections": { - "title": "登錄時啟動", - "hint": "登錄本用戶後是否自動運行 BitFun" - }, - "toggleLabel": "開機自動啟動", - "toggleDescription": "登錄系統後自動啟動 BitFun;具體表現因操作系統而異。", - "messages": { - "loading": "載入中…", - "loadFailed": "無法讀取開機啟動設置", - "saveFailed": "無法更新開機啟動設置" - } - }, "logging": { "sections": { "logging": "日誌",