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.
93 lines
2.6 KiB
93 lines
2.6 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))
|
|
}
|
|
}
|
|
|
|
exports.AddCommitToQueue = function (data) {
|
|
if (!fs.existsSync(pathJoin("data/commit-queue.json"))) {
|
|
fs.writeFileSync(pathJoin("data/commit-queue.json"), "[]")
|
|
}
|
|
let all = fs.readFileSync(pathJoin("data/commit-queue.json"))
|
|
all = JSON.parse(all);
|
|
all.push(data);
|
|
fs.writeFileSync(pathJoin("data/commit-queue.json"), JSON.stringify(all))
|
|
}
|
|
|
|
exports.PopCommitByQueue = function () {
|
|
if (!fs.existsSync(pathJoin("data/commit-queue.json"))) {
|
|
fs.writeFileSync(pathJoin("data/commit-queue.json"), "[]")
|
|
}
|
|
let all = fs.readFileSync(pathJoin("data/commit-queue.json"))
|
|
all = JSON.parse(all);
|
|
var data = all.pop();
|
|
fs.writeFileSync(pathJoin("data/commit-queue.json"), JSON.stringify(all))
|
|
return data;
|
|
}
|
|
|
|
exports.ignoreDaibMap = {}
|
|
|
|
|
|
|
|
if (!fs.existsSync(pathJoin("data/ignore-daib-map.json"))) {
|
|
fs.writeFileSync(pathJoin("data/ignore-daib-map.json"), JSON.stringify({}));
|
|
}
|
|
|
|
exports.GetIgnoreDaibMap = function () {
|
|
return JSON.parse(fs.readFileSync(pathJoin("data/ignore-daib-map.json")))
|
|
}
|
|
|
|
exports.SyncIgnoreDaibMap = function (result) {
|
|
if (fs.readFileSync(pathJoin("data/ignore-daib-map.json")) + "" != JSON.stringify(result) + "") {
|
|
fs.writeFileSync(pathJoin("data/ignore-daib-map.json"), JSON.stringify(result))
|
|
}
|
|
}
|