diff --git a/app/ai-assistant/page.tsx b/app/ai-assistant/page.tsx index f1f6be6..4247770 100644 --- a/app/ai-assistant/page.tsx +++ b/app/ai-assistant/page.tsx @@ -343,7 +343,11 @@ export default function AIAssistantPage() {

请完成所有分析步骤

- @@ -612,7 +616,11 @@ export default function AIAssistantPage() {

请完成所有策略步骤

- diff --git a/app/api/database-structure/route.ts b/app/api/database-structure/route.ts index 048a793..84ee395 100644 --- a/app/api/database-structure/route.ts +++ b/app/api/database-structure/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from "next/server" -import { getDatabases, getDatabaseStructure } from "@/lib/db-connector" +import { getDatabases, getDatabaseStructure } from "@/lib/mongodb-mock-connector" // 更新导入路径 export async function GET(request: Request) { try { diff --git a/app/components/BottomNav.tsx b/app/components/BottomNav.tsx index 11b1994..cdbe979 100644 --- a/app/components/BottomNav.tsx +++ b/app/components/BottomNav.tsx @@ -2,14 +2,13 @@ import Link from "next/link" import { usePathname } from "next/navigation" -import { Home, Database, Search, Target, Brain } from "lucide-react" +import { Home, Database, Target, BrainCircuit } from "lucide-react" // 引入AI智能助手图标 const navItems = [ { href: "/", icon: Home, label: "概览" }, { href: "/data-platform", icon: Database, label: "数据中台" }, - { href: "/user-discovery", icon: Search, label: "用户发现" }, - { href: "/user-valuation", icon: Target, label: "用户估值" }, - { href: "/ai-analysis", icon: Brain, label: "AI分析" }, + { href: "/user-portrait", icon: Target, label: "用户画像" }, // 整合用户池功能 + { href: "/ai-assistant", icon: BrainCircuit, label: "AI助手" }, // 新增AI智能助手 ] export default function BottomNav() { diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 357a8b4..aca2202 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -18,7 +18,7 @@ export default function Header() { setSearchQuery(e.target.value)} diff --git a/app/components/MobileHeader.tsx b/app/components/MobileHeader.tsx index 4732ef3..6107e90 100644 --- a/app/components/MobileHeader.tsx +++ b/app/components/MobileHeader.tsx @@ -10,7 +10,7 @@ interface MobileHeaderProps { title?: string } -export default function MobileHeader({ onMenuToggle, title = "数据资产中台" }: MobileHeaderProps) { +export default function MobileHeader({ onMenuToggle, title = "卡若数据资产中台" }: MobileHeaderProps) { const [showSearch, setShowSearch] = useState(false) const [searchQuery, setSearchQuery] = useState("") @@ -46,7 +46,7 @@ export default function MobileHeader({ onMenuToggle, title = "数据资产中台
setSearchQuery(e.target.value)} diff --git a/app/components/MobileSidebar.tsx b/app/components/MobileSidebar.tsx index b2ed6fa..ec8a179 100644 --- a/app/components/MobileSidebar.tsx +++ b/app/components/MobileSidebar.tsx @@ -7,16 +7,14 @@ import { cn } from "@/lib/utils" import { Database, LayoutDashboard, - Users, Target, X, ChevronDown, ChevronRight, - Search, - BarChart3, - TrendingUp, - Brain, - HelpCircle, + UserCheck, + Layers, + Tag, + BrainCircuit, } from "lucide-react" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" @@ -29,9 +27,7 @@ interface MobileSidebarProps { export default function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) { const pathname = usePathname() const [expandedSections, setExpandedSections] = useState({ - "user-discovery": false, - "user-valuation": false, - "ai-analysis": false, + "user-portrait": false, // 用户画像默认不展开 }) const toggleSection = (section: string) => { @@ -70,77 +66,40 @@ export default function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) { description: "多源数据整合中心", }, { - title: "用户发现", - href: "/user-discovery", - icon: , - primary: true, - expandable: true, - section: "user-discovery", - description: "用户行为洞察分析", - children: [ - { - title: "行为分析", - href: "/user-discovery/behavior", - icon: , - description: "用户行为模式分析", - }, - { - title: "用户分群", - href: "/user-discovery/segmentation", - icon: , - description: "智能用户分群", - }, - ], - }, - { - title: "用户估值", - href: "/user-valuation", + title: "用户画像", // 整合用户池功能 + href: "/user-portrait", icon: , primary: true, expandable: true, - section: "user-valuation", - description: "用户价值评估模型", - hasHelp: true, + section: "user-portrait", + description: "用户数据管理与画像分析", children: [ { - title: "估值模型", - href: "/user-valuation/model", - icon: , - description: "RFM价值评估", - hasHelp: true, + title: "用户管理", // 原用户池的用户管理 + href: "/user-portrait/management", + icon: , + description: "IMEI、手机号管理", }, { - title: "升级路径", - href: "/user-valuation/upgrade-paths", - icon: , - description: "用户价值提升策略", - hasHelp: true, + title: "用户分群", // 原用户池的用户分群 + href: "/user-portrait/segmentation", + icon: , + description: "智能用户分群", + }, + { + title: "标签管理", // 原用户画像的标签管理 + href: "/user-portrait/tags", + icon: , + description: "用户标签体系", }, ], }, { - title: "AI分析", - href: "/ai-analysis", - icon: , + title: "AI智能助手", // 新增AI智能助手 + href: "/ai-assistant", + icon: , primary: true, - expandable: true, - section: "ai-analysis", - description: "智能数据洞察", - tag: "AI", - children: [ - { - title: "趋势识别", - href: "/ai-analysis/trends", - icon: , - description: "AI趋势预测", - }, - { - title: "异常检测", - href: "/ai-analysis/anomaly", - icon: , - description: "智能异常监控", - }, - ], + description: "AI数据分析与营销策略", }, ] @@ -148,8 +107,6 @@ export default function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) { switch (tag) { case "核心": return "bg-blue-100 text-blue-700 border-blue-200" - case "AI": - return "bg-purple-100 text-purple-700 border-purple-200" default: return "bg-gray-100 text-gray-700 border-gray-200" } @@ -180,7 +137,7 @@ export default function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) {

- 数据资产中台 + 卡若数据资产中台

) : ( @@ -139,7 +136,7 @@ export default function Sidebar() {
{ + toast({ + title: "连接到AI", + description: `数据源 "${sourceName}" 已准备好连接到AI模型。`, + }) + // 实际应用中,这里会触发一个后端API调用或跳转到AI配置页面 + } + return (
{/* 页面标题和工具栏 */} @@ -182,309 +202,346 @@ export default function DataPlatformPage() {
- {/* 数据中台概览 */} - setExpandedSections((prev) => ({ ...prev, overview: open }))} - > - - - -
-
- -
- 平台概览 - 数据中台整体运行状况 -
-
- {expandedSections.overview ? ( - - ) : ( - - )} -
-
-
- - -
-
-
- {platformData.overview.totalRecords.toLocaleString()} -
-
总数据量
-
-
-
- {platformData.overview.dataSources} -
-
数据源
-
-
-
- {platformData.overview.dataQuality}% -
-
数据质量
-
-
-
- {platformData.overview.storageUsed}GB -
-
存储使用
-
-
-
-
-
- 存储使用率 - - {platformData.overview.storageUsed}GB / {platformData.overview.storageTotal}GB - -
- -
-
-
- 数据质量 - {platformData.overview.dataQuality}% -
- -
-
-
-
-
-
+ + + 概览 + 数据源 + 集成统计 + 数据质量 + AI 模型 + - {/* 数据源管理 */} - setExpandedSections((prev) => ({ ...prev, sources: open }))} - > - - - -
-
- -
- 数据源管理 - - 数据源连接状态 ({platformData.dataSources.length}) - -
-
- {expandedSections.sources ? ( - - ) : ( - - )} -
-
-
- - -
- {platformData.dataSources.map((source, index) => ( -
-
-
-
- {getStatusIcon(source.status)} -

{source.name}

- {source.status} - - {source.type} - -
-

{source.description}

-
- 数据量: {source.records.toLocaleString()} - 最后同步: {source.lastSync} - 质量评分: {source.quality}% -
-
-
-
-
{source.quality}%
-
数据质量
-
- + + {/* 数据中台概览 */} + setExpandedSections((prev) => ({ ...prev, overview: open }))} + > + + + +
+
+ +
+ 平台概览 + 数据中台整体运行状况
-
- + {expandedSections.overview ? ( + + ) : ( + + )} +
+ + + + +
+
+
+ {platformData.overview.totalRecords.toLocaleString()} +
+
总数据量
+
+
+
+ {platformData.overview.dataSources} +
+
数据源
+
+
+
+ {platformData.overview.dataQuality}% +
+
数据质量
+
+
+
+ {platformData.overview.storageUsed}GB +
+
存储使用
- ))} -
- - -
-
+
+
+
+ 存储使用率 + + {platformData.overview.storageUsed}GB / {platformData.overview.storageTotal}GB + +
+ +
+
+
+ 数据质量 + {platformData.overview.dataQuality}% +
+ +
+
+ + + + +
- {/* 数据集成统计 */} - setExpandedSections((prev) => ({ ...prev, integration: open }))} - > - - - -
-
- -
- 集成统计 - 数据集成性能指标 -
-
- {expandedSections.integration ? ( - - ) : ( - - )} -
-
-
- - -
-
-
- - 集成概况 -
-
-
- 总集成数 - {platformData.integrationStats.totalIntegrations} -
-
- 活跃集成 - {platformData.integrationStats.activeIntegrations} -
-
- 待处理 - {platformData.integrationStats.pendingIntegrations} + + {/* 数据源管理 */} + setExpandedSections((prev) => ({ ...prev, sources: open }))} + > + + + +
+
+ +
+ 数据源管理 + + 数据源连接状态 ({platformData.dataSources.length}) + +
+ {expandedSections.sources ? ( + + ) : ( + + )}
-
+ + + + +
+ {platformData.dataSources.map((source, index) => ( +
+
+
+
+ {getStatusIcon(source.status)} +

{source.name}

+ {source.status} + + {source.type} + +
+

{source.description}

+
+ 数据量: {source.records.toLocaleString()} + 最后同步: {source.lastSync} + 质量评分: {source.quality}% +
+
+
+
+
{source.quality}%
+
数据质量
+
+
+ + +
+
+
+
+ +
+
+ ))} +
+
+
+ + + -
-
- - 性能指标 + + {/* 数据集成统计 */} + setExpandedSections((prev) => ({ ...prev, integration: open }))} + > + + + +
+
+ +
+ 集成统计 + 数据集成性能指标 +
+
+ {expandedSections.integration ? ( + + ) : ( + + )}
-
-
- 成功率 - {platformData.integrationStats.successRate}% -
-
- 平均同步时间 - {platformData.integrationStats.avgSyncTime} -
-
- 失败集成 - {platformData.integrationStats.failedIntegrations} -
-
-
- -
-
- - 实时状态 -
-
-
- 最后更新 - {platformData.overview.lastUpdate} -
-
- 同步状态 - {platformData.overview.syncStatus} -
-
- 系统负载 - 正常 -
-
-
-
- - - - - - {/* 数据质量监控 */} - setExpandedSections((prev) => ({ ...prev, quality: open }))} - > - - - -
-
- -
- 数据质量监控 - 数据质量多维度评估 -
-
- {expandedSections.quality ? ( - - ) : ( - - )} -
-
-
- - -
- {Object.entries(platformData.dataQuality).map(([key, value], index) => { - const labels = { - completeness: "完整性", - accuracy: "准确性", - consistency: "一致性", - timeliness: "及时性", - validity: "有效性", - uniqueness: "唯一性", - } - - const colors = [ - "bg-blue-50 text-blue-600", - "bg-green-50 text-green-600", - "bg-purple-50 text-purple-600", - "bg-orange-50 text-orange-600", - "bg-pink-50 text-pink-600", - "bg-indigo-50 text-indigo-600", - ] - - return ( -
-
-
{value}%
-
{labels[key as keyof typeof labels]}
-
- + + + + +
+
+
+ + 集成概况 +
+
+
+ 总集成数 + {platformData.integrationStats.totalIntegrations} +
+
+ 活跃集成 + {platformData.integrationStats.activeIntegrations} +
+
+ 待处理 + {platformData.integrationStats.pendingIntegrations}
- ) - })} -
-
-
- - + +
+
+ + 性能指标 +
+
+
+ 成功率 + {platformData.integrationStats.successRate}% +
+
+ 平均同步时间 + {platformData.integrationStats.avgSyncTime} +
+
+ 失败集成 + {platformData.integrationStats.failedIntegrations} +
+
+
+ +
+
+ + 实时状态 +
+
+
+ 最后更新 + {platformData.overview.lastUpdate} +
+
+ 同步状态 + {platformData.overview.syncStatus} +
+
+ 系统负载 + 正常 +
+
+
+
+ + + + + + + + {/* 数据质量监控 */} + setExpandedSections((prev) => ({ ...prev, quality: open }))} + > + + + +
+
+ +
+ 数据质量监控 + 数据质量多维度评估 +
+
+ {expandedSections.quality ? ( + + ) : ( + + )} +
+
+
+ + +
+ {Object.entries(platformData.dataQuality).map(([key, value], index) => { + const labels = { + completeness: "完整性", + accuracy: "准确性", + consistency: "一致性", + timeliness: "及时性", + validity: "有效性", + uniqueness: "唯一性", + } + + const colors = [ + "bg-blue-50 text-blue-600", + "bg-green-50 text-green-600", + "bg-purple-50 text-purple-600", + "bg-orange-50 text-orange-600", + "bg-pink-50 text-pink-600", + "bg-indigo-50 text-indigo-600", + ] + + return ( +
+
+
{value}%
+
{labels[key as keyof typeof labels]}
+
+ +
+
+
+ ) + })} +
+
+
+
+
+
+ + + {/* AI 模型管理 */} + + +
) } diff --git a/app/layout.tsx b/app/layout.tsx index 89a0831..e867aee 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -6,8 +6,8 @@ import ClientLayout from "./ClientLayout" const inter = Inter({ subsets: ["latin"] }) export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: "卡若数据资产中台", + description: "基于IMEI、手机号的用户数据资产管理平台", generator: 'v0.dev' } diff --git a/app/page.tsx b/app/page.tsx index 1d82555..846823a 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -8,15 +8,17 @@ import { Progress } from "@/components/ui/progress" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Database, + Users, Target, - Brain, - Search, - BarChart3, + TrendingUp, RefreshCw, Download, ChevronRight, Activity, Zap, + UserCheck, + Layers, + Tag, } from "lucide-react" import Link from "next/link" @@ -31,24 +33,24 @@ export default function HomePage() { sources: 8, lastUpdate: "2分钟前", }, - userDiscovery: { + userPool: { + totalUsers: 125678, activeUsers: 45678, newUsers: 1234, - engagement: "87.5%", growth: "+8.2%", }, + userPortrait: { + totalTags: 342, + activeTags: 287, + coverage: "95.8%", + growth: "+5.3%", + }, userValuation: { avgValue: 3248, highValue: 12456, growth: "+15.8%", upgradeRate: "12.5%", }, - aiAnalysis: { - insights: 156, - anomalies: 3, - predictions: 89, - accuracy: "94.2%", - }, } // 实时活动数据 @@ -56,21 +58,21 @@ export default function HomePage() { { id: 1, type: "data_sync", - message: "电商平台数据同步完成", + message: "IMEI数据同步完成", time: "刚刚", status: "success", }, { id: 2, - type: "user_discovery", - message: "发现新用户行为模式", + type: "user_pool", + message: "新增用户池分群", time: "2分钟前", status: "info", }, { id: 3, - type: "ai_analysis", - message: "AI检测到异常流量", + type: "user_portrait", + message: "标签规则自动执行", time: "5分钟前", status: "warning", }, @@ -87,12 +89,12 @@ export default function HomePage() { switch (type) { case "data_sync": return - case "user_discovery": - return - case "user_valuation": + case "user_pool": + return + case "user_portrait": return - case "ai_analysis": - return + case "user_valuation": + return default: return } @@ -117,7 +119,7 @@ export default function HomePage() {

