Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix(settings): improve platform detection and shortcut display

Yujing Zheng322adc77e064
diff --git a/src/hooks/use-global-shortcut.ts b/src/hooks/use-global-shortcut.ts
index 12cf47ed..906d9a39 100644
--- a/src/hooks/use-global-shortcut.ts
+++ b/src/hooks/use-global-shortcut.ts
@@ -56,21 +56,15 @@ function isTextInput(element: HTMLElement | null): boolean {
* - Windows/Linux: Requires event.ctrlKey
*/
function hasPlatformModifierKey(event: KeyboardEvent): boolean {
- // Detect platform via user agent (Tauri sets this correctly)
- const isMac = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent)
-
- if (isMac) {
- return event.metaKey
- } else {
- return event.ctrlKey
- }
+ // Reuse the platform class already set in main.tsx
+ const isMac = document.documentElement.classList.contains("platform-macos")
+ return isMac ? event.metaKey : event.ctrlKey
}
/**
* Register global keyboard shortcuts.
*
* @param shortcuts - Map of key names to callback functions
- * @param deps - Optional dependency array to re-register shortcuts when values change
*
* Keys should be lowercase event.key values (e.g., "," for comma, "s" for S key).
*
@@ -78,7 +72,7 @@ function hasPlatformModifierKey(event: KeyboardEvent): boolean {
* - User is typing in a text input field
* - User is composing text via IME (Chinese/Japanese/Korean input methods)
*/
-export function useGlobalShortcut(shortcuts: ShortcutMap, deps: unknown[] = []): void {
+export function useGlobalShortcut(shortcuts: ShortcutMap): void {
const handleKeyDown = useCallback(
(event: KeyboardEvent) => {
// Suppress shortcuts when user is typing in a text input field
@@ -87,8 +81,8 @@ export function useGlobalShortcut(shortcuts: ShortcutMap, deps: unknown[] = []):
}
// Suppress shortcuts during IME composition (e.g., typing Chinese characters)
- // keyCode 229 is the legacy "IME activity" signal
- if (event.keyCode === 229) {
+ // Check both modern isComposing and legacy keyCode 229 signal (matches isImeComposing pattern)
+ if (event.isComposing || event.keyCode === 229) {
return
}
@@ -113,5 +107,5 @@ export function useGlobalShortcut(shortcuts: ShortcutMap, deps: unknown[] = []):
return () => {
window.removeEventListener("keydown", handleKeyDown)
}
- }, [handleKeyDown, ...deps])
+ }, [handleKeyDown])
}
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 5c53859d..ede5f1bd 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -26,7 +26,7 @@
"review": "Review",
"skills": "Skills",
"settings": "Settings",
- "settingsShortcut": " (⌘,)",
+ "settingsShortcut": " (Cmd/Ctrl+,)",
"switchProject": "Switch Project",
"updateAvailable": "Update available",
"updateAvailableSuffix": " · update"
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 0eee43d5..25393718 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -26,7 +26,7 @@
"review": "待审阅",
"skills": "Skills",
"settings": "设置",
- "settingsShortcut": " (⌘,)",
+ "settingsShortcut": " (Cmd/Ctrl+,)",
"switchProject": "切换项目",
"updateAvailable": "有可用更新",
"updateAvailableSuffix": " · 有更新"