/* * 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 TemplatesPage = { async render() { return '
'; }, async mount() { document.getElementById('page-title').textContent = '邮件模板'; document.getElementById('page-actions').innerHTML = ''; await this.load(); }, async load() { const ct = document.getElementById('page-content'); try { const templates = await API.get('/settings/email-templates'); ct.innerHTML = templates.map(t => `
${U.esc(t.name)}${t.code}
主题${U.esc(t.subject)}
${t.description ? `
说明${U.esc(t.description)}
` : ''}
`).join(''); } catch (e) { ct.innerHTML = `
${e.message}
`; } }, async edit(code, name) { try { const t = await API.get(`/settings/email-templates/${code}`); U.modal(`编辑: ${name}`, `
可用变量: ${t.description?.match(/\{\{[^}]+\}\}/g)?.join(', ') || '{{site_name}}'}
`, '800px'); document.getElementById('et-form').onsubmit = async e => { e.preventDefault(); try { await API.put(`/settings/email-templates/${code}`, { subject: document.getElementById('et-subject').value, body: document.getElementById('et-body').value, }); App.closeModal(); this.load(); } catch (ex) { alert(ex.message); } }; } catch (e) { alert(e.message); } } };