feat(accounts): add Outlook register button and auto-fill token
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>
This commit is contained in:
1 parent
6a511d76ff
commit
4df3d5fecd
3 files changed
+39
-11
No files matched your search
@@ -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 = `<span class="account-provider-tag">${escapeHtml(providerLabel)}</span>`;
|
||||
|
||||
let tokenBadge = '<span class="badge badge-gray">– 未知</span>';
|
||||
if (acc.token_status === 'valid') {
|
||||
@@ -235,6 +259,7 @@
|
||||
</div>
|
||||
${acc.remark && acc.remark.trim() ? `<div style="font-size:0.72rem;color:var(--text-muted);margin-top:2px;">📝 ${escapeHtml(acc.remark)}</div>` : ''}
|
||||
<div style="display:flex;flex-wrap:wrap;gap:3px;margin-top:3px;">
|
||||
${providerTagHtml}
|
||||
${(acc.tags || []).map(tag => `<span class="tag" style="background-color:${tag.color};color:white;">${escapeHtml(tag.name)}</span>`).join('')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+12
-10
@@ -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;
|
||||
|
||||
@@ -168,7 +168,8 @@
|
||||
<span class="group-color-dot" id="currentGroupColor" style="background-color:#666;"></span>
|
||||
<span id="currentGroupName">选择分组</span>
|
||||
</span>
|
||||
<div style="display:flex;gap:4px;">
|
||||
<div style="display:flex;gap:4px;align-items:center;">
|
||||
<button id="registerOutlookBtn" class="btn btn-sm" onclick="showGetRefreshTokenModal()" title="通过 OAuth 获取 Token 注册 Outlook 账号" style="display:none;background-color:#0078d4;color:#fff;font-size:0.75rem;padding:3px 8px;border:none;border-radius:4px;cursor:pointer;">🔑 注册</button>
|
||||
<button class="btn-icon" onclick="showTagManagementModal()" title="管理标签">🏷️</button>
|
||||
<button class="btn-icon" onclick="showAddAccountModal()" title="导入账号">+</button>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user