feat: cloud.html 自动读取URL ?key=参数并填入充值输入框

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hfshfg
2026-04-06 16:55:15 +08:00
parent e67c6a5586
commit 42b2ead421

View File

@@ -955,6 +955,23 @@ document.getElementById('keyInput').addEventListener('input', function() {
document.getElementById('balanceLine').textContent = '粘贴 Key 后自动查询余额'; document.getElementById('balanceLine').textContent = '粘贴 Key 后自动查询余额';
} }
}); });
// URL 参数自动填入 Key从 U 盘 switch.html 跳转过来时携带)
(function() {
const params = new URLSearchParams(window.location.search);
const key = params.get('key') || params.get('api_key') || '';
if (key && key.startsWith('sk-')) {
const inp = document.getElementById('keyInput');
inp.value = key;
updateHint(key);
if (validateKey(key)) queryBalance(key);
// 滚动到充值区
setTimeout(() => {
const el = document.getElementById('recharge');
if (el) el.scrollIntoView({behavior: 'smooth', block: 'start'});
}, 300);
}
})();
</script> </script>
</body> </body>
</html> </html>