From b986f570ded902b039517e407e7f4ff6ff3de567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9C=AC=E9=87=8C=E7=9A=84=E6=B0=B8?= =?UTF-8?q?=E5=B9=B3?= Date: Wed, 23 Jul 2025 16:00:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=9C=AC=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E5=A6=82=E4=B8=8B?= =?UTF-8?q?=20=E9=A6=96=E9=A1=B5=E4=BB=A3=E7=A0=81=E7=B2=BE=E7=AE=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/pages/home/index.tsx | 162 ++++--------------- nkebao/src/pages/mine/Profile.tsx | 258 ------------------------------ nkebao/src/pages/mine/index.tsx | 8 +- 3 files changed, 34 insertions(+), 394 deletions(-) delete mode 100644 nkebao/src/pages/mine/Profile.tsx diff --git a/nkebao/src/pages/home/index.tsx b/nkebao/src/pages/home/index.tsx index a72b4dc24..f23111fb8 100644 --- a/nkebao/src/pages/home/index.tsx +++ b/nkebao/src/pages/home/index.tsx @@ -46,81 +46,11 @@ const Home: React.FC = () => { const [dashboard, setDashboard] = useState({}); const [sevenDayStats, setSevenDayStats] = useState({}); const [isLoading, setIsLoading] = useState(true); - const [apiError, setApiError] = useState(""); - - // 场景获客数据 - const scenarioFeatures = [ - { - id: "3", - name: "抖音获客", - icon: "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-QR8ManuDplYTySUJsY4mymiZkDYnQ9.png", - color: "bg-blue-100 text-blue-600", - value: 156, - growth: 12, - }, - { - id: "4", - name: "小红书获客", - icon: "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-yvnMxpoBUzcvEkr8DfvHgPHEo1kmQ3.png", - color: "bg-red-100 text-red-600", - value: 89, - growth: 8, - }, - { - id: "6", - name: "公众号获客", - icon: "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-Gsg0CMf5tsZb41mioszdjqU1WmsRxW.png", - color: "bg-green-100 text-green-600", - value: 234, - growth: 15, - }, - { - id: "1", - name: "海报获客", - icon: "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-x92XJgXy4MI7moNYlA1EAes2FqDxMH.png", - color: "bg-orange-100 text-orange-600", - value: 167, - growth: 10, - }, - ]; - - // 今日数据统计 - const todayStatsData = [ - { - title: "朋友圈同步", - value: "12", - icon: , - color: "text-purple-600", - path: "/workspace/moments-sync", - }, - { - title: "群发任务", - value: "8", - icon: , - color: "text-orange-600", - path: "/workspace/group-push", - }, - { - title: "获客转化", - value: "85%", - icon: , - color: "text-green-600", - path: "/scenarios", - }, - { - title: "系统活跃度", - value: "98%", - icon: , - color: "text-blue-600", - path: "/workspace", - }, - ]; useEffect(() => { const fetchData = async () => { try { setIsLoading(true); - setApiError(""); // 并行请求多个接口 const [dashboardResult, planStatsResult, sevenDayResult, todayResult] = @@ -136,7 +66,6 @@ const Home: React.FC = () => { setDashboard(dashboardResult.value); } else { console.warn("仪表板API失败:", dashboardResult.reason); - setApiError("API连接异常,显示默认数据"); } // 处理计划统计数据 @@ -163,18 +92,21 @@ const Home: React.FC = () => { ), color: "#8b5cf6", + path: "/workspace/moments-sync", }, { label: "群发任务", value: todayResult.value?.groupPushNum || 0, icon: , color: "#f97316", + path: "/workspace/group-push", }, { label: "获客转化率", value: todayResult.value?.passRate || "0%", icon: , color: "#22c55e", + path: "/scenarios", }, { label: "系统活跃度", @@ -183,6 +115,7 @@ const Home: React.FC = () => { ), color: "#3b82f6", + path: "/workspace", }, ]; setTodayStats(todayStatsData); @@ -191,7 +124,6 @@ const Home: React.FC = () => { } } catch (error) { console.error("获取数据失败:", error); - setApiError(error instanceof Error ? error.message : "数据加载失败"); } finally { setIsLoading(false); } @@ -208,38 +140,6 @@ const Home: React.FC = () => { navigate("/wechat-accounts"); }; - if (isLoading) { - return ( - -
- 存客宝 -
- - } - footer={} - loading={true} - > -
-
-
- {[...Array(3)].map((_, i) => ( -
-
-
- -
-
-
- ))} -
-
-
-
- ); - } - return ( { } - footer={} + footer={} + loading={isLoading} >
@@ -298,32 +199,29 @@ const Home: React.FC = () => {

场景获客统计

- {scenarioFeatures - .sort((a, b) => b.value - a.value) - .slice(0, 4) // 只显示前4个 - .map((scenario) => ( -
- navigate( - `/scenarios/list/${scenario.id}/${encodeURIComponent( - scenario.name - )}` - ) - } - > -
- {scenario.name} -
-
{scenario.value}
-
{scenario.name}
+ {sceneStats.map((scenario) => ( +
+ navigate( + `/scenarios/list/${scenario.id}/${encodeURIComponent( + scenario.name + )}` + ) + } + > +
+ {scenario.name}
- ))} +
{scenario.allNum}
+
{scenario.name}
+
+ ))}
@@ -333,7 +231,7 @@ const Home: React.FC = () => {

今日数据

- {todayStatsData.map((stat, index) => ( + {todayStats.map((stat, index) => (
{
{stat.icon}
{stat.value}
-
{stat.title}
+
{stat.label}
))} diff --git a/nkebao/src/pages/mine/Profile.tsx b/nkebao/src/pages/mine/Profile.tsx deleted file mode 100644 index bb302b3b9..000000000 --- a/nkebao/src/pages/mine/Profile.tsx +++ /dev/null @@ -1,258 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { useNavigate } from 'react-router-dom'; -import { ChevronRight, Settings, Bell, LogOut, Smartphone, MessageCircle, Database, FolderOpen } from 'lucide-react'; -import { Card, CardContent } from '@/components/ui/card'; -import { Button } from '@/components/ui/button'; -import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; -import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'; -import { useAuth } from '@/contexts/AuthContext'; -import { useToast } from '@/components/ui/toast'; -import Layout from '@/components/Layout'; -import BottomNav from '@/components/BottomNav'; -import UnifiedHeader from '@/components/UnifiedHeader'; -import '@/components/Layout.css'; - -export default function Profile() { - const navigate = useNavigate(); - const { user, logout, isAuthenticated } = useAuth(); - const { toast } = useToast(); - const [showLogoutDialog, setShowLogoutDialog] = useState(false); - const [userInfo, setUserInfo] = useState(null); - const [stats, setStats] = useState({ - devices: 12, - wechat: 25, - traffic: 8, - content: 156, - }); - - // 从localStorage获取用户信息 - useEffect(() => { - const userInfoStr = localStorage.getItem('userInfo'); - if (userInfoStr) { - setUserInfo(JSON.parse(userInfoStr)); - } - }, []); - - // 用户信息 - const currentUserInfo = { - name: userInfo?.username || user?.username || "卡若", - email: userInfo?.email || "zhangsan@example.com", - role: "管理员", - joinDate: "2023-01-15", - lastLogin: "2024-01-20 14:30", - }; - - // 功能模块数据 - const functionModules = [ - { - id: "devices", - title: "设备管理", - description: "管理您的设备和微信账号", - icon: , - count: stats.devices, - path: "/devices", - bgColor: "bg-blue-50", - }, - { - id: "wechat", - title: "微信号管理", - description: "管理微信账号和好友", - icon: , - count: stats.wechat, - path: "/wechat-accounts", - bgColor: "bg-green-50", - }, - { - id: "traffic", - title: "流量池", - description: "管理用户流量池和分组", - icon: , - count: stats.traffic, - path: "/traffic-pool", - bgColor: "bg-purple-50", - }, - { - id: "content", - title: "内容库", - description: "管理营销内容和素材", - icon: , - count: stats.content, - path: "/content", - bgColor: "bg-orange-50", - }, - ]; - - // 加载统计数据 - const loadStats = async () => { - try { - // 这里可以调用实际的API - // const [deviceStats, wechatStats, trafficStats, contentStats] = await Promise.allSettled([ - // getDeviceStats(), - // getWechatStats(), - // getTrafficStats(), - // getContentStats(), - // ]); - - // 暂时使用模拟数据 - setStats({ - devices: 12, - wechat: 25, - traffic: 8, - content: 156, - }); - } catch (error) { - console.error("加载统计数据失败:", error); - } - }; - - useEffect(() => { - loadStats(); - }, []); - - const handleLogout = () => { - // 清除本地存储的用户信息 - localStorage.removeItem('token'); - localStorage.removeItem('token_expired'); - localStorage.removeItem('s2_accountId'); - localStorage.removeItem('userInfo'); - setShowLogoutDialog(false); - logout(); - navigate('/login'); - toast({ - title: '退出成功', - description: '您已安全退出系统', - }); - }; - - const handleFunctionClick = (path: string) => { - navigate(path); - }; - - if (!isAuthenticated) { - return ( -
-
请先登录
-
- ); - } - - return ( - console.log('Notifications'), - }, - { - type: 'icon', - icon: Settings, - onClick: () => console.log('Settings'), - }, - ]} - /> - } - footer={} - > -
-
- {/* 用户信息卡片 */} - - -
- - - - {currentUserInfo.name.charAt(0)} - - -
-
-