数据概览

-

智能数据分析平台总览

+

卡若数据资产中台总览

setSearchQuery(e.target.value)} + /> +
+ + + + +
+ + {/* 移动端卡片布局 */} +
+ {filteredUsers.map((user) => ( +
+
+
+ + {user.name} + +
+

{user.name}

+

{user.lastActive}

+
+
+ {user.status} +
+ +
+
+

IMEI

+

{user.imei.slice(-6)}

+
+
+

手机号

+

{user.phone}

+
+
+

设备

+

{user.deviceBrand}

+
+
+

位置

+

{user.location}

+
+
+ +
+
+

流量池

+ + {user.pool} + +
+
+

平台

+ + {user.platform} + +
+
+ +
+ {user.tags.map((tag, index) => ( + + {tag} + + ))} +
+ +
+ + +
+
+ ))} +
+ + {/* 桌面端表格布局 */} +
+ + + + + + + + + + + + + + + {filteredUsers.map((user) => ( + + + + + + + + + + + ))} + +
用户IMEI/手机号设备信息位置流量池/平台状态标签操作
+
+ + {user.name} + +
+

{user.name}

+

{user.lastActive}

+
+
+
+

{user.imei}

+

{user.phone}

+
+
+

{user.deviceBrand}

+

{user.deviceModel}

