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