-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maosource
committed
Mar 4, 2022
1 parent
9a25f3e
commit 1f0ad32
Showing
8 changed files
with
6,474 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./front/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM registry.cn-hangzhou.aliyuncs.com/yiidii-hub/nginx-openjdk:v1 | ||
MAINTAINER yd <[email protected]> | ||
# envs | ||
ENV JDX_DIR=/jdx | ||
|
||
# 工作目录 | ||
WORKDIR ${JDX_DIR} | ||
|
||
# 后端 | ||
ADD ./back/target/jdx.jar ${JDX_DIR}/app.jar | ||
ADD ./back/docker/ ${JDX_DIR}/ | ||
|
||
# 前端 | ||
RUN rm /etc/nginx/conf.d/default.conf | ||
ADD default.conf /etc/nginx/conf.d/ | ||
ADD ./front/dist/ /usr/share/nginx/html/ | ||
|
||
# 其他操作 | ||
RUN mkdir -p ${JDX_DIR}/logs/console | ||
|
||
# 入口文件 | ||
ENTRYPOINT ["sh", "docker-entrypoint.sh"] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
server { | ||
# 项目在容器内部运行的端口 | ||
listen 80; | ||
server_name localhost; | ||
|
||
# 前端访问路径配置 | ||
location / { | ||
root /usr/share/nginx/html; | ||
# 防止刷新404 | ||
try_files $uri $uri/ /index.html; | ||
index index.html index.htm; | ||
} | ||
|
||
location /api/{ | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header REMOTE-HOST $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_pass http://localhost:8090/; | ||
} | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
此文件为Node.js专用。其他用户请忽略 | ||
*/ | ||
//此处填写京东账号cookie。 | ||
let CookieJDs = [ | ||
'',//账号一ck,例:pt_key=XXX;pt_pin=XXX; | ||
'',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推 | ||
] | ||
// 判断环境变量里面是否有京东ck | ||
if (process.env.JD_COOKIE) { | ||
if (process.env.JD_COOKIE.indexOf('&') > -1) { | ||
CookieJDs = process.env.JD_COOKIE.split('&'); | ||
} else if (process.env.JD_COOKIE.indexOf('\n') > -1) { | ||
CookieJDs = process.env.JD_COOKIE.split('\n'); | ||
} else { | ||
CookieJDs = [process.env.JD_COOKIE]; | ||
} | ||
} | ||
if (JSON.stringify(process.env).indexOf('GITHUB')>-1) { | ||
console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`); | ||
!(async () => { | ||
await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`) | ||
await process.exit(0); | ||
})() | ||
} | ||
CookieJDs = [...new Set(CookieJDs.filter(item => !!item))] | ||
console.log(`\n===============共${CookieJDs.length}个京东账号Cookie===============\n`); | ||
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; | ||
for (let i = 0; i < CookieJDs.length; i++) { | ||
if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`); | ||
const index = (i + 1 === 1) ? '' : (i + 1); | ||
exports['CookieJD' + index] = CookieJDs[i].trim(); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
'use strict'; | ||
|
||
const got = require('got'); | ||
require('dotenv').config(); | ||
const { readFile } = require('fs/promises'); | ||
const path = require('path'); | ||
|
||
const qlDir = '/ql'; | ||
const authFile = path.join(qlDir, 'config/auth.json'); | ||
|
||
const api = got.extend({ | ||
prefixUrl: 'http://127.0.0.1:5600', | ||
retry: { limit: 0 }, | ||
}); | ||
|
||
async function getToken() { | ||
const authConfig = JSON.parse(await readFile(authFile)); | ||
return authConfig.token; | ||
} | ||
|
||
module.exports.getEnvs = async () => { | ||
const token = await getToken(); | ||
const body = await api({ | ||
url: 'api/envs', | ||
searchParams: { | ||
searchValue: 'JD_COOKIE', | ||
t: Date.now(), | ||
}, | ||
headers: { | ||
Accept: 'application/json', | ||
authorization: `Bearer ${token}`, | ||
}, | ||
}).json(); | ||
return body.data; | ||
}; | ||
|
||
module.exports.getEnvsCount = async () => { | ||
const data = await this.getEnvs(); | ||
return data.length; | ||
}; | ||
|
||
module.exports.addEnv = async (cookie, remarks) => { | ||
const token = await getToken(); | ||
const body = await api({ | ||
method: 'post', | ||
url: 'api/envs', | ||
params: { t: Date.now() }, | ||
json: [{ | ||
name: 'JD_COOKIE', | ||
value: cookie, | ||
remarks, | ||
}], | ||
headers: { | ||
Accept: 'application/json', | ||
authorization: `Bearer ${token}`, | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
}, | ||
}).json(); | ||
return body; | ||
}; | ||
|
||
module.exports.updateEnv = 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.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({ | ||
method: 'put', | ||
url: 'api/envs/disable', | ||
params: { t: Date.now() }, | ||
body: JSON.stringify([eid]), | ||
headers: { | ||
Accept: 'application/json', | ||
authorization: `Bearer ${token}`, | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
}, | ||
}).json(); | ||
return body; | ||
}; | ||
|
||
module.exports.EnableCk = async (eid) => { | ||
const token = await getToken(); | ||
const body = await api({ | ||
method: 'put', | ||
url: 'api/envs/enable', | ||
params: { t: Date.now() }, | ||
body: JSON.stringify([eid]), | ||
headers: { | ||
Accept: 'application/json', | ||
authorization: `Bearer ${token}`, | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
}, | ||
}).json(); | ||
return body; | ||
}; | ||
|
||
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) => { | ||
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++) { | ||
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]); | ||
if(tempptpin==Ptpin){ | ||
return envs[i]; | ||
} | ||
} | ||
return ""; | ||
}; | ||
|
||
module.exports.delEnv = async (eid) => { | ||
const token = await getToken(); | ||
const body = await api({ | ||
method: 'delete', | ||
url: 'api/envs', | ||
params: { t: Date.now() }, | ||
body: JSON.stringify([eid]), | ||
headers: { | ||
Accept: 'application/json', | ||
authorization: `Bearer ${token}`, | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
}, | ||
}).json(); | ||
return body; | ||
}; |
Oops, something went wrong.