- 在CipherStash-xToken.js中为GetXToken函数的请求配置添加timeout: 5000 - 在CipherStash-xToken.js中为GetXToken函数的请求配置添加agent代理选项 - 在api.js中优化日志输出,增加代理信息显示 - 移除了node_modules/.package-lock.json文件的变更记录(无实际代码改动)
863 lines
32 KiB
JavaScript
863 lines
32 KiB
JavaScript
import express, { urlencoded } from "express";
|
||
import { GetXToken, defaultConfig, Remark, CipherTable } from "./CipherStash-xToken.js";
|
||
import { defaultConfigh5st, handleH5stRequest } from './h5st.js';
|
||
import { readFile } from 'fs';
|
||
const app = express();
|
||
app.use(urlencoded({ extended: true }));
|
||
|
||
// 读取配置文件
|
||
readFile(`${defaultConfig.ConfigName}.txt`, 'utf8', (err, data) => {
|
||
if (err) {
|
||
console.warn(`查无配置文件,将使用默认配置;配置文件名:${defaultConfig.ConfigName}.txt`);
|
||
} else {
|
||
const lines = data.split('\n');
|
||
if (lines.length >= 2) {
|
||
defaultConfig.route = lines[0].trim();
|
||
defaultConfig.port = parseInt(lines[1].trim(), 10) || 6689;
|
||
}
|
||
}
|
||
|
||
app.get(defaultConfig.route, function (req, res) {
|
||
/**
|
||
* 接口文档
|
||
*/
|
||
|
||
const apiDoc = `<html>
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<style>
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
margin: 0;
|
||
padding: 0;
|
||
background-color: #f5f5f5;
|
||
color: #333;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
header {
|
||
color: #fff;
|
||
padding: 20px 0;
|
||
text-align: center;
|
||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||
background-color: #555;
|
||
}
|
||
|
||
.container {
|
||
width: 90%;
|
||
max-width: 1200px;
|
||
margin: 20px auto;
|
||
background-color: #fff;
|
||
padding: 30px;
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||
border-radius: 5px;
|
||
}
|
||
|
||
h1,
|
||
h2,
|
||
h3 {
|
||
color: #2c3e50;
|
||
}
|
||
|
||
h1 {
|
||
margin: 0;
|
||
font-size: 28px;
|
||
}
|
||
|
||
h2 {
|
||
border-bottom: 1px solid #eee;
|
||
padding-bottom: 10px;
|
||
margin-top: 30px;
|
||
}
|
||
|
||
h3 {
|
||
color: #3498db;
|
||
margin-top: 25px;
|
||
padding-top: 10px;
|
||
border-top: 1px dashed #eee;
|
||
}
|
||
|
||
.nav-container {
|
||
background-color: #f8f9fa;
|
||
padding: 15px;
|
||
border-radius: 5px;
|
||
margin: 20px 0;
|
||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.nav-title {
|
||
font-weight: bold;
|
||
margin-bottom: 10px;
|
||
color: #2c3e50;
|
||
}
|
||
|
||
.nav-links {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 10px;
|
||
}
|
||
|
||
.nav-link {
|
||
background-color: #eaf2f8;
|
||
color: #2980b9;
|
||
padding: 8px 15px;
|
||
border-radius: 20px;
|
||
text-decoration: none;
|
||
font-size: 14px;
|
||
transition: all 0.3s;
|
||
}
|
||
|
||
.nav-link:hover {
|
||
background-color: #d4e6f1;
|
||
transform: translateY(-2px);
|
||
}
|
||
|
||
table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 15px 0;
|
||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
th,
|
||
td {
|
||
padding: 12px;
|
||
border: 1px solid #ddd;
|
||
text-align: left;
|
||
word-break: break-all;
|
||
/* 强制换行处理长内容 */
|
||
}
|
||
|
||
th {
|
||
background-color: #f2f2f2;
|
||
font-weight: bold;
|
||
}
|
||
|
||
tr:nth-child(even) {
|
||
background-color: #f9f9f9;
|
||
}
|
||
|
||
.warning {
|
||
background-color: #fff3cd;
|
||
color: #856404;
|
||
padding: 15px;
|
||
border-radius: 5px;
|
||
margin: 20px 0;
|
||
border-left: 5px solid #ffeeba;
|
||
}
|
||
|
||
.api-section {
|
||
margin-bottom: 40px;
|
||
}
|
||
|
||
.result-box {
|
||
background-color: #f8f9fa;
|
||
padding: 15px;
|
||
border-radius: 5px;
|
||
margin-top: 10px;
|
||
overflow-x: auto;
|
||
font-family: monospace;
|
||
font-size: 14px;
|
||
border-left: 3px solid #3498db;
|
||
}
|
||
|
||
/* 新增的返回顶部按钮样式 */
|
||
.back-to-top-btn {
|
||
position: fixed;
|
||
bottom: 30px;
|
||
right: 30px;
|
||
background-color: #3498db;
|
||
color: white;
|
||
width: 50px;
|
||
height: 50px;
|
||
border-radius: 50%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
text-decoration: none;
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||
transition: all 0.3s;
|
||
z-index: 999;
|
||
opacity: 0;
|
||
visibility: hidden;
|
||
transform: translateY(20px);
|
||
}
|
||
|
||
.back-to-top-btn.show {
|
||
opacity: 1;
|
||
visibility: visible;
|
||
transform: translateY(0);
|
||
}
|
||
|
||
.back-to-top-btn:hover {
|
||
background-color: #2980b9;
|
||
transform: translateY(-3px);
|
||
}
|
||
|
||
.back-to-top-btn i {
|
||
font-size: 20px;
|
||
}
|
||
</style>
|
||
<!-- 引入Font Awesome图标库 -->
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<!-- 新增的返回顶部按钮 -->
|
||
<a href="#" class="back-to-top-btn" id="backToTopBtn">
|
||
<i class="fas fa-arrow-up"></i>
|
||
</a>
|
||
|
||
<header>
|
||
<h1>API 加密算法文档</h1>
|
||
</header>
|
||
|
||
<div class="container">
|
||
<div class="warning">
|
||
<strong>重要提示:</strong>请勿将这些算法用于任何违法行为
|
||
</div>
|
||
|
||
<div class="nav-container">
|
||
<div class="nav-title">算法快速导航</div>
|
||
<div class="nav-links">
|
||
<a href="#x-api-eid-token" class="nav-link">1. X-Api-Eid-Token</a>
|
||
</div>
|
||
</div>
|
||
|
||
<h2>请求概览</h2>
|
||
<table>
|
||
<tr>
|
||
<th>请求方法</th>
|
||
<td>POST</td>
|
||
</tr>
|
||
<tr>
|
||
<th>表单格式</th>
|
||
<td>x-www-form-urlencoded</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<div class="api-section">
|
||
<h2>API 接口详情</h2>
|
||
<div class="api" id="x-api-eid-token">
|
||
<h3>1. X-Api-Eid-Token算法</h3>
|
||
<p>用于生成API请求的Eid Token</p>
|
||
|
||
<h4>请求字段:</h4>
|
||
<table>
|
||
<tr>
|
||
<th>Key</th>
|
||
<th>Value</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
<tr>
|
||
<td>type</td>
|
||
<td>11</td>
|
||
<td>固定值</td>
|
||
</tr>
|
||
<tr>
|
||
<td>str</td>
|
||
<td>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36</td>
|
||
<td>UserAgent参数</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<h4>返回结果示例:</h4>
|
||
<div class="result-box">
|
||
{"code":0,"msg":"成功","data":{"token":"jdd03CGY3XHRBUYYHUESZTTF3NUFTJCY35XFKI3IUEKMFIHWCAB4RFTZRNKR3GWD6UUOGNBMK6AFDAK3KLDJY5BJSBLFKI4AAAAMZ44RCAVAAAAAACRXJASXS2ZLTX4X","eid":"CGY3XHRBUYYHUESZTTF3NUFTJCY35XFKI3IUEKMFIHWCAB4RFTZRNKR3GWD6UUOGNBMK6AFDAK3KLDJY5BJSBLFKI4","gia_d":1,"deMap":null,"ds":120}}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
// 返回顶部按钮显示/隐藏逻辑
|
||
window.addEventListener('scroll', function () {
|
||
var backToTopBtn = document.getElementById('backToTopBtn');
|
||
if (window.pageYOffset > 300) {
|
||
backToTopBtn.classList.add('show');
|
||
} else {
|
||
backToTopBtn.classList.remove('show');
|
||
}
|
||
});
|
||
|
||
// 返回顶部功能
|
||
document.getElementById('backToTopBtn').addEventListener('click', function (e) {
|
||
e.preventDefault();
|
||
window.scrollTo({
|
||
top: 0,
|
||
behavior: 'smooth'
|
||
});
|
||
});
|
||
</script>
|
||
</body>
|
||
|
||
</html>`;
|
||
|
||
// 返回 API 文档
|
||
res.send(apiDoc);
|
||
});
|
||
|
||
app.post(defaultConfig.route, async function (req, res) {
|
||
try {
|
||
let { type, str, proxy } = req.body;
|
||
let content = '';
|
||
|
||
console.log(`${new Date().toLocaleString()} --> 客户端:${req.ip} --> 代理:${proxy} --> 执行算法:${CipherTable[type]}`);
|
||
|
||
// 创建对象映射
|
||
const algorithmMap = {
|
||
'1': async () => await GetXToken(str, proxy)
|
||
};
|
||
|
||
// 匹配对应的对象
|
||
const handler = algorithmMap[type];
|
||
content = handler ? await handler() : '查无此算法';
|
||
|
||
res.send(content);
|
||
} catch (e) {
|
||
console.log(`${new Date().toLocaleString()} --> 客户端:${req.ip} --> 执行异常:${e}`);
|
||
res.send('解析异常,请检查请求参数');
|
||
}
|
||
});
|
||
});
|
||
|
||
app.get(`${defaultConfigh5st.route}/apidoc`, (req, res) => {
|
||
/**
|
||
* 同意异常日志
|
||
*
|
||
* @param {*} e
|
||
*/
|
||
function error(e) {
|
||
console.log(`${new Date().toLocaleString()} --> 客户端:${req.ip} --> 解析异常:${e}`);
|
||
res.send(defaultConfigh5st.errorStr);
|
||
}
|
||
|
||
try {
|
||
// api 文档
|
||
apiDoc = `<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>API接口文档</title>
|
||
<script src="https://cdn.tailwindcss.com"></script>
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||
<style>
|
||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');
|
||
|
||
body {
|
||
font-family: 'Noto Sans SC', sans-serif;
|
||
background-color: #f8fafc;
|
||
color: #1e293b;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.gradient-bg {
|
||
background: linear-gradient(135deg, #c9c8db 0%, #817e88 100%);
|
||
}
|
||
|
||
.card {
|
||
background: white;
|
||
border-radius: 12px;
|
||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||
}
|
||
|
||
.card:hover {
|
||
transform: translateY(-2px);
|
||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
||
}
|
||
|
||
.tag {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 0.25rem 0.5rem;
|
||
border-radius: 6px;
|
||
font-size: 0.75rem;
|
||
font-weight: 600;
|
||
margin-right: 0.5rem;
|
||
}
|
||
|
||
.tag i {
|
||
margin-right: 0.25rem;
|
||
font-size: 0.6rem;
|
||
}
|
||
|
||
.tag-required {
|
||
background-color: #ef4444;
|
||
color: white;
|
||
}
|
||
|
||
.tag-optional {
|
||
background-color: #f59e0b;
|
||
color: white;
|
||
}
|
||
|
||
.tag-info {
|
||
background-color: #3b82f6;
|
||
color: white;
|
||
}
|
||
|
||
.warning-banner {
|
||
background: rgb(252, 119, 119);
|
||
color: white;
|
||
border-radius: 8px;
|
||
padding: 1rem;
|
||
margin-bottom: 1.5rem;
|
||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.divider {
|
||
height: 1px;
|
||
background: linear-gradient(90deg, rgba(226, 232, 240, 0) 0%, rgba(226, 232, 240, 1) 50%, rgba(226, 232, 240, 0) 100%);
|
||
margin: 2rem 0;
|
||
}
|
||
|
||
pre {
|
||
background-color: #1e293b;
|
||
color: #e2e8f0;
|
||
padding: 1rem;
|
||
border-radius: 8px;
|
||
overflow-x: auto;
|
||
font-family: 'Courier New', Courier, monospace;
|
||
font-size: 0.875rem;
|
||
line-height: 1.5;
|
||
margin: 1rem 0;
|
||
}
|
||
|
||
.table-container {
|
||
overflow-x: auto;
|
||
-webkit-overflow-scrolling: touch;
|
||
}
|
||
|
||
table {
|
||
width: 100%;
|
||
border-collapse: separate;
|
||
border-spacing: 0;
|
||
margin: 1rem 0;
|
||
}
|
||
|
||
th {
|
||
background-color: #f1f5f9;
|
||
color: #64748b;
|
||
font-weight: 600;
|
||
text-align: left;
|
||
padding: 0.75rem 1rem;
|
||
font-size: 0.875rem;
|
||
border-bottom: 1px solid #e2e8f0;
|
||
}
|
||
|
||
td {
|
||
padding: 0.75rem 1rem;
|
||
border-bottom: 1px solid #e2e8f0;
|
||
font-size: 0.875rem;
|
||
vertical-align: top;
|
||
}
|
||
|
||
tr:last-child td {
|
||
border-bottom: none;
|
||
}
|
||
|
||
tr:hover td {
|
||
background-color: #f8fafc;
|
||
}
|
||
|
||
code {
|
||
background-color: #f1f5f9;
|
||
color: #3b82f6;
|
||
padding: 0.2rem 0.4rem;
|
||
border-radius: 4px;
|
||
font-family: 'Courier New', Courier, monospace;
|
||
font-size: 0.875rem;
|
||
}
|
||
|
||
.section-title {
|
||
position: relative;
|
||
padding-left: 1rem;
|
||
}
|
||
|
||
.section-title:before {
|
||
content: '';
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0.5rem;
|
||
height: 1.5rem;
|
||
width: 4px;
|
||
background: linear-gradient(to bottom, #4f46e5, #7c3aed);
|
||
border-radius: 2px;
|
||
}
|
||
</style>
|
||
</head>
|
||
|
||
<body class="antialiased">
|
||
<div class="min-h-screen">
|
||
<!-- 头部 -->
|
||
<div class="gradient-bg text-white py-8 px-4 md:px-8">
|
||
<div class="max-w-4xl mx-auto">
|
||
<h1 style="text-align: center" class="text-3xl md:text-4xl font-bold mb-2">API 接口文档</h1>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 主要内容 -->
|
||
<div class="max-w-4xl mx-auto px-4 md:px-8 py-8">
|
||
<!-- 警告横幅 -->
|
||
<div class="warning-banner flex items-center">
|
||
<i class="fas fa-exclamation-triangle mr-2"></i>
|
||
<span>请勿将本API用于任何违法行为</span>
|
||
</div>
|
||
|
||
<!-- 基本请求信息 -->
|
||
<div class="card p-6 mb-8">
|
||
<h2 class="text-2xl font-bold mb-6 text-gray-800 section-title">接口请求模式</h2>
|
||
|
||
<div class="table-container">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>请求方法</th>
|
||
<th>表单格式</th>
|
||
<th>备注</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="font-medium">GET</td>
|
||
<td></td>
|
||
<td></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="font-medium">POST</td>
|
||
<td>x-www-form-urlencoded</td>
|
||
<td>适用于数据量较大的请求</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card p-6 mb-8">
|
||
<h2 class="text-2xl font-bold mb-6 text-gray-800 section-title">字段概述</h2>
|
||
<p class="text-gray-600 mb-6">参数计算所涉及的字段名(区分大小写)及其描述:</p>
|
||
|
||
<h3 class="text-xl font-semibold mt-6 mb-4 text-gray-700">基础字段</h3>
|
||
<div class="table-container mb-8">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>字段名</th>
|
||
<th>描述</th>
|
||
<th>备注</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><code>khd</code></td>
|
||
<td>客户端代号(jx、pc、jm、m(不填写默认m))</td>
|
||
<td><span class="tag tag-optional"><i
|
||
class="fas fa-question-circle"></i>选填</span>接口请求不通可选择对应的平台代号</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ai</code></td>
|
||
<td>需求的官方接口抓包中的h5st数据进行拆分 - 第3个位置</td>
|
||
<td><span class="tag tag-required"><i
|
||
class="fas fa-exclamation-circle"></i>必填</span>原始抓包数据中的h5st参数值中提取</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>pin</code></td>
|
||
<td>cookie中pin或者pt_pin字段的属性值</td>
|
||
<td><span class="tag tag-optional"><i
|
||
class="fas fa-question-circle"></i>可选</span>无需登录则不填</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>sua</code></td>
|
||
<td>user-agent第一个括号内的参数</td>
|
||
<td><span class="tag tag-required"><i
|
||
class="fas fa-exclamation-circle"></i>必填</span>注意跟实际的一致(空格允许存在)</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<h3 class="text-xl font-semibold mt-6 mb-4 text-gray-700">官方接口字段(字段名与官方接口一致)- 理论支持所有出现过的字段</h3>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>提示</span> 官方接口有出现对应字段时才需拼接到请求参数</p>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>示例</span> appid=xx&functionId=xx 以此类推;未出现字段无需拼接Key、Value</p>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>注意</span> 区分大小写</p>
|
||
|
||
<div class="table-container">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>字段名</th>
|
||
<th>备注</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><code>appid</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>functionId</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>body</code></td>
|
||
<td><span class="tag tag-optional"><i
|
||
class="fas fa-question-circle"></i>选填</span>数据过长可使用post模式请求、或者手动进行SHA256进行加密后再次填写
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>clientVersion</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>client</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>t</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>jsonp</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>api</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>appId</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>v</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>metrics</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>outputDimensions</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>filters</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>orderBy</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>pageNum</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>pageSize</code></td>
|
||
<td><span class="tag tag-optional"><i class="fas fa-question-circle"></i>选填</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="divider"></div>
|
||
|
||
<!-- API接口示例 -->
|
||
<h2 class="text-2xl font-bold mb-6 text-gray-800 section-title">API 接口示例</h2>
|
||
|
||
<!-- 例子1 -->
|
||
<div class="card p-6 mb-8">
|
||
<h3 class="text-xl font-semibold mb-4 text-gray-700">例子1:jx端获取订单列表数据</h3>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>注意</span> 自行替换正确的IP地址,pin替换实际的参数,sua注意空格</p>
|
||
|
||
<div class="table-container mb-4">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>字段名</th>
|
||
<th>示例值</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><code>khd</code></td>
|
||
<td>jx</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ai</code></td>
|
||
<td>25f73</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>pin</code></td>
|
||
<td>根据实际填写cookie中pin或者pt_pin字段的属性值</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>sua</code></td>
|
||
<td>Windows NT 10.0; Win64; x64</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>functionId</code></td>
|
||
<td>lite_newUserAllOrderList</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>appid</code></td>
|
||
<td>jx_h5</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>t</code></td>
|
||
<td>1748489096059</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>clientVersion</code></td>
|
||
<td>1.2.5</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>client</code></td>
|
||
<td>jxh5</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>body</code></td>
|
||
<td>{"page":1,"pagesize":10,"buid":325,"appCode":"ms0ca95114","time":1748489096059,"signStr":"db3c8b3733006239b535be3975c072ab"}
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<!-- GET请求示例 -->
|
||
<div class="mb-6">
|
||
<h4 class="text-lg font-medium mb-2 text-gray-700">GET请求示例</h4>
|
||
<div class="bg-gray-100 p-4 rounded-md">
|
||
<div class="font-medium mb-1">请求URL:</div>
|
||
<pre
|
||
class="text-sm">http://127.0.0.1:${defaultConfigh5st.port}${defaultConfigh5st.route}?khd=jx&ai=25f73&pin=&sua=Windows NT 10.0; Win64; x64&functionId=lite_newUserAllOrderList&appid=jx_h5&t=1748489096059&clientVersion=1.2.5&client=jxh5&body=</pre>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- POST请求示例 -->
|
||
<div>
|
||
<h4 class="text-lg font-medium mb-2 text-gray-700">POST请求示例 (x-www-form-urlencoded)</h4>
|
||
<div class="bg-gray-100 p-4 rounded-md">
|
||
<div class="font-medium mb-1">请求URL:</div>
|
||
<pre class="text-sm">http://127.0.0.1:${defaultConfigh5st.port}${defaultConfigh5st.route}</pre>
|
||
|
||
<div class="font-medium mt-3 mb-1">请求头:</div>
|
||
<pre class="text-sm">Content-Type: application/x-www-form-urlencoded</pre>
|
||
|
||
<div class="font-medium mt-3 mb-1">请求体:</div>
|
||
<pre
|
||
class="text-sm">khd=jx&ai=25f73&pin=&sua=Windows NT 10.0; Win64; x64&functionId=lite_newUserAllOrderList&appid=jx_h5&t=1748489096059&clientVersion=1.2.5&client=jxh5&body=</pre>
|
||
</div>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>提示</span> body参数带中文时需要将body属性值进行URL编码</p>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 例子2 -->
|
||
<div class="card p-6 mb-8">
|
||
<h3 class="text-xl font-semibold mb-4 text-gray-700">例子2:j麦接口</h3>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>注意</span> 自行替换正确的IP地址,body,pin替换实际的参数,sua注意空格</p>
|
||
|
||
<div class="table-container mb-4">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>字段名</th>
|
||
<th>示例值</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><code>khd</code></td>
|
||
<td>jm</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ai</code></td>
|
||
<td> 0248a</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>pin</code></td>
|
||
<td>根据实际填写cookie中pin或者pt_pin字段的属性值</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>sua</code></td>
|
||
<td>Windows NT 10.0; Win64; x64</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>api</code></td>
|
||
<td>dsm.wareshopv2.ware.wareListService.queryWareList</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>v</code></td>
|
||
<td>1.0</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>appId</code></td>
|
||
<td>3MC69M4R3HFKCQ4S01DN</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>body</code></td>
|
||
<td>{"a": "1"}</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<!-- GET请求示例 -->
|
||
<div class="mb-6">
|
||
<h4 class="text-lg font-medium mb-2 text-gray-700">GET请求示例</h4>
|
||
<div class="bg-gray-100 p-4 rounded-md">
|
||
<div class="font-medium mb-1">请求URL:</div>
|
||
<pre
|
||
class="text-sm">http://127.0.0.1:${defaultConfigh5st.port}${defaultConfigh5st.route}?khd=jm&ai=0248a&pin=&sua=Windows NT 10.0; Win64&api=dsm.wareshopv2.ware.wareListService.queryWareList&v=1.0&appId=3MC69M4R3HFKCQ4S01DN&body={"a":"1"}</pre>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- POST请求示例 -->
|
||
<div>
|
||
<h4 class="text-lg font-medium mb-2 text-gray-700">POST请求示例 (x-www-form-urlencoded)</h4>
|
||
<div class="bg-gray-100 p-4 rounded-md">
|
||
<div class="font-medium mb-1">请求URL:</div>
|
||
<pre class="text-sm">http://127.0.0.1:${defaultConfigh5st.port}${defaultConfigh5st.route}</pre>
|
||
|
||
<div class="font-medium mt-3 mb-1">请求头:</div>
|
||
<pre class="text-sm">Content-Type: application/x-www-form-urlencoded</pre>
|
||
|
||
<div class="font-medium mt-3 mb-1">请求体:</div>
|
||
<pre
|
||
class="text-sm">khd=jm&ai=0248a&pin=&sua=Windows NT 10.0; Win64&api=dsm.wareshopv2.ware.wareListService.queryWareList&v=1.0&appId=3MC69M4R3HFKCQ4S01DN&body={"a":"1"}</pre>
|
||
</div>
|
||
<p class="text-sm text-gray-500 mt-2"><span class="tag tag-info"><i
|
||
class="fas fa-info-circle"></i>提示</span> body参数带中文时需要将body属性值进行URL编码</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
|
||
</html>`
|
||
|
||
res.send(apiDoc);
|
||
} catch (e) {
|
||
error(e);
|
||
}
|
||
});
|
||
app.post(defaultConfigh5st.route, (req, res) => handleH5stRequest(req, res, req.body));
|
||
app.get(defaultConfigh5st.route, (req, res) => handleH5stRequest(req, res, req.query));
|
||
|
||
app.listen(defaultConfig.port, '0.0.0.0', () => {
|
||
console.log(`${defaultConfig.CipherName}服务端启动成功!!!`);
|
||
console.log(`路由:${defaultConfig.route}`);
|
||
console.log(`端口:${defaultConfig.port}`)
|
||
}); |