83 lines
3.3 KiB
HTML
83 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>令牌测试页面</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<div class="container mt-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4>管理员令牌测试</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<label for="tokenInput" class="form-label">管理员令牌</label>
|
|
<input type="text" class="form-control" id="tokenInput" placeholder="请输入管理员令牌">
|
|
<small class="text-muted">正确的令牌应该是: onmyoji_admin_token_2024</small>
|
|
</div>
|
|
<button class="btn btn-primary" onclick="testToken()">测试令牌</button>
|
|
<div id="result" class="mt-3"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function testToken() {
|
|
const token = document.getElementById('tokenInput').value.trim();
|
|
const resultDiv = document.getElementById('result');
|
|
|
|
if (!token) {
|
|
resultDiv.innerHTML = '<div class="alert alert-warning">请输入令牌</div>';
|
|
return;
|
|
}
|
|
|
|
resultDiv.innerHTML = '<div class="alert alert-info">正在测试...</div>';
|
|
|
|
try {
|
|
const response = await fetch('/onmyoji_gacha/api/stats/daily', {
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
console.log('响应状态:', response.status);
|
|
console.log('响应头:', response.headers);
|
|
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
resultDiv.innerHTML = `
|
|
<div class="alert alert-success">
|
|
<h5>✅ 令牌验证成功!</h5>
|
|
<pre>${JSON.stringify(data, null, 2)}</pre>
|
|
</div>
|
|
`;
|
|
} else {
|
|
const errorText = await response.text();
|
|
resultDiv.innerHTML = `
|
|
<div class="alert alert-danger">
|
|
<h5>❌ 令牌验证失败</h5>
|
|
<p>状态码: ${response.status}</p>
|
|
<p>错误信息: ${errorText}</p>
|
|
</div>
|
|
`;
|
|
}
|
|
} catch (error) {
|
|
resultDiv.innerHTML = `
|
|
<div class="alert alert-danger">
|
|
<h5>❌ 请求失败</h5>
|
|
<p>${error.message}</p>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |