feat(settings): keep dialog open after apply

This commit is contained in:
t8y2 2026-05-28 20:36:56 +08:00
parent fcdc7cfc07
commit f45ee8f272
5 changed files with 23 additions and 1 deletions

View File

@ -276,7 +276,7 @@ function hasChanges(): boolean {
);
}
async function applySettings() {
async function persistSettings() {
if (hasBlockingShortcutConflicts.value) return;
settingsStore.updateEditorSettings({
fontFamily: editFontFamily.value,
@ -299,6 +299,14 @@ async function applySettings() {
await settingsStore.updateDesktopSettings({
show_tray_icon: editShowTrayIcon.value,
});
}
async function applySettings() {
await persistSettings();
}
async function applySettingsAndClose() {
await persistSettings();
emit("update:open", false);
}
@ -1796,6 +1804,9 @@ watch(
<Button :disabled="!hasChanges() || hasBlockingShortcutConflicts" @click="applySettings">
{{ t("settings.apply") }}
</Button>
<Button :disabled="!hasChanges() || hasBlockingShortcutConflicts" @click="applySettingsAndClose">
{{ t("settings.applyAndClose") }}
</Button>
</DialogFooter>
<DialogFooter

View File

@ -1464,6 +1464,7 @@ export default {
syncSecretsSkipped: "Encrypted secrets were present but were not restored.",
syncDownloadConfirm: "Download and apply the remote DBX snapshot? Local metadata and saved SQL will be replaced.",
apply: "Apply",
applyAndClose: "Apply and Close",
reset: "Reset",
resetDefaults: "Reset Defaults",
save: "Save",

View File

@ -1359,6 +1359,7 @@ export default {
syncDownloadConfirm:
"¿Descargar y aplicar la instantánea remota de DBX? Se reemplazarán metadatos locales y SQL guardado.",
apply: "Aplicar",
applyAndClose: "Aplicar y cerrar",
reset: "Restablecer",
resetDefaults: "Restablecer valores por defecto",
executeMode: "Modo de ejecución (Cmd+Enter)",

View File

@ -1430,6 +1430,7 @@ export default {
syncSecretsSkipped: "远端包含加密敏感信息,但本次未恢复。",
syncDownloadConfirm: "要下载并应用远端 DBX 快照吗?本地元信息和保存的 SQL 会被替换。",
apply: "应用",
applyAndClose: "应用并关闭",
reset: "重置",
resetDefaults: "恢复默认",
save: "保存",

View File

@ -60,6 +60,14 @@ test("shortcut conflicts only block applying changed shortcut settings", () => {
assert.match(source, /:disabled="!hasChanges\(\) \|\| hasBlockingShortcutConflicts"/);
});
test("settings dialog exposes separate apply and apply-and-close actions", () => {
assert.match(source, /async function persistSettings\(\)/);
assert.match(source, /async function applySettings\(\)/);
assert.match(source, /async function applySettingsAndClose\(\)/);
assert.match(source, /await persistSettings\(\);[\s\S]*emit\("update:open", false\)/);
assert.match(source, /t\("settings\.applyAndClose"\)/);
});
test("settings dialog exposes sidebar activation in navigation settings", () => {
assert.match(source, /value: "navigation"/);
assert.match(source, /activeSettingsTab === ['"]navigation['"]/);