Files

75 lines
3.1 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Token 设置工具</title>
<style>
body { font-family: sans-serif; padding: 20px; max-width: 600px; margin: 0 auto; }
h1 { color: #333; }
.section { background: #f5f5f5; padding: 20px; margin: 20px 0; border-radius: 8px; }
button { background: #1677ff; color: white; border: none; padding: 12px 30px; font-size: 16px; border-radius: 6px; cursor: pointer; }
button:hover { background: #0958d9; }
.success { color: #52c41a; font-weight: bold; margin-top: 10px; }
.token-display { background: #fff; padding: 10px; border-radius: 4px; word-break: break-all; font-family: monospace; font-size: 12px; margin-top: 10px; }
</style>
</head>
<body>
<h1>🔧 开发调试工具</h1>
<div class="section">
<h3>步骤 1:复制 Token</h3>
<div class="token-display" id="tokenDisplay"></div>
<button onclick="copyToken()">复制 Token</button>
<span id="copyResult"></span>
</div>
<div class="section">
<h3>步骤 2:设置 Token</h3>
<ol>
<li>按 F12 打开开发者工具</li>
<li>切换到 Console 标签</li>
<li>粘贴并执行:<br><code>localStorage.setItem('token', 刚才复制的token)</code></li>
</ol>
</div>
<div class="section">
<h3>步骤 3:验证</h3>
<button onclick="verifyToken()">验证 Token 是否设置成功</button>
<div id="verifyResult" style="margin-top: 10px;"></div>
</div>
<script>
const token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJjb21wYW55X2lkIjoyLCJ1c2VybmFtZSI6Ilx1Njc0ZVx1NGY3M1x1NTM1YSIsImlhdCI6MTc3MjAwOTA0MCwiZXhwIjoxNzcyNjEzODQwfQ.mFsGM4bxRZdAMTQ3QgHO-DoFCWZUhUNY2N62VkN6FZ4';
document.getElementById('tokenDisplay').textContent = token;
function copyToken() {
navigator.clipboard.writeText(token).then(() => {
document.getElementById('copyResult').textContent = ' ✅ 已复制!';
}).catch(() => {
// 备用方案
const textarea = document.createElement('textarea');
textarea.value = token;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
document.getElementById('copyResult').textContent = ' ✅ 已复制!';
});
}
function verifyToken() {
const saved = localStorage.getItem('token');
const resultDiv = document.getElementById('verifyResult');
if (saved === token) {
resultDiv.innerHTML = '<span class="success">✅ Token 验证成功!可以刷新主页面了。</span>';
} else if (saved) {
resultDiv.innerHTML = '<span style="color: orange;">⚠️ Token 已存在但不匹配,请重新设置</span>';
} else {
resultDiv.innerHTML = '<span style="color: red;">✗ Token 未设置,请按照步骤2设置</span>';
}
}
</script>
</body>
</html>