fix(app): keep tray preference persistence stable

This commit is contained in:
t8y2
2026-05-22 10:39:47 +08:00
parent bc41936e48
commit a29b95b9fa
10 changed files with 100 additions and 86 deletions
@@ -60,7 +60,7 @@ const editTheme = ref(settingsStore.editorSettings.theme);
const editExecuteMode = ref(settingsStore.editorSettings.executeMode);
const editWordWrap = ref(settingsStore.editorSettings.wordWrap);
const editAppLayout = ref(settingsStore.editorSettings.appLayout);
const editRunInBackground = ref(settingsStore.desktopSettings.run_in_background);
const editShowTrayIcon = ref(settingsStore.desktopSettings.show_tray_icon);
const editRedisScanPageSize = ref(settingsStore.editorSettings.redisScanPageSize);
const editShortcuts = ref(normalizeShortcutSettings(settingsStore.editorSettings.shortcuts));
const editSidebarActivation = ref(settingsStore.editorSettings.sidebarActivation);
@@ -124,7 +124,7 @@ watch(
editExecuteMode.value = settingsStore.editorSettings.executeMode;
editWordWrap.value = settingsStore.editorSettings.wordWrap;
editAppLayout.value = settingsStore.editorSettings.appLayout;
editRunInBackground.value = settingsStore.desktopSettings.run_in_background;
editShowTrayIcon.value = settingsStore.desktopSettings.show_tray_icon;
editRedisScanPageSize.value = settingsStore.editorSettings.redisScanPageSize;
editShortcuts.value = normalizeShortcutSettings(settingsStore.editorSettings.shortcuts);
editSidebarActivation.value = settingsStore.editorSettings.sidebarActivation;
@@ -155,7 +155,7 @@ function hasChanges(): boolean {
editExecuteMode.value !== settingsStore.editorSettings.executeMode ||
editWordWrap.value !== settingsStore.editorSettings.wordWrap ||
editAppLayout.value !== settingsStore.editorSettings.appLayout ||
editRunInBackground.value !== settingsStore.desktopSettings.run_in_background ||
editShowTrayIcon.value !== settingsStore.desktopSettings.show_tray_icon ||
editRedisScanPageSize.value !== settingsStore.editorSettings.redisScanPageSize ||
JSON.stringify(editShortcuts.value) !== JSON.stringify(settingsStore.editorSettings.shortcuts) ||
editSidebarActivation.value !== settingsStore.editorSettings.sidebarActivation ||
@@ -181,7 +181,7 @@ async function applySettings() {
sidebarHiddenTablePrefixes: normalizeSidebarHiddenTablePrefixes(editSidebarHiddenTablePrefixes.value),
});
await settingsStore.updateDesktopSettings({
run_in_background: editRunInBackground.value,
show_tray_icon: editShowTrayIcon.value,
});
emit("update:open", false);
}
@@ -193,7 +193,7 @@ function resetDefaults() {
editExecuteMode.value = DEFAULT_EDITOR_SETTINGS.executeMode;
editWordWrap.value = DEFAULT_EDITOR_SETTINGS.wordWrap;
editAppLayout.value = DEFAULT_EDITOR_SETTINGS.appLayout;
editRunInBackground.value = DEFAULT_DESKTOP_SETTINGS.run_in_background;
editShowTrayIcon.value = DEFAULT_DESKTOP_SETTINGS.show_tray_icon;
editRedisScanPageSize.value = DEFAULT_EDITOR_SETTINGS.redisScanPageSize;
editShortcuts.value = normalizeShortcutSettings(DEFAULT_EDITOR_SETTINGS.shortcuts);
editSidebarActivation.value = DEFAULT_EDITOR_SETTINGS.sidebarActivation;
@@ -301,7 +301,7 @@ watch(
confirmNewPassword.value = "";
await settingsStore.initAiConfig();
await settingsStore.initDesktopSettings();
editRunInBackground.value = settingsStore.desktopSettings.run_in_background;
editShowTrayIcon.value = settingsStore.desktopSettings.show_tray_icon;
syncAiEditState();
}
},
@@ -840,10 +840,10 @@ watch(
class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2"
>
<div class="space-y-1">
<Label for="run-in-background">{{ t("settings.runInBackground") }}</Label>
<p class="text-xs text-muted-foreground">{{ t("settings.runInBackgroundDescription") }}</p>
<Label for="show-tray-icon">{{ t("settings.showTrayIcon") }}</Label>
<p class="text-xs text-muted-foreground">{{ t("settings.showTrayIconDescription") }}</p>
</div>
<Switch id="run-in-background" v-model="editRunInBackground" />
<Switch id="show-tray-icon" v-model="editShowTrayIcon" />
</div>
</section>
+3 -3
View File
@@ -1194,9 +1194,9 @@ export default {
appLayoutSeparatedDescription: "Clear panel separation with block-style tabs.",
appLayoutClassic: "Classic compact",
appLayoutClassicDescription: "Continuous tab bar with compact panel headers.",
runInBackground: "Keep running after closing window",
runInBackgroundDescription:
"When enabled, DBX shows a tray/menu bar icon and closing the window keeps it in the background. When disabled, no icon is shown and closing the window quits the app.",
showTrayIcon: "Show tray/menu bar icon",
showTrayIconDescription:
"When disabled, no icon is shown, but closing the window still hides DBX in the background as before.",
sidebarActivation: "Sidebar activation",
sidebarActivationSingle: "Single click",
sidebarActivationSingleDescription: "Open actionable sidebar items with one click.",
+3 -3
View File
@@ -1092,9 +1092,9 @@ export default {
appLayoutSeparatedDescription: "Separación clara de paneles con pestañas en bloque.",
appLayoutClassic: "Clásico compacto",
appLayoutClassicDescription: "Barra de pestañas continua con encabezados de panel compactos.",
runInBackground: "Seguir ejecutando al cerrar la ventana",
runInBackgroundDescription:
"Si está activado, DBX muestra un icono en la bandeja/barra de menú y cerrar la ventana lo deja en segundo plano. Si está desactivado, no se muestra el icono y cerrar la ventana sale de la app.",
showTrayIcon: "Mostrar icono en bandeja/barra de menú",
showTrayIconDescription:
"Si está desactivado, no se muestra el icono, pero cerrar la ventana sigue ocultando DBX en segundo plano como antes.",
sidebarActivation: "Activación de la barra lateral",
sidebarActivationSingle: "Un clic",
sidebarActivationSingleDescription: "Abrir elementos accionables de la barra lateral con un clic.",
+2 -3
View File
@@ -1172,9 +1172,8 @@ export default {
appLayoutSeparatedDescription: "面板分隔更清晰,标签页为块状样式。",
appLayoutClassic: "经典紧凑",
appLayoutClassicDescription: "使用连续标签栏和更紧凑的面板标题。",
runInBackground: "关闭窗口后后台驻留",
runInBackgroundDescription:
"开启时显示系统托盘/菜单栏图标,关闭窗口会隐藏到后台;关闭后不显示图标,关闭窗口将退出应用。",
showTrayIcon: "显示系统托盘/菜单栏图标",
showTrayIconDescription: "关闭后不显示图标,但关闭窗口仍会像之前一样隐藏到后台。",
sidebarActivation: "侧边栏打开方式",
sidebarActivationSingle: "单击打开",
sidebarActivationSingleDescription: "单击即可打开侧边栏中的可操作项目。",
+1 -1
View File
@@ -468,7 +468,7 @@ export async function loadAiConfig(): Promise<AiConfig | null> {
}
export async function loadDesktopSettings(): Promise<DesktopSettings> {
return { run_in_background: true };
return { show_tray_icon: true };
}
export async function saveDesktopSettings(_settings: DesktopSettings): Promise<void> {
+1 -1
View File
@@ -41,7 +41,7 @@ export interface JavaRuntimeConfig {
}
export interface DesktopSettings {
run_in_background: boolean;
show_tray_icon: boolean;
}
export interface DriverInstallProgress {
+2 -2
View File
@@ -35,11 +35,11 @@ export interface AiConfig {
}
export interface DesktopSettings {
run_in_background: boolean;
show_tray_icon: boolean;
}
export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
run_in_background: true,
show_tray_icon: true,
};
export interface AiProviderPreset extends Omit<AiConfig, "apiKey"> {