feat: 本次提交更新内容如下
css module迁移
This commit is contained in:
@@ -7,10 +7,6 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AppRouter />
|
<AppRouter />
|
||||||
<div style={{ margin: 16 }}>
|
|
||||||
<Button type="primary">Antd 按钮</Button>
|
|
||||||
<MobileButton color="primary">Antd-Mobile 按钮</MobileButton>
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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');
|
|
||||||
20
nkebao/src/com/Layout/Layout.tsx
Normal file
20
nkebao/src/com/Layout/Layout.tsx
Normal file
@@ -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<LayoutProps> = ({ children, header, footer }) => {
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
{header && <header>{header}</header>}
|
||||||
|
<main className="bg-gray-50">{children}</main>
|
||||||
|
{footer && <footer>{footer}</footer>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
10
nkebao/src/com/Layout/layout.module.scss
Normal file
10
nkebao/src/com/Layout/layout.module.scss
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
height: 100vh;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container main {
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
const Home: React.FC = () => {
|
|
||||||
return <h1>首页 Home</h1>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Home;
|
|
||||||
14
nkebao/src/pages/home/api.ts
Normal file
14
nkebao/src/pages/home/api.ts
Normal file
@@ -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');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 你可以根据需要继续添加其他接口
|
||||||
|
// 例如:场景获客统计、今日数据统计等
|
||||||
35
nkebao/src/pages/home/index.scss
Normal file
35
nkebao/src/pages/home/index.scss
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
65
nkebao/src/pages/home/index.tsx
Normal file
65
nkebao/src/pages/home/index.tsx
Normal file
@@ -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 (
|
||||||
|
<Layout
|
||||||
|
loading={loading}
|
||||||
|
header={<h1 className="home-title">首页 Home</h1>}
|
||||||
|
footer={<div>底部内容</div>} // 如有底部内容可加
|
||||||
|
>
|
||||||
|
<div className="home-cards">
|
||||||
|
<Card title="设备数量" className="home-card">
|
||||||
|
<div className="home-card-value">{stats.totalDevices}</div>
|
||||||
|
<div className="home-card-desc">在线设备:{stats.onlineDevices}</div>
|
||||||
|
</Card>
|
||||||
|
<Card title="微信号数量" className="home-card">
|
||||||
|
<div className="home-card-value">{stats.totalWechatAccounts}</div>
|
||||||
|
<div className="home-card-desc">
|
||||||
|
在线微信号:{stats.onlineWechatAccounts}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
{loading && <div className="home-loading">加载中...</div>}
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Home;
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import About from "@/pages/About";
|
|
||||||
|
|
||||||
const aboutRoutes = [
|
|
||||||
{
|
|
||||||
path: "/about",
|
|
||||||
element: <About />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default aboutRoutes;
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import Home from "@/pages/Home";
|
import Home from "@/pages/home/index";
|
||||||
|
|
||||||
const homeRoutes = [
|
const homeRoutes = [
|
||||||
{
|
{
|
||||||
@@ -6,12 +6,6 @@ const homeRoutes = [
|
|||||||
element: <Home />,
|
element: <Home />,
|
||||||
auth: false, // 不需要权限
|
auth: false, // 不需要权限
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/dashboard",
|
|
||||||
element: <Dashboard />,
|
|
||||||
auth: true, // 需要登录
|
|
||||||
requiredRole: "admin", // 需要 admin 角色
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export default homeRoutes;
|
export default homeRoutes;
|
||||||
|
|||||||
Reference in New Issue
Block a user