语言匹配 + 4
这个提交包含在:
44
WebUI.js
44
WebUI.js
@ -7,24 +7,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var net = __importStar(require("net"));
|
||||
var Core = __importStar(require("./Core"));
|
||||
var fs = __importStar(require("fs"));
|
||||
const net = __importStar(require("net"));
|
||||
const Core = __importStar(require("./Core"));
|
||||
const fs = __importStar(require("fs"));
|
||||
var MainConnect;
|
||||
var MainGroup;
|
||||
var ServerWeb = new net.Server();
|
||||
var MessageCount = 0;
|
||||
ServerWeb.on("listening", function () {
|
||||
process.on("exit", function () {
|
||||
ServerWeb.on("listening", () => {
|
||||
process.on("exit", () => {
|
||||
ServerWeb.close();
|
||||
});
|
||||
ServerWeb.on("connection", function (UserSock) {
|
||||
UserSock.on("data", function (data) {
|
||||
ServerWeb.on("connection", (UserSock) => {
|
||||
UserSock.on("data", (data) => {
|
||||
if (data.toString().indexOf(" ") != 0) {
|
||||
var path = data.toString().split(" ");
|
||||
if (path[1] == "/") {
|
||||
fs.readFile("./WebUI.html", function (err, data) {
|
||||
UserSock.write("HTTP/1.1 200 OK\r\nContent-Length: " + data.length + "\r\n\r\n");
|
||||
fs.readFile("./WebUI.html", (err, data) => {
|
||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
||||
UserSock.write(data);
|
||||
UserSock.end();
|
||||
});
|
||||
@ -32,8 +32,8 @@ ServerWeb.on("listening", function () {
|
||||
else if (path[1].substr(0, 5) == "/OAC_") {
|
||||
var Do = path[1].replace("/OAC_", "");
|
||||
if (Do == "GETMESSAGE") {
|
||||
fs.readFile("./Message.json", function (err, data) {
|
||||
UserSock.write("HTTP/1.1 200 OK\r\nContent-Length: " + data.length + "\r\n\r\n");
|
||||
fs.readFile("./Message.json", (err, data) => {
|
||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${data.length}\r\n\r\n`);
|
||||
UserSock.write(data);
|
||||
UserSock.end();
|
||||
});
|
||||
@ -41,7 +41,7 @@ ServerWeb.on("listening", function () {
|
||||
else if (Do.substr(0, new String("SETMESSAGE_").length) == "SETMESSAGE_") {
|
||||
var Token = Do.replace("SETMESSAGE_", "");
|
||||
var T2 = Token.split("_");
|
||||
fs.readFile("./Message.json", function (err, data) {
|
||||
fs.readFile("./Message.json", (err, data) => {
|
||||
var data_obj = JSON.parse(data.toString());
|
||||
T2[0] = decodeURIComponent(T2[0]);
|
||||
if (T2[1] == "") {
|
||||
@ -51,8 +51,8 @@ ServerWeb.on("listening", function () {
|
||||
else {
|
||||
data_obj[T2[0]] = decodeURIComponent(T2[1]);
|
||||
}
|
||||
fs.writeFile("./Message.json", JSON.stringify(data_obj), function (err) {
|
||||
UserSock.write("HTTP/1.1 200 OK\r\nContent-Length: " + new String("DONE").length + "\r\n\r\n");
|
||||
fs.writeFile("./Message.json", JSON.stringify(data_obj), (err) => {
|
||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String("DONE").length}\r\n\r\n`);
|
||||
UserSock.write(new String("DONE").valueOf());
|
||||
UserSock.end();
|
||||
});
|
||||
@ -60,21 +60,21 @@ ServerWeb.on("listening", function () {
|
||||
}
|
||||
else if (Do == "GETCOUNT") {
|
||||
var ret = new String(MessageCount);
|
||||
UserSock.write("HTTP/1.1 200 OK\r\nContent-Length: " + new String(ret).length + "\r\nContent-Type:text/html;charset=utf-8\r\n\r\n");
|
||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||
UserSock.write(ret.valueOf());
|
||||
UserSock.end();
|
||||
}
|
||||
else if (Do == "RESTART") {
|
||||
var ret = new String("DOING!");
|
||||
UserSock.write("HTTP/1.1 200 OK\r\nContent-Length: " + new String(ret).length + "\r\nContent-Type:text/html;charset=utf-8\r\n\r\n");
|
||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${new String(ret).length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||
UserSock.write(ret.valueOf());
|
||||
UserSock.end();
|
||||
process.exit();
|
||||
}
|
||||
else if (Do == "GETSERVICES") {
|
||||
fs.readFile("./MoudelV2.json", function (err2, data2) {
|
||||
fs.readFile("./MoudelV2.json", (err2, data2) => {
|
||||
var ret = data2;
|
||||
UserSock.write("HTTP/1.1 200 OK\r\nContent-Length: " + ret.length + "\r\nContent-Type:text/html;charset=utf-8\r\n\r\n");
|
||||
UserSock.write(`HTTP/1.1 200 OK\r\nContent-Length: ${ret.length}\r\nContent-Type:text/html;charset=utf-8\r\n\r\n`);
|
||||
UserSock.write(ret);
|
||||
UserSock.end();
|
||||
});
|
||||
@ -82,7 +82,7 @@ ServerWeb.on("listening", function () {
|
||||
}
|
||||
else {
|
||||
var data2 = "404";
|
||||
UserSock.write("HTTP/1.1 404\r\nContent-Length: " + data2.length + "\r\n\r\n");
|
||||
UserSock.write(`HTTP/1.1 404\r\nContent-Length: ${data2.length}\r\n\r\n`);
|
||||
UserSock.write(data2.valueOf());
|
||||
UserSock.end();
|
||||
}
|
||||
@ -91,15 +91,15 @@ ServerWeb.on("listening", function () {
|
||||
UserSock.end("HTTP/1.1 404");
|
||||
}
|
||||
});
|
||||
UserSock.on("close", function () {
|
||||
UserSock.on("close", () => {
|
||||
UserSock.end();
|
||||
});
|
||||
UserSock.on("end", function () {
|
||||
UserSock.on("end", () => {
|
||||
UserSock.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
ServerWeb.listen(8081, "0.0.0.0");
|
||||
Core.AddListener(function (connect, Info) {
|
||||
Core.AddListener((connect, Info) => {
|
||||
MessageCount = MessageCount.valueOf() + 1;
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户