+
+
+

{user.location}

+
+
+ + {user.pool} + +

{user.platform}

+
+
+ {user.status} + +
+ {user.tags.slice(0, 3).map((tag, index) => ( + + {tag} + + ))} + {user.tags.length > 3 && ( + + +{user.tags.length - 3} + + )} +
+
+
+ + +
+
+
+ + + + + + {/* 用户分群 (从原 user-pool/page.tsx 整合) */} + setExpandedSections((prev) => ({ ...prev, userSegmentation: open }))} + > + + + +
+
+ +
+ 用户分群 + 智能用户分群管理 +
+
+ {expandedSections.userSegmentation ? ( + + ) : ( + + )} +
+
+
+ + +
+ {userSegments.map((segment, index) => ( +
+

{segment.name}

+

{segment.count.toLocaleString()}

+

{segment.description}

+
+
))} @@ -339,7 +703,7 @@ export default function UserPortrait() { - {/* 标签管理 */} + {/* 标签管理 (原用户画像的标签管理,现在是用户画像的一部分) */} setExpandedSections((prev) => ({ ...prev, tagManagement: open }))} @@ -403,223 +767,6 @@ export default function UserPortrait() { - {/* 用户列表 */} - setExpandedSections((prev) => ({ ...prev, userList: open }))} - > - - - -
-
- -
- 用户列表 - - 用户数据管理 ({filteredUsers.length}) - -
-
- {expandedSections.userList ? ( - - ) : ( - - )} -
-
-
- - -
-
- - setSearchQuery(e.target.value)} - /> -
- - - - -
- -
- {/* 移动端卡片布局 */} - {filteredUsers.map((user) => ( -
-
-
- - {user.name} - -
-

{user.name}

-

{user.company}

-
-
- = 90 - ? "bg-green-100 text-green-800" - : user.rfmScore >= 80 - ? "bg-blue-100 text-blue-800" - : user.rfmScore >= 70 - ? "bg-yellow-100 text-yellow-800" - : "bg-gray-100 text-gray-800" - } - > - {user.rfmScore} - -
-
- {user.lastActive} - ¥{user.value.toLocaleString()} -
-
- {user.tags.slice(0, 3).map((tag, index) => ( - - {tag} - - ))} - {user.tags.length > 3 && ( - - +{user.tags.length - 3} - - )} -
-
- - -
-
- ))} -
- - {/* 桌面端表格布局 */} -
- - - - - - - - - - - - - - {filteredUsers.map((user) => ( - - - - - - - - - - ))} - -
用户公司价值评分微信账号标签操作
-
- - {user.name} - -
-

