300 lines
10 KiB
HTML
300 lines
10 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<title>授权处理中</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
color: #333;
|
|
}
|
|
.container {
|
|
background: white;
|
|
border-radius: 16px;
|
|
padding: 40px 30px;
|
|
width: 100%;
|
|
max-width: 500px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
|
|
text-align: center;
|
|
}
|
|
/* 响应式调整 */
|
|
@media (max-width: 768px) {
|
|
.container {
|
|
padding: 30px 20px;
|
|
margin: 10px;
|
|
}
|
|
}
|
|
@media (max-width: 480px) {
|
|
.container {
|
|
padding: 25px 15px;
|
|
border-radius: 12px;
|
|
}
|
|
}
|
|
.icon {
|
|
width: 80px;
|
|
height: 80px;
|
|
margin: 0 auto 25px;
|
|
position: relative;
|
|
}
|
|
.spinner {
|
|
width: 100%;
|
|
height: 100%;
|
|
border: 3px solid rgba(102, 126, 234, 0.2);
|
|
border-top-color: #667eea;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
}
|
|
@keyframes spin {
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
.checkmark {
|
|
display: none;
|
|
width: 100%;
|
|
height: 100%;
|
|
color: #52c41a;
|
|
font-size: 60px;
|
|
line-height: 80px;
|
|
}
|
|
.status-title {
|
|
font-size: 24px;
|
|
font-weight: 600;
|
|
margin-bottom: 15px;
|
|
color: #1a1a1a;
|
|
}
|
|
.status-desc {
|
|
color: #666;
|
|
line-height: 1.6;
|
|
margin-bottom: 30px;
|
|
font-size: 15px;
|
|
}
|
|
.progress-container {
|
|
margin: 25px 0;
|
|
}
|
|
.progress-bar {
|
|
height: 6px;
|
|
background: #f0f0f0;
|
|
border-radius: 3px;
|
|
overflow: hidden;
|
|
}
|
|
.progress-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #667eea, #764ba2);
|
|
width: 0%;
|
|
transition: width 0.3s ease;
|
|
border-radius: 3px;
|
|
}
|
|
.time-info {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
font-size: 13px;
|
|
color: #999;
|
|
margin-top: 8px;
|
|
}
|
|
.btn {
|
|
display: inline-block;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
padding: 12px 28px;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
margin-top: 10px;
|
|
}
|
|
.btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
|
|
}
|
|
.btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
.countdown {
|
|
font-size: 14px;
|
|
color: #ff4d4f;
|
|
margin-top: 15px;
|
|
font-weight: 500;
|
|
}
|
|
.hidden {
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- 等待状态 -->
|
|
<div id="waitingPanel">
|
|
<div class="icon">
|
|
<div class="spinner"></div>
|
|
</div>
|
|
<h2 class="status-title">授权处理中</h2>
|
|
<p class="status-desc">
|
|
系统正在处理您的授权请求,请稍候...
|
|
<br>此过程通常需要几秒钟时间。
|
|
</p>
|
|
|
|
<div class="progress-container">
|
|
<div class="progress-bar">
|
|
<div class="progress-fill" id="progressFill"></div>
|
|
</div>
|
|
<div class="time-info">
|
|
<span id="elapsedTime">已等待: 0秒</span>
|
|
<span>剩余: <span id="remainingTime">600秒</span></span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="countdown" id="countdown">
|
|
页面将在 <span id="refreshCount">60</span> 秒后自动刷新
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 成功状态 -->
|
|
<div id="successPanel" class="hidden">
|
|
<div class="icon">
|
|
<div class="checkmark">✓</div>
|
|
</div>
|
|
<h2 class="status-title">授权成功</h2>
|
|
<p class="status-desc" id="successDesc">
|
|
您的应用已成功授权并绑定!
|
|
</p>
|
|
<a href="/" class="btn">返回首页</a>
|
|
<a href="/app/manage" class="btn" style="background:#52c41a; margin-left:10px;">管理应用</a>
|
|
</div>
|
|
|
|
<!-- 超时状态 -->
|
|
<div id="timeoutPanel" class="hidden">
|
|
<div class="icon" style="color:#ff4d4f;">!</div>
|
|
<h2 class="status-title">授权超时</h2>
|
|
<p class="status-desc">
|
|
授权处理时间过长,链接已失效。
|
|
<br>请重新发起授权流程。
|
|
</p>
|
|
<a href="/auth/retry" class="btn" style="background:#ff4d4f;">重新授权</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const state = '{$state}';
|
|
const startTime = parseInt('{$start_time}');
|
|
const timeout = parseInt('{$timeout}');
|
|
const pollingInterval = parseInt('{$polling_interval}');
|
|
|
|
let refreshTimer = 60;
|
|
let pollingTimer;
|
|
let progressInterval;
|
|
|
|
// 更新等待时间和进度条
|
|
function updateProgress() {
|
|
const now = Math.floor(Date.now() / 1000);
|
|
const elapsed = now - startTime;
|
|
const remaining = timeout - elapsed;
|
|
|
|
// 更新显示时间
|
|
document.getElementById('elapsedTime').textContent = `已等待: ${elapsed}秒`;
|
|
document.getElementById('remainingTime').textContent = `${remaining}秒`;
|
|
|
|
// 更新进度条
|
|
const progressPercent = Math.min((elapsed / timeout) * 100, 100);
|
|
document.getElementById('progressFill').style.width = `${progressPercent}%`;
|
|
|
|
// 检查超时
|
|
if (elapsed >= timeout) {
|
|
showTimeout();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// 自动刷新倒计时
|
|
function startRefreshCountdown() {
|
|
const countdownElement = document.getElementById('refreshCount');
|
|
countdownElement.textContent = refreshTimer;
|
|
|
|
const countdownInterval = setInterval(() => {
|
|
refreshTimer--;
|
|
countdownElement.textContent = refreshTimer;
|
|
|
|
if (refreshTimer <= 0) {
|
|
clearInterval(countdownInterval);
|
|
location.reload();
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
// 轮询检查状态
|
|
function pollStatus() {
|
|
if (!updateProgress()) return;
|
|
|
|
fetch(`/index/index/checkAuthStatus?state=${state}&t=${Date.now()}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.code === 1) {
|
|
if (data.data.status === 'success') {
|
|
showSuccess(data.data);
|
|
} else if (data.data.status === 'pending') {
|
|
// 继续等待
|
|
setTimeout(pollStatus, pollingInterval);
|
|
}
|
|
} else {
|
|
// 出错或超时
|
|
if (data.msg.includes('超时') || data.msg.includes('过期')) {
|
|
showTimeout();
|
|
} else {
|
|
setTimeout(pollStatus, pollingInterval);
|
|
}
|
|
}
|
|
})
|
|
.catch(() => {
|
|
setTimeout(pollStatus, pollingInterval);
|
|
});
|
|
}
|
|
|
|
// 显示成功状态
|
|
function showSuccess(data) {
|
|
clearInterval(progressInterval);
|
|
if (pollingTimer) clearTimeout(pollingTimer);
|
|
|
|
document.getElementById('waitingPanel').classList.add('hidden');
|
|
document.getElementById('successPanel').classList.remove('hidden');
|
|
document.getElementById('successDesc').innerHTML = `
|
|
应用ID: <strong>${data.app_id || '未知'}</strong><br>
|
|
绑定时间: ${new Date(data.bind_time * 1000).toLocaleString()}
|
|
`;
|
|
}
|
|
|
|
// 显示超时状态
|
|
function showTimeout() {
|
|
clearInterval(progressInterval);
|
|
if (pollingTimer) clearTimeout(pollingTimer);
|
|
|
|
document.getElementById('waitingPanel').classList.add('hidden');
|
|
document.getElementById('timeoutPanel').classList.remove('hidden');
|
|
}
|
|
|
|
// 初始化
|
|
progressInterval = setInterval(updateProgress, 1000);
|
|
startRefreshCountdown();
|
|
pollStatus();
|
|
|
|
// 页面可见性变化时重置计时器
|
|
document.addEventListener('visibilitychange', function() {
|
|
if (!document.hidden) {
|
|
refreshTimer = 60;
|
|
updateProgress();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |