From ae2c7e4e74912d623cd9dd5d8556fffe37617809 Mon Sep 17 00:00:00 2001 From: cooper Date: Wed, 13 May 2026 21:45:13 +0800 Subject: [PATCH] fix style pack export guard and switch-style sync --- openless-all/app/src-tauri/src/coordinator.rs | 10 ++++++++++ openless-all/app/src/pages/Style.tsx | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/openless-all/app/src-tauri/src/coordinator.rs b/openless-all/app/src-tauri/src/coordinator.rs index 93bf34e8..f4196698 100644 --- a/openless-all/app/src-tauri/src/coordinator.rs +++ b/openless-all/app/src-tauri/src/coordinator.rs @@ -1438,6 +1438,16 @@ fn switch_to_previous_style(inner: &Arc) { "[coord] switch style hotkey changed active style pack to {}", prefs.active_style_pack_id ); + if let Some(app) = inner.app.lock().clone() { + let _ = app.emit("prefs:changed", &prefs); + let _ = app.emit_to("main", "prefs:changed", &prefs); + let app_for_main = app.clone(); + let _ = app.run_on_main_thread(move || { + if let Err(err) = crate::refresh_tray_microphone_menu(&app_for_main) { + log::warn!("[tray] refresh style menu after switch style hotkey failed: {err}"); + } + }); + } } } diff --git a/openless-all/app/src/pages/Style.tsx b/openless-all/app/src/pages/Style.tsx index 476e2f96..1b34406a 100644 --- a/openless-all/app/src/pages/Style.tsx +++ b/openless-all/app/src/pages/Style.tsx @@ -112,6 +112,7 @@ export function Style() { importFailed: (message: string) => (isEnglish ? `Failed to import ZIP: ${message}` : `导入 ZIP 失败:${message}`), exportSuccess: (path: string) => (isEnglish ? `Exported to ${path}` : `已导出到 ${path}`), exportFailed: (message: string) => (isEnglish ? `Failed to export ZIP: ${message}` : `导出 ZIP 失败:${message}`), + exportDirtyFirst: isEnglish ? 'Save this pack before exporting ZIP.' : '请先保存当前风格包,再导出 ZIP。', resetBuiltin: isEnglish ? 'Reset' : '重置', resetSuccess: (name: string) => (isEnglish ? `Reset "${name}".` : `已重置“${name}”`), resetFailed: (message: string) => (isEnglish ? `Failed to reset pack: ${message}` : `重置风格包失败:${message}`), @@ -468,6 +469,11 @@ export function Style() { const handleExportZip = async (pack = selectedPack) => { if (!pack) return; + if (editorOpen && dirty && selectedPack && pack.id === selectedPack.id) { + setError(copy.exportDirtyFirst); + setNotice(null); + return; + } setBusy('exporting'); try { const defaultName = `${sanitizeZipFileName(pack.name)}.zip`;