Fix CSS issue and create missing documentation files Add new data platform and mobile optimization features Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
408 lines
17 KiB
TypeScript
408 lines
17 KiB
TypeScript
"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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
|
|
import {
|
|
Database,
|
|
Target,
|
|
Brain,
|
|
Search,
|
|
BarChart3,
|
|
RefreshCw,
|
|
Download,
|
|
ChevronRight,
|
|
Activity,
|
|
Zap,
|
|
} from "lucide-react"
|
|
import Link from "next/link"
|
|
|
|
export default function HomePage() {
|
|
const [timeRange, setTimeRange] = useState("today")
|
|
|
|
// 今日数据概览
|
|
const todayStats = {
|
|
dataSync: {
|
|
total: 1245678,
|
|
growth: "+12.5%",
|
|
sources: 8,
|
|
lastUpdate: "2分钟前",
|
|
},
|
|
userDiscovery: {
|
|
activeUsers: 45678,
|
|
newUsers: 1234,
|
|
engagement: "87.5%",
|
|
growth: "+8.2%",
|
|
},
|
|
userValuation: {
|
|
avgValue: 3248,
|
|
highValue: 12456,
|
|
growth: "+15.8%",
|
|
upgradeRate: "12.5%",
|
|
},
|
|
aiAnalysis: {
|
|
insights: 156,
|
|
anomalies: 3,
|
|
predictions: 89,
|
|
accuracy: "94.2%",
|
|
},
|
|
}
|
|
|
|
// 实时活动数据
|
|
const realtimeActivities = [
|
|
{
|
|
id: 1,
|
|
type: "data_sync",
|
|
message: "电商平台数据同步完成",
|
|
time: "刚刚",
|
|
status: "success",
|
|
},
|
|
{
|
|
id: 2,
|
|
type: "user_discovery",
|
|
message: "发现新用户行为模式",
|
|
time: "2分钟前",
|
|
status: "info",
|
|
},
|
|
{
|
|
id: 3,
|
|
type: "ai_analysis",
|
|
message: "AI检测到异常流量",
|
|
time: "5分钟前",
|
|
status: "warning",
|
|
},
|
|
{
|
|
id: 4,
|
|
type: "user_valuation",
|
|
message: "用户价值模型更新完成",
|
|
time: "8分钟前",
|
|
status: "success",
|
|
},
|
|
]
|
|
|
|
const getActivityIcon = (type: string) => {
|
|
switch (type) {
|
|
case "data_sync":
|
|
return <Database className="h-4 w-4" />
|
|
case "user_discovery":
|
|
return <Search className="h-4 w-4" />
|
|
case "user_valuation":
|
|
return <Target className="h-4 w-4" />
|
|
case "ai_analysis":
|
|
return <Brain className="h-4 w-4" />
|
|
default:
|
|
return <Activity className="h-4 w-4" />
|
|
}
|
|
}
|
|
|
|
const getStatusColor = (status: string) => {
|
|
switch (status) {
|
|
case "success":
|
|
return "text-green-600"
|
|
case "warning":
|
|
return "text-yellow-600"
|
|
case "info":
|
|
return "text-blue-600"
|
|
default:
|
|
return "text-gray-600"
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="container mx-auto py-4 md:py-6 space-y-4 md:space-y-6">
|
|
{/* 页面标题和工具栏 */}
|
|
<div className="flex flex-col md:flex-row md:justify-between md:items-center gap-4">
|
|
<div>
|
|
<h1 className="text-2xl md:text-3xl font-bold tracking-tight">数据概览</h1>
|
|
<p className="text-sm md:text-base text-muted-foreground">智能数据分析平台总览</p>
|
|
</div>
|
|
<div className="flex gap-2">
|
|
<Select value={timeRange} onValueChange={setTimeRange}>
|
|
<SelectTrigger className="w-[120px] text-sm">
|
|
<SelectValue placeholder="时间范围" />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="today">今日</SelectItem>
|
|
<SelectItem value="week">本周</SelectItem>
|
|
<SelectItem value="month">本月</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
<Button variant="outline" size="icon" className="h-9 w-9 bg-transparent">
|
|
<RefreshCw className="h-4 w-4" />
|
|
</Button>
|
|
<Button variant="outline" size="sm" className="hidden md:flex bg-transparent">
|
|
<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-4">
|
|
{/* 数据中台 */}
|
|
<Link href="/data-platform">
|
|
<Card className="border-none shadow-md hover:shadow-lg transition-all duration-300 cursor-pointer group">
|
|
<CardHeader className="bg-gradient-to-r from-blue-50 to-indigo-50 pb-3">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-2">
|
|
<Database className="h-5 w-5 text-blue-600" />
|
|
<CardTitle className="text-base">数据中台</CardTitle>
|
|
</div>
|
|
<Badge className="bg-blue-100 text-blue-700">核心</Badge>
|
|
</div>
|
|
<CardDescription className="text-xs">多源数据整合中心</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="pt-3">
|
|
<div className="space-y-2">
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">数据总量</span>
|
|
<span className="font-bold">{todayStats.dataSync.total.toLocaleString()}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">数据源</span>
|
|
<span className="font-bold">{todayStats.dataSync.sources}个</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">增长率</span>
|
|
<span className="text-green-600 font-bold">{todayStats.dataSync.growth}</span>
|
|
</div>
|
|
<div className="flex items-center justify-between mt-3">
|
|
<span className="text-xs text-gray-500">最后更新: {todayStats.dataSync.lastUpdate}</span>
|
|
<ChevronRight className="h-4 w-4 text-gray-400 group-hover:text-blue-600 transition-colors" />
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</Link>
|
|
|
|
{/* 用户发现 */}
|
|
<Link href="/user-discovery">
|
|
<Card className="border-none shadow-md hover:shadow-lg transition-all duration-300 cursor-pointer group">
|
|
<CardHeader className="bg-gradient-to-r from-green-50 to-emerald-50 pb-3">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-2">
|
|
<Search className="h-5 w-5 text-green-600" />
|
|
<CardTitle className="text-base">用户发现</CardTitle>
|
|
</div>
|
|
</div>
|
|
<CardDescription className="text-xs">用户行为洞察分析</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="pt-3">
|
|
<div className="space-y-2">
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">活跃用户</span>
|
|
<span className="font-bold">{todayStats.userDiscovery.activeUsers.toLocaleString()}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">新增用户</span>
|
|
<span className="font-bold">{todayStats.userDiscovery.newUsers.toLocaleString()}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">参与度</span>
|
|
<span className="text-green-600 font-bold">{todayStats.userDiscovery.engagement}</span>
|
|
</div>
|
|
<div className="flex items-center justify-between mt-3">
|
|
<span className="text-xs text-green-600">增长 {todayStats.userDiscovery.growth}</span>
|
|
<ChevronRight className="h-4 w-4 text-gray-400 group-hover:text-green-600 transition-colors" />
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</Link>
|
|
|
|
{/* 用户估值 */}
|
|
<Link href="/user-valuation">
|
|
<Card className="border-none shadow-md hover:shadow-lg transition-all duration-300 cursor-pointer group">
|
|
<CardHeader className="bg-gradient-to-r from-purple-50 to-pink-50 pb-3">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-2">
|
|
<Target className="h-5 w-5 text-purple-600" />
|
|
<CardTitle className="text-base">用户估值</CardTitle>
|
|
</div>
|
|
</div>
|
|
<CardDescription className="text-xs">用户价值评估模型</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="pt-3">
|
|
<div className="space-y-2">
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">平均估值</span>
|
|
<span className="font-bold">¥{todayStats.userValuation.avgValue.toLocaleString()}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">高价值用户</span>
|
|
<span className="font-bold">{todayStats.userValuation.highValue.toLocaleString()}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">升级率</span>
|
|
<span className="text-purple-600 font-bold">{todayStats.userValuation.upgradeRate}</span>
|
|
</div>
|
|
<div className="flex items-center justify-between mt-3">
|
|
<span className="text-xs text-purple-600">增长 {todayStats.userValuation.growth}</span>
|
|
<ChevronRight className="h-4 w-4 text-gray-400 group-hover:text-purple-600 transition-colors" />
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</Link>
|
|
|
|
{/* AI分析 */}
|
|
<Link href="/ai-analysis">
|
|
<Card className="border-none shadow-md hover:shadow-lg transition-all duration-300 cursor-pointer group">
|
|
<CardHeader className="bg-gradient-to-r from-orange-50 to-red-50 pb-3">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-2">
|
|
<Brain className="h-5 w-5 text-orange-600" />
|
|
<CardTitle className="text-base">AI分析</CardTitle>
|
|
</div>
|
|
<Badge className="bg-orange-100 text-orange-700">AI</Badge>
|
|
</div>
|
|
<CardDescription className="text-xs">智能数据洞察</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="pt-3">
|
|
<div className="space-y-2">
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">AI洞察</span>
|
|
<span className="font-bold">{todayStats.aiAnalysis.insights}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">异常检测</span>
|
|
<span className="font-bold">{todayStats.aiAnalysis.anomalies}</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span className="text-sm text-gray-600">预测准确率</span>
|
|
<span className="text-orange-600 font-bold">{todayStats.aiAnalysis.accuracy}</span>
|
|
</div>
|
|
<div className="flex items-center justify-between mt-3">
|
|
<span className="text-xs text-orange-600">预测 {todayStats.aiAnalysis.predictions}个</span>
|
|
<ChevronRight className="h-4 w-4 text-gray-400 group-hover:text-orange-600 transition-colors" />
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</Link>
|
|
</div>
|
|
|
|
{/* 实时数据流 */}
|
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4 md:gap-6">
|
|
{/* 今日关键指标 */}
|
|
<Card className="lg:col-span-2 border-none shadow-md">
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<BarChart3 className="h-5 w-5 text-blue-600" />
|
|
今日关键指标
|
|
</CardTitle>
|
|
<CardDescription>实时数据监控</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
<div className="text-center p-3 bg-blue-50 rounded-lg">
|
|
<div className="text-2xl font-bold text-blue-600">98.5%</div>
|
|
<div className="text-xs text-gray-600">系统可用性</div>
|
|
</div>
|
|
<div className="text-center p-3 bg-green-50 rounded-lg">
|
|
<div className="text-2xl font-bold text-green-600">2.3s</div>
|
|
<div className="text-xs text-gray-600">平均响应时间</div>
|
|
</div>
|
|
<div className="text-center p-3 bg-purple-50 rounded-lg">
|
|
<div className="text-2xl font-bold text-purple-600">156</div>
|
|
<div className="text-xs text-gray-600">AI洞察数</div>
|
|
</div>
|
|
<div className="text-center p-3 bg-orange-50 rounded-lg">
|
|
<div className="text-2xl font-bold text-orange-600">94.2%</div>
|
|
<div className="text-xs text-gray-600">预测准确率</div>
|
|
</div>
|
|
</div>
|
|
<div className="mt-4 space-y-3">
|
|
<div>
|
|
<div className="flex justify-between text-sm mb-1">
|
|
<span>数据处理进度</span>
|
|
<span>87%</span>
|
|
</div>
|
|
<Progress value={87} className="h-2" />
|
|
</div>
|
|
<div>
|
|
<div className="flex justify-between text-sm mb-1">
|
|
<span>AI模型训练</span>
|
|
<span>92%</span>
|
|
</div>
|
|
<Progress value={92} className="h-2" />
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
{/* 实时活动 */}
|
|
<Card className="border-none shadow-md">
|
|
<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">
|
|
{realtimeActivities.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 ${getStatusColor(activity.status)}`}>
|
|
{getActivityIcon(activity.type)}
|
|
</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 text-sm bg-transparent">
|
|
查看全部活动
|
|
</Button>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
|
|
{/* 快速操作 */}
|
|
<Card className="border-none shadow-md">
|
|
<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">
|
|
<Link href="/data-platform">
|
|
<Button variant="outline" className="w-full h-16 flex flex-col gap-1 bg-transparent">
|
|
<Database className="h-5 w-5" />
|
|
<span className="text-xs">数据导入</span>
|
|
</Button>
|
|
</Link>
|
|
<Link href="/user-discovery/behavior">
|
|
<Button variant="outline" className="w-full h-16 flex flex-col gap-1 bg-transparent">
|
|
<Search className="h-5 w-5" />
|
|
<span className="text-xs">行为分析</span>
|
|
</Button>
|
|
</Link>
|
|
<Link href="/user-valuation/model">
|
|
<Button variant="outline" className="w-full h-16 flex flex-col gap-1 bg-transparent">
|
|
<Target className="h-5 w-5" />
|
|
<span className="text-xs">价值评估</span>
|
|
</Button>
|
|
</Link>
|
|
<Link href="/ai-analysis/trends">
|
|
<Button variant="outline" className="w-full h-16 flex flex-col gap-1 bg-transparent">
|
|
<Brain className="h-5 w-5" />
|
|
<span className="text-xs">AI预测</span>
|
|
</Button>
|
|
</Link>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
)
|
|
}
|