diff --git a/js/admin.js b/js/admin.js
index 0946946..97b7fcc 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -210,6 +210,10 @@ function renderAdminLinks() {
});
}
+// ============================================================
+// ⚙️ 论坛设置(含自定义 CSS)
+// ============================================================
+
function renderAdminSettings() {
const container = document.getElementById('adminContent');
container.innerHTML = `
@@ -374,6 +378,166 @@ function renderAdminSettings() {
});
}
+// ============================================================
+// 📄 自定义页面管理
+// ============================================================
+
+let editingPageId = null;
+
+function renderAdminCustomPages() {
+ const container = document.getElementById('adminContent');
+ container.innerHTML = `
+
加载中...
';
+ API.getAdminCustomPages().then(pages => {
+ if (pages.length === 0) {
+ container.innerHTML = '
+
×
+
${isEdit ? '✏️ 编辑页面' : '📄 添加页面'}
+
+
+
+ ${isEdit ? '
⚠️ 名称不可修改
' : '
只允许字母、数字、短横线和下划线
'}
+
+
+
+
+
+
+
+
+
+
+
+
+
支持 HTML、CSS(<style>)、JS(<script>),内容会在独立的沙盒中渲染
+
+
+
+ `;
+
+ document.body.appendChild(modal);
+
+ modal.querySelector('.close').addEventListener('click', function() {
+ modal.remove();
+ });
+ modal.addEventListener('click', function(e) {
+ if (e.target === this) modal.remove();
+ });
+
+ modal.querySelector('#editorSaveBtn').addEventListener('click', async function() {
+ const name = document.getElementById('editorPageName').value.trim();
+ const title = document.getElementById('editorPageTitle').value.trim();
+ const content = document.getElementById('editorContent').value.trim();
+ const enabled = document.getElementById('editorEnabled').value === 'true';
+
+ if (!name) { alert('请输入页面名称'); return; }
+ if (!title) { alert('请输入导航栏显示名称'); return; }
+ if (!content) { alert('请输入页面内容'); return; }
+ if (!/^[a-zA-Z0-9\-_]+$/.test(name)) {
+ alert('页面名称只允许字母、数字、短横线和下划线');
+ return;
+ }
+
+ try {
+ if (isEdit) {
+ await API.updateCustomPage(page.id, title, content, enabled);
+ } else {
+ await API.createCustomPage(name, title, content);
+ }
+ modal.remove();
+ loadCustomPageList();
+ loadCustomPagesNav();
+ } catch (err) {
+ alert('保存失败:' + err.message);
+ }
+ });
+}
+
// ============================================================
// 自定义 CSS 警告模态框
// ============================================================