This commit is contained in:
Faker
2022-04-06 15:02:38 +08:00
parent b88fd522e4
commit 2acf16aff7
14 changed files with 11174 additions and 473 deletions

View File

@@ -6,10 +6,17 @@ const { readFile } = require('fs/promises');
const path = require('path');
const qlDir = '/ql';
const authFile = path.join(qlDir, 'config/auth.json');
const fs = require('fs');
let Fileexists = fs.existsSync('/ql/data/config/auth.json');
let authFile="";
if (Fileexists)
authFile="/ql/data/config/auth.json"
else
authFile="/ql/config/auth.json"
//const authFile = path.join(qlDir, 'config/auth.json');
const api = got.extend({
prefixUrl: 'http://localhost:5600',
prefixUrl: 'http://127.0.0.1:5600',
retry: { limit: 0 },
});
@@ -18,7 +25,7 @@ async function getToken() {
return authConfig.token;
}
module.exports.getEnvs = async () => {
module.exports.getEnvs = async () => {
const token = await getToken();
const body = await api({
url: 'api/envs',
@@ -80,6 +87,27 @@ module.exports.updateEnv = async (cookie, eid, remarks) => {
return body;
};
module.exports.updateEnv11 = async (cookie, eid, remarks) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.DisableCk = async (eid) => {
const token = await getToken();
const body = await api({
@@ -112,21 +140,48 @@ module.exports.EnableCk = async (eid) => {
return body;
};
module.exports.getstatus = async (eid) => {
const envs = await this.getEnvs();
for (let i = 0; i < envs.length; i++) {
if(envs[i]._id==eid){
return envs[i].status;
}
}
return 99;
module.exports.getstatus = async(eid) => {
const envs = await this.getEnvs();
var tempid = 0;
for (let i = 0; i < envs.length; i++) {
tempid = 0;
if (envs[i]._id) {
tempid = envs[i]._id;
}
if (envs[i].id) {
tempid = envs[i].id;
}
if (tempid == eid) {
return envs[i].status;
}
}
return 99;
};
module.exports.getEnvById = async (eid) => {
module.exports.getEnvById = async(eid) => {
const envs = await this.getEnvs();
var tempid = 0;
for (let i = 0; i < envs.length; i++) {
tempid = 0;
if (envs[i]._id) {
tempid = envs[i]._id;
}
if (envs[i].id) {
tempid = envs[i].id;
}
if (tempid == eid) {
return envs[i].value;
}
}
return "";
};
module.exports.getEnvByPtPin = async (Ptpin) => {
const envs = await this.getEnvs();
for (let i = 0; i < envs.length; i++) {
if(envs[i]._id==eid){
return envs[i].value;
for (let i = 0; i < envs.length; i++) {
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
if(tempptpin==Ptpin){
return envs[i];
}
}
return "";