feat: optimize interface and database connection

Adjust MongoDB mock connector and update database structure.
Enhance sidebar, data platform, and AI analysis tools.
Clean up unnecessary code and update development docs.

#VERCEL_SKIP

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
This commit is contained in:
v0
2025-07-21 00:11:52 +00:00
parent 892c5b4855
commit ecd8a48863
26 changed files with 1821 additions and 1024 deletions

View File

@@ -26,9 +26,19 @@ import {
Copy,
Check,
Zap,
Plus,
Download,
} from "lucide-react"
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogFooter,
} from "@/components/ui/dialog"
import { useToast } from "@/components/ui/use-toast"
import { Textarea } from "@/components/ui/textarea"
interface AIAnalysisTask {
id: string
@@ -297,8 +307,8 @@ export function AIAnalysisTools() {
description: "为特定用户分群生成营销策略",
type: "strategy-generation",
parameters: {
targetSegment: "所有用户",
campaignGoal: "提高转化率",
targetSegment: "流失风险用户",
campaignGoal: "提高留存率",
budgetConstraint: "中等",
channelPreference: ["短信", "应用内推送", "邮件"],
},
@@ -664,9 +674,7 @@ export function AIAnalysisTools() {
<Plus className="h-6 w-6 text-muted-foreground" />
</div>
<h3 className="text-lg font-medium mb-2"></h3>
<p className="text-sm text-muted-foreground text-center mb-4">
</p>
<p className="text-sm text-muted-foreground text-center mb-4"></p>
<Button variant="outline"></Button>
</CardContent>
</Card>
@@ -719,9 +727,7 @@ export function AIAnalysisTools() {
<SelectItem value="10">10</SelectItem>
</SelectContent>
</Select>
<p className="text-sm text-muted-foreground">
AI分析任务数量
</p>
<p className="text-sm text-muted-foreground">AI分析任务数量</p>
</div>
<Separator />
@@ -920,4 +926,231 @@ export function AIAnalysisTools() {
</TableHeader>
<TableBody>
{selectedTask.result.clusters.map((cluster: any, index: number) => (
<TableRow key={
<TableRow key={index}>
<TableCell className="font-medium">{cluster.name}</TableCell>
<TableCell>{cluster.size.toLocaleString()}</TableCell>
<TableCell>
<div className="flex flex-wrap gap-1">
{cluster.characteristics.map((char: string, charIndex: number) => (
<Badge key={charIndex} variant="outline">
{char}
</Badge>
))}
</div>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</div>
)}
{selectedTask.result.tagCategories && (
<div className="space-y-2">
<h4 className="text-sm font-medium"></h4>
<div className="rounded-md border">
<Table>
<TableHeader>
<TableRow>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{selectedTask.result.tagCategories.map((category: any, index: number) => (
<TableRow key={index}>
<TableCell className="font-medium">{category.name}</TableCell>
<TableCell>{category.count}</TableCell>
<TableCell>{category.coverage}</TableCell>
<TableCell>
<div className="flex flex-wrap gap-1">
{category.examples.map((example: string, exampleIndex: number) => (
<Badge key={exampleIndex} variant="outline">
{example}
</Badge>
))}
</div>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</div>
)}
</div>
)}
</div>
)}
<DialogFooter>
<Button variant="outline" onClick={() => setSelectedTaskId(null)}>
</Button>
{selectedTask?.status === "completed" && (
<Button>
<Download className="mr-2 h-4 w-4" />
</Button>
)}
</DialogFooter>
</DialogContent>
</Dialog>
{/* 添加模型对话框 */}
<Dialog open={isAddingModel} onOpenChange={setIsAddingModel}>
<DialogContent className="sm:max-w-[500px]">
<DialogHeader>
<DialogTitle>AI模型</DialogTitle>
<DialogDescription>AI模型连接</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="model-name" className="text-right">
</Label>
<Input id="model-name" className="col-span-3" placeholder="例如GPT-4" />
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="model-provider" className="text-right">
</Label>
<Input id="model-provider" className="col-span-3" placeholder="例如OpenAI" />
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="model-type" className="text-right">
</Label>
<Select>
<SelectTrigger id="model-type" className="col-span-3">
<SelectValue placeholder="选择模型类型" />
</SelectTrigger>
<SelectContent>
<SelectItem value="llm"></SelectItem>
<SelectItem value="image-gen"></SelectItem>
<SelectItem value="custom"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="api-endpoint" className="text-right">
API端点
</Label>
<Input id="api-endpoint" className="col-span-3" placeholder="例如https://api.openai.com/v1/chat" />
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="api-key" className="text-right">
API密钥
</Label>
<Input id="api-key" type="password" className="col-span-3" placeholder="输入API密钥" />
</div>
<div className="grid grid-cols-4 items-start gap-4">
<Label htmlFor="capabilities" className="text-right pt-2">
</Label>
<Textarea id="capabilities" className="col-span-3" placeholder="例如:文本生成, 内容分析" rows={3} />
</div>
<div className="grid grid-cols-4 items-center gap-4">
<div className="text-right">
<Label htmlFor="model-status"></Label>
</div>
<div className="flex items-center space-x-2 col-span-3">
<Switch id="model-status" defaultChecked />
<Label htmlFor="model-status"></Label>
</div>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setIsAddingModel(false)}>
</Button>
<Button onClick={() => setIsAddingModel(false)}></Button>
</DialogFooter>
</DialogContent>
</Dialog>
{/* 创建分析任务对话框 */}
<Dialog open={isCreatingTask} onOpenChange={setIsCreatingTask}>
<DialogContent className="sm:max-w-[600px]">
<DialogHeader>
<DialogTitle></DialogTitle>
<DialogDescription></DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="task-name" className="text-right">
</Label>
<Input id="task-name" className="col-span-3" placeholder="例如:高价值用户流失预测" />
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="task-type" className="text-right">
</Label>
<Select>
<SelectTrigger id="task-type" className="col-span-3">
<SelectValue placeholder="选择分析类型" />
</SelectTrigger>
<SelectContent>
<SelectItem value="behavior-analysis"></SelectItem>
<SelectItem value="segment-discovery"></SelectItem>
<SelectItem value="churn-prediction"></SelectItem>
<SelectItem value="strategy-generation"></SelectItem>
<SelectItem value="tag-generation"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="task-datasource" className="text-right">
</Label>
<Select>
<SelectTrigger id="task-datasource" className="col-span-3">
<SelectValue placeholder="选择数据源" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all"></SelectItem>
<SelectItem value="user-db"></SelectItem>
<SelectItem value="transaction"></SelectItem>
<SelectItem value="behavior"></SelectItem>
<SelectItem value="user-value"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid grid-cols-4 items-start gap-4">
<Label htmlFor="task-parameters" className="text-right pt-2">
</Label>
<Textarea
id="task-parameters"
className="col-span-3"
placeholder="输入JSON格式的分析参数例如{ 'userSegment': '高价值用户', 'timeRange': '近30天' }"
rows={5}
/>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<div className="text-right">
<Label htmlFor="schedule-task"></Label>
</div>
<div className="flex items-center space-x-2 col-span-3">
<Switch id="schedule-task" />
<Label htmlFor="schedule-task"></Label>
</div>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setIsCreatingTask(false)}>
</Button>
<Button onClick={() => setIsCreatingTask(false)}>
<Play className="mr-2 h-4 w-4" />
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
)
}