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
feat: add tray and startup settings
nash_su0e292ee0902a
diff --git a/package-lock.json b/package-lock.jsonindex e4b3c187..6da1e1bd 100644--- a/package-lock.json+++ b/package-lock.json@@ -17,6 +17,7 @@"@react-sigma/core": "^5.0.6","@tailwindcss/vite": "^4.2.2","@tauri-apps/api": "^2.11.0",+ "@tauri-apps/plugin-autostart": "^2.5.1","@tauri-apps/plugin-dialog": "^2.7.1","@tauri-apps/plugin-http": "^2.5.9","@tauri-apps/plugin-opener": "^2.5.4",@@ -2954,6 +2955,15 @@"node": ">= 10"}},+ "node_modules/@tauri-apps/plugin-autostart": {+ "version": "2.5.1",+ "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-autostart/-/plugin-autostart-2.5.1.tgz",+ "integrity": "sha512-zS/xx7yzveCcotkA+8TqkI2lysmG2wvQXv2HGAVExITmnFfHAdj1arGsbbfs3o6EktRHf6l34pJxc3YGG2mg7w==",+ "license": "MIT OR Apache-2.0",+ "dependencies": {+ "@tauri-apps/api": "^2.8.0"+ }+ },"node_modules/@tauri-apps/plugin-dialog": {"version": "2.7.1","resolved": "https://registry.npmjs.org/@tauri-apps/plugin-dialog/-/plugin-dialog-2.7.1.tgz",diff --git a/package.json b/package.jsonindex 897379fe..ff12cc51 100644--- a/package.json+++ b/package.json@@ -23,6 +23,7 @@"@react-sigma/core": "^5.0.6","@tailwindcss/vite": "^4.2.2","@tauri-apps/api": "^2.11.0",+ "@tauri-apps/plugin-autostart": "^2.5.1","@tauri-apps/plugin-dialog": "^2.7.1","@tauri-apps/plugin-http": "^2.5.9","@tauri-apps/plugin-opener": "^2.5.4",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 5571e829..b46964a2 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -547,6 +547,17 @@ version = "1.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"+[[package]]+name = "auto-launch"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471"+dependencies = [+ "dirs 4.0.0",+ "thiserror 1.0.69",+ "winreg 0.10.1",+]+[[package]]name = "autocfg"version = "1.5.0"@@ -2088,13 +2099,33 @@ dependencies = ["subtle",]+[[package]]+name = "dirs"+version = "4.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"+dependencies = [+ "dirs-sys 0.3.7",+]+[[package]]name = "dirs"version = "6.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"dependencies = [- "dirs-sys",+ "dirs-sys 0.5.0",+]++[[package]]+name = "dirs-sys"+version = "0.3.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"+dependencies = [+ "libc",+ "redox_users 0.4.6",+ "winapi",][[package]]@@ -2105,7 +2136,7 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"dependencies = ["libc","option-ext",- "redox_users",+ "redox_users 0.5.2","windows-sys 0.61.2",]@@ -2268,7 +2299,7 @@ dependencies = ["rustc_version","toml 1.1.2+spec-1.1.0","vswhom",- "winreg",+ "winreg 0.55.0",][[package]]@@ -3988,7 +4019,7 @@ dependencies = ["datafusion-physical-expr","datafusion-sql","deepsize",- "dirs",+ "dirs 6.0.0","fst","futures","half",@@ -4451,6 +4482,7 @@ dependencies = ["sha2","tauri","tauri-build",+ "tauri-plugin-autostart","tauri-plugin-dialog","tauri-plugin-http","tauri-plugin-opener",@@ -6001,6 +6033,17 @@ dependencies = ["bitflags 2.11.1",]+[[package]]+name = "redox_users"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"+dependencies = [+ "getrandom 0.2.17",+ "libredox",+ "thiserror 1.0.69",+]+[[package]]name = "redox_users"version = "0.5.2"@@ -7204,7 +7247,7 @@ dependencies = ["anyhow","bytes","cookie",- "dirs",+ "dirs 6.0.0","dunce","embed_plist","getrandom 0.3.4",@@ -7255,7 +7298,7 @@ checksum = "3a318b234cc2dea65f575467bafcfb76286bce228ebc3778e337d61d03213007"dependencies = ["anyhow","cargo_toml",- "dirs",+ "dirs 6.0.0","glob","heck 0.5.0","json-patch",@@ -7325,6 +7368,20 @@ dependencies = ["walkdir",]+[[package]]+name = "tauri-plugin-autostart"+version = "2.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "459383cebc193cdd03d1ba4acc40f2c408a7abce419d64bdcd2d745bc2886f70"+dependencies = [+ "auto-launch",+ "serde",+ "serde_json",+ "tauri",+ "tauri-plugin",+ "thiserror 2.0.18",+]+[[package]]name = "tauri-plugin-dialog"version = "2.7.1"@@ -8001,7 +8058,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "15edbb0d80583e85ee8df283410038e17314df5cba30da2087a54a85216c0773"dependencies = ["crossbeam-channel",- "dirs",+ "dirs 6.0.0","libappindicator","muda","objc2",@@ -9014,6 +9071,15 @@ dependencies = ["memchr",]+[[package]]+name = "winreg"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"+dependencies = [+ "winapi",+]+[[package]]name = "winreg"version = "0.55.0"@@ -9140,7 +9206,7 @@ dependencies = ["block2","cookie","crossbeam-channel",- "dirs",+ "dirs 6.0.0","dom_query","dpi","dunce",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 5bd5080d..f3f590db 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -19,8 +19,9 @@ path = "src/main.rs"tauri-build = { version = "2", features = [] }[dependencies]-tauri = { version = "2", features = ["protocol-asset"] }+tauri = { version = "2", features = ["protocol-asset", "tray-icon"] }tauri-plugin-opener = "2"+tauri-plugin-autostart = "2.5.1"serde = { version = "1", features = ["derive"] }serde_json = "1"chrono = { version = "0.4", features = ["clock"] }diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex a6d3041b..1289c5c9 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -5,6 +5,7 @@"windows": ["main"],"permissions": ["core:default",+ "autostart:default","opener:default","dialog:default","store:default",diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex a786058a..b5edf95e 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -3,9 +3,14 @@ mod clip_server;mod commands;mod panic_guard;mod proxy;+mod tray;mod types;use panic_guard::run_guarded;+use std::sync::Mutex;+use tauri::Manager;++struct CloseBehaviorState(Mutex<String>);#[tauri::command]fn clip_server_status() -> String {@@ -48,6 +53,32 @@ fn set_proxy_env(config: proxy::ProxyConfig) -> String {summary}+#[tauri::command]+fn set_close_behavior(+ value: String,+ state: tauri::State<'_, CloseBehaviorState>,+) -> Result<String, String> {+ let normalized = match value.as_str() {+ "ask" | "minimize" | "exit" => value,+ other => return Err(format!("Invalid close behavior: {other}")),+ };+ let mut guard = state+ .0+ .lock()+ .map_err(|_| "Close behavior state is unavailable".to_string())?;+ *guard = normalized.clone();+ Ok(normalized)+}++fn close_behavior<R: tauri::Runtime>(window: &tauri::Window<R>) -> String {+ window+ .state::<CloseBehaviorState>()+ .0+ .lock()+ .map(|value| value.clone())+ .unwrap_or_else(|_| "ask".to_string())+}+#[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {clip_server::start_clip_server();@@ -56,6 +87,10 @@ pub fn run() {.plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_store::Builder::default().build())+ .plugin(tauri_plugin_autostart::init(+ tauri_plugin_autostart::MacosLauncher::LaunchAgent,+ None::<Vec<&str>>,+ ))// Rust-backed fetch so third-party LLM APIs that reject// browser-origin headers via CORS preflight (MiniMax, Volcengine// Ark's api/coding/v3, etc.) still work. Requests leave the app@@ -64,7 +99,6 @@ pub fn run() {.setup(|app| {// Let the PDF extractor find the bundled pdfium dynamic// library via Tauri's platform-correct resource path.- use tauri::Manager;if let Ok(dir) = app.path().resource_dir() {commands::fs::set_resource_dir_hint(dir);}@@ -93,6 +127,10 @@ pub fn run() {app.manage(commands::claude_cli::ClaudeCliState::default());app.manage(commands::codex_cli::CodexCliState::default());app.manage(commands::file_sync::FileSyncState::default());+ app.manage(CloseBehaviorState(Mutex::new("ask".to_string())));+ if let Err(err) = tray::create_tray(app.handle()) {+ eprintln!("[tray] system tray unavailable, continuing without it: {err}");+ }api_server::start_api_server(app.handle().clone());Ok(())})@@ -146,34 +184,44 @@ pub fn run() {commands::file_sync::retry_file_change_task,commands::file_sync::ignore_file_change_task,set_proxy_env,+ set_close_behavior,]).on_window_event(|window, event| {if let tauri::WindowEvent::CloseRequested { api, .. } = event {- #[cfg(target_os = "macos")]- {- let _ = window.hide();- api.prevent_close();- }-- #[cfg(not(target_os = "macos"))]- {- use tauri::Manager;- api.prevent_close();- let win = window.clone();- let app = window.app_handle().clone();- tauri::async_runtime::spawn(async move {- use tauri_plugin_dialog::DialogExt;- let confirmed = app- .dialog()- .message("Are you sure you want to quit LLM Wiki?")- .title("Confirm Exit")- .kind(tauri_plugin_dialog::MessageDialogKind::Warning)- .blocking_show();-- if confirmed {+ api.prevent_close();+ let behavior = close_behavior(window);+ let win = window.clone();+ let app = window.app_handle().clone();+ match behavior.as_str() {+ "exit" => {+ tauri::async_runtime::spawn(async move {let _ = win.destroy();- }- });+ app.exit(0);+ });+ }+ "minimize" => {+ let _ = window.hide();+ }+ _ => {+ tauri::async_runtime::spawn(async move {+ use tauri_plugin_dialog::DialogExt;+ let confirmed = app+ .dialog()+ .message(+ "Quit LLM Wiki? Choose OK to exit. Choose Cancel to hide the window and keep background features running.",+ )+ .title("LLM Wiki")+ .kind(tauri_plugin_dialog::MessageDialogKind::Warning)+ .blocking_show();++ if confirmed {+ let _ = win.destroy();+ app.exit(0);+ } else {+ let _ = win.hide();+ }+ });+ }}}})diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rsnew file mode 100644index 00000000..47e476dc--- /dev/null+++ b/src-tauri/src/tray.rs@@ -0,0 +1,51 @@+use tauri::{+ menu::{Menu, MenuItem},+ tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},+ AppHandle, Manager, Runtime,+};++fn show_main_window<R: Runtime>(app: &AppHandle<R>) {+ if let Some(window) = app.get_webview_window("main") {+ let _ = window.show();+ let _ = window.unminimize();+ let _ = window.set_focus();+ }+}++pub fn create_tray<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<()> {+ let show = MenuItem::with_id(app, "show", "Show LLM Wiki", true, None::<&str>)?;+ let quit = MenuItem::with_id(app, "quit", "Quit LLM Wiki", true, None::<&str>)?;+ let menu = Menu::with_items(app, &[&show, &quit])?;++ let mut builder = TrayIconBuilder::with_id("main")+ .tooltip("LLM Wiki")+ .menu(&menu)+ .show_menu_on_left_click(false)+ .on_menu_event(|app, event| match event.id().as_ref() {+ "show" => show_main_window(app),+ "quit" => {+ if let Some(window) = app.get_webview_window("main") {+ let _ = window.destroy();+ }+ app.exit(0);+ }+ _ => {}+ })+ .on_tray_icon_event(|tray, event| {+ if let TrayIconEvent::Click {+ button: MouseButton::Left,+ button_state: MouseButtonState::Up,+ ..+ } = event+ {+ show_main_window(tray.app_handle());+ }+ });++ if let Some(icon) = app.default_window_icon() {+ builder = builder.icon(icon.clone());+ }++ builder.build(app)?;+ Ok(())+}diff --git a/src/App.tsx b/src/App.tsxindex 998880c2..d4c29daf 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -1,12 +1,14 @@import { useState, useEffect } from "react"import { open } from "@tauri-apps/plugin-dialog"+import { invoke } from "@tauri-apps/api/core"+import { disable as disableAutostart, enable as enableAutostart, isEnabled as isAutostartEnabled } from "@tauri-apps/plugin-autostart"import i18n from "@/i18n"import { useWikiStore } from "@/stores/wiki-store"import { useReviewStore } from "@/stores/review-store"import { useLintStore } from "@/stores/lint-store"import { useChatStore } from "@/stores/chat-store"import { listDirectory, openProject } from "@/commands/fs"-import { getLastProject, getRecentProjects, saveLastProject, loadLlmConfig, loadLanguage, loadSearchApiConfig, loadEmbeddingConfig, loadMultimodalConfig, loadOutputLanguage, loadProviderConfigs, loadActivePresetId, loadProxyConfig, loadScheduledImportConfig, saveScheduledImportConfig, loadSourceWatchConfig, loadApiConfig } from "@/lib/project-store"+import { getLastProject, getRecentProjects, saveLastProject, loadLlmConfig, loadLanguage, loadSearchApiConfig, loadEmbeddingConfig, loadMultimodalConfig, loadOutputLanguage, loadProviderConfigs, loadActivePresetId, loadProxyConfig, loadScheduledImportConfig, saveScheduledImportConfig, loadSourceWatchConfig, loadApiConfig, loadGeneralConfig } from "@/lib/project-store"import { loadReviewItems, loadLintItems, loadChatHistory } from "@/lib/persist"import { setupAutoSave } from "@/lib/auto-save"import { startClipWatcher } from "@/lib/clip-watcher"@@ -239,6 +241,23 @@ function App() {token: typeof savedApi.token === "string" ? savedApi.token : "",})}+ const savedGeneral = await loadGeneralConfig()+ useWikiStore.getState().setGeneralConfig(savedGeneral)+ try {+ await invoke<string>("set_close_behavior", { value: savedGeneral.closeBehavior })+ } catch (err) {+ console.warn("[general] failed to hydrate close behavior:", err)+ }+ try {+ const currentAutostart = await isAutostartEnabled()+ if (savedGeneral.autostart && !currentAutostart) {+ await enableAutostart()+ } else if (!savedGeneral.autostart && currentAutostart) {+ await disableAutostart()+ }+ } catch (err) {+ console.warn("[general] failed to sync autostart:", err)+ }const savedLang = await loadLanguage()if (savedLang) {await i18n.changeLanguage(savedLang)diff --git a/src/components/settings/sections/general-section.tsx b/src/components/settings/sections/general-section.tsxnew file mode 100644index 00000000..24b44f28--- /dev/null+++ b/src/components/settings/sections/general-section.tsx@@ -0,0 +1,96 @@+import { useTranslation } from "react-i18next"+import { Label } from "@/components/ui/label"+import type { CloseBehavior } from "@/stores/wiki-store"+import type { SettingsDraft, DraftSetter } from "../settings-types"++interface Props {+ draft: SettingsDraft+ setDraft: DraftSetter+}++const CLOSE_BEHAVIORS: Array<{ value: CloseBehavior; labelKey: string; hintKey: string }> = [+ {+ value: "ask",+ labelKey: "settings.sections.general.closeAsk",+ hintKey: "settings.sections.general.closeAskHint",+ },+ {+ value: "minimize",+ labelKey: "settings.sections.general.closeMinimize",+ hintKey: "settings.sections.general.closeMinimizeHint",+ },+ {+ value: "exit",+ labelKey: "settings.sections.general.closeExit",+ hintKey: "settings.sections.general.closeExitHint",+ },+]++export function GeneralSection({ draft, setDraft }: Props) {+ const { t } = useTranslation()++ return (+ <div className="space-y-6">+ <div>+ <h2 className="text-xl font-semibold">+ {t("settings.sections.general.title", { defaultValue: "General" })}+ </h2>+ <p className="mt-1 text-sm text-muted-foreground">+ {t("settings.sections.general.description", {+ defaultValue: "Startup and window behavior for the desktop app.",+ })}+ </p>+ </div>++ <label className="flex items-start gap-2">+ <input+ type="checkbox"+ checked={draft.autostart}+ onChange={(e) => setDraft("autostart", e.target.checked)}+ className="mt-0.5 h-4 w-4"+ />+ <div className="space-y-1">+ <span className="text-sm">+ {t("settings.sections.general.autostart", { defaultValue: "Launch at system startup" })}+ </span>+ <p className="text-xs text-muted-foreground">+ {t("settings.sections.general.autostartHint", {+ defaultValue: "Starts LLM Wiki automatically after you sign in to this computer.",+ })}+ </p>+ </div>+ </label>++ <div className="space-y-2">+ <Label>{t("settings.sections.general.closeBehavior", { defaultValue: "When closing the window" })}</Label>+ <div className="grid gap-2">+ {CLOSE_BEHAVIORS.map((option) => {+ const active = draft.closeBehavior === option.value+ return (+ <button+ key={option.value}+ type="button"+ onClick={() => setDraft("closeBehavior", option.value)}+ className={`rounded-md border px-3 py-2 text-left text-sm transition-colors ${+ active+ ? "border-primary bg-primary/10 text-foreground ring-1 ring-primary/30"+ : "border-border hover:bg-accent"+ }`}+ >+ <span className="font-medium">{t(option.labelKey)}</span>+ <span className="mt-0.5 block text-xs text-muted-foreground">+ {t(option.hintKey)}+ </span>+ </button>+ )+ })}+ </div>+ <p className="text-xs text-muted-foreground">+ {t("settings.sections.general.closeBehaviorHint", {+ defaultValue: "This setting applies when you click the title-bar close button. The tray menu can still quit the app directly.",+ })}+ </p>+ </div>+ </div>+ )+}diff --git a/src/components/settings/settings-types.ts b/src/components/settings/settings-types.tsindex 60379601..8fa34d6c 100644--- a/src/components/settings/settings-types.ts+++ b/src/components/settings/settings-types.ts@@ -1,5 +1,5 @@import type { CustomApiMode } from "./llm-presets"-import type { AzureModelFamily, ReasoningConfig, SourceWatchConfig } from "@/stores/wiki-store"+import type { AzureModelFamily, CloseBehavior, ReasoningConfig, SourceWatchConfig } from "@/stores/wiki-store"/*** Shape of the draft state each section reads from and writes into.@@ -67,6 +67,10 @@ export interface SettingsDraft {uiLanguage: stringtheme: "light" | "dark" | "system"+ // General app behavior+ autostart: boolean+ closeBehavior: CloseBehavior+// Source folder auto watchsourceWatchConfig: SourceWatchConfigdiff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsxindex 0ab205d5..c3e63aec 100644--- a/src/components/settings/settings-view.tsx+++ b/src/components/settings/settings-view.tsx@@ -13,9 +13,11 @@ import {Clock,FolderSync,Server,+ Settings,} from "lucide-react"import { useTranslation } from "react-i18next"import { invoke } from "@tauri-apps/api/core"+import { disable as disableAutostart, enable as enableAutostart } from "@tauri-apps/plugin-autostart"import i18n from "@/i18n"import { Button } from "@/components/ui/button"import { useWikiStore } from "@/stores/wiki-store"@@ -35,11 +37,13 @@ import { NetworkSection } from "./sections/network-section"import { ScheduledImportSection } from "./sections/scheduled-import-section"import { SourceWatchSection } from "./sections/source-watch-section"import { ApiServerSection } from "./sections/api-server-section"+import { GeneralSection } from "./sections/general-section"import { ChangelogSection } from "./sections/changelog-section"import { MaintenanceSection } from "./sections/maintenance-section"import { AboutSection } from "./sections/about-section"type CategoryId =+ | "general"| "llm"| "embedding"| "multimodal"@@ -64,6 +68,7 @@ interface Category {}const CATEGORIES: Category[] = [+ { id: "general", labelKey: "settings.categories.general", icon: Settings },{ id: "llm", labelKey: "settings.categories.llm", icon: Bot },{ id: "embedding", labelKey: "settings.categories.embedding", icon: Binary },{ id: "multimodal", labelKey: "settings.categories.multimodal", icon: ImageIcon },@@ -88,6 +93,7 @@ function initialDraft(scheduledImport: ReturnType<typeof useWikiStore.getState>["scheduledImportConfig"],sourceWatch: ReturnType<typeof useWikiStore.getState>["sourceWatchConfig"],apiConfig: ReturnType<typeof useWikiStore.getState>["apiConfig"],+ generalConfig: ReturnType<typeof useWikiStore.getState>["generalConfig"],maxHistoryMessages: number,uiLanguage: string,projectPath?: string,@@ -146,6 +152,8 @@ function initialDraft(apiEnabled: apiConfig.enabled,apiAllowUnauthenticated: apiConfig.allowUnauthenticated,apiToken: apiConfig.token,+ autostart: generalConfig.autostart,+ closeBehavior: generalConfig.closeBehavior,uiLanguage,theme: theme ?? "system",}@@ -170,6 +178,8 @@ export function SettingsView() {const setSourceWatchConfig = useWikiStore((s) => s.setSourceWatchConfig)const apiConfig = useWikiStore((s) => s.apiConfig)const setApiConfig = useWikiStore((s) => s.setApiConfig)+ const generalConfig = useWikiStore((s) => s.generalConfig)+ const setGeneralConfig = useWikiStore((s) => s.setGeneralConfig)const maxHistoryMessages = useChatStore((s) => s.maxHistoryMessages)const setMaxHistoryMessages = useChatStore((s) => s.setMaxHistoryMessages)// Drives the red dot next to the "About" row in the settings@@ -195,6 +205,7 @@ export function SettingsView() {scheduledImportConfig,sourceWatchConfig,apiConfig,+ generalConfig,maxHistoryMessages,i18n.language,project?.path,@@ -248,6 +259,7 @@ export function SettingsView() {scheduledImportConfig,sourceWatchConfig,apiConfig,+ generalConfig,maxHistoryMessages,prev.uiLanguage,project?.path,@@ -263,6 +275,7 @@ export function SettingsView() {scheduledImportConfig,sourceWatchConfig,apiConfig,+ generalConfig,maxHistoryMessages,project,])@@ -281,6 +294,7 @@ export function SettingsView() {saveScheduledImportConfig,saveSourceWatchConfig,saveApiConfig,+ saveGeneralConfig,} = await import("@/lib/project-store")const newLlm = {@@ -404,6 +418,27 @@ export function SettingsView() {console.warn("[api] failed to reload API server config cache:", err)}+ const newGeneralConfig = {+ autostart: draft.autostart,+ closeBehavior: draft.closeBehavior,+ }+ setGeneralConfig(newGeneralConfig)+ await saveGeneralConfig(newGeneralConfig)+ try {+ if (newGeneralConfig.autostart) {+ await enableAutostart()+ } else {+ await disableAutostart()+ }+ } catch (err) {+ console.warn("[general] failed to update autostart:", err)+ }+ try {+ await invoke<string>("set_close_behavior", { value: newGeneralConfig.closeBehavior })+ } catch (err) {+ console.warn("[general] failed to update close behavior:", err)+ }+if (draft.uiLanguage !== i18n.language) {await i18n.changeLanguage(draft.uiLanguage)await saveLanguage(draft.uiLanguage)@@ -429,6 +464,7 @@ export function SettingsView() {setScheduledImportConfig,setSourceWatchConfig,setApiConfig,+ setGeneralConfig,scheduledImportConfig,setMaxHistoryMessages,outputLanguage,@@ -437,6 +473,8 @@ export function SettingsView() {const body = useMemo(() => {switch (active) {+ case "general":+ return <GeneralSection draft={draft} setDraft={setDraft} />case "llm":// The LLM section manages its own store state (per-provider// configs + active preset) and persists directly — it bypassesdiff --git a/src/i18n/en.json b/src/i18n/en.jsonindex eb20172d..d60a5fbc 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -205,6 +205,7 @@"language": "Language","languageHint": "Interface language (wiki content follows source material language)","categories": {+ "general": "General","llm": "LLM Models","embedding": "Embeddings","multimodal": "Image Captioning",@@ -220,6 +221,20 @@"about": "About"},"sections": {+ "general": {+ "title": "General",+ "description": "Startup and window behavior for the desktop app.",+ "autostart": "Launch at system startup",+ "autostartHint": "Starts LLM Wiki automatically after you sign in to this computer.",+ "closeBehavior": "When closing the window",+ "closeBehaviorHint": "This setting applies when you click the title-bar close button. The tray menu can still quit the app directly.",+ "closeAsk": "Ask every time",+ "closeAskHint": "Show a confirmation. Cancel hides the window and keeps background features running.",+ "closeMinimize": "Hide to tray",+ "closeMinimizeHint": "Keep LLM Wiki running in the background when the window closes. Requires system tray support; some Linux desktops may not show tray icons.",+ "closeExit": "Quit app",+ "closeExitHint": "Exit LLM Wiki immediately when the window closes."+ },"llm": {"title": "LLM Models","description": "One row per vendor. Toggling one on automatically turns off the others. Changes save instantly; each vendor's API key is stored independently so switching doesn't lose data.",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex fb60b3d6..2db59037 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -205,6 +205,7 @@"language": "语言","languageHint": "界面语言(Wiki 内容语言以原始资料为准)","categories": {+ "general": "通用","llm": "LLM 模型","embedding": "向量嵌入","multimodal": "图片描述",@@ -220,6 +221,20 @@"about": "关于"},"sections": {+ "general": {+ "title": "通用",+ "description": "桌面应用的启动和窗口关闭行为。",+ "autostart": "登录系统后自动启动",+ "autostartHint": "登录这台电脑后自动启动 LLM Wiki。",+ "closeBehavior": "关闭窗口时",+ "closeBehaviorHint": "点击标题栏关闭按钮时使用这个设置。托盘菜单仍可直接退出应用。",+ "closeAsk": "每次询问",+ "closeAskHint": "显示确认框。取消会隐藏窗口,并保持后台功能继续运行。",+ "closeMinimize": "隐藏到托盘",+ "closeMinimizeHint": "关闭窗口时让 LLM Wiki 留在后台运行。依赖系统托盘支持;部分 Linux 桌面可能不显示托盘图标。",+ "closeExit": "退出应用",+ "closeExitHint": "关闭窗口时立即退出 LLM Wiki。"+ },"llm": {"title": "LLM 模型","description": "每个厂商一条独立配置。打开开关即切换为当前活跃 provider;其他的会自动关闭。配置改动即时保存,每个厂商的 API Key 独立存储,切换之间不丢失。",diff --git a/src/lib/project-store.ts b/src/lib/project-store.tsindex 6aff30ca..524707ea 100644--- a/src/lib/project-store.ts+++ b/src/lib/project-store.ts@@ -1,6 +1,6 @@import { load } from "@tauri-apps/plugin-store"import type { WikiProject } from "@/types/wiki"-import type { ApiConfig, LlmConfig, SearchApiConfig, EmbeddingConfig, MultimodalConfig, OutputLanguage, ProviderConfigs, ProxyConfig, ScheduledImportConfig, SourceWatchConfig } from "@/stores/wiki-store"+import type { ApiConfig, GeneralConfig, LlmConfig, SearchApiConfig, EmbeddingConfig, MultimodalConfig, OutputLanguage, ProviderConfigs, ProxyConfig, ScheduledImportConfig, SourceWatchConfig } from "@/stores/wiki-store"import { normalizeSourceWatchConfig } from "@/lib/source-watch-config"import { normalizePath } from "@/lib/path-utils"@@ -157,6 +157,36 @@ export async function loadApiConfig(): Promise<ApiConfig | null> {return (await store.get<ApiConfig>(API_CONFIG_KEY)) ?? null}+const GENERAL_CONFIG_KEY = "generalConfig"++export const DEFAULT_GENERAL_CONFIG: GeneralConfig = {+ autostart: false,+ closeBehavior: "ask",+}++export function normalizeGeneralConfig(config?: Partial<GeneralConfig> | null): GeneralConfig {+ const closeBehavior = config?.closeBehavior+ return {+ autostart: typeof config?.autostart === "boolean" ? config.autostart : DEFAULT_GENERAL_CONFIG.autostart,+ closeBehavior:+ closeBehavior === "ask" || closeBehavior === "minimize" || closeBehavior === "exit"+ ? closeBehavior+ : DEFAULT_GENERAL_CONFIG.closeBehavior,+ }+}++export async function saveGeneralConfig(config: GeneralConfig): Promise<void> {+ const store = await getStore()+ await store.set(GENERAL_CONFIG_KEY, normalizeGeneralConfig(config))+ await store.save()+}++export async function loadGeneralConfig(): Promise<GeneralConfig> {+ const store = await getStore()+ const config = await store.get<Partial<GeneralConfig>>(GENERAL_CONFIG_KEY)+ return normalizeGeneralConfig(config)+}+const SCHEDULED_IMPORT_KEY_PREFIX = "scheduledImportConfig:"function scheduledImportKey(projectPath: string): string {diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.tsindex 0c46605a..dfb537e0 100644--- a/src/stores/wiki-store.ts+++ b/src/stores/wiki-store.ts@@ -186,6 +186,13 @@ interface ApiConfig {token: string}+export type CloseBehavior = "ask" | "minimize" | "exit"++export interface GeneralConfig {+ autostart: boolean+ closeBehavior: CloseBehavior+}+interface SourceWatchConfig {enabled: booleanautoIngest: boolean@@ -305,6 +312,7 @@ interface WikiState {scheduledImportConfig: ScheduledImportConfigsourceWatchConfig: SourceWatchConfigapiConfig: ApiConfig+ generalConfig: GeneralConfigdataVersion: numbersetProject: (project: WikiProject | null) => void@@ -326,6 +334,7 @@ interface WikiState {setScheduledImportConfig: (config: ScheduledImportConfig) => voidsetSourceWatchConfig: (config: SourceWatchConfig) => voidsetApiConfig: (config: ApiConfig) => void+ setGeneralConfig: (config: GeneralConfig) => voidbumpDataVersion: () => void}@@ -431,6 +440,11 @@ export const useWikiStore = create<WikiState>((set) => ({token: "",},+ generalConfig: {+ autostart: false,+ closeBehavior: "ask",+ },+setLlmConfig: (llmConfig) => set({ llmConfig }),setProviderConfigs: (providerConfigs) => set({ providerConfigs }),setActivePresetId: (activePresetId) => set({ activePresetId }),@@ -442,6 +456,7 @@ export const useWikiStore = create<WikiState>((set) => ({setScheduledImportConfig: (scheduledImportConfig) => set({ scheduledImportConfig }),setSourceWatchConfig: (sourceWatchConfig) => set({ sourceWatchConfig }),setApiConfig: (apiConfig) => set({ apiConfig }),+ setGeneralConfig: (generalConfig) => set({ generalConfig }),bumpDataVersion: () => set((state) => ({ dataVersion: state.dataVersion + 1 })),}))