mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-06-10 03:07:32 +08:00
storage
This commit is contained in:
3
app.js
3
app.js
@@ -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');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user