fix: 修复linux上配置文件路径错误的问题
This commit is contained in:
+4
-2
@@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
const { debounce } = require('lodash');
|
const { debounce } = require('lodash');
|
||||||
|
|
||||||
@@ -17,8 +18,9 @@ const config = {
|
|||||||
skipTrayIcon: false
|
skipTrayIcon: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let configPath = path.resolve(path.dirname(process.execPath), 'config.json');
|
||||||
try {
|
try {
|
||||||
let userConfig = fs.readFileSync('./config.json');
|
let userConfig = fs.readFileSync(configPath);
|
||||||
if (userConfig) {
|
if (userConfig) {
|
||||||
Object.assign(config, JSON.parse(userConfig.toString()));
|
Object.assign(config, JSON.parse(userConfig.toString()));
|
||||||
}
|
}
|
||||||
@@ -28,7 +30,7 @@ catch { }
|
|||||||
async function flushConfig() {
|
async function flushConfig() {
|
||||||
const flush = promisify(fs.writeFile.bind(fs));
|
const flush = promisify(fs.writeFile.bind(fs));
|
||||||
try {
|
try {
|
||||||
await flush('./config.json', JSON.stringify(config, null, 4));
|
await flush(configPath, JSON.stringify(config, null, 4));
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
const { notify } = require('./tools');
|
const { notify } = require('./tools');
|
||||||
|
|||||||
Reference in New Issue
Block a user