/* * 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 SourcesPage = { 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 { // 管理视图: 全量含 enabled(可显示/切换启用停用) const rows = await API.get('/sources?manage=1'); ct.innerHTML = rows.length === 0 ? '

暂无来源

' : `
${rows.map(s => ` `).join('')}
code名称排序状态操作
${U.esc(s.code)} ${U.esc(s.label)} ${s.sort_order} ${s.enabled ? '启用' : '停用'}

来源用于标识玩家身份归属(如: 网易端/皮肤站/正版/离线)。已被身份数据使用的来源不能删除, 只能停用。

`; } catch (e) { ct.innerHTML = `
${e.message}
`; } }, showAdd() { U.modal('添加来源', `
`); document.getElementById('src-form').onsubmit = async e => { e.preventDefault(); try { await API.post('/sources', { code: document.getElementById('src-code').value, label: document.getElementById('src-label').value, sort_order: document.getElementById('src-sort').value, }); App.closeModal(); this.load(); } catch(ex){alert(ex.message);} }; }, showEdit(code, label, enabled, sortOrder) { U.modal('编辑来源', `
`); document.getElementById('src-edit-form').onsubmit = async e => { e.preventDefault(); try { await API.put(`/sources/${code}`, { label: document.getElementById('se-label').value, enabled: document.getElementById('se-enabled').value === '1', sort_order: document.getElementById('se-sort').value, }); App.closeModal(); this.load(); } catch(ex){alert(ex.message);} }; }, async del(code) { if (!await U.confirm(`确认删除来源 ${code}?`)) return; try { await API.delete(`/sources/${code}`); this.load(); } catch(ex){alert(ex.message);} } };