新增用戶信息統計功能,更新主頁面以顯示用戶相關數據,並調整相應的狀態管理邏輯。

This commit is contained in:
超级老白兔
2025-08-15 17:59:22 +08:00
parent 94196b1fe3
commit 504220f630
2 changed files with 18 additions and 6 deletions

View File

@@ -3,3 +3,7 @@ import request from "@/api/request";
export function getDashboard() {
return request("/v1/dashboard", {}, "GET");
}
// 用户信息统计
export function getUserInfoStats() {
return request("/v1/dashboard/userInfoStats", {}, "GET");
}

View File

@@ -12,7 +12,7 @@ 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";
import { getDashboard, getUserInfoStats } from "./api";
import NavCommon from "@/components/NavCommon";
const Mine: React.FC = () => {
const navigate = useNavigate();
@@ -24,6 +24,12 @@ const Mine: React.FC = () => {
content: 156,
balance: 0,
});
const [userInfoStats, setUserInfoStats] = useState({
contentLibraryNum: 0,
deviceNum: 0,
userNum: 0,
wechatNum: 0,
});
// 用户信息
const currentUserInfo = {
@@ -43,7 +49,7 @@ const Mine: React.FC = () => {
title: "设备管理",
description: "管理您的设备和微信账号",
icon: <PhoneOutlined />,
count: stats.devices,
count: userInfoStats.deviceNum,
path: "/mine/devices",
bgColor: "#e6f7ff",
iconColor: "#1890ff",
@@ -53,7 +59,7 @@ const Mine: React.FC = () => {
title: "微信号管理",
description: "管理微信账号和好友",
icon: <MessageOutlined />,
count: stats.wechat,
count: userInfoStats.wechatNum,
path: "/wechat-accounts",
bgColor: "#f6ffed",
iconColor: "#52c41a",
@@ -63,7 +69,7 @@ const Mine: React.FC = () => {
title: "流量池",
description: "管理用户流量池和分组",
icon: <DatabaseOutlined />,
count: stats.traffic,
count: userInfoStats.userNum,
path: "/mine/traffic-pool",
bgColor: "#f9f0ff",
iconColor: "#722ed1",
@@ -73,7 +79,7 @@ const Mine: React.FC = () => {
title: "内容库",
description: "管理营销内容和素材",
icon: <FolderOpenOutlined />,
count: stats.content,
count: userInfoStats.contentLibraryNum,
path: "/mine/content",
bgColor: "#fff7e6",
iconColor: "#fa8c16",
@@ -83,7 +89,7 @@ const Mine: React.FC = () => {
title: "触客宝",
description: "触客宝",
icon: <PhoneOutlined />,
count: stats.content,
count: 0,
path: "/mine/ckbox",
bgColor: "#fff7e6",
iconColor: "#fa8c16",
@@ -101,6 +107,8 @@ const Mine: React.FC = () => {
content: 999,
balance: res.balance || 0,
});
const res2 = await getUserInfoStats();
setUserInfoStats(res2);
} catch (error) {
console.error("加载统计数据失败:", error);
}