const fs = require("fs")
const path = require("path")
const {app } = require('electron')
var obj = {"type":"1","url":"http://192.168.3.203:8087/"};
var o = {}
var f = false;
try {
    o = fs.readFileSync(path.join(app.getPath('userData'), '/url.config.json'));

}catch (err){
    f = true;
    // 创建 newdir 目录
    fs.mkdir(app.getPath('userData'), function(err) {
        if (err) {
            throw err;
        }
        console.log('make dir success.');
        fs.writeFileSync(path.join(app.getPath('userData'), '/url.config.json'),JSON.stringify(obj))

    });
}finally {
    if(f){
        module.exports = obj
    }else{
        module.exports = JSON.parse(o)
    }
}

