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:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user