mirror of
https://github.com/shufflewzc/faker3.git
synced 2025-03-15 07:04:42 +08:00
1
This commit is contained in:
parent
f30b31e860
commit
1a48f2bc31
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -4,16 +4,17 @@ const got = require('got');
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const { readFile } = require('fs/promises');
|
const { readFile } = require('fs/promises');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const qlDir = '/ql';
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
let Fileexists280 = fs.existsSync('/ql/data/db/keyv.sqlite');
|
||||||
let Fileexists = fs.existsSync('/ql/data/config/auth.json');
|
let Fileexists = fs.existsSync('/ql/data/config/auth.json');
|
||||||
let authFile="";
|
let authFile = "";
|
||||||
if (Fileexists)
|
if (Fileexists280)
|
||||||
authFile="/ql/data/config/auth.json"
|
authFile = "/ql/data/db/keyv.sqlite"
|
||||||
|
else if (Fileexists)
|
||||||
|
authFile = "/ql/data/config/auth.json"
|
||||||
else
|
else
|
||||||
authFile="/ql/config/auth.json"
|
authFile = "/ql/config/auth.json"
|
||||||
//const authFile = path.join(qlDir, 'config/auth.json');
|
|
||||||
|
|
||||||
const api = got.extend({
|
const api = got.extend({
|
||||||
prefixUrl: 'http://127.0.0.1:5600',
|
prefixUrl: 'http://127.0.0.1:5600',
|
||||||
@ -21,10 +22,11 @@ const api = got.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function getToken() {
|
async function getToken() {
|
||||||
const authConfig = JSON.parse(await readFile(authFile));
|
const authConfig = await readFile(authFile);
|
||||||
return authConfig.token;
|
// console.log(authConfig.toString().match(/"token":"(.*?)",/)[1])
|
||||||
|
return authConfig.toString().match(/"token":"(.*?)",/)[1];
|
||||||
}
|
}
|
||||||
|
// getToken()
|
||||||
module.exports.getEnvs = async () => {
|
module.exports.getEnvs = async () => {
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
const body = await api({
|
const body = await api({
|
||||||
@ -140,7 +142,7 @@ module.exports.EnableCk = async (eid) => {
|
|||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getstatus = async(eid) => {
|
module.exports.getstatus = async (eid) => {
|
||||||
const envs = await this.getEnvs();
|
const envs = await this.getEnvs();
|
||||||
var tempid = 0;
|
var tempid = 0;
|
||||||
for (let i = 0; i < envs.length; i++) {
|
for (let i = 0; i < envs.length; i++) {
|
||||||
@ -158,7 +160,7 @@ module.exports.getstatus = async(eid) => {
|
|||||||
return 99;
|
return 99;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getEnvById = async(eid) => {
|
module.exports.getEnvById = async (eid) => {
|
||||||
const envs = await this.getEnvs();
|
const envs = await this.getEnvs();
|
||||||
var tempid = 0;
|
var tempid = 0;
|
||||||
for (let i = 0; i < envs.length; i++) {
|
for (let i = 0; i < envs.length; i++) {
|
||||||
@ -180,7 +182,7 @@ module.exports.getEnvByPtPin = async (Ptpin) => {
|
|||||||
const envs = await this.getEnvs();
|
const envs = await this.getEnvs();
|
||||||
for (let i = 0; i < envs.length; i++) {
|
for (let i = 0; i < envs.length; i++) {
|
||||||
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
|
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
|
||||||
if(tempptpin==Ptpin){
|
if (tempptpin == Ptpin) {
|
||||||
return envs[i];
|
return envs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user