feat(desktop): ✨ 实现一些功能
1. 实现任务暂停功能 2. 实现页面的国际化功能 3.优化项目的结构以及BUG 4. 优化系统架构 5. 实现一大堆的功能
This commit is contained in:
@@ -5,6 +5,9 @@ import path from 'path'
|
||||
import { ReadingReflectionTaskBatch } from './entities/ReadingReflectionTaskBatch'
|
||||
import { ReadingReflectionTaskItem } from './entities/ReadingReflectionTaskItem'
|
||||
import { ReadingPersona } from './entities/ReadingPersona' // 必须导入
|
||||
import { DatabaseConnectionError } from '@main/utils/errors/databaseError'
|
||||
import { ErrorHandler } from '@main/utils/errorHandler'
|
||||
import logger from '@shared/utils/logger'
|
||||
|
||||
const dbPath = app.isPackaged
|
||||
? path.join(app.getPath('userData'), 'reflections.db')
|
||||
@@ -26,9 +29,20 @@ export const initDB = async () => {
|
||||
if (!AppDataSource.isInitialized) {
|
||||
try {
|
||||
await AppDataSource.initialize()
|
||||
console.log('Database initialized successfully at:', dbPath)
|
||||
} catch (err) {
|
||||
console.error('Error during Data Source initialization', err)
|
||||
logger.info('DATABASE_INITIALIZED', {
|
||||
message: 'Database initialized successfully',
|
||||
path: dbPath
|
||||
})
|
||||
} catch (err: any) {
|
||||
const error = new DatabaseConnectionError('数据库初始化失败', {
|
||||
originalError: err.message,
|
||||
stack: err.stack,
|
||||
path: dbPath
|
||||
}, {
|
||||
cause: err
|
||||
})
|
||||
ErrorHandler.handleError(error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
return AppDataSource
|
||||
|
||||
Reference in New Issue
Block a user