diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 2fdd36b..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/app/.DS_Store b/app/.DS_Store deleted file mode 100644 index bef46af..0000000 Binary files a/app/.DS_Store and /dev/null differ diff --git a/app/ClientLayout.tsx b/app/ClientLayout.tsx index 4e70405..2d8bcc9 100644 --- a/app/ClientLayout.tsx +++ b/app/ClientLayout.tsx @@ -1,15 +1,14 @@ "use client" import type React from "react" -import "./globals.css" + +import { MainNav } from "@/components/main-nav" +import { UserNav } from "@/components/user-nav" +import { ThemeToggle } from "@/components/theme-toggle" +import { Search } from "lucide-react" +import { Input } from "@/components/ui/input" import { Inter } from "next/font/google" -import { useState, useEffect } from "react" -import { usePathname } from "next/navigation" -import Sidebar from "./components/Sidebar" -import MobileHeader from "./components/MobileHeader" -import MobileSidebar from "./components/MobileSidebar" -import BottomNav from "./components/BottomNav" -import { Toaster } from "@/components/ui/toaster" +import "./globals.css" const inter = Inter({ subsets: ["latin"] }) @@ -18,74 +17,37 @@ export default function ClientLayout({ }: { children: React.ReactNode }) { - const pathname = usePathname() - const [isMobile, setIsMobile] = useState(false) - const [sidebarOpen, setSidebarOpen] = useState(false) - const isLoginPage = pathname === "/login" - - useEffect(() => { - const checkMobile = () => { - setIsMobile(window.innerWidth < 768) - } - - checkMobile() - window.addEventListener("resize", checkMobile) - - return () => window.removeEventListener("resize", checkMobile) - }, []) - - if (isLoginPage) { - return ( - - - 神射手 - 登录 - - - - {children} - - - - ) - } - return ( - 用户数据资产中台 - + 神射手数据资产中台 + - {/* 背景装饰 */} -
-
-
-
-
+
+
+
+ +
+
+
+ + +
+
+ + +
+
+
+
{children}
- -
- {/* 桌面端侧边栏 */} - {!isMobile && } - - {/* 移动端侧边栏 */} - {isMobile && setSidebarOpen(false)} />} - - {/* 主内容区域 */} -
- {/* 移动端头部 */} - {isMobile && setSidebarOpen(true)} />} - - {/* 内容区域 */} -
{children}
-
-
- - {/* 移动端底部导航 */} - {isMobile && } - - ) diff --git a/app/ai-assistant/data-analysis/page.tsx b/app/ai-assistant/data-analysis/page.tsx new file mode 100644 index 0000000..ea555c2 --- /dev/null +++ b/app/ai-assistant/data-analysis/page.tsx @@ -0,0 +1,175 @@ +"use client" + +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Badge } from "@/components/ui/badge" +import { Button } from "@/components/ui/button" +import { BarChart3, TrendingUp, Users, Download, RefreshCw } from 'lucide-react' +import { BarChart, Bar, LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pie, Cell } from 'recharts' + +export default function DataAnalysis() { + const userBehaviorData = [ + { hour: '00:00', active: 1250, purchases: 85, interactions: 4200 }, + { hour: '04:00', active: 850, purchases: 35, interactions: 1800 }, + { hour: '08:00', active: 5600, purchases: 420, interactions: 18500 }, + { hour: '12:00', active: 8900, purchases: 680, interactions: 28600 }, + { hour: '16:00', active: 7200, purchases: 520, interactions: 22400 }, + { hour: '20:00', active: 9500, purchases: 750, interactions: 32800 }, + ] + + const channelData = [ + { name: '微信朋友圈', value: 35, color: '#8b5cf6' }, + { name: '微信群', value: 28, color: '#3b82f6' }, + { name: '一对一私聊', value: 22, color: '#10b981' }, + { name: '小程序', value: 15, color: '#f59e0b' }, + ] + + const conversionData = [ + { stage: '浏览', users: 100000, rate: 100 }, + { stage: '兴趣', users: 45000, rate: 45 }, + { stage: '咨询', users: 18000, rate: 18 }, + { stage: '下单', users: 5400, rate: 5.4 }, + { stage: '复购', users: 1620, rate: 1.6 }, + ] + + return ( +
+
+
+

数据分析

+

用户行为分析、渠道分析与转化漏斗

+
+
+ + +
+
+ + {/* 关键指标 */} +
+ + + 今日活跃用户 + + +
285.6K
+ +12.5% +
+
+ + + 转化率 + + +
5.4%
+ +0.8% +
+
+ + + 人均互动次数 + + +
8.6
+ +1.2 +
+
+ + + 客单价 + + +
¥328
+ +15.2% +
+
+
+ + {/* 用户行为趋势 */} +
+ + + + + 用户活跃时段分布 + + + + + + + + + + + + + + + + + + + + 渠道分布 + + + + + + `${name} ${value}%`} + outerRadius={100} + fill="#8884d8" + dataKey="value" + > + {channelData.map((entry, index) => ( + + ))} + + + + + + +
+ + {/* 转化漏斗 */} + + + + + 用户转化漏斗 + + + +
+ {conversionData.map((stage, index) => ( +
+
+ {stage.stage} +
+ {stage.users.toLocaleString()}人 + {stage.rate}% +
+
+
+ {stage.rate}% +
+
+ ))} +
+
+
+
+ ) +} diff --git a/app/ai-assistant/page.tsx b/app/ai-assistant/page.tsx index 335985b..d0a0bda 100644 --- a/app/ai-assistant/page.tsx +++ b/app/ai-assistant/page.tsx @@ -1,188 +1,235 @@ "use client" -import { useCallback, useMemo, useState } from "react" -import { BarChart3, Database, FileText } from 'lucide-react' -import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card" -import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs" +import Link from "next/link" +import { useState } from "react" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" -import TaskList from "@/components/ai-assistant/task-list" -import CreateTaskDialog from "@/components/ai-assistant/create-task-dialog" -import ReportCards from "@/components/ai-assistant/report-cards" -import { sanitizeText } from "@/lib/text-sanitize" -import type { AnalysisTask, DatabaseInfo, ReportItem, ReportTemplate } from "@/types/ai-assistant" +import { Textarea } from "@/components/ui/textarea" +import { Cpu, BarChart3, TrendingUp, Users, Target, Brain, ArrowRight, Send, Sparkles } from 'lucide-react' -const initialTasks: AnalysisTask[] = [ - { - id: "task_001", - name: "用户行为分析报告", - database: "微信用户数据库", - status: "completed", - progress: 100, - createdAt: "2025-01-15T09:00:00Z", - completedAt: "2025-01-15T09:30:00Z", - reportUrl: "/reports/user-behavior-analysis.pdf", - description: "基于近30天行为的聚合与序列分析", - }, - { - id: "task_002", - name: "流量关键词趋势分析", - database: "流量关键词库", - status: "running", - progress: 65, - createdAt: "2025-01-15T10:00:00Z", - description: "关注核心流量词与曝光、点击、转化等指标", - }, - { - id: "task_003", - name: "用户价值分层报告", - database: "微信用户数据库", - status: "pending", - progress: 0, - createdAt: "2025-01-15T10:30:00Z", - description: "RFM 分层、价值区间分布与运营建议", - }, -] +export default function AIAssistant() { + const [message, setMessage] = useState("") + const [chatHistory, setChatHistory] = useState([ + { + role: "assistant", + content: "你好!我是神射手AI助手,可以帮助你分析用户数据、生成报告、预测趋势。有什么我可以帮助你的吗?", + timestamp: "10:30", + }, + ]) -const databases: DatabaseInfo[] = [ - { id: "db_001", name: "微信用户数据库", type: "MySQL", tables: 25, records: 4000000000, lastUpdated: "2025-01-15T11:00:00Z" }, - { id: "db_002", name: "流量关键词库", type: "PostgreSQL", tables: 8, records: 150000, lastUpdated: "2025-01-15T10:45:00Z" }, - { id: "db_003", name: "用户行为日志", type: "MongoDB", tables: 12, records: 1500000000, lastUpdated: "2025-01-15T11:15:00Z" }, -] + // AI功能卡片 + const aiFeatures = [ + { + icon: , + title: "数据分析", + description: "自动分析用户行为,生成洞察报告", + color: "from-blue-500 to-cyan-500", + href: "/platform/ai-assistant/data-analysis", + stats: { reports: 1258, insights: 856 } + }, + { + icon: , + title: "趋势预测", + description: "预测用户行为和价值变化趋势", + color: "from-purple-500 to-pink-500", + href: "/platform/ai-assistant/trend-prediction", + stats: { accuracy: 94.2, predictions: 2450 } + }, + { + icon: , + title: "用户画像", + description: "智能生成用户群体画像", + color: "from-green-500 to-emerald-500", + href: "/platform/ai-assistant/user-profiling", + stats: { profiles: 4285, segments: 128 } + }, + { + icon: , + title: "精准推荐", + description: "推荐最佳营销策略和用户群", + color: "from-orange-500 to-red-500", + href: "/platform/ai-assistant/recommendation", + stats: { campaigns: 586, conversion: 18.5 } + }, + ] -const templates: ReportTemplate[] = [ - { id: "template_001", name: "用户画像分析报告", description: "深度分析用户特征、行为模式和价值分层", category: "用户分析", fields: ["用户基本信息", "RFM分析", "行为轨迹", "价值评估", "推荐策略"] }, - { id: "template_002", name: "流量趋势分析报告", description: "分析关键词搜索趋势和流量变化", category: "流量分析", fields: ["关键词热度", "搜索趋势", "竞争分析", "机会识别", "优化建议"] }, - { id: "template_003", name: "业务运营报告", description: "综合业务数据分析和运营建议", category: "运营分析", fields: ["核心指标", "增长分析", "用户留存", "转化漏斗", "运营建议"] }, - { id: "template_004", name: "数据质量报告", description: "评估数据完整性、准确性和一致性", category: "数据质量", fields: ["数据完整性", "准确性检查", "一致性验证", "异常检测", "改进建议"] }, -] + // 快捷问题 + const quickQuestions = [ + "分析今日新增用户特征", + "预测本月用户增长趋势", + "高价值用户流失预警", + "生成本周运营报告", + ] -const reportItems: ReportItem[] = [ - { id: "rpt-1", title: "用户行为分析报告", source: "数据源:微信用户数据库", description: '本报告基于近30天互动行为,输出用户行为模式与高频路径。\\n"]]}', updatedAt: new Date().toISOString() }, - { id: "rpt-2", title: "流量关键词趋势分析", source: "数据源:流量关键词库", description: '追踪 000000 类流量词及其曝光、点击、转化趋势,适配日/周/月视角。\\n" ]]}', updatedAt: new Date().toISOString() }, - { id: "rpt-3", title: "用户价值分层报告", source: "数据源:微信用户数据库", description: '结合 RFM 得分与标签,给出 S/A/B/C/D 分层与经营建议。\\n" ]] }', updatedAt: new Date().toISOString() }, -] + const handleSend = () => { + if (!message.trim()) return -export default function AIAssistantPage() { - const [tasks, setTasks] = useState(initialTasks) - - // 进度推进(仅演示用) - const tick = useCallback(() => { - setTasks((prev) => - prev.map((t) => { - if (t.status === "running" && t.progress < 100) { - const p = Math.min(100, t.progress + Math.random() * 12) - if (p >= 100) { - return { - ...t, - progress: 100, - status: "completed", - completedAt: new Date().toISOString(), - reportUrl: `/reports/${t.id}.pdf`, - } - } - return { ...t, progress: p } - } - return t - }), - ) - }, []) - - const onCreate = (task: AnalysisTask) => { - setTasks((prev) => [task, ...prev]) - // 模拟启动 - setTimeout(() => { - setTasks((prev) => prev.map((t) => (t.id === task.id ? { ...t, status: "running" } : t))) - }, 800) + setChatHistory([ + ...chatHistory, + { + role: "user", + content: message, + timestamp: new Date().toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" }), + }, + { + role: "assistant", + content: "正在分析您的问题,请稍候...", + timestamp: new Date().toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" }), + }, + ]) + setMessage("") } - const sanitizedItems = useMemo( - () => reportItems.map((i) => ({ ...i, description: sanitizeText(i.description) })), - [], - ) - return ( -
-
-
-

