/* * MC Report System * Copyright (C) 2026 Sea Network Technology Studio * Author: CangLan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ const VerifyPage = { async render() { const params = new URLSearchParams((location.hash.split('?')[1] || '')); const token = params.get('token'); if (token) { return `
验证中,请稍候...
返回登录
`; } return `
返回登录
`; }, mount() { const params = new URLSearchParams((location.hash.split('?')[1] || '')); const token = params.get('token'); if (token) { this.verifyToken(token); return; } document.getElementById('verify-form').addEventListener('submit', async e => { e.preventDefault(); const code = document.getElementById('vf-code').value.trim(); const msg = document.getElementById('vf-msg'); try { const r = await API.post('/auth/verify-email', { code }); msg.className = 'alert alert-s'; msg.textContent = r.message || '验证成功'; msg.classList.remove('hidden'); setTimeout(() => location.hash = '#/login', 2000); } catch(ex) { msg.className = 'alert alert-e'; msg.textContent = ex.message; msg.classList.remove('hidden'); } }); }, async verifyToken(token) { const msg = document.getElementById('vf-msg'); try { const r = await API.post('/auth/verify-email', { code: token }); msg.className = 'alert alert-s'; msg.textContent = r.message || '验证成功'; setTimeout(() => location.hash = '#/login', 2000); } catch (ex) { msg.className = 'alert alert-e'; msg.textContent = ex.message; } } };