import { Template } from "interface/template"; import { Container, Heading, Text, Box, Flex, Table, Button, TextField, DropdownMenu, ScrollArea, DataList, Badge, } from "@radix-ui/themes"; import { PlusIcon, MagnifyingGlassIcon, DotsHorizontalIcon, Pencil1Icon, TrashIcon, EyeOpenIcon, ReaderIcon, } from "@radix-ui/react-icons"; import { useState } from "react"; import type { PostDisplay } from "interface/fields"; // 模拟文章数据 const mockPosts: PostDisplay[] = [ { id: 1, title: "构建现代化的前端开发工作流", content: "在现代前端开发中...", authorName: "张三", publishedAt: new Date("2024-03-15"), status: "published", isEditor: false, createdAt: new Date("2024-03-15"), updatedAt: new Date("2024-03-15"), metaKeywords: "", metaDescription: "", categories: [{ name: "前端开发" }], tags: [{ name: "工程化" }, { name: "效率提升" }], }, // ... 可以添加更多模拟数据 ]; export default new Template({}, ({ http, args }) => { const [searchTerm, setSearchTerm] = useState(""); const [selectedStatus, setSelectedStatus] = useState("all"); return ( {/* 页面标题和操作栏 */} 文章管理 {/* 搜索和筛选栏 */} ) => setSearchTerm(e.target.value) } > setSelectedStatus("all")}> 全部 setSelectedStatus("published")}> 已发布 setSelectedStatus("draft")}> 草稿 {/* 文章列表 */} {/* 桌面端表格视图 */}
标题 作者 分类 状态 发布时间 操作 {mockPosts.map((post) => ( {post.title} {post.authorName} {post.categories?.map((category) => ( {category.name} ))} {post.status === "published" ? ( 已发布 ) : ( 草稿 )} {post.publishedAt?.toLocaleDateString()} ))}
{/* 移动端列表视图 */}
{mockPosts.map((post) => ( 标题 {post.title} 作者 {post.authorName} 分类 {post.categories?.map((category) => ( {category.name} ))} 状态 {post.status === "published" ? ( 已发布 ) : ( 草稿 )} 发布时间 {post.publishedAt?.toLocaleDateString()} 操作 ))}
); });