This commit is contained in:
gaoshuaixing
2020-12-18 16:10:16 +08:00
parent 0751b43fe8
commit fdc796045a
2 changed files with 6 additions and 4 deletions

3
app.js
View File

@@ -9,6 +9,8 @@ const path = require('path');
const lowdb = require('lowdb');
const FileSync = require('lowdb/adapters/FileSync');
const utils = require('./app/utils/utils');
const os = require('os');
const storageDir = path.normalize(os.homedir() + '/electron-egg-storage/');
class AppBootHook {
constructor(app) {
@@ -39,7 +41,6 @@ class AppBootHook {
// Worker is ready, can do some things
// don't need to block the app boot.
// 数据库
const storageDir = path.normalize('./storage/');
if (!fs.existsSync(storageDir)) {
utils.mkdir(storageDir);
utils.chmodPath(storageDir, '777');

View File

@@ -6,10 +6,11 @@ const FileSync = require('lowdb/adapters/FileSync');
const fs = require('fs');
const getPort = require('get-port');
const utils = require('../app/utils/utils');
const storageDir = path.normalize('./storage/');
const os = require('os');
const storageDir = path.normalize(os.homedir() + '/electron-egg-storage/');
exports.setup = function () {
// console.log('storageDir', storageDir);
if (!fs.existsSync(storageDir)) {
utils.mkdir(storageDir);
utils.chmodPath(storageDir, '777');
@@ -27,7 +28,7 @@ exports.setup = function () {
exports.instance = function (file = null) {
if (!file) {
file = path.normalize('./storage/db.json');
file = path.normalize(storageDir +'db.json');
}
const isExist = fs.existsSync(file);
if (!isExist) {