feat: 本次提交更新内容如下
搞登录拦截模块
This commit is contained in:
20
nkebao/src/components/Layout/Layout.tsx
Normal file
20
nkebao/src/components/Layout/Layout.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import styles from "./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={styles.container}>
|
||||
{header && <header>{header}</header>}
|
||||
<main>{children}</main>
|
||||
{footer && <footer>{footer}</footer>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Layout;
|
||||
10
nkebao/src/components/Layout/layout.module.scss
Normal file
10
nkebao/src/components/Layout/layout.module.scss
Normal file
@@ -0,0 +1,10 @@
|
||||
.container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.container main {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
53
nkebao/src/components/LineChart.tsx
Normal file
53
nkebao/src/components/LineChart.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import React from "react";
|
||||
import ReactECharts from "echarts-for-react";
|
||||
|
||||
interface LineChartProps {
|
||||
title?: string;
|
||||
xData: string[];
|
||||
yData: number[];
|
||||
height?: number | string;
|
||||
}
|
||||
|
||||
const LineChart: React.FC<LineChartProps> = ({
|
||||
title = "",
|
||||
xData,
|
||||
yData,
|
||||
height = 200,
|
||||
}) => {
|
||||
const option = {
|
||||
title: {
|
||||
text: title,
|
||||
left: "center",
|
||||
textStyle: { fontSize: 16 },
|
||||
},
|
||||
tooltip: { trigger: "axis" },
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data: xData,
|
||||
boundaryGap: false,
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
boundaryGap: ["10%", "10%"], // 上下留白
|
||||
min: (value: any) => value.min - 10, // 下方多留一点空间
|
||||
max: (value: any) => value.max + 10, // 上方多留一点空间
|
||||
minInterval: 1,
|
||||
axisLabel: { margin: 12 },
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: yData,
|
||||
type: "line",
|
||||
smooth: true,
|
||||
symbol: "circle",
|
||||
lineStyle: { color: "#1677ff" },
|
||||
itemStyle: { color: "#1677ff" },
|
||||
},
|
||||
],
|
||||
grid: { left: 40, right: 24, top: 40, bottom: 32 },
|
||||
};
|
||||
|
||||
return <ReactECharts option={option} style={{ height, width: "100%" }} />;
|
||||
};
|
||||
|
||||
export default LineChart;
|
||||
81
nkebao/src/components/MeauMobile/MeauMoible.tsx
Normal file
81
nkebao/src/components/MeauMobile/MeauMoible.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { TabBar } from "antd-mobile";
|
||||
import {
|
||||
AppOutline,
|
||||
ShopbagOutline,
|
||||
PieOutline,
|
||||
UserOutline,
|
||||
} from "antd-mobile-icons";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
key: "home",
|
||||
title: "首页",
|
||||
icon: <AppOutline />,
|
||||
path: "/",
|
||||
},
|
||||
{
|
||||
key: "scene",
|
||||
title: "场景获客",
|
||||
icon: <ShopbagOutline />,
|
||||
path: "/scene",
|
||||
},
|
||||
{
|
||||
key: "work",
|
||||
title: "工作台",
|
||||
icon: <PieOutline />,
|
||||
path: "/work",
|
||||
},
|
||||
{
|
||||
key: "mine",
|
||||
title: "我的",
|
||||
icon: <UserOutline />,
|
||||
path: "/mine",
|
||||
},
|
||||
];
|
||||
|
||||
// 需要展示菜单的路由白名单(可根据实际业务调整)
|
||||
const menuPaths = ["/", "/scene", "/work", "/mine"];
|
||||
|
||||
const MeauMobile: React.FC = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const [activeKey, setActiveKey] = useState("home");
|
||||
|
||||
// 根据当前路由自动设置 activeKey,支持嵌套路由
|
||||
useEffect(() => {
|
||||
const found = tabs.find((tab) =>
|
||||
tab.path === "/"
|
||||
? location.pathname === "/"
|
||||
: location.pathname.startsWith(tab.path)
|
||||
);
|
||||
if (found) setActiveKey(found.key);
|
||||
}, [location.pathname]);
|
||||
|
||||
// 判断当前路由是否需要展示菜单
|
||||
const showMenu = menuPaths.some((path) =>
|
||||
path === "/"
|
||||
? location.pathname === "/"
|
||||
: location.pathname.startsWith(path)
|
||||
);
|
||||
if (!showMenu) return null;
|
||||
|
||||
return (
|
||||
<TabBar
|
||||
style={{ background: "#fff" }}
|
||||
activeKey={activeKey}
|
||||
onChange={(key) => {
|
||||
setActiveKey(key);
|
||||
const tab = tabs.find((t) => t.key === key);
|
||||
if (tab && tab.path) navigate(tab.path);
|
||||
}}
|
||||
>
|
||||
{tabs.map((item) => (
|
||||
<TabBar.Item key={item.key} icon={item.icon} title={item.title} />
|
||||
))}
|
||||
</TabBar>
|
||||
);
|
||||
};
|
||||
|
||||
export default MeauMobile;
|
||||
Reference in New Issue
Block a user