feat(mail): 添加收件箱功能,自动获得验证码

This commit is contained in:
cnlimiter
2026-03-20 12:54:39 +08:00
parent 87ff48cdaf
commit b1a8d02353
16 changed files with 186 additions and 44 deletions

View File

@@ -329,6 +329,7 @@ function renderAccounts(accounts) {
<a href="#" class="dropdown-item" onclick="event.preventDefault();closeMoreMenu(this);refreshToken(${account.id})">刷新</a>
<a href="#" class="dropdown-item" onclick="event.preventDefault();closeMoreMenu(this);uploadAccount(${account.id})">上传</a>
<a href="#" class="dropdown-item" onclick="event.preventDefault();closeMoreMenu(this);markSubscription(${account.id})">标记</a>
<a href="#" class="dropdown-item" onclick="event.preventDefault();closeMoreMenu(this);checkInboxCode(${account.id})">收件箱</a>
</div>
</div>
<button class="btn btn-danger btn-sm" onclick="deleteAccount(${account.id}, '${escapeHtml(account.email)}')">删除</button>
@@ -1217,3 +1218,34 @@ async function saveCookies(id) {
toast.error('保存 Cookies 失败: ' + e.message);
}
}
// 查询收件箱验证码
async function checkInboxCode(id) {
toast.info('正在查询收件箱...');
try {
const result = await api.post(`/accounts/${id}/inbox-code`);
if (result.success) {
showInboxCodeResult(result.code, result.email);
} else {
toast.error('查询失败: ' + (result.error || '未收到验证码'));
}
} catch (error) {
toast.error('查询失败: ' + error.message);
}
}
function showInboxCodeResult(code, email) {
elements.modalBody.innerHTML = `
<div style="text-align:center; padding:24px 16px;">
<div style="font-size:13px;color:var(--text-muted);margin-bottom:12px;">
${escapeHtml(email)} 最新验证码
</div>
<div style="font-size:36px;font-weight:700;letter-spacing:8px;
color:var(--primary);font-family:monospace;margin-bottom:20px;">
${escapeHtml(code)}
</div>
<button class="btn btn-primary" onclick="copyToClipboard('${escapeHtml(code)}')">复制验证码</button>
</div>
`;
elements.detailModal.classList.add('active');
}

View File

@@ -21,7 +21,7 @@ let toastShown = false; // 标记是否已显示过 toast
let availableServices = {
tempmail: { available: true, services: [] },
outlook: { available: false, services: [] },
custom_domain: { available: false, services: [] },
moe_mail: { available: false, services: [] },
temp_mail: { available: false, services: [] },
duck_mail: { available: false, services: [] },
freemail: { available: false, services: [] }
@@ -293,15 +293,15 @@ function updateEmailServiceOptions() {
}
// 自定义域名
if (availableServices.custom_domain.available) {
if (availableServices.moe_mail.available) {
const optgroup = document.createElement('optgroup');
optgroup.label = `🔗 自定义域名 (${availableServices.custom_domain.count} 个服务)`;
optgroup.label = `🔗 自定义域名 (${availableServices.moe_mail.count} 个服务)`;
availableServices.custom_domain.services.forEach(service => {
availableServices.moe_mail.services.forEach(service => {
const option = document.createElement('option');
option.value = `custom_domain:${service.id || 'default'}`;
option.value = `moe_mail:${service.id || 'default'}`;
option.textContent = service.name + (service.default_domain ? ` (@${service.default_domain})` : '');
option.dataset.type = 'custom_domain';
option.dataset.type = 'moe_mail';
if (service.id) {
option.dataset.serviceId = service.id;
}
@@ -402,8 +402,8 @@ function handleServiceChange(e) {
if (service) {
addLog('info', `[系统] 已选择 Outlook 账户: ${service.name}`);
}
} else if (type === 'custom_domain') {
const service = availableServices.custom_domain.services.find(s => s.id == id);
} else if (type === 'moe_mail') {
const service = availableServices.moe_mail.services.find(s => s.id == id);
if (service) {
addLog('info', `[系统] 已选择自定义域名服务: ${service.name}`);
}

View File

@@ -4,7 +4,7 @@
// 状态
let outlookServices = [];
let customServices = []; // 合并 custom_domain + temp_mail + duck_mail
let customServices = []; // 合并 moe_mail + temp_mail + duck_mail
let selectedOutlook = new Set();
let selectedCustom = new Set();
@@ -293,11 +293,11 @@ function getCustomServiceAddress(service) {
return `${escapeHtml(baseUrl)}<div style="color: var(--text-muted); margin-top: 4px;">默认域名:@${escapeHtml(domain)}</div>`;
}
// 加载自定义邮箱服务(custom_domain + temp_mail + duck_mail + freemail 合并)
// 加载自定义邮箱服务(moe_mail + temp_mail + duck_mail + freemail 合并)
async function loadCustomServices() {
try {
const [r1, r2, r3, r4] = await Promise.all([
api.get('/email-services?service_type=custom_domain'),
api.get('/email-services?service_type=moe_mail'),
api.get('/email-services?service_type=temp_mail'),
api.get('/email-services?service_type=duck_mail'),
api.get('/email-services?service_type=freemail')
@@ -422,7 +422,7 @@ async function handleAddCustom(e) {
let serviceType, config;
if (subType === 'moemail') {
serviceType = 'custom_domain';
serviceType = 'moe_mail';
config = {
base_url: formData.get('api_url'),
api_key: formData.get('api_key'),

View File

@@ -351,7 +351,7 @@ const statusMap = {
service: {
tempmail: 'Tempmail.lol',
outlook: 'Outlook',
custom_domain: '自定义域名',
moe_mail: 'MoeMail',
temp_mail: 'Temp-Mail自部署',
duck_mail: 'DuckMail',
freemail: 'Freemail'