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.
115 lines
3.0 KiB
115 lines
3.0 KiB
// All of the Node.js APIs are available in the preload process.
|
|
// It has the same sandbox as a Chrome extension.
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
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;
|
|
}
|
|
|
|
function inits() {
|
|
|
|
function p(page, cb) {
|
|
$.get(`http://oa.ouxuan.net/api.php?m=index&a=getyydata&adminid=${adminid}&cfrom=mweb&event=wwc&num=work&key=&loadci=1&page=${page}`, function (data) {
|
|
var data = JSON.parse(data);
|
|
if (data.code == 200) {
|
|
if (page < data["data"]["maxpage"]) {
|
|
p(page + 1, function (rows) {
|
|
cb(data["data"]["rows"].concat(rows))
|
|
})
|
|
} else {
|
|
for (var i in data["data"]["rows"]) {
|
|
$.ajax({
|
|
url: "http://oa.ouxuan.net/task.php?a=x&num=work&show=we&mid=" + data["data"]["rows"][i]["id"],
|
|
async: false,
|
|
success: function (html) {
|
|
var last = ""
|
|
$(html).find("div").each(function (item) {
|
|
if (last == "所属项目") {
|
|
a = ($(this).text()).split("(")
|
|
a.pop()
|
|
a = a.join("(")
|
|
data["data"]["rows"][i]["project"] = a
|
|
console.log(a)
|
|
}
|
|
last = $(this).text()
|
|
})
|
|
}
|
|
});
|
|
}
|
|
cb(data["data"]["rows"])
|
|
}
|
|
}
|
|
})
|
|
}
|
|
var start = function () {
|
|
|
|
p(1, function (data) {
|
|
// alert( JSON.stringify(data));
|
|
result = {};
|
|
for (let i in data) {
|
|
if (!result[data[i]["project"]]) {
|
|
result[data[i]["project"]] = [];
|
|
}
|
|
result[data[i]["project"]].push(data[i])
|
|
}
|
|
fs.writeFileSync("task.json", JSON.stringify(result))
|
|
setTimeout(function () {
|
|
|
|
// location.reload()
|
|
}, 1 * 1000);
|
|
})
|
|
}
|
|
setTimeout(() => {
|
|
|
|
console.log(js)
|
|
console.log(js.request('adminid'))
|
|
console.log(adminid)
|
|
start()
|
|
}, 2000);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
let m = get("m");
|
|
inits()
|
|
if (PageJs[m]) {
|
|
PageJs[m]()
|
|
} else {
|
|
// alert("未有指定动作:" + m);
|
|
}
|
|
})
|
|
|
|
PageJs = {
|
|
login() {
|
|
if (fs.existsSync("username.json")) {
|
|
let data = fs.readFileSync("username.json");
|
|
data = JSON.parse(data)
|
|
const adminuser = document.getElementById("adminuser")
|
|
adminuser.value = data["username"];
|
|
const adminpass = document.getElementById("adminpass")
|
|
adminpass.value = data["password"];
|
|
loginsubmit(0)
|
|
} else {
|
|
_loginsubmit = loginsubmit
|
|
loginsubmit = function () {
|
|
const adminuser = document.getElementById("adminuser")
|
|
const adminpass = document.getElementById("adminpass")
|
|
fs.writeFileSync("username.json", JSON.stringify({
|
|
username: adminuser.value,
|
|
password: adminpass.value,
|
|
}))
|
|
_loginsubmit(0)
|
|
}
|
|
}
|
|
}
|
|
}
|