You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.4 KiB
68 lines
2.4 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>商机模块接口验收 — 骨架自检</title>
|
|
<style>
|
|
body { font-family: system-ui, sans-serif; padding: 24px; background: #f5f5f5; }
|
|
h1 { font-size: 1.3rem; margin-bottom: 8px; }
|
|
p { color: #555; margin: 4px 0 16px; }
|
|
button { padding: 8px 18px; font-size: 14px; cursor: pointer;
|
|
background: #1976d2; color: #fff; border: none; border-radius: 4px; }
|
|
button:hover { background: #1565c0; }
|
|
pre { background: #fff; border: 1px solid #ddd; border-radius: 4px;
|
|
padding: 14px; font-size: 12px; white-space: pre-wrap; margin-top: 12px;
|
|
min-height: 60px; }
|
|
ul { list-style: none; padding: 0; margin-top: 12px; }
|
|
li { padding: 4px 0; font-size: 13px; }
|
|
.nav { margin-top: 28px; border-top: 1px solid #ddd; padding-top: 16px; }
|
|
.nav a { margin-right: 14px; color: #1976d2; font-size: 13px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>🔬 商机模块接口验收 — 骨架自检</h1>
|
|
<p>点击下方按钮验证 common.js 基础能力(token 获取 + apiFetch + renderResult)</p>
|
|
|
|
<button onclick="runCheck()">▶ 运行自检</button>
|
|
|
|
<ul id="assertions"></ul>
|
|
<pre id="result">(等待运行…)</pre>
|
|
|
|
<div class="nav">
|
|
<strong>子域 Demo 页:</strong><br><br>
|
|
<a href="03-list.html">03 列表族</a>
|
|
<a href="04-detail.html">04 详情+状态机</a>
|
|
<a href="05-rules.html">05 规则族</a>
|
|
</div>
|
|
|
|
<script src="common.js"></script>
|
|
<script>
|
|
async function runCheck() {
|
|
document.getElementById('assertions').innerHTML = '';
|
|
document.getElementById('result').textContent = '运行中…';
|
|
|
|
// 1. 获取 token
|
|
let token;
|
|
try {
|
|
token = await getToken();
|
|
} catch(e) {
|
|
assert('getToken() 不抛异常', false, String(e));
|
|
renderResult('result', { status: 0, ok: false, data: null, raw: String(e), durationMs: 0 });
|
|
return;
|
|
}
|
|
assert('getToken() 返回非空字符串', typeof token === 'string' && token.length > 0, token);
|
|
|
|
// 2. 调一个简单的后端接口(debug token 自身)
|
|
const res = await apiFetch('GET', '/api/auth/debug/token', null, { userId: '739564171091247104' });
|
|
assert('apiFetch() 返回 HTTP 200', res.status === 200, `实际 ${res.status}`);
|
|
assert('响应 data.success === true', res.data?.success === true, JSON.stringify(res.data));
|
|
assert('响应耗时 < 3000 ms', res.durationMs < 3000, `实际 ${res.durationMs} ms`);
|
|
|
|
// 3. 渲染结果
|
|
renderResult('result', res);
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|