From 6f6cbadacd2cd0c6439c987774247c8221fb1c95 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: Thu, 17 Jul 2025 23:19:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AC=E6=AC=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E5=A6=82=E4=B8=8B=20css=20?= =?UTF-8?q?module=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/App.tsx | 4 -- nkebao/src/api/module/auth.ts | 22 -------- nkebao/src/com/Layout/Layout.tsx | 20 ++++++++ nkebao/src/com/Layout/layout.module.scss | 10 ++++ nkebao/src/pages/Home.tsx | 7 --- nkebao/src/pages/home/api.ts | 14 +++++ nkebao/src/pages/home/index.scss | 35 +++++++++++++ nkebao/src/pages/home/index.tsx | 65 ++++++++++++++++++++++++ nkebao/src/router/module/about.tsx | 10 ---- nkebao/src/router/module/home.tsx | 8 +-- 10 files changed, 145 insertions(+), 50 deletions(-) delete mode 100644 nkebao/src/api/module/auth.ts create mode 100644 nkebao/src/com/Layout/Layout.tsx create mode 100644 nkebao/src/com/Layout/layout.module.scss delete mode 100644 nkebao/src/pages/Home.tsx create mode 100644 nkebao/src/pages/home/api.ts create mode 100644 nkebao/src/pages/home/index.scss create mode 100644 nkebao/src/pages/home/index.tsx delete mode 100644 nkebao/src/router/module/about.tsx diff --git a/nkebao/src/App.tsx b/nkebao/src/App.tsx index 4437b1404..40792893b 100644 --- a/nkebao/src/App.tsx +++ b/nkebao/src/App.tsx @@ -7,10 +7,6 @@ function App() { return ( <> -
- - Antd-Mobile 按钮 -
); } diff --git a/nkebao/src/api/module/auth.ts b/nkebao/src/api/module/auth.ts deleted file mode 100644 index dba5ef64a..000000000 --- a/nkebao/src/api/module/auth.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { request } from '@/api/request'; - -export const list = (data?: any) => - request('/cw/companyUser/list', data, 'GET'); - -export const joinAudit = (data: any) => - request('/cw/companyUser/joinAudit', data, 'PUT'); - -export const listJoinAudit = (data?: any) => - request('/cw/companyUser/listJoinAudit', data, 'GET'); - -export const CwCompanyUserApplyAdd = (data: any) => - request('/cw/CwCompanyUserApply/add', data, 'PUT'); - -export const CwCompanyUserApplyAdminList = (data?: any) => - request('/cw/CwCompanyUserApply/adminList', data, 'GET'); - -export const CwCompanyUserApplyAudit = (data: any) => - request('/cw/CwCompanyUserApply/audit', data, 'POST'); - -export const CwCompanyUserApplyUserList = (data?: any) => - request('/cw/CwCompanyUserApply/userList', data, 'GET'); \ No newline at end of file diff --git a/nkebao/src/com/Layout/Layout.tsx b/nkebao/src/com/Layout/Layout.tsx new file mode 100644 index 000000000..405808952 --- /dev/null +++ b/nkebao/src/com/Layout/Layout.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import "layout.module.scss"; +interface LayoutProps { + loading?: boolean; + children?: React.ReactNode; + header?: React.ReactNode; + footer?: React.ReactNode; +} + +const Layout: React.FC = ({ children, header, footer }) => { + return ( +
+ {header &&
{header}
} +
{children}
+ {footer &&
{footer}
} +
+ ); +}; + +export default Layout; diff --git a/nkebao/src/com/Layout/layout.module.scss b/nkebao/src/com/Layout/layout.module.scss new file mode 100644 index 000000000..e6e6cb0b4 --- /dev/null +++ b/nkebao/src/com/Layout/layout.module.scss @@ -0,0 +1,10 @@ +.container { + display: flex; + height: 100vh; + flex-direction: column; +} + +.container main { + flex: 1; + overflow: auto; +} \ No newline at end of file diff --git a/nkebao/src/pages/Home.tsx b/nkebao/src/pages/Home.tsx deleted file mode 100644 index 2f0a324ae..000000000 --- a/nkebao/src/pages/Home.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; - -const Home: React.FC = () => { - return

首页 Home

; -}; - -export default Home; diff --git a/nkebao/src/pages/home/api.ts b/nkebao/src/pages/home/api.ts new file mode 100644 index 000000000..535147142 --- /dev/null +++ b/nkebao/src/pages/home/api.ts @@ -0,0 +1,14 @@ +import request from '@/api/request'; + +// 设备统计 +export function getDeviceStats() { + return request('/v1/dashboard/device-stats', {}, 'GET'); +} + +// 微信号统计 +export function getWechatStats() { + return request('/v1/dashboard/wechat-stats', {}, 'GET'); +} + +// 你可以根据需要继续添加其他接口 +// 例如:场景获客统计、今日数据统计等 diff --git a/nkebao/src/pages/home/index.scss b/nkebao/src/pages/home/index.scss new file mode 100644 index 000000000..d8def7fd0 --- /dev/null +++ b/nkebao/src/pages/home/index.scss @@ -0,0 +1,35 @@ +.home-page { + padding: 16px; + background: #f5f5f5; + min-height: 100vh; + .home-title { + font-size: 22px; + font-weight: bold; + margin-bottom: 16px; + color: #1677ff; + text-align: center; + } + .home-cards { + display: flex; + gap: 16px; + flex-direction: column; + .home-card { + .home-card-value { + font-size: 28px; + font-weight: bold; + color: #1677ff; + margin-bottom: 8px; + } + .home-card-desc { + font-size: 14px; + color: #888; + } + } + } + .home-loading { + margin-top: 24px; + text-align: center; + color: #999; + font-size: 16px; + } +} \ No newline at end of file diff --git a/nkebao/src/pages/home/index.tsx b/nkebao/src/pages/home/index.tsx new file mode 100644 index 000000000..e96bd9349 --- /dev/null +++ b/nkebao/src/pages/home/index.tsx @@ -0,0 +1,65 @@ +import React, { useEffect, useState } from "react"; +import { Card, Toast } from "antd-mobile"; +import { getDeviceStats, getWechatStats } from "./api"; +import Layout from "@/com/Layout/Layout"; +import "./index.scss"; + +const Home: React.FC = () => { + const [stats, setStats] = useState({ + totalDevices: 0, + onlineDevices: 0, + totalWechatAccounts: 0, + onlineWechatAccounts: 0, + }); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchStats = async () => { + setLoading(true); + try { + const [device, wechat] = await Promise.all([ + getDeviceStats(), + getWechatStats(), + ]); + setStats({ + totalDevices: device.total || 0, + onlineDevices: device.online || 0, + totalWechatAccounts: wechat.total || 0, + onlineWechatAccounts: wechat.active || 0, + }); + } catch (err: any) { + Toast.show({ + content: err?.message || "数据加载失败", + position: "top", + }); + } finally { + setLoading(false); + } + }; + fetchStats(); + }, []); + + return ( + 首页 Home} + footer={
底部内容
} // 如有底部内容可加 + > +
+ +
{stats.totalDevices}
+
在线设备:{stats.onlineDevices}
+
+ +
{stats.totalWechatAccounts}
+
+ 在线微信号:{stats.onlineWechatAccounts} +
+
+
+ {loading &&
加载中...
} +
+ ); +}; + +export default Home; diff --git a/nkebao/src/router/module/about.tsx b/nkebao/src/router/module/about.tsx deleted file mode 100644 index d76d7e08e..000000000 --- a/nkebao/src/router/module/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import About from "@/pages/About"; - -const aboutRoutes = [ - { - path: "/about", - element: , - }, -]; - -export default aboutRoutes; diff --git a/nkebao/src/router/module/home.tsx b/nkebao/src/router/module/home.tsx index a4c5247a4..840b36dc4 100644 --- a/nkebao/src/router/module/home.tsx +++ b/nkebao/src/router/module/home.tsx @@ -1,4 +1,4 @@ -import Home from "@/pages/Home"; +import Home from "@/pages/home/index"; const homeRoutes = [ { @@ -6,12 +6,6 @@ const homeRoutes = [ element: , auth: false, // 不需要权限 }, - { - path: "/dashboard", - element: , - auth: true, // 需要登录 - requiredRole: "admin", // 需要 admin 角色 - }, ]; export default homeRoutes;