mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-26 10:40:26 +08:00
Fixed: userData path not found error
This commit is contained in:
@@ -2,11 +2,18 @@ import Datastore from 'lowdb'
|
||||
import LodashId from 'lodash-id'
|
||||
import FileSync from 'lowdb/adapters/FileSync'
|
||||
import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
import { remote, app } from 'electron'
|
||||
|
||||
const APP = process.type === 'renderer' ? remote.app : app
|
||||
const STORE_PATH = APP.getPath('userData')
|
||||
|
||||
if (process.type !== 'renderer') {
|
||||
if (!fs.pathExistsSync(STORE_PATH)) {
|
||||
fs.mkdirpSync(STORE_PATH)
|
||||
}
|
||||
}
|
||||
|
||||
const adapter = new FileSync(path.join(STORE_PATH, '/data.json'))
|
||||
|
||||
const db = Datastore(adapter)
|
||||
|
||||
Reference in New Issue
Block a user