AI智能助手

-

数据库分析与智能报告生成

+
+ {/* Header */} +
+
+
+ +
+
+

AI智能助手

+

数据分析、报告生成与智能预测

+
+
+
+ +
+ {/* AI状态 */} + + + + + AI运行状态 + + + +
+
+ 系统状态 + +
+ 运行中 +
+
+
+ 模型版本 + v3.5 +
+
+ 响应速度 + 0.8s +
+
+ 准确率 + 94.2% +
+
+
+
+ + {/* AI功能卡片 */} +
+ {aiFeatures.map((feature, index) => ( + + + +
+
+ {feature.icon} +
+
+
+

{feature.title}

+ +
+

{feature.description}

+
+
+
+ {Object.entries(feature.stats).map(([key, value], i) => ( +
+
{key === 'reports' ? '报告数' : key === 'insights' ? '洞察数' : key === 'accuracy' ? '准确率' : key === 'predictions' ? '预测数' : key === 'profiles' ? '画像数' : key === 'segments' ? '分组数' : key === 'campaigns' ? '活动数' : '转化率'}
+
+ {typeof value === 'number' && value % 1 !== 0 ? `${value}%` : value} +
+
+ ))} +
+
+
+ + ))}
- - - - - 数据分析 - - - - 数据库 - - - - 报告模板 - - - - -
-

数据分析任务

- -
- - - - -
- - - - - - - 数据库 - - - - {databases.map((db) => ( - - -
{db.name}
-
- {db.type} · {db.tables} 表 -
-
- 最近更新 {new Date(db.lastUpdated).toLocaleString("zh-CN")} -
-
-
+ {/* 对话区域 */} +
+ + + + + AI对话 + + + + {/* 聊天历史 */} +
+ {chatHistory.map((chat, index) => ( +
+
+
{chat.content}
+
{chat.timestamp}
+
+
))} - - - +
- - - - - - 报告模板 - - - - {templates.map((t) => ( - - -
{t.name}
-
{t.category}
-
字段: {t.fields.join(" / ")}
-
-
+ {/* 快捷问题 */} +
+ {quickQuestions.map((question, index) => ( + ))} - - - - +
+ + {/* 输入框 */} +
+