import { Template } from "interface/template"; import { Container, Heading, Text, Box, Flex, Card, Button, TextField, DropdownMenu, ScrollArea, Dialog, Tabs, Switch, IconButton } from "@radix-ui/themes"; import { PlusIcon, MagnifyingGlassIcon, DownloadIcon, GearIcon, CodeIcon, Cross2Icon, CheckIcon, UpdateIcon, TrashIcon, ExclamationTriangleIcon } from "@radix-ui/react-icons"; import { useState } from "react"; import type { PluginConfig } from "interface/plugin"; // 模拟插件数据 const mockPlugins: (PluginConfig & { id: number; preview?: string; installed?: boolean })[] = [ { id: 1, name: "comment-system", displayName: "评论系统", version: "1.0.0", description: "支持多种评论系统集成,包括Disqus、Gitalk等", author: "Admin", enabled: true, icon: "https://api.iconify.design/material-symbols:comment.svg", preview: "https://images.unsplash.com/photo-1516116216624-53e697fedbea?w=500&auto=format", managePath: "/dashboard/plugins/comment-system", installed: true, configuration: { system: { title: "评论系统配置", description: "配置评论系统参数", data: { provider: "gitalk", clientId: "", clientSecret: "" } } }, routes: new Set() }, { id: 2, name: "image-optimization", displayName: "图片优化", version: "1.0.0", description: "自动优化上传的图片,支持压缩、裁剪、水印等功能", author: "ThirdParty", enabled: false, icon: "https://api.iconify.design/material-symbols:image.svg", preview: "https://images.unsplash.com/photo-1618005198919-d3d4b5a92ead?w=500&auto=format", installed: true, configuration: { system: { title: "图片优化配置", description: "配置图片优化参数", data: { quality: 80, maxWidth: 1920, watermark: false } } }, routes: new Set() } ]; // 模拟市场插件数据 interface MarketPlugin { id: number; name: string; displayName: string; version: string; description: string; author: string; preview?: string; downloads: number; rating: number; } const marketPlugins: MarketPlugin[] = [ { id: 4, name: "image-optimization", displayName: "图片优化", version: "1.0.0", description: "自动优化上传的图片,支持压缩、裁剪、水印等功能", author: "ThirdParty", preview: "https://images.unsplash.com/photo-1516116216624-53e697fedbea?w=500&auto=format", downloads: 1200, rating: 4.5 }, { id: 5, name: "markdown-plus", displayName: "Markdown增强", version: "2.0.0", description: "增强的Markdown编辑器,支持更多扩展语法和实时预览", author: "ThirdParty", preview: "https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=500&auto=format", downloads: 3500, rating: 4.8 } ]; export default new Template({}, ({ http, args }) => { const [searchTerm, setSearchTerm] = useState(""); const [isAddDialogOpen, setIsAddDialogOpen] = useState(false); const [isSettingsOpen, setIsSettingsOpen] = useState(false); const [selectedPlugin, setSelectedPlugin] = useState(null); // 处理插件启用/禁用 const handleTogglePlugin = (pluginId: number) => { // 这里添加启用/禁用插件的逻辑 console.log('Toggle plugin:', pluginId); }; return ( {/* 页面标题和操作栏 */} 插件管理 共 {mockPlugins.length} 个插件 {/* 搜索栏 */} ) => setSearchTerm(e.target.value)} > {/* 插件列表 */} {mockPlugins.map((plugin) => ( {/* 插件预览图 */} {plugin.preview && ( {plugin.displayName} )} {/* 插件信息 */} {plugin.displayName} handleTogglePlugin(plugin.id)} /> 版本 {plugin.version} · 作者 {plugin.author} {plugin.description} {/* 操作按钮 */} {plugin.managePath && plugin.enabled && ( )} ))} {/* 安装插件对话框 */} 安装插件 上传插件包进行安装 { console.log(e.target.files); }} /> ); });