import { Low, JSONFile } from 'lowdb' import { join } from 'path' import { app } from '@electron/remote' const file = join(app.getPath('userData'), 'gofaster-db.json') const adapter = new JSONFile(file) const db = new Low(adapter) // 初始化数据库 async function initDB() { await db.read() db.data ||= { settings: {}, activities: [], stats: {} } await db.write() } export { db, initDB }