Files
MarkLite/src/renderer/db/schema.ts
T
thzxx c0e16f2885 v0.3.7: 修复保存竞争态 + 新增源码编辑模式
Bug修复:
  - BUG-10 修复: 保存文件时 watcher restart 触发虚假 change 事件覆盖编辑器内容
    - ipc-handlers.ts: restart watcher 在 setSelfWriting(true) 保护内执行
    - App.tsx handleReloadModified: 增加 if (tab?.isModified) return 安全守卫

新功能:
  - 新增源码(Source)视图模式,直接用 textarea 编辑原始 Markdown
  - ViewMode 扩展为 editor|preview|source
  - 工具栏增加源码按钮,快捷键 Ctrl+3
  - 内容与 WYSIWYG 编辑器共享 tabStore,切换模式不丢内容

验证: TS 0错误, ESLint 0错误(1个预存警告), 90/90测试通过
2026-06-04 15:17:26 +08:00

48 lines
1.0 KiB
TypeScript

import Dexie, { type EntityTable } from 'dexie'
export interface TabSnapshot {
id: string
filePath: string | null
content: string
scrollTop: number
selectionStart: number
selectionEnd: number
isModified: boolean
updatedAt: number
}
export interface ActiveTabRecord {
id: string // 固定为 'current'
activeTabId: string | null
}
export interface SettingsRecord {
id: string // 固定为 'default'
darkMode: boolean
viewMode: 'editor' | 'preview' | 'source'
sidebarCollapsed: boolean
sidebarWidth: number
}
export interface RecentFile {
id?: number
filePath: string
lastOpened: number
}
const db = new Dexie('MarkLite') as Dexie & {
tabSnapshots: EntityTable<TabSnapshot, 'id'>
settings: EntityTable<SettingsRecord, 'id'>
recentFiles: EntityTable<RecentFile, 'id'>
activeTab: EntityTable<ActiveTabRecord, 'id'>
}
db.version(1).stores({
tabSnapshots: 'id, filePath, updatedAt',
settings: 'id',
recentFiles: '++id, filePath, lastOpened',
activeTab: 'id'
})
export { db }