You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
const osHomedir = require('os-homedir');
|
|
var app = require('electron').app
|
|
if (!app) {
|
|
r = require('electron').remote
|
|
app = require('electron').remote.app
|
|
}
|
|
|
|
const path = require('path')
|
|
const fs = require('fs');
|
|
|
|
var pathJoin = function (name) {
|
|
// return path.join(path.dirname(app.getPath('exe')), name);
|
|
return path.join(osHomedir(), "ouxuan.oa", name)
|
|
}
|
|
|
|
exports.pathJoin = pathJoin
|
|
|
|
|
|
if (!fs.existsSync(pathJoin("data"))) {
|
|
fs.mkdirSync(pathJoin("data"), {
|
|
recursive: true
|
|
})
|
|
}
|
|
|
|
|
|
exports.ProjectMapPath = pathJoin("data/project-map.json")
|
|
|
|
exports.TaskPath = pathJoin("data/task.json")
|
|
exports.UsernamePath = pathJoin("data/username.json")
|
|
|
|
|
|
if (!fs.existsSync(pathJoin("data/open-type-map.json"))) {
|
|
fs.writeFileSync(pathJoin("data/open-type-map.json"), "{}")
|
|
}
|
|
exports.OpenTypeMapPath = pathJoin("data/open-type-map.json")
|
|
|
|
|
|
|
|
if (!fs.existsSync(pathJoin("data/config.json"))) {
|
|
fs.writeFileSync(pathJoin("data/config.json"), JSON.stringify({
|
|
TaskType: "my", // wwc 未完成
|
|
TaskCount: 0,
|
|
}))
|
|
}
|
|
|
|
exports.GetConfig = function () {
|
|
return JSON.parse(fs.readFileSync(pathJoin("data/config.json")))
|
|
}
|
|
|
|
exports.SyncConfig = function (config) {
|
|
if (fs.readFileSync(pathJoin("data/config.json")) + "" != JSON.stringify(config) + "") {
|
|
fs.writeFileSync(pathJoin("data/config.json"), JSON.stringify(config))
|
|
}
|
|
}
|