feat: refactor data asset center for enhanced search and analytics

Refactor homepage for focused search and data display; streamline data platform; enhance user and tag management; focus AI assistant on data analysis and report generation.

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
This commit is contained in:
v0
2025-07-25 06:42:34 +00:00
parent ecd8a48863
commit 4eed69520c
40 changed files with 6853 additions and 6111 deletions

View File

@@ -0,0 +1,268 @@
"use client"
import { useState } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Progress } from "@/components/ui/progress"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import {
BarChart3,
TrendingUp,
Users,
Database,
Activity,
RefreshCw,
Download,
Eye,
Zap,
Target,
AlertCircle,
} from "lucide-react"
export default function DashboardPage() {
const [timeRange, setTimeRange] = useState("today")
const dashboardStats = {
totalUsers: 125678,
activeUsers: 45678,
dataVolume: 1245678,
aiAccuracy: 96.8,
growthRate: 12.5,
qualityScore: 94.2,
}
const recentActivities = [
{
id: 1,
type: "data_sync",
message: "用户数据同步完成",
time: "2分钟前",
status: "success",
},
{
id: 2,
type: "ai_analysis",
message: "AI模型训练完成",
time: "5分钟前",
status: "success",
},
{
id: 3,
type: "quality_check",
message: "数据质量检查通过",
time: "10分钟前",
status: "warning",
},
]
return (
<div className="container mx-auto py-6 space-y-6">
{/* 页面标题 */}
<div className="flex flex-col md:flex-row md:justify-between md:items-center gap-4">
<div>
<h1 className="text-3xl font-bold tracking-tight"></h1>
<p className="text-muted-foreground"></p>
</div>
<div className="flex gap-2">
<Select value={timeRange} onValueChange={setTimeRange}>
<SelectTrigger className="w-[120px]">
<SelectValue placeholder="时间范围" />
</SelectTrigger>
<SelectContent>
<SelectItem value="today"></SelectItem>
<SelectItem value="week"></SelectItem>
<SelectItem value="month"></SelectItem>
</SelectContent>
</Select>
<Button variant="outline" size="icon">
<RefreshCw className="h-4 w-4" />
</Button>
<Button variant="outline">
<Download className="mr-2 h-4 w-4" />
</Button>
</div>
</div>
{/* 核心指标卡片 */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<Card className="bg-gradient-to-r from-blue-50 to-cyan-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium"></CardTitle>
<Users className="h-4 w-4 text-blue-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-blue-600">{dashboardStats.totalUsers.toLocaleString()}</div>
<div className="flex items-center mt-2">
<TrendingUp className="h-3 w-3 text-green-500 mr-1" />
<span className="text-xs text-green-600">+{dashboardStats.growthRate}%</span>
</div>
</CardContent>
</Card>
<Card className="bg-gradient-to-r from-green-50 to-emerald-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium"></CardTitle>
<Activity className="h-4 w-4 text-green-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-green-600">{dashboardStats.activeUsers.toLocaleString()}</div>
<div className="text-xs text-muted-foreground mt-2">
{((dashboardStats.activeUsers / dashboardStats.totalUsers) * 100).toFixed(1)}%
</div>
</CardContent>
</Card>
<Card className="bg-gradient-to-r from-purple-50 to-pink-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium"></CardTitle>
<Database className="h-4 w-4 text-purple-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-purple-600">{dashboardStats.dataVolume.toLocaleString()}</div>
<div className="text-xs text-muted-foreground mt-2"></div>
</CardContent>
</Card>
<Card className="bg-gradient-to-r from-orange-50 to-red-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium">AI准确率</CardTitle>
<Target className="h-4 w-4 text-orange-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-orange-600">{dashboardStats.aiAccuracy}%</div>
<div className="text-xs text-muted-foreground mt-2"></div>
</CardContent>
</Card>
</div>
{/* 详细分析 */}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
{/* 数据质量监控 */}
<Card className="lg:col-span-2">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<BarChart3 className="h-5 w-5 text-blue-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-4">
<div>
<div className="flex justify-between text-sm mb-2">
<span></span>
<span className="font-medium">{dashboardStats.qualityScore}%</span>
</div>
<Progress value={dashboardStats.qualityScore} className="h-2" />
</div>
<div>
<div className="flex justify-between text-sm mb-2">
<span></span>
<span className="font-medium">98.5%</span>
</div>
<Progress value={98.5} className="h-2" />
</div>
<div>
<div className="flex justify-between text-sm mb-2">
<span></span>
<span className="font-medium">96.2%</span>
</div>
<Progress value={96.2} className="h-2" />
</div>
<div>
<div className="flex justify-between text-sm mb-2">
<span></span>
<span className="font-medium">94.8%</span>
</div>
<Progress value={94.8} className="h-2" />
</div>
</div>
</CardContent>
</Card>
{/* 实时活动 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Activity className="h-5 w-5 text-green-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-3">
{recentActivities.map((activity) => (
<div key={activity.id} className="flex items-start gap-3 p-2 hover:bg-gray-50 rounded-lg">
<div
className={`p-1 rounded-full ${
activity.status === "success"
? "text-green-600"
: activity.status === "warning"
? "text-yellow-600"
: "text-red-600"
}`}
>
{activity.status === "success" ? (
<Zap className="h-4 w-4" />
) : activity.status === "warning" ? (
<AlertCircle className="h-4 w-4" />
) : (
<AlertCircle className="h-4 w-4" />
)}
</div>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium truncate">{activity.message}</p>
<p className="text-xs text-gray-500">{activity.time}</p>
</div>
</div>
))}
</div>
<Button variant="outline" className="w-full mt-4 bg-transparent">
</Button>
</CardContent>
</Card>
</div>
{/* 快速操作 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Zap className="h-5 w-5 text-yellow-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 md:grid-cols-4 gap-3">
<Button variant="outline" className="h-16 flex flex-col gap-1 bg-transparent">
<Eye className="h-5 w-5" />
<span className="text-xs"></span>
</Button>
<Button variant="outline" className="h-16 flex flex-col gap-1 bg-transparent">
<Database className="h-5 w-5" />
<span className="text-xs"></span>
</Button>
<Button variant="outline" className="h-16 flex flex-col gap-1 bg-transparent">
<Users className="h-5 w-5" />
<span className="text-xs"></span>
</Button>
<Button variant="outline" className="h-16 flex flex-col gap-1 bg-transparent">
<Target className="h-5 w-5" />
<span className="text-xs">AI分析</span>
</Button>
</div>
</CardContent>
</Card>
</div>
)
}

View File

@@ -0,0 +1,283 @@
"use client"
import { useState } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Badge } from "@/components/ui/badge"
import { Progress } from "@/components/ui/progress"
import {
Activity,
Server,
Database,
Cpu,
HardDrive,
Network,
AlertTriangle,
CheckCircle,
XCircle,
RefreshCw,
Bell,
} from "lucide-react"
export default function MonitoringPage() {
const [isRefreshing, setIsRefreshing] = useState(false)
const [lastUpdate, setLastUpdate] = useState(new Date())
const systemMetrics = {
cpu: 45.2,
memory: 67.8,
disk: 34.5,
network: 23.1,
}
const serviceStatus = [
{ name: "数据接入服务", status: "running", uptime: "99.9%", responseTime: "120ms" },
{ name: "AI分析引擎", status: "running", uptime: "99.7%", responseTime: "340ms" },
{ name: "用户画像服务", status: "warning", uptime: "98.5%", responseTime: "580ms" },
{ name: "数据存储服务", status: "running", uptime: "99.8%", responseTime: "45ms" },
{ name: "搜索引擎", status: "running", uptime: "99.6%", responseTime: "89ms" },
]
const alerts = [
{
id: 1,
level: "warning",
message: "用户画像服务响应时间超过阈值",
time: "5分钟前",
service: "用户画像服务",
},
{
id: 2,
level: "info",
message: "数据同步任务完成",
time: "10分钟前",
service: "数据接入服务",
},
{
id: 3,
level: "success",
message: "AI模型训练完成",
time: "15分钟前",
service: "AI分析引擎",
},
]
const handleRefresh = () => {
setIsRefreshing(true)
setTimeout(() => {
setIsRefreshing(false)
setLastUpdate(new Date())
}, 2000)
}
const getStatusIcon = (status: string) => {
switch (status) {
case "running":
return <CheckCircle className="h-4 w-4 text-green-500" />
case "warning":
return <AlertTriangle className="h-4 w-4 text-yellow-500" />
case "error":
return <XCircle className="h-4 w-4 text-red-500" />
default:
return <CheckCircle className="h-4 w-4 text-gray-500" />
}
}
const getStatusColor = (status: string) => {
switch (status) {
case "running":
return "bg-green-100 text-green-800"
case "warning":
return "bg-yellow-100 text-yellow-800"
case "error":
return "bg-red-100 text-red-800"
default:
return "bg-gray-100 text-gray-800"
}
}
const getAlertIcon = (level: string) => {
switch (level) {
case "warning":
return <AlertTriangle className="h-4 w-4 text-yellow-500" />
case "error":
return <XCircle className="h-4 w-4 text-red-500" />
case "success":
return <CheckCircle className="h-4 w-4 text-green-500" />
default:
return <Bell className="h-4 w-4 text-blue-500" />
}
}
return (
<div className="container mx-auto py-6 space-y-6">
{/* 页面标题 */}
<div className="flex flex-col md:flex-row md:justify-between md:items-center gap-4">
<div>
<h1 className="text-3xl font-bold tracking-tight"></h1>
<p className="text-muted-foreground"></p>
</div>
<div className="flex items-center gap-2">
<span className="text-sm text-muted-foreground">: {lastUpdate.toLocaleTimeString()}</span>
<Button variant="outline" size="icon" onClick={handleRefresh} disabled={isRefreshing}>
<RefreshCw className={`h-4 w-4 ${isRefreshing ? "animate-spin" : ""}`} />
</Button>
</div>
</div>
{/* 系统资源监控 */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<Card className="bg-gradient-to-r from-blue-50 to-cyan-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium">CPU使用率</CardTitle>
<Cpu className="h-4 w-4 text-blue-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-blue-600">{systemMetrics.cpu}%</div>
<Progress value={systemMetrics.cpu} className="mt-2 h-2" />
<div className="text-xs text-muted-foreground mt-1"></div>
</CardContent>
</Card>
<Card className="bg-gradient-to-r from-green-50 to-emerald-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium">使</CardTitle>
<HardDrive className="h-4 w-4 text-green-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-green-600">{systemMetrics.memory}%</div>
<Progress value={systemMetrics.memory} className="mt-2 h-2" />
<div className="text-xs text-muted-foreground mt-1"></div>
</CardContent>
</Card>
<Card className="bg-gradient-to-r from-purple-50 to-pink-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium">使</CardTitle>
<Database className="h-4 w-4 text-purple-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-purple-600">{systemMetrics.disk}%</div>
<Progress value={systemMetrics.disk} className="mt-2 h-2" />
<div className="text-xs text-muted-foreground mt-1"></div>
</CardContent>
</Card>
<Card className="bg-gradient-to-r from-orange-50 to-red-50 border-none shadow-md">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium"></CardTitle>
<Network className="h-4 w-4 text-orange-600" />
</div>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-orange-600">{systemMetrics.network}%</div>
<Progress value={systemMetrics.network} className="mt-2 h-2" />
<div className="text-xs text-muted-foreground mt-1"></div>
</CardContent>
</Card>
</div>
{/* 服务状态监控 */}
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Server className="h-5 w-5 text-blue-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-3">
{serviceStatus.map((service, index) => (
<div key={index} className="flex items-center justify-between p-3 border rounded-lg">
<div className="flex items-center gap-3">
{getStatusIcon(service.status)}
<div>
<p className="font-medium text-sm">{service.name}</p>
<p className="text-xs text-muted-foreground">: {service.responseTime}</p>
</div>
</div>
<div className="text-right">
<Badge className={getStatusColor(service.status)}>
{service.status === "running" ? "运行中" : service.status === "warning" ? "警告" : "错误"}
</Badge>
<p className="text-xs text-muted-foreground mt-1">: {service.uptime}</p>
</div>
</div>
))}
</div>
</CardContent>
</Card>
{/* 告警信息 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Bell className="h-5 w-5 text-yellow-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-3">
{alerts.map((alert) => (
<div key={alert.id} className="flex items-start gap-3 p-3 border rounded-lg">
{getAlertIcon(alert.level)}
<div className="flex-1 min-w-0">
<p className="text-sm font-medium">{alert.message}</p>
<div className="flex items-center gap-2 mt-1">
<span className="text-xs text-muted-foreground">{alert.service}</span>
<span className="text-xs text-muted-foreground"></span>
<span className="text-xs text-muted-foreground">{alert.time}</span>
</div>
</div>
</div>
))}
</div>
<Button variant="outline" className="w-full mt-4 bg-transparent">
</Button>
</CardContent>
</Card>
</div>
{/* 性能趋势 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Activity className="h-5 w-5 text-green-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="text-center p-4 bg-blue-50 rounded-lg">
<div className="text-2xl font-bold text-blue-600">99.8%</div>
<div className="text-sm text-muted-foreground"></div>
<div className="text-xs text-green-600 mt-1"> 0.2%</div>
</div>
<div className="text-center p-4 bg-green-50 rounded-lg">
<div className="text-2xl font-bold text-green-600">156ms</div>
<div className="text-sm text-muted-foreground"></div>
<div className="text-xs text-green-600 mt-1"> 12ms</div>
</div>
<div className="text-center p-4 bg-purple-50 rounded-lg">
<div className="text-2xl font-bold text-purple-600">1.2M</div>
<div className="text-sm text-muted-foreground"></div>
<div className="text-xs text-green-600 mt-1"> 15%</div>
</div>
</div>
</CardContent>
</Card>
</div>
)
}

View File

@@ -0,0 +1,3 @@
export default function Loading() {
return null
}

View File

@@ -0,0 +1,439 @@
"use client"
import { useState, useEffect } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { Badge } from "@/components/ui/badge"
import { Avatar } from "@/components/ui/avatar"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import {
Search,
Filter,
SortAsc,
User,
Tag,
Database,
BrainCircuit,
Phone,
Mail,
MapPin,
Calendar,
TrendingUp,
Eye,
RefreshCw,
} from "lucide-react"
export default function SearchPage() {
const [searchQuery, setSearchQuery] = useState("")
const [searchType, setSearchType] = useState("all")
const [sortBy, setSortBy] = useState("relevance")
const [isSearching, setIsSearching] = useState(false)
const [searchResults, setSearchResults] = useState<any[]>([])
// 模拟搜索数据
const mockSearchData = [
{
id: "user_001",
type: "user",
name: "张明华",
phone: "13800138000",
email: "zhangsan@example.com",
company: "科技创新有限公司",
tags: ["高价值", "技术决策者", "活跃用户", "iOS用户"],
aiInsights: ["科技爱好者", "决策影响者", "高消费潜力"],
lastActive: "2小时前",
location: "北京市",
avatar: "/placeholder.svg?height=40&width=40",
rfmScore: 95,
sources: ["抖音", "微信", "表单提交"],
joinDate: "2023-06-15",
relevanceScore: 98,
},
{
id: "user_002",
type: "user",
name: "李雨婷",
phone: "13900139001",
email: "lisi@example.com",
company: "数字营销公司",
tags: ["中高价值", "产品经理", "内容创作者"],
aiInsights: ["创意思维", "社交活跃", "品牌敏感"],
lastActive: "1天前",
location: "上海市",
avatar: "/placeholder.svg?height=40&width=40",
rfmScore: 78,
sources: ["小红书", "微信", "客服咨询"],
joinDate: "2023-08-22",
relevanceScore: 85,
},
{
id: "tag_001",
type: "tag",
name: "高价值用户",
description: "RFM评分超过80分的用户",
userCount: 12456,
category: "价值分类",
createdDate: "2023-05-10",
relevanceScore: 92,
},
{
id: "insight_001",
type: "insight",
title: "用户行为模式分析",
description: "基于AI分析的用户行为偏好洞察",
confidence: 94.5,
affectedUsers: 8765,
createdDate: "2023-12-01",
relevanceScore: 88,
},
]
// 搜索处理
const handleSearch = async (query: string) => {
if (!query.trim()) {
setSearchResults([])
return
}
setIsSearching(true)
// 模拟搜索延迟
setTimeout(() => {
const filtered = mockSearchData.filter((item) => {
const searchText = query.toLowerCase()
if (searchType !== "all" && item.type !== searchType) {
return false
}
// 根据不同类型进行搜索
switch (item.type) {
case "user":
return (
item.name.toLowerCase().includes(searchText) ||
item.phone.includes(searchText) ||
item.email.toLowerCase().includes(searchText) ||
item.company.toLowerCase().includes(searchText) ||
item.tags.some((tag: string) => tag.toLowerCase().includes(searchText)) ||
item.aiInsights.some((insight: string) => insight.toLowerCase().includes(searchText)) ||
item.location.toLowerCase().includes(searchText)
)
case "tag":
return (
item.name.toLowerCase().includes(searchText) ||
item.description.toLowerCase().includes(searchText) ||
item.category.toLowerCase().includes(searchText)
)
case "insight":
return item.title.toLowerCase().includes(searchText) || item.description.toLowerCase().includes(searchText)
default:
return false
}
})
// 排序
if (sortBy === "relevance") {
filtered.sort((a, b) => b.relevanceScore - a.relevanceScore)
} else if (sortBy === "date") {
filtered.sort(
(a, b) => new Date(b.createdDate || b.joinDate).getTime() - new Date(a.createdDate || a.joinDate).getTime(),
)
} else if (sortBy === "name") {
filtered.sort((a, b) => (a.name || a.title).localeCompare(b.name || b.title))
}
setSearchResults(filtered)
setIsSearching(false)
}, 800)
}
// 搜索输入处理
useEffect(() => {
const timeoutId = setTimeout(() => {
if (searchQuery) {
handleSearch(searchQuery)
}
}, 500)
return () => clearTimeout(timeoutId)
}, [searchQuery, searchType, sortBy])
const getTypeIcon = (type: string) => {
switch (type) {
case "user":
return <User className="h-4 w-4 text-blue-500" />
case "tag":
return <Tag className="h-4 w-4 text-green-500" />
case "insight":
return <BrainCircuit className="h-4 w-4 text-purple-500" />
default:
return <Database className="h-4 w-4 text-gray-500" />
}
}
const getTypeBadgeColor = (type: string) => {
switch (type) {
case "user":
return "bg-blue-100 text-blue-700"
case "tag":
return "bg-green-100 text-green-700"
case "insight":
return "bg-purple-100 text-purple-700"
default:
return "bg-gray-100 text-gray-700"
}
}
return (
<div className="container mx-auto py-6 space-y-6">
{/* 页面标题 */}
<div className="flex flex-col md:flex-row md:justify-between md:items-center gap-4">
<div>
<h1 className="text-3xl font-bold tracking-tight"></h1>
<p className="text-muted-foreground">AI驱动的全局智能搜索引擎</p>
</div>
</div>
{/* 搜索栏 */}
<Card className="bg-gradient-to-r from-purple-50 to-blue-50 border-none shadow-lg">
<CardContent className="p-6">
<div className="space-y-4">
{/* 主搜索框 */}
<div className="relative">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-muted-foreground" />
<Input
type="text"
placeholder="搜索用户、标签、洞察或任何相关信息..."
className="pl-10 h-12 text-base border-2 border-purple-200 focus:border-purple-400"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
{isSearching && (
<div className="absolute right-3 top-1/2 transform -translate-y-1/2">
<RefreshCw className="h-5 w-5 animate-spin text-purple-500" />
</div>
)}
</div>
{/* 搜索选项 */}
<div className="flex flex-wrap gap-4">
<div className="flex items-center gap-2">
<Filter className="h-4 w-4 text-muted-foreground" />
<Select value={searchType} onValueChange={setSearchType}>
<SelectTrigger className="w-[120px]">
<SelectValue placeholder="类型" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all"></SelectItem>
<SelectItem value="user"></SelectItem>
<SelectItem value="tag"></SelectItem>
<SelectItem value="insight"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="flex items-center gap-2">
<SortAsc className="h-4 w-4 text-muted-foreground" />
<Select value={sortBy} onValueChange={setSortBy}>
<SelectTrigger className="w-[120px]">
<SelectValue placeholder="排序" />
</SelectTrigger>
<SelectContent>
<SelectItem value="relevance"></SelectItem>
<SelectItem value="date"></SelectItem>
<SelectItem value="name"></SelectItem>
</SelectContent>
</Select>
</div>
</div>
</div>
</CardContent>
</Card>
{/* 搜索结果 */}
{searchQuery && (
<Card>
<CardHeader>
<CardTitle className="flex items-center justify-between">
<span></span>
<Badge variant="outline">{searchResults.length} </Badge>
</CardTitle>
<CardDescription>
: "{searchQuery}"{searchType !== "all" && ` · 类型: ${searchType}`}
</CardDescription>
</CardHeader>
<CardContent>
{searchResults.length > 0 ? (
<div className="space-y-4">
{searchResults.map((result) => (
<div
key={result.id}
className="flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
>
{/* 类型图标 */}
<div className="flex-shrink-0 mt-1">
{result.type === "user" ? (
<Avatar className="h-10 w-10">
<img src={result.avatar || "/placeholder.svg"} alt={result.name} />
</Avatar>
) : (
<div className="w-10 h-10 rounded-full bg-gray-100 flex items-center justify-center">
{getTypeIcon(result.type)}
</div>
)}
</div>
{/* 内容 */}
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-2">
<h3 className="font-semibold text-lg truncate">{result.name || result.title}</h3>
<Badge className={getTypeBadgeColor(result.type)}>
{result.type === "user" ? "用户" : result.type === "tag" ? "标签" : "洞察"}
</Badge>
{result.relevanceScore && (
<Badge variant="outline" className="text-xs">
: {result.relevanceScore}%
</Badge>
)}
</div>
{/* 用户信息 */}
{result.type === "user" && (
<div className="space-y-2">
<div className="flex items-center gap-4 text-sm text-muted-foreground">
<span className="flex items-center gap-1">
<Phone className="h-3 w-3" />
{result.phone}
</span>
<span className="flex items-center gap-1">
<Mail className="h-3 w-3" />
{result.email}
</span>
<span className="flex items-center gap-1">
<MapPin className="h-3 w-3" />
{result.location}
</span>
</div>
<div className="flex items-center gap-2">
<span className="text-sm text-muted-foreground">:</span>
<span className="text-sm">{result.company}</span>
<Badge className="bg-orange-100 text-orange-700 text-xs">RFM: {result.rfmScore}</Badge>
</div>
<div className="flex flex-wrap gap-1">
{result.aiInsights.slice(0, 3).map((insight: string, index: number) => (
<Badge key={index} className="text-xs bg-purple-100 text-purple-700">
{insight}
</Badge>
))}
</div>
</div>
)}
{/* 标签信息 */}
{result.type === "tag" && (
<div className="space-y-2">
<p className="text-sm text-muted-foreground">{result.description}</p>
<div className="flex items-center gap-4 text-sm">
<span className="flex items-center gap-1">
<User className="h-3 w-3" />
{result.userCount.toLocaleString()}
</span>
<span className="flex items-center gap-1">
<Tag className="h-3 w-3" />
{result.category}
</span>
<span className="flex items-center gap-1">
<Calendar className="h-3 w-3" />
{result.createdDate}
</span>
</div>
</div>
)}
{/* 洞察信息 */}
{result.type === "insight" && (
<div className="space-y-2">
<p className="text-sm text-muted-foreground">{result.description}</p>
<div className="flex items-center gap-4 text-sm">
<span className="flex items-center gap-1">
<TrendingUp className="h-3 w-3" />
: {result.confidence}%
</span>
<span className="flex items-center gap-1">
<User className="h-3 w-3" />
: {result.affectedUsers.toLocaleString()}
</span>
<span className="flex items-center gap-1">
<Calendar className="h-3 w-3" />
{result.createdDate}
</span>
</div>
</div>
)}
</div>
{/* 操作按钮 */}
<div className="flex-shrink-0">
<Button variant="outline" size="sm">
<Eye className="h-4 w-4 mr-1" />
</Button>
</div>
</div>
))}
</div>
) : (
<div className="text-center py-12">
<Search className="h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50" />
<h3 className="text-lg font-medium mb-2"></h3>
<p className="text-muted-foreground">使</p>
</div>
)}
</CardContent>
</Card>
)}
{/* 搜索建议 */}
{!searchQuery && (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<BrainCircuit className="h-5 w-5 text-purple-600" />
</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h4 className="font-medium mb-3"></h4>
<div className="flex flex-wrap gap-2">
{["高价值用户", "技术决策者", "活跃用户", "流失风险", "新用户"].map((term) => (
<Button
key={term}
variant="outline"
size="sm"
onClick={() => setSearchQuery(term)}
className="text-xs"
>
{term}
</Button>
))}
</div>
</div>
<div>
<h4 className="font-medium mb-3"></h4>
<div className="space-y-2">
<div className="text-sm text-muted-foreground"> 搜索特定用户: 输入姓名</div>
<div className="text-sm text-muted-foreground"> 查找标签: 输入标签名称或描述</div>
<div className="text-sm text-muted-foreground"> 发现洞察: 输入行为模式或分析结果</div>
</div>
</div>
</div>
</CardContent>
</Card>
)}
</div>
)
}