'use client'; // 管理后台 - 自定义页面管理(列表) import { useEffect, useState } from 'react'; import { API } from '@/lib/api'; import CustomPageEditor from './CustomPageEditor'; export default function AdminCustomPages() { const [pages, setPages] = useState(null); const [error, setError] = useState(null); const [editing, setEditing] = useState(null); // null | 'new' | page对象 const load = () => { API.adminGetCustomPages() .then((data) => { setPages(data || []); setError(null); }) .catch((e) => { setError(e.message); setPages([]); }); }; useEffect(load, []); const handleDelete = async (p) => { if (!confirm('确定要删除这个页面吗?')) return; try { await API.adminDeleteCustomPage(p.id); load(); } catch (err) { alert('删除失败:' + err.message); } }; if (error) return
加载失败:{error}
; return ( <>

📄 自定义页面

{pages === null ? (
加载中...
) : pages.length === 0 ? (
暂无自定义页面
) : (
{pages.map((p) => ( ))}
名称 标题 URL 状态 操作
{p.name} {p.title} ?custom={p.name} {p.enabled ? '✅ 启用' : '❌ 禁用'}
)}
{editing && ( setEditing(null)} onSaved={() => { setEditing(null); load(); }} /> )} ); }