Fixed: userData path not found error

This commit is contained in:
Molunerfinn 2017-12-08 15:52:41 +08:00
parent d87501212f
commit cfa360bb09
4 changed files with 10 additions and 3 deletions

View File

@ -2,11 +2,18 @@ import Datastore from 'lowdb'
import LodashId from 'lodash-id' import LodashId from 'lodash-id'
import FileSync from 'lowdb/adapters/FileSync' import FileSync from 'lowdb/adapters/FileSync'
import path from 'path' import path from 'path'
import fs from 'fs-extra'
import { remote, app } from 'electron' import { remote, app } from 'electron'
const APP = process.type === 'renderer' ? remote.app : app const APP = process.type === 'renderer' ? remote.app : app
const STORE_PATH = APP.getPath('userData') 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 adapter = new FileSync(path.join(STORE_PATH, '/data.json'))
const db = Datastore(adapter) const db = Datastore(adapter)

View File

@ -23,7 +23,7 @@ const settingWinURL = process.env.NODE_ENV === 'development'
: `file://${__dirname}/index.html#setting/upload` : `file://${__dirname}/index.html#setting/upload`
function createTray () { function createTray () {
tray = new Tray(`${__static}/menubarDefaultTemplate.png`) tray = new Tray(`${__static}/menubar.png`)
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
{ {
role: 'quit', role: 'quit',
@ -111,7 +111,7 @@ function createTray () {
} }
window.webContents.send('dragFiles', imgs) window.webContents.send('dragFiles', imgs)
}) })
toggleWindow() // toggleWindow()
} }
const createWindow = () => { const createWindow = () => {
@ -146,7 +146,7 @@ const createSettingWindow = () => {
settingWindow = new BrowserWindow({ settingWindow = new BrowserWindow({
height: 450, height: 450,
width: 800, width: 800,
show: true, show: false,
frame: true, frame: true,
center: true, center: true,
fullscreenable: false, fullscreenable: false,

BIN
static/menubar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B