From 4df3d5fecd256f5ccf59fd1c28c55b98649b2078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=BB=8D=E5=BA=B7?= <3052147989@qq.com> Date: Tue, 3 Mar 2026 22:53:16 +0800 Subject: [PATCH] feat(accounts): add Outlook register button and auto-fill token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a '🔑 注册' button to account panel header; show only when a non-temp group selected; on successful OAuth exchange auto-open Add Account modal and pre-fill client_id + refresh_token. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- static/js/features/groups.js | 25 +++++++++++++++++++++++++ static/js/main.js | 22 ++++++++++++---------- templates/index.html | 3 ++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/static/js/features/groups.js b/static/js/features/groups.js index 4225754..5bebcc8 100644 --- a/static/js/features/groups.js +++ b/static/js/features/groups.js @@ -129,6 +129,12 @@ } } + // 显示「注册Outlook账号」按钮(仅在非临时邮箱分组时) + const registerBtn = document.getElementById('registerOutlookBtn'); + if (registerBtn) { + registerBtn.style.display = isTempEmailGroup ? 'none' : ''; + } + // 更新底部按钮 updateAccountPanelFooter(); @@ -173,6 +179,22 @@ } } + // 获取 provider 的中文展示名(账号卡片 tag) + function getProviderLabel(provider) { + const key = (provider || 'outlook').toString().toLowerCase(); + const labels = { + outlook: 'Outlook', + gmail: 'Gmail', + qq: 'QQ邮箱', + '163': '163邮箱', + '126': '126邮箱', + yahoo: 'Yahoo邮箱', + aliyun: '阿里邮箱', + custom: '自定义IMAP' + }; + return labels[key] || provider || '未知'; + } + // 渲染邮箱列表 function renderAccountList(accounts) { const container = document.getElementById('accountList'); @@ -210,6 +232,8 @@ const initial = (acc.email || '?')[0].toUpperCase(); const isFailed = acc.last_refresh_status === 'failed'; const gradient = avatarGradients[index % avatarGradients.length]; + const providerLabel = getProviderLabel(acc.provider || acc.account_type || 'outlook'); + const providerTagHtml = `${escapeHtml(providerLabel)}`; let tokenBadge = '– 未知'; if (acc.token_status === 'valid') { @@ -235,6 +259,7 @@ ${acc.remark && acc.remark.trim() ? `
📝 ${escapeHtml(acc.remark)}
` : ''}
+ ${providerTagHtml} ${(acc.tags || []).map(tag => `${escapeHtml(tag.name)}`).join('')}
diff --git a/static/js/main.js b/static/js/main.js index a78353d..894ce3d 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -915,18 +915,20 @@ ${details} const data = await response.json(); if (data.success) { - // 生成完整的导入格式 - const importFormat = `your@outlook.com----yourpassword----${data.client_id}----${data.refresh_token}`; - - // 显示结果 - document.getElementById('refreshTokenOutput').value = importFormat; - document.getElementById('refreshTokenResult').style.display = 'block'; - - showToast('✅ Refresh Token 获取成功!', 'success'); - - // 重置按钮状态(不隐藏,允许重复使用) btn.disabled = false; btn.textContent = '换取 Token'; + + // 关闭 Token 弹窗,打开添加账号弹窗并预填充 + hideGetRefreshTokenModal(); + showAddAccountModal(); + + const inputEl = document.getElementById('accountInput'); + if (inputEl) { + inputEl.value = `your@outlook.com----yourpassword----${data.client_id}----${data.refresh_token}`; + inputEl.select(); + } + + showToast('✅ Token 获取成功!请将邮箱和密码替换后点导入', 'success'); } else { handleApiError(data, '换取 Token 失败'); btn.disabled = false; diff --git a/templates/index.html b/templates/index.html index ebc677e..844ad5e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -168,7 +168,8 @@ 选择分组 -
+
+