{currentUserInfo.name}

- - {currentUserInfo.role} - -
-

{currentUserInfo.email}

-
-
最近登录: {currentUserInfo.lastLogin}
-
-
-
- - -
-
-
-
- - {/* 我的功能 */} - - -
- {functionModules.map((module) => ( -
handleFunctionClick(module.path)} - > -
{module.icon}
-
-
{module.title}
-
{module.description}
-
-
- - {module.count} - - -
-
- ))} -
-
-
- - {/* 退出登录 */} - -
-
- - {/* 退出登录确认对话框 */} - - - - 确认退出登录 - - 您确定要退出登录吗?退出后需要重新登录才能使用完整功能。 - - -
- - -
-
-
-
- ); -} \ No newline at end of file diff --git a/nkebao/src/pages/mine/index.tsx b/nkebao/src/pages/mine/index.tsx index b6298f529..2358d586d 100644 --- a/nkebao/src/pages/mine/index.tsx +++ b/nkebao/src/pages/mine/index.tsx @@ -35,10 +35,10 @@ const Mine: React.FC = () => { // 用户信息 const currentUserInfo = { - name: userInfo?.username || "售前", - email: userInfo?.email || "zhangsan@example.com", - role: "管理员", - lastLogin: "2024-01-20 14:30", + name: userInfo?.username || "-", + email: userInfo?.email || "-", + role: "-", + lastLogin: "-", avatar: userInfo?.avatar || "", }; From 41f0286fff9df0ddd6bbfe97f5993682d0391045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9C=AC=E9=87=8C=E7=9A=84=E6=B0=B8?= =?UTF-8?q?=E5=B9=B3?= Date: Wed, 23 Jul 2025 16:20:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=9C=AC=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E5=A6=82=E4=B8=8B?= =?UTF-8?q?=20=E5=AF=B9=E6=8E=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/pages/mine/api.ts | 17 +++------- nkebao/src/pages/mine/index.module.scss | 1 - nkebao/src/pages/mine/index.tsx | 45 +++++++++---------------- 3 files changed, 19 insertions(+), 44 deletions(-) diff --git a/nkebao/src/pages/mine/api.ts b/nkebao/src/pages/mine/api.ts index 535147142..3f9d424f2 100644 --- a/nkebao/src/pages/mine/api.ts +++ b/nkebao/src/pages/mine/api.ts @@ -1,14 +1,5 @@ -import request from '@/api/request'; - -// 设备统计 -export function getDeviceStats() { - return request('/v1/dashboard/device-stats', {}, 'GET'); +import request from "@/api/request"; +// 首页仪表盘总览 +export function getDashboard() { + return request("/v1/dashboard", {}, "GET"); } - -// 微信号统计 -export function getWechatStats() { - return request('/v1/dashboard/wechat-stats', {}, 'GET'); -} - -// 你可以根据需要继续添加其他接口 -// 例如:场景获客统计、今日数据统计等 diff --git a/nkebao/src/pages/mine/index.module.scss b/nkebao/src/pages/mine/index.module.scss index fc1d92c7f..d0ddc66a8 100644 --- a/nkebao/src/pages/mine/index.module.scss +++ b/nkebao/src/pages/mine/index.module.scss @@ -40,7 +40,6 @@ font-size: 18px; font-weight: 600; color: #333; - margin-bottom: 4px; } .user-level { diff --git a/nkebao/src/pages/mine/index.tsx b/nkebao/src/pages/mine/index.tsx index 2358d586d..4019d842f 100644 --- a/nkebao/src/pages/mine/index.tsx +++ b/nkebao/src/pages/mine/index.tsx @@ -13,10 +13,11 @@ import { import MeauMobile from "@/components/MeauMobile/MeauMoible"; import Layout from "@/components/Layout/Layout"; import style from "./index.module.scss"; - +import { useUserStore } from "@/store/module/user"; +import { getDashboard } from "./api"; const Mine: React.FC = () => { const navigate = useNavigate(); - const [userInfo, setUserInfo] = useState(null); + const { user } = useUserStore(); const [stats, setStats] = useState({ devices: 12, wechat: 25, @@ -25,21 +26,15 @@ const Mine: React.FC = () => { }); const [showLogoutDialog, setShowLogoutDialog] = useState(false); - // 从localStorage获取用户信息 - useEffect(() => { - const userInfoStr = localStorage.getItem("userInfo"); - if (userInfoStr) { - setUserInfo(JSON.parse(userInfoStr)); - } - }, []); - // 用户信息 const currentUserInfo = { - name: userInfo?.username || "-", - email: userInfo?.email || "-", - role: "-", - lastLogin: "-", - avatar: userInfo?.avatar || "", + name: user?.username || "-", + email: user?.account || "-", + role: user?.isAdmin === 1 ? "管理员" : "普通用户", + lastLogin: user?.lastLoginTime + ? new Date(user.lastLoginTime * 1000).toLocaleString() + : "-", + avatar: user?.avatar || "", }; // 功能模块数据 @@ -89,20 +84,12 @@ const Mine: React.FC = () => { // 加载统计数据 const loadStats = async () => { try { - // 这里可以调用实际的API - // const [deviceStats, wechatStats, trafficStats, contentStats] = await Promise.allSettled([ - // getDeviceStats(), - // getWechatStats(), - // getTrafficStats(), - // getContentStats(), - // ]); - - // 暂时使用模拟数据 + const res = await getDashboard(); setStats({ - devices: 12, - wechat: 25, - traffic: 8, - content: 156, + devices: res.deviceNum, + wechat: res.wechatNum, + traffic: 999, + content: 999, }); } catch (error) { console.error("加载统计数据失败:", error); @@ -196,7 +183,6 @@ const Mine: React.FC = () => { display: "flex", alignItems: "center", gap: "8px", - marginBottom: "4px", }} >
{currentUserInfo.name}
@@ -225,7 +211,6 @@ const Mine: React.FC = () => {
-