fix(settings): persist silent startup preference
This commit is contained in:
1 parent
f9b389781f
commit
e01bf54a54
6 files changed
+135
-4
No files matched your search
@@ -349,6 +349,8 @@ export const jaOverrides = {
|
||||
'config.software.title': 'ソフトウェア設定',
|
||||
'config.software.autostart': 'システム起動時に開始',
|
||||
'config.software.autostartDescription': 'サインイン後に EasyCLIProxyAPI を自動的に起動します',
|
||||
'config.software.silentStart': 'サイレント起動',
|
||||
'config.software.silentStartDescription': 'メインウィンドウを表示せず、システムトレイで直接起動します',
|
||||
'config.software.closeBehavior': '終了動作',
|
||||
'config.software.closeBehaviorDescription': 'ウィンドウを閉じたときにアプリを終了するか、システムトレイで実行を続けるかを選択します',
|
||||
'config.software.behavior.ask': '毎回確認',
|
||||
|
||||
@@ -296,6 +296,8 @@ export const zhCN = {
|
||||
'config.software.title': '软件设置',
|
||||
'config.software.autostart': '开机自启',
|
||||
'config.software.autostartDescription': '登录系统后自动启动 EasyCLIProxyAPI',
|
||||
'config.software.silentStart': '静默启动',
|
||||
'config.software.silentStartDescription': '启动应用时不显示主窗口,直接在系统托盘运行',
|
||||
'config.software.closeBehavior': '关闭行为',
|
||||
'config.software.closeBehaviorDescription': '决定关闭窗口时是退出程序还是继续在系统托盘运行',
|
||||
'config.software.behavior.ask': '每次询问',
|
||||
@@ -1225,6 +1227,8 @@ export const en: Record<MessageKey, string> = {
|
||||
'config.software.title': 'Software Settings',
|
||||
'config.software.autostart': 'Launch at startup',
|
||||
'config.software.autostartDescription': 'Automatically launch EasyCLIProxyAPI when you sign in',
|
||||
'config.software.silentStart': 'Silent Launch',
|
||||
'config.software.silentStartDescription': 'Start without showing the main window and run directly in the system tray',
|
||||
'config.software.closeBehavior': 'Close behavior',
|
||||
'config.software.closeBehaviorDescription': 'Choose whether closing the window exits the app or keeps it running in the system tray',
|
||||
'config.software.behavior.ask': 'Ask every time',
|
||||
|
||||
@@ -62,6 +62,7 @@ type NetworkDraftDirty = Record<NetworkDraftField, boolean>;
|
||||
type SoftwareSettings = {
|
||||
closeBehavior: CloseBehavior;
|
||||
autostartEnabled: boolean;
|
||||
silentStartEnabled: boolean;
|
||||
};
|
||||
|
||||
const cleanNetworkDraft = (): NetworkDraftDirty => ({
|
||||
@@ -85,6 +86,7 @@ export function ConfigPanelPage() {
|
||||
const [softwareSettingsLoading, setSoftwareSettingsLoading] = useState(true);
|
||||
const [softwareCloseBehaviorDraft, setSoftwareCloseBehaviorDraft] = useState<CloseBehavior>('ask');
|
||||
const [softwareAutostartDraft, setSoftwareAutostartDraft] = useState(false);
|
||||
const [softwareSilentStartDraft, setSoftwareSilentStartDraft] = useState(false);
|
||||
const [softwareSavedStatusVisible, setSoftwareSavedStatusVisible] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [loadError, setLoadError] = useState('');
|
||||
@@ -202,6 +204,7 @@ export function ConfigPanelPage() {
|
||||
setSoftwareSettings(result);
|
||||
setSoftwareCloseBehaviorDraft(result.closeBehavior);
|
||||
setSoftwareAutostartDraft(result.autostartEnabled);
|
||||
setSoftwareSilentStartDraft(result.silentStartEnabled);
|
||||
} catch (error) {
|
||||
setSoftwareSettings(null);
|
||||
showNotice(t('config.error.saveFailed', { error: String(error) }), 'error');
|
||||
@@ -469,6 +472,7 @@ export function ConfigPanelPage() {
|
||||
if (
|
||||
softwareCloseBehaviorDraft === softwareSettings.closeBehavior
|
||||
&& softwareAutostartDraft === softwareSettings.autostartEnabled
|
||||
&& softwareSilentStartDraft === softwareSettings.silentStartEnabled
|
||||
) return;
|
||||
|
||||
setBusyAction('software');
|
||||
@@ -477,16 +481,19 @@ export function ConfigPanelPage() {
|
||||
settings: {
|
||||
closeBehavior: softwareCloseBehaviorDraft,
|
||||
autostartEnabled: softwareAutostartDraft,
|
||||
silentStartEnabled: softwareSilentStartDraft,
|
||||
},
|
||||
});
|
||||
setSoftwareSettings(result);
|
||||
setSoftwareCloseBehaviorDraft(result.closeBehavior);
|
||||
setSoftwareAutostartDraft(result.autostartEnabled);
|
||||
setSoftwareSilentStartDraft(result.silentStartEnabled);
|
||||
setSoftwareSavedStatusVisible(true);
|
||||
showNotice(t('config.notice.softwareUpdated'), 'success');
|
||||
} catch (error) {
|
||||
setSoftwareCloseBehaviorDraft(softwareSettings.closeBehavior);
|
||||
setSoftwareAutostartDraft(softwareSettings.autostartEnabled);
|
||||
setSoftwareSilentStartDraft(softwareSettings.silentStartEnabled);
|
||||
setSoftwareSavedStatusVisible(false);
|
||||
showNotice(t('config.error.saveFailed', { error: String(error) }), 'error');
|
||||
void loadSoftwareSettings();
|
||||
@@ -518,7 +525,11 @@ export function ConfigPanelPage() {
|
||||
&& softwareCloseBehaviorDraft !== softwareSettings.closeBehavior;
|
||||
const softwareAutostartDirty = softwareSettings !== null
|
||||
&& softwareAutostartDraft !== softwareSettings.autostartEnabled;
|
||||
const softwareSettingsDirty = softwareCloseBehaviorDirty || softwareAutostartDirty;
|
||||
const softwareSilentStartDirty = softwareSettings !== null
|
||||
&& softwareSilentStartDraft !== softwareSettings.silentStartEnabled;
|
||||
const softwareSettingsDirty = softwareCloseBehaviorDirty
|
||||
|| softwareAutostartDirty
|
||||
|| softwareSilentStartDirty;
|
||||
const softwareStatusLabel = softwareSettingsLoading
|
||||
? t('common.loading')
|
||||
: softwareSettings === null
|
||||
@@ -1083,6 +1094,31 @@ export function ConfigPanelPage() {
|
||||
<span className="switch-track" />
|
||||
</label>
|
||||
</div>
|
||||
<div className="config-software-setting-row">
|
||||
<div className="config-software-setting-copy">
|
||||
<span className="config-software-setting-icon" aria-hidden="true">
|
||||
<EyeOff size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<strong>{t('config.software.silentStart')}</strong>
|
||||
<small>{t('config.software.silentStartDescription')}</small>
|
||||
</div>
|
||||
</div>
|
||||
<label className="switch-control" title={t('config.software.silentStart')}>
|
||||
<input
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
aria-label={t('config.software.silentStart')}
|
||||
checked={softwareSilentStartDraft}
|
||||
disabled={softwareSettingsLoading || softwareSettings === null || busyAction !== null}
|
||||
onChange={(event) => {
|
||||
setSoftwareSavedStatusVisible(false);
|
||||
setSoftwareSilentStartDraft(event.currentTarget.checked);
|
||||
}}
|
||||
/>
|
||||
<span className="switch-track" />
|
||||
</label>
|
||||
</div>
|
||||
<div className="config-software-setting-row config-software-close-row">
|
||||
<div className="config-software-setting-copy">
|
||||
<span className="config-software-setting-icon" aria-hidden="true">
|
||||
|
||||
Reference in new issue
Block a user