diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index c7af41c..0440394 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -14,7 +14,6 @@ import { useIpcListeners } from './hooks/useIpcListeners' import { MeToast } from './lib/toast' import { closeDatabase } from './db/schema' import { Toolbar } from './components/Toolbar/Toolbar' -import { StatusBar } from './components/StatusBar' import { TabBar } from './components/TabBar/TabBar' import { Editor } from './components/Editor/Editor' import { Sidebar } from './components/Sidebar/Sidebar' @@ -126,7 +125,6 @@ export function App() { )} - {showAbout && } diff --git a/src/renderer/components/Editor/Editor.tsx b/src/renderer/components/Editor/Editor.tsx index fd76b1e..ae3fd43 100644 --- a/src/renderer/components/Editor/Editor.tsx +++ b/src/renderer/components/Editor/Editor.tsx @@ -56,8 +56,6 @@ export const Editor = React.memo(function Editor({ themeMode, onAppSave }: Edito const updateTabScroll = useTabStore(s => s.updateTabScroll) const viewMode = useEditorStore(s => s.viewMode) const setViewMode = useEditorStore(s => s.setViewMode) - const setStats = useEditorStore(s => s.setStats) - const setCursor = useEditorStore(s => s.setCursor) const setZenMode = useEditorStore(s => s.setZenMode) const containerRef = useRef(null) @@ -197,38 +195,12 @@ export const Editor = React.memo(function Editor({ themeMode, onAppSave }: Edito // 首次渲染后延迟触发一次 setTimeout(renderMermaid, 300) - // v0.6.0: 实时状态同步 — getStats + 光标/zen 事件 → editorStore(状态栏消费) - const syncStats = () => { - try { - const s = editor.getStats() - setStats({ - characters: s.characters, - words: s.words, - chineseChars: s.chineseChars, - englishWords: s.englishWords, - lines: s.lines, - readingTime: s.readingTime, - }) - } catch { - /* 容错 */ - } - } - const syncCursor = (pos?: { line: number; column: number }) => { - try { - setCursor(pos ?? editor.getCursorPosition()) - } catch { - /* 容错 */ - } - } + // v0.6.0: Zen 状态同步 → editorStore(Toolbar 消费) + // 文档统计由编辑器自带底栏展示(wordCount: true),无需应用层同步 const syncZen = (zen: boolean) => { setZenMode(Boolean(zen)) } - editor.on('change', syncStats) - editor.on('input', syncStats) - editor.on('cursorMove', syncCursor) editor.on('zenChange', syncZen) - syncStats() - syncCursor() return () => { editor.destroy() diff --git a/src/renderer/components/StatusBar/StatusBar.tsx b/src/renderer/components/StatusBar/StatusBar.tsx deleted file mode 100644 index 9974f7f..0000000 --- a/src/renderer/components/StatusBar/StatusBar.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react' -import { useEditorStore } from '../../stores/editorStore' -import { useAutoSaveStore } from '../../stores/autoSaveStore' - -/** - * v0.6.0: 状态栏 — 展示文档统计 / 光标位置 / 自动保存状态。 - * 数据来自 editorStore(Editor 组件绑定 MetonaEditor 事件实时写入)。 - */ -export const StatusBar = React.memo(function StatusBar() { - const stats = useEditorStore(s => s.stats) - const cursor = useEditorStore(s => s.cursor) - const zenMode = useEditorStore(s => s.zenMode) - const isAutoSaving = useAutoSaveStore(s => s.isAutoSaving) - const autoSaveEnabled = useAutoSaveStore(s => s.autoSaveEnabled) - - return ( -
- {zenMode && 🧘 Zen} - {stats && ( - - {stats.words} 词 · {stats.lines} 行 · {stats.readingTime} 分钟 - - )} - - {cursor && ( - // getCursorPosition: line 为 1-based,column 为 0-based - - 行 {cursor.line}, 列 {cursor.column + 1} - - )} - - {isAutoSaving ? '保存中...' : autoSaveEnabled ? '自动保存' : '手动保存'} - -
- ) -}) - -StatusBar.displayName = 'StatusBar' diff --git a/src/renderer/components/StatusBar/index.ts b/src/renderer/components/StatusBar/index.ts deleted file mode 100644 index 05e9f44..0000000 --- a/src/renderer/components/StatusBar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { StatusBar } from './StatusBar' diff --git a/src/renderer/stores/__tests__/editorStore.test.ts b/src/renderer/stores/__tests__/editorStore.test.ts index 9d35e6c..7f93601 100644 --- a/src/renderer/stores/__tests__/editorStore.test.ts +++ b/src/renderer/stores/__tests__/editorStore.test.ts @@ -103,30 +103,7 @@ describe('editorStore', () => { describe('editor live state (v0.6.0)', () => { beforeEach(() => { - useEditorStore.setState({ stats: null, cursor: null, zenMode: false }) - }) - - it('should set stats', () => { - useEditorStore.getState().setStats({ - characters: 10, - words: 2, - chineseChars: 5, - englishWords: 1, - lines: 3, - readingTime: 1, - }) - expect(useEditorStore.getState().stats?.words).toBe(2) - expect(useEditorStore.getState().stats?.lines).toBe(3) - }) - - it('should clear stats', () => { - useEditorStore.getState().setStats(null) - expect(useEditorStore.getState().stats).toBeNull() - }) - - it('should set cursor position', () => { - useEditorStore.getState().setCursor({ line: 5, column: 12 }) - expect(useEditorStore.getState().cursor).toEqual({ line: 5, column: 12 }) + useEditorStore.setState({ zenMode: false }) }) it('should set zen mode', () => { diff --git a/src/renderer/stores/editorStore.ts b/src/renderer/stores/editorStore.ts index eeee1c1..eaf50fb 100644 --- a/src/renderer/stores/editorStore.ts +++ b/src/renderer/stores/editorStore.ts @@ -16,21 +16,6 @@ export function getMetonaEditor(): MarkdownEditor | null { const THEME_CYCLE: ThemeMode[] = ['light', 'dark', 'warm'] -/** v0.6.0: 编辑器实时状态(由 Editor 组件绑定事件写入,状态栏消费) */ -export interface EditorLiveStats { - characters: number - words: number - chineseChars: number - englishWords: number - lines: number - readingTime: number -} - -export interface EditorCursor { - line: number - column: number -} - interface EditorState { viewMode: ViewMode themeMode: ThemeMode @@ -38,9 +23,7 @@ interface EditorState { externallyModified: { filePath: string } | null // UX-02: 全局加载状态 loadingStates: Record - // v0.6.0: 编辑器实时状态 - stats: EditorLiveStats | null - cursor: EditorCursor | null + // v0.6.0: Zen 模式状态(Toolbar 消费) zenMode: boolean setViewMode: (mode: ViewMode) => void @@ -50,9 +33,6 @@ interface EditorState { // UX-02: 加载状态管理 setLoading: (key: string, loading: boolean) => void isLoading: (key: string) => boolean - // v0.6.0: 编辑器状态同步 - setStats: (stats: EditorLiveStats | null) => void - setCursor: (cursor: EditorCursor | null) => void setZenMode: (zen: boolean) => void } @@ -61,8 +41,6 @@ export const useEditorStore = create((set, get) => ({ themeMode: 'light', externallyModified: null, loadingStates: {}, - stats: null, - cursor: null, zenMode: false, setViewMode: (mode: ViewMode) => set({ viewMode: mode }), @@ -80,7 +58,5 @@ export const useEditorStore = create((set, get) => ({ loadingStates: { ...state.loadingStates, [key]: loading }, })), isLoading: (key: string) => get().loadingStates[key] ?? false, - setStats: (stats: EditorLiveStats | null) => set({ stats }), - setCursor: (cursor: EditorCursor | null) => set({ cursor }), setZenMode: (zenMode: boolean) => set({ zenMode }), })) diff --git a/src/renderer/styles/global.css b/src/renderer/styles/global.css index 3698a57..149701a 100644 --- a/src/renderer/styles/global.css +++ b/src/renderer/styles/global.css @@ -87,38 +87,6 @@ body { min-height: 0; } -/* v0.6.0: StatusBar */ -#statusbar { - height: var(--statusbar-height); - background: var(--bg); - border-top: 1px solid var(--border); - display: flex; - align-items: center; - gap: 16px; - padding: 0 12px; - font-size: 12px; - color: var(--text-tertiary); - flex-shrink: 0; - user-select: none; -} - -.statusbar-item { - white-space: nowrap; -} - -.statusbar-spacer { - flex: 1; -} - -.statusbar-zen { - color: var(--primary); - font-weight: 500; -} - -.statusbar-autosave.saving { - color: var(--primary); -} - #main-content { flex: 1; display: flex;