You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
418 B
20 lines
418 B
4 weeks ago
|
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 }
|