{user.name}

-

{user.lastActive}

-
-
-
-

{user.company}

-

{user.category}

-
-

¥{user.value.toLocaleString()}

-

{user.pool}

-
- = 90 - ? "bg-green-100 text-green-800" - : user.rfmScore >= 80 - ? "bg-blue-100 text-blue-800" - : user.rfmScore >= 70 - ? "bg-yellow-100 text-yellow-800" - : "bg-gray-100 text-gray-800" - } - > - {user.rfmScore} - - - - -
- {user.tags.slice(0, 3).map((tag, index) => ( - - {tag} - - ))} - {user.tags.length > 3 && ( - - +{user.tags.length - 3} - - )} -
-
- -
-
-
-
-
-
- {/* 微信账号对话框 */}

创建新模板

-

- 创建自定义分析模板,保存常用的分析配置 -

+

创建自定义分析模板,保存常用的分析配置

@@ -719,9 +727,7 @@ export function AIAnalysisTools() { 10 -

- 设置同时执行的AI分析任务数量,数值越大系统负载越高 -

+

设置同时执行的AI分析任务数量,数值越大系统负载越高

@@ -920,4 +926,231 @@ export function AIAnalysisTools() { {selectedTask.result.clusters.map((cluster: any, index: number) => ( - + {cluster.name} + {cluster.size.toLocaleString()} + +
+ {cluster.characteristics.map((char: string, charIndex: number) => ( + + {char} + + ))} +
+
+
+ ))} +
+ +
+
+ )} + + {selectedTask.result.tagCategories && ( +
+

生成的标签分类

+
+ + + + 分类名称 + 标签数量 + 覆盖率 + 示例标签 + + + + {selectedTask.result.tagCategories.map((category: any, index: number) => ( + + {category.name} + {category.count} + {category.coverage} + +
+ {category.examples.map((example: string, exampleIndex: number) => ( + + {example} + + ))} +
+
+
+ ))} +
+
+
+
+ )} +
+ )} +
+ )} + + + {selectedTask?.status === "completed" && ( + + )} + + + + + {/* 添加模型对话框 */} + + + + 添加AI模型 + 配置新的AI模型连接 + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +