feat: ship v0.3.0 with P2.1 editor polish and P3 AI collaboration
Add chapter reorder, search replace, inspiration capture, and AI chat with context editing, settings, offline handling, and naming checks. Fix dev black screen by keeping process.env reads in the main process only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { DEFAULT_SHORTCUTS } from '../../shared/default-shortcuts'
|
||||
import type { GlobalSettings } from '../../shared/types'
|
||||
import { DEFAULT_AI_CONFIG, type GlobalSettings } from '../../shared/types'
|
||||
|
||||
const FILE = 'global_settings.json'
|
||||
|
||||
function defaultAiConfig() {
|
||||
return {
|
||||
...DEFAULT_AI_CONFIG,
|
||||
baseUrl: process.env.BILIN_AI_BASE_URL ?? DEFAULT_AI_CONFIG.baseUrl,
|
||||
model: process.env.BILIN_AI_MODEL ?? DEFAULT_AI_CONFIG.model
|
||||
}
|
||||
}
|
||||
|
||||
function defaults(): GlobalSettings {
|
||||
return {
|
||||
penName: '未命名作者',
|
||||
@@ -16,7 +24,9 @@ function defaults(): GlobalSettings {
|
||||
snapshotIntervalMs: 300_000,
|
||||
snapshotMaxAuto: 20,
|
||||
snapshotMaxPersist: 3,
|
||||
searchHistory: []
|
||||
searchHistory: [],
|
||||
aiConfig: defaultAiConfig(),
|
||||
namingIgnoreWords: []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +45,8 @@ export class GlobalSettingsService {
|
||||
return {
|
||||
...defaults(),
|
||||
...raw,
|
||||
shortcuts: { ...DEFAULT_SHORTCUTS, ...raw.shortcuts }
|
||||
shortcuts: { ...DEFAULT_SHORTCUTS, ...raw.shortcuts },
|
||||
aiConfig: { ...DEFAULT_AI_CONFIG, ...raw.aiConfig }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +57,8 @@ export class GlobalSettingsService {
|
||||
...partial,
|
||||
shortcuts: partial.shortcuts
|
||||
? { ...current.shortcuts, ...partial.shortcuts }
|
||||
: current.shortcuts
|
||||
: current.shortcuts,
|
||||
aiConfig: partial.aiConfig ? { ...current.aiConfig, ...partial.aiConfig } : current.aiConfig
|
||||
}
|
||||
writeFileSync(this.filePath(), JSON.stringify(next, null, 2), 'utf-8')
|
||||
return next
|
||||
|
||||
Reference in New Issue
Block a user