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: improve dark theme rendering
nash_subf6394f665c4
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 36e2d17c..c2d0e942 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -16,7 +16,13 @@"width": 1200,"height": 800,"resizable": true,- "fullscreen": false+ "fullscreen": false,+ "hiddenTitle": true,+ "titleBarStyle": "Overlay",+ "trafficLightPosition": {+ "x": 16,+ "y": 16+ }}],"security": {diff --git a/src/App.tsx b/src/App.tsxindex 615c283d..998880c2 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -446,7 +446,7 @@ function App() {if (loading) {return (- <div className="flex h-screen items-center justify-center bg-background text-muted-foreground">+ <div className="flex h-full items-center justify-center bg-background text-muted-foreground">Loading...</div>)diff --git a/src/components/editor/wiki-reader.tsx b/src/components/editor/wiki-reader.tsxindex ff706164..f4ea67ef 100644--- a/src/components/editor/wiki-reader.tsx+++ b/src/components/editor/wiki-reader.tsx@@ -12,7 +12,6 @@ import { detectLanguage } from "@/lib/detect-language"import { getHtmlLang, getTextDirection } from "@/lib/language-metadata"import { useWikiStore } from "@/stores/wiki-store"import { MermaidDiagram, unwrapMermaidPre } from "@/components/mermaid-diagram"-import "@milkdown/theme-nord/style.css"interface WikiReaderProps {body: string@@ -59,7 +58,7 @@ export function WikiReader({ body }: WikiReaderProps) {return (<div- className="milkdown-theme-nord min-w-0 max-w-none"+ className="prose prose-invert min-w-0 max-w-none"dir={direction}lang={htmlLang}style={{ textAlign: "start" }}@@ -86,6 +85,30 @@ export function WikiReader({ body }: WikiReaderProps) {</a>)},+ h1: ({ children, ...props }) => (+ <h1+ className="mb-4 mt-0 border-b border-border/60 pb-3 text-3xl font-semibold leading-tight tracking-normal text-foreground"+ {...props}+ >+ {children}+ </h1>+ ),+ h2: ({ children, ...props }) => (+ <h2+ className="mb-3 mt-8 border-b border-border/40 pb-2 text-2xl font-semibold leading-tight tracking-normal text-foreground"+ {...props}+ >+ {children}+ </h2>+ ),+ h3: ({ children, ...props }) => (+ <h3+ className="mb-2 mt-6 text-xl font-semibold leading-snug tracking-normal text-foreground"+ {...props}+ >+ {children}+ </h3>+ ),img: ({ src, alt, ...props }) => (<imgsrc={diff --git a/src/components/graph/graph-view.tsx b/src/components/graph/graph-view.tsxindex 254b44ad..dfdfeba3 100644--- a/src/components/graph/graph-view.tsx+++ b/src/components/graph/graph-view.tsx@@ -61,6 +61,13 @@ const COMMUNITY_COLORS = []type ColorMode = "type" | "community"+type GraphThemePalette = {+ defaultEdge: string+ label: string+ mutedNodeMixTarget: string+ dimmedEdge: string+ activeEdge: string+}const BASE_NODE_SIZE = 8const MAX_NODE_SIZE = 28@@ -71,6 +78,39 @@ const WORKER_LAYOUT_NODE_THRESHOLD = 220type HoverState = { node: string; neighbors: Set<string> } | null+function graphThemePalette(isDark: boolean): GraphThemePalette {+ return isDark+ ? {+ defaultEdge: "rgba(100,116,139,0.18)",+ label: "#e2e8f0",+ mutedNodeMixTarget: "#334155",+ dimmedEdge: "rgba(71,85,105,0.12)",+ activeEdge: "#38bdf8",+ }+ : {+ defaultEdge: "#cbd5e1",+ label: "#1e293b",+ mutedNodeMixTarget: "#e2e8f0",+ dimmedEdge: "rgba(148,163,184,0.22)",+ activeEdge: "#1e293b",+ }+}++function useResolvedDarkMode(): boolean {+ const [isDark, setIsDark] = useState(() => document.documentElement.classList.contains("dark"))++ useEffect(() => {+ const root = document.documentElement+ const sync = () => setIsDark(root.classList.contains("dark"))+ sync()+ const observer = new MutationObserver(sync)+ observer.observe(root, { attributes: true, attributeFilter: ["class"] })+ return () => observer.disconnect()+ }, [])++ return isDark+}+function nodeColor(type: string): string {if (NODE_TYPE_COLORS[type]) return NODE_TYPE_COLORS[type]let hash = 0@@ -329,10 +369,12 @@ function GraphRenderSettings({hoverState,highlightedNodes,nodeCount,+ palette,}: {hoverState: HoverStatehighlightedNodes: Set<string>nodeCount: number+ palette: GraphThemePalette}) {const sigma = useSigma()const setSettings = useSetSettings()@@ -363,7 +405,7 @@ function GraphRenderSettings({result.forceLabel = true}if ((hasHover && !isHoverNode && !isHoverNeighbor) || (hasHighlight && !isHighlighted)) {- result.color = mixColor(attrs.color ?? "#94a3b8", "#e2e8f0", 0.75)+ result.color = mixColor(attrs.color ?? "#94a3b8", palette.mutedNodeMixTarget, 0.75)result.label = ""result.size = (attrs.size ?? BASE_NODE_SIZE) * 0.6}@@ -383,18 +425,18 @@ function GraphRenderSettings({return result}if ((hasHover && !hoverEdge) || (hasHighlight && !highlightedEdge)) {- result.color = "#f1f5f9"+ result.color = palette.dimmedEdgeresult.size = 0.3}if (hoverEdge || highlightedEdge) {- result.color = "#1e293b"+ result.color = palette.activeEdgeresult.size = Math.max(2, (attrs.size ?? 1) * 1.5)}return result},})sigma.refresh()- }, [setSettings, sigma, hoverState, highlightedNodes, nodeCount])+ }, [setSettings, sigma, hoverState, highlightedNodes, nodeCount, palette])return null}@@ -498,6 +540,8 @@ export function GraphView() {const dataVersion = useWikiStore((s) => s.dataVersion)const setSelectedFile = useWikiStore((s) => s.setSelectedFile)const setFileContent = useWikiStore((s) => s.setFileContent)+ const isDarkMode = useResolvedDarkMode()+ const graphPalette = useMemo(() => graphThemePalette(isDarkMode), [isDarkMode])const [nodes, setNodes] = useState<GraphNode[]>([])const [edges, setEdges] = useState<GraphEdge[]>([])@@ -964,11 +1008,11 @@ export function GraphView() {renderEdgeLabels: false,hideEdgesOnMove: true,hideLabelsOnMove: true,- defaultEdgeColor: "#cbd5e1",+ defaultEdgeColor: graphPalette.defaultEdge,defaultNodeColor: "#94a3b8",labelSize: 13,labelWeight: "bold",- labelColor: { color: "#1e293b" },+ labelColor: { color: graphPalette.label },stagePadding: 30,}}>@@ -988,6 +1032,7 @@ export function GraphView() {hoverState={hoverState}highlightedNodes={searchActive ? searchedGraph.matchedNodeIds : highlightedNodes}nodeCount={searchedGraph.nodes.length}+ palette={graphPalette}/><ZoomControls /></SigmaContainer>diff --git a/src/components/layout/app-layout.tsx b/src/components/layout/app-layout.tsxindex bcfe85ee..a504bb42 100644--- a/src/components/layout/app-layout.tsx+++ b/src/components/layout/app-layout.tsx@@ -96,7 +96,7 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {// existing IconSidebar + content row below. Banner is shrink-0// so it doesn't compress the work area; main row is flex-1 so// it fills the rest of the viewport.- <div className="flex h-screen flex-col bg-background text-foreground">+ <div className="flex h-full flex-col bg-background text-foreground"><UpdateBanner /><div className="flex min-h-0 flex-1"><IconSidebar onSwitchProject={onSwitchProject} />diff --git a/src/components/project/welcome-screen.tsx b/src/components/project/welcome-screen.tsxindex d1a08f9f..bdf69815 100644--- a/src/components/project/welcome-screen.tsx+++ b/src/components/project/welcome-screen.tsx@@ -31,7 +31,7 @@ export function WelcomeScreen({}return (- <div className="flex h-screen items-center justify-center bg-background">+ <div className="flex h-full items-center justify-center bg-background"><div className="flex flex-col items-center gap-8 px-4"><div className="text-center"><h1 className="text-3xl font-bold">{t("app.title")}</h1>diff --git a/src/components/settings/sections/interface-section.tsx b/src/components/settings/sections/interface-section.tsxindex f637bfe5..0431655a 100644--- a/src/components/settings/sections/interface-section.tsx+++ b/src/components/settings/sections/interface-section.tsx@@ -1,11 +1,12 @@import { useTranslation } from "react-i18next"import { Label } from "@/components/ui/label"import type { SettingsDraft, DraftSetter } from "../settings-types"+import type { AppTheme } from "@/lib/theme"interface Props {draft: SettingsDraftsetDraft: DraftSetter- onThemeChange?: (theme: "light" | "dark" | "system") => void+ onThemeChange?: (theme: AppTheme) => void}const UI_LANGUAGES = [diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsxindex 422bffa0..0ab205d5 100644--- a/src/components/settings/settings-view.tsx+++ b/src/components/settings/settings-view.tsx@@ -22,6 +22,7 @@ import { useWikiStore } from "@/stores/wiki-store"import { useChatStore } from "@/stores/chat-store"import { useUpdateStore, hasAvailableUpdate } from "@/stores/update-store"import { loadSourceWatchConfig, saveLanguage, saveTheme, loadTheme } from "@/lib/project-store"+import { applyTheme, type AppTheme } from "@/lib/theme"import type { SettingsDraft, DraftSetter } from "./settings-types"import { normalizeSourceWatchConfig } from "@/lib/source-watch-config"import { LlmProviderSection } from "./sections/llm-provider-section"@@ -90,7 +91,7 @@ function initialDraft(maxHistoryMessages: number,uiLanguage: string,projectPath?: string,- theme?: "light" | "dark" | "system",+ theme?: AppTheme,): SettingsDraft {// Show absolute path: if stored path is empty, show default using project path// If stored path is relative (legacy), prepend project path@@ -150,23 +151,6 @@ function initialDraft(}}-function applyTheme(theme: "light" | "dark" | "system") {- const root = document.documentElement- if (theme === "system") {- // Remove the class and let the media query handle it- root.classList.remove("light", "dark")- // Check system preference- if (window.matchMedia("(prefers-color-scheme: dark)").matches) {- root.classList.add("dark")- } else {- root.classList.add("light")- }- } else {- root.classList.remove("light", "dark")- root.classList.add(theme)- }-}-export function SettingsView() {const { t } = useTranslation()const project = useWikiStore((s) => s.project)@@ -200,7 +184,7 @@ export function SettingsView() {const [active, setActive] = useState<CategoryId>("llm")const [saved, setSaved] = useState(false)- const [currentTheme, setCurrentTheme] = useState<"light" | "dark" | "system">("system")+ const [currentTheme, setCurrentTheme] = useState<AppTheme>("system")const [draft, setDraftState] = useState<SettingsDraft>(() =>initialDraft(llmConfig,@@ -267,6 +251,7 @@ export function SettingsView() {maxHistoryMessages,prev.uiLanguage,project?.path,+ prev.theme,),)}, [@@ -447,6 +432,7 @@ export function SettingsView() {scheduledImportConfig,setMaxHistoryMessages,outputLanguage,+ currentTheme,])const body = useMemo(() => {diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex 3c9c80b9..eb20172d 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -494,7 +494,7 @@"uiLanguage": "UI Language","uiLanguageHint": "Affects labels, buttons, and other UI strings only. The AI output language is set separately in Output Preferences.","theme": "Theme",- "themeHint": "Choose between light, dark, or system theme. System theme follows your operating system's appearance setting.",+ "themeHint": "Preview applies immediately. Save settings to keep the selected theme. System follows your operating system appearance.","themeLight": "Light","themeDark": "Dark","themeSystem": "System"diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex 418c3bcf..fb60b3d6 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -494,7 +494,7 @@"uiLanguage": "UI 语言","uiLanguageHint": "只影响按钮、标签这些 UI 文案,不影响 AI 输出语言(那个在\"输出偏好\"里单独设置)。","theme": "主题",- "themeHint": "选择浅色、深色或跟随系统主题。系统主题会跟随操作系统的外观设置。",+ "themeHint": "预览会立即生效。保存设置后会记住所选主题。跟随系统会使用操作系统的外观设置。","themeLight": "浅色","themeDark": "深色","themeSystem": "跟随系统"diff --git a/src/index.css b/src/index.cssindex b153bb06..5efc33ab 100644--- a/src/index.css+++ b/src/index.css@@ -49,6 +49,7 @@}:root {+ --window-titlebar-height: 0px;--background: oklch(1 0 0);--foreground: oklch(0.145 0 0);--card: oklch(1 0 0);@@ -117,18 +118,47 @@--sidebar-ring: oklch(0.556 0 0);}+.platform-macos {+ --window-titlebar-height: 30px;+}+@layer base {* {@apply border-border outline-ring/50;}+ html,+ body,+ #root {+ height: 100%;+ }body {@apply bg-background text-foreground;}+ #root {+ box-sizing: border-box;+ height: 100vh;+ background: var(--background);+ }+ .platform-macos #root {+ padding-top: var(--window-titlebar-height);+ }html {@apply font-sans;}}+.platform-macos body::before {+ content: "";+ position: fixed;+ z-index: 2147483647;+ top: 0;+ right: 0;+ left: 0;+ height: var(--window-titlebar-height);+ background: var(--background);+ -webkit-app-region: drag;+}+/* Legend scrollbar - left side */.legend-scroll {scrollbar-width: thin;@@ -150,4 +180,4 @@.legend-scroll::-webkit-scrollbar-corner {background: transparent;-}\ No newline at end of file+}diff --git a/src/lib/ingest-queue.integration.test.ts b/src/lib/ingest-queue.integration.test.tsindex 869f4690..8c2dbc86 100644--- a/src/lib/ingest-queue.integration.test.ts+++ b/src/lib/ingest-queue.integration.test.ts@@ -94,8 +94,6 @@ describe("ingest-queue persistence — write", () => {return false}})- // Add small delay to ensure file is fully written- await new Promise(resolve => setTimeout(resolve, 50))const parsed = JSON.parse(await readQueueFile())expect(parsed[0].sourcePath).toBe("raw/sources/a.md")})@@ -114,8 +112,6 @@ describe("ingest-queue persistence — write", () => {return false}})- // Add small delay to ensure file is fully written- await new Promise(resolve => setTimeout(resolve, 50))const parsed = JSON.parse(await readQueueFile())expect(parsed).toHaveLength(1)expect(parsed[0].sourcePath).toBe("raw/sources/a.md")@@ -134,8 +130,6 @@ describe("ingest-queue persistence — write", () => {return false}})- // Add small delay to ensure file is fully written- await new Promise(resolve => setTimeout(resolve, 50))const parsed = JSON.parse(await readQueueFile()) as Array<{ sourcePath: string; folderContext: string }>const paths = parsed.map((p) => p.sourcePath)expect(paths).toContain("raw/sources/注意力机制.pdf")@@ -276,8 +270,6 @@ describe("ingest-queue persistence — restore round-trip", () => {return false}})- // Add small delay to ensure file is fully written- await new Promise(resolve => setTimeout(resolve, 50))// Verify on-disk state before we blow away memoryconst onDisk = JSON.parse(await readQueueFile()) as Array<{ sourcePath: string; folderContext: string }>expect(onDisk[0].sourcePath).toBe("raw/sources/注意力.pdf")diff --git a/src/lib/theme.ts b/src/lib/theme.tsnew file mode 100644index 00000000..eae9731c--- /dev/null+++ b/src/lib/theme.ts@@ -0,0 +1,46 @@+import { loadTheme } from "@/lib/project-store"++export type AppTheme = "light" | "dark" | "system"++let activeTheme: AppTheme = "system"+let mediaQuery: MediaQueryList | null = null+let mediaListenerInstalled = false++function systemPrefersDark(): boolean {+ return window.matchMedia("(prefers-color-scheme: dark)").matches+}++export function applyTheme(theme: AppTheme): void {+ activeTheme = theme+ const root = document.documentElement+ const resolved = theme === "system"+ ? systemPrefersDark()+ ? "dark"+ : "light"+ : theme++ root.classList.remove("light", "dark")+ root.classList.add(resolved)+ root.dataset.theme = theme+}++export function watchSystemTheme(): void {+ if (mediaListenerInstalled) return+ mediaQuery = window.matchMedia("(prefers-color-scheme: dark)")+ mediaQuery.addEventListener("change", () => {+ if (activeTheme === "system") applyTheme("system")+ })+ mediaListenerInstalled = true+}++export async function loadAndApplyTheme(): Promise<AppTheme> {+ try {+ const savedTheme = await loadTheme()+ const theme = savedTheme ?? "system"+ applyTheme(theme)+ return theme+ } catch {+ applyTheme("system")+ return "system"+ }+}diff --git a/src/main.tsx b/src/main.tsxindex 99acfa8e..c68671ac 100644--- a/src/main.tsx+++ b/src/main.tsx@@ -3,38 +3,20 @@ import ReactDOM from "react-dom/client";import App from "./App";import "./index.css";import "@/i18n";-import { loadTheme } from "@/lib/project-store";+import { loadAndApplyTheme, watchSystemTheme } from "@/lib/theme";++function applyPlatformClass() {+ const isTauri = "__TAURI_INTERNALS__" in window || "__TAURI__" in window;+ if (isTauri && navigator.userAgent.includes("Mac OS X")) {+ document.documentElement.classList.add("platform-macos");+ }+}// Apply theme before render to avoid flashasync function initApp() {- const root = document.documentElement;-- // Try to load saved theme- try {- const savedTheme = await loadTheme();- if (savedTheme) {- if (savedTheme === "system") {- // Follow system preference- if (window.matchMedia("(prefers-color-scheme: dark)").matches) {- root.classList.add("dark");- } else {- root.classList.add("light");- }- } else {- root.classList.add(savedTheme);- }- } else {- // Default to system preference- if (window.matchMedia("(prefers-color-scheme: dark)").matches) {- root.classList.add("dark");- } else {- root.classList.add("light");- }- }- } catch {- // Default to light if loading fails- root.classList.add("light");- }+ applyPlatformClass();+ await loadAndApplyTheme();+ watchSystemTheme();ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(<React.StrictMode>