Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 0 additions & 31 deletions src/web-ui/src/infrastructure/api/service-api/SystemAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';


Expand Down Expand Up @@ -172,19 +171,6 @@ export class SystemAPI {
}
}

/** Desktop only: whether the app is registered to launch at OS login. */
async getLaunchAtLoginEnabled(): Promise<boolean> {
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<void> {
if (typeof window === 'undefined' || !('__TAURI__' in window)) {
Expand All @@ -199,23 +185,6 @@ export class SystemAPI {
}
}

/** Desktop only: register or unregister launch at OS login. */
async setLaunchAtLoginEnabled(enabled: boolean): Promise<void> {
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. */
Expand Down
99 changes: 0 additions & 99 deletions src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 <ConfigPageLoading text={t('launchAtLogin.messages.loading')} />;
}

return (
<div className="bitfun-launch-at-login-config">
<div className="bitfun-launch-at-login-config__content">
<ConfigPageMessage message={message} />
<ConfigPageSection
title={t('launchAtLogin.sections.title')}
description={t('launchAtLogin.sections.hint')}
>
<ConfigPageRow
label={t('launchAtLogin.toggleLabel')}
description={t('launchAtLogin.toggleDescription')}
align="center"
>
<Switch
checked={enabled}
onChange={(e) => {
void handleToggle(e.target.checked);
}}
disabled={saving}
/>
</ConfigPageRow>
</ConfigPageSection>
</div>
</div>
);
}

function BasicsAutoUpdateSection() {
const { t } = useTranslation('settings/basics');
const isTauri = typeof window !== 'undefined' && '__TAURI__' in window;
Expand Down Expand Up @@ -813,7 +715,6 @@ const BasicsConfig: React.FC = () => {
<ConfigPageLayout className="bitfun-basics-config">
<ConfigPageHeader title={t('title')} subtitle={t('subtitle')} />
<ConfigPageContent className="bitfun-basics-config__content">
<BasicsLaunchAtLoginSection />
<BasicsAutoUpdateSection />
<BasicsWindowBehaviorSection />
<BasicsLoggingSection />
Expand Down
13 changes: 0 additions & 13 deletions src/web-ui/src/locales/en-US/settings/basics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 0 additions & 13 deletions src/web-ui/src/locales/zh-CN/settings/basics.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,6 @@
"saved": "已保存更新偏好"
}
},
"launchAtLogin": {
"sections": {
"title": "登录时启动",
"hint": "登录本用户后是否自动运行 BitFun"
},
"toggleLabel": "开机自动启动",
"toggleDescription": "登录系统后自动启动 BitFun;具体表现因操作系统而异。",
"messages": {
"loading": "加载中…",
"loadFailed": "无法读取开机启动设置",
"saveFailed": "无法更新开机启动设置"
}
},
"logging": {
"sections": {
"logging": "日志",
Expand Down
13 changes: 0 additions & 13 deletions src/web-ui/src/locales/zh-TW/settings/basics.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,6 @@
"flowChatPxOption": "{{n}} px"
}
},
"launchAtLogin": {
"sections": {
"title": "登錄時啟動",
"hint": "登錄本用戶後是否自動運行 BitFun"
},
"toggleLabel": "開機自動啟動",
"toggleDescription": "登錄系統後自動啟動 BitFun;具體表現因操作系統而異。",
"messages": {
"loading": "載入中…",
"loadFailed": "無法讀取開機啟動設置",
"saveFailed": "無法更新開機啟動設置"
}
},
"logging": {
"sections": {
"logging": "日誌",
Expand Down
Loading