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.
90 lines
2.3 KiB
90 lines
2.3 KiB
const fs = require('fs');
|
|
const path = require('path')
|
|
const libdata = require(path.join(__dirname, "data.js"));
|
|
const libdata2 = require(path.join(__dirname, "../data.js"));
|
|
const ipc = require('electron').ipcRenderer
|
|
|
|
|
|
function get(name) {
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
var r = window.location.search.substr(1).match(reg);
|
|
if (r != null) return (r[2]); return null;
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
|
|
libdata.syncTaskToFile(function () {
|
|
ipc.send('put-in-tray')
|
|
})
|
|
setInterval(function () {
|
|
if (libdata.syncDaibanCount()) {
|
|
ipc.send('new-task-notification')
|
|
console.log("通知中...")
|
|
libdata.syncTaskToFile();
|
|
}
|
|
}, 5 * 1000)
|
|
|
|
function CommitByQueue() {
|
|
setTimeout(() => {
|
|
let item = libdata2.PopCommitByQueue();
|
|
console.log("PopCommitByQueue")
|
|
if (item && item.id) {
|
|
console.log(item)
|
|
let data = {
|
|
sm: item.commit,
|
|
name: "评论",
|
|
mid: item.id,
|
|
modenum: "work"
|
|
};
|
|
$.ajax({
|
|
url: "http://oa.ouxuan.net/index.php?a=pinglun&m=flowopt&d=flow&ajaxbool=true",
|
|
async: false,
|
|
data: data,
|
|
success: function () {
|
|
ipc.send('new-notification', "有一条新的评论被同步", `分支:${item.branch} 评论内容:${item.commit}`)
|
|
}
|
|
});
|
|
}
|
|
CommitByQueue();
|
|
}, 1000);
|
|
}
|
|
CommitByQueue();
|
|
|
|
|
|
let m = get("m");
|
|
if (PageJs[m]) {
|
|
PageJs[m]()
|
|
} else {
|
|
// alert("未有指定动作:" + m);
|
|
}
|
|
})
|
|
|
|
PageJs = {
|
|
login() {
|
|
|
|
|
|
_loginsubmit = loginsubmit
|
|
loginsubmit = function () {
|
|
const adminuser = document.getElementById("adminuser")
|
|
const adminpass = document.getElementById("adminpass")
|
|
fs.writeFileSync(libdata2.UsernamePath, JSON.stringify({
|
|
username: adminuser.value,
|
|
password: adminpass.value,
|
|
}))
|
|
_loginsubmit(0)
|
|
}
|
|
if (fs.existsSync(libdata2.UsernamePath)) {
|
|
let data = fs.readFileSync(libdata2.UsernamePath);
|
|
data = JSON.parse(data)
|
|
const adminuser = document.getElementById("adminuser")
|
|
adminuser.value = data["username"];
|
|
const adminpass = document.getElementById("adminpass")
|
|
adminpass.value = data["password"];
|
|
loginsubmit(0)
|
|
}
|
|
}
|
|
}
|
|
|