import { useState } from 'react' import { Button } from '@/components/ui/button' import { Checkbox } from '@/components/ui/checkbox' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Download } from 'lucide-react' import type { PluginInfo } from './types' interface InstallDialogProps { open: boolean plugin: PluginInfo | null onOpenChange: (open: boolean) => void onInstall: (branch: string) => void } export function InstallDialog({ open, plugin, onOpenChange, onInstall }: InstallDialogProps) { const [selectedBranch, setSelectedBranch] = useState('main') const [customBranch, setCustomBranch] = useState('') const [branchInputMode, setBranchInputMode] = useState<'preset' | 'custom'>('preset') const [showAdvancedOptions, setShowAdvancedOptions] = useState(false) const handleInstall = () => { const branch = branchInputMode === 'custom' ? customBranch : selectedBranch if (!branch || branch.trim() === '') { return } onInstall(branch) onOpenChange(false) } return ( 安装插件 安装 {plugin?.manifest.name}
{/* 基本信息 */}

版本: {plugin?.manifest.version}

作者: {typeof plugin?.manifest.author === 'string' ? plugin.manifest.author : plugin?.manifest.author?.name}

{/* 高级选项开关 */}
setShowAdvancedOptions(checked as boolean)} />
{/* 高级选项内容 */} {showAdvancedOptions && (
setBranchInputMode(value as 'preset' | 'custom')}> 预设分支 自定义分支 {/* 预设分支选择 */} {branchInputMode === 'preset' && (
)} {/* 自定义分支输入 */} {branchInputMode === 'custom' && (
setCustomBranch(e.target.value)} />

输入 Git 分支名称、标签或提交哈希

)}
)} {!showAdvancedOptions && (

将从默认分支 (main) 安装插件

)}
) }