提交 1dd30bce authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 3cd06846
import { useState } from 'react' import { useState, useEffect, useMemo } from 'react'
import { Outlet, NavLink, useLocation } from 'react-router' import { Outlet, NavLink, useLocation } from 'react-router'
import { import {
CircleArrowRight, CircleArrowRight,
...@@ -26,6 +26,7 @@ type MenuItem = Required<MenuProps>['items'][number] ...@@ -26,6 +26,7 @@ type MenuItem = Required<MenuProps>['items'][number]
export default function DataLayout() { export default function DataLayout() {
const [collapsed, setCollapsed] = useState(false) const [collapsed, setCollapsed] = useState(false)
const [openKeys, setOpenKeys] = useState<string[]>([])
const toggleCollapsed = () => { const toggleCollapsed = () => {
setCollapsed(!collapsed) setCollapsed(!collapsed)
...@@ -34,108 +35,129 @@ export default function DataLayout() { ...@@ -34,108 +35,129 @@ export default function DataLayout() {
const location = useLocation() const location = useLocation()
const selectedKeys = [location.pathname] const selectedKeys = [location.pathname]
const menus: MyMenuItem[] = [ const menus: MyMenuItem[] = useMemo(() => {
{ return [
icon: <Database />, {
name: '数据采集', icon: <Database />,
path: '/data/write', name: '数据采集',
children: [ path: '/data/write',
{ name: '我的数据集', path: '/data/write/my' }, children: [
{ name: '数据复制', path: '/data/write/copy' }, { name: '我的数据集', path: '/data/write/my' },
{ name: '数据导入', path: '/data/write/upload' }, { name: '数据复制', path: '/data/write/copy' },
{ name: '数据爬虫', path: '/data/write/crawler', disabled: true }, { name: '数据导入', path: '/data/write/upload' },
{ name: 'API数据采集', path: '/data/write/api', disabled: true }, { name: '数据爬虫', path: '/data/write/crawler', disabled: true },
{ name: '数据库对接', path: '/data/write/db', disabled: true }, { name: 'API数据采集', path: '/data/write/api', disabled: true },
{ name: '内置数据集管理', path: '/data/write/built' }, { name: '数据库对接', path: '/data/write/db', disabled: true },
], { name: '内置数据集管理', path: '/data/write/built' },
}, ],
{ },
icon: <SearchCheck />, {
name: '数据理解与探索', icon: <SearchCheck />,
path: '/data/read', name: '数据理解与探索',
children: [ path: '/data/read',
{ name: '数据理解', path: '/data/read/understanding' }, children: [
{ name: '数据探索', path: '/data/read/exploration' }, { name: '数据理解', path: '/data/read/understanding' },
], { name: '数据探索', path: '/data/read/exploration' },
}, ],
{ },
icon: <Filter />, {
name: '数据预处理', icon: <Filter />,
path: '/data/preprocess', name: '数据预处理',
children: [ path: '/data/preprocess',
{ name: '缺失值处理', path: '/data/preprocess/null' }, children: [
{ name: '重复值处理', path: '/data/preprocess/repeat' }, { name: '缺失值处理', path: '/data/preprocess/null' },
{ name: '过大值处理', path: '/data/preprocess/max' }, { name: '重复值处理', path: '/data/preprocess/repeat' },
{ name: '过小值处理', path: '/data/preprocess/min' }, { name: '过大值处理', path: '/data/preprocess/max' },
{ name: '逻辑错误值处理', path: '/data/preprocess/error' }, { name: '过小值处理', path: '/data/preprocess/min' },
{ name: '数据拆分', path: '/data/preprocess/split' }, { name: '逻辑错误值处理', path: '/data/preprocess/error' },
{ name: '数据去空格', path: '/data/preprocess/space' }, { name: '数据拆分', path: '/data/preprocess/split' },
{ name: '数据去标点', path: '/data/preprocess/symbol' }, { name: '数据去空格', path: '/data/preprocess/space' },
{ name: '数据类型转换', path: '/data/preprocess/type' }, { name: '数据去标点', path: '/data/preprocess/symbol' },
{ name: '数据排序', path: '/data/preprocess/sort' }, { name: '数据类型转换', path: '/data/preprocess/type' },
{ name: '数据拼接', path: '/data/preprocess/splice' }, { name: '数据排序', path: '/data/preprocess/sort' },
], { name: '数据拼接', path: '/data/preprocess/splice' },
}, ],
{ },
icon: <Bolt />, {
name: '数据加工', icon: <Bolt />,
path: '/data/process', name: '数据加工',
children: [ path: '/data/process',
{ name: '值映射', path: '/data/process/mapping' }, children: [
{ name: '数据分箱', path: '/data/process/binning' }, { name: '值映射', path: '/data/process/mapping' },
{ name: '数据分组', path: '/data/process/group' }, { name: '数据分箱', path: '/data/process/binning' },
{ name: '数据脱敏', path: '/data/process/desensitization' }, { name: '数据分组', path: '/data/process/group' },
{ name: '日期计算', path: '/data/process/date' }, { name: '数据脱敏', path: '/data/process/desensitization' },
{ name: '文本计算', path: '/data/process/string' }, { name: '日期计算', path: '/data/process/date' },
{ name: '数值计算', path: '/data/process/number' }, { name: '文本计算', path: '/data/process/string' },
{ name: '逻辑计算', path: '/data/process/logic' }, { name: '数值计算', path: '/data/process/number' },
{ name: '数据透视', path: '/data/process/perspective' }, { name: '逻辑计算', path: '/data/process/logic' },
], { name: '数据透视', path: '/data/process/perspective' },
}, ],
{ },
icon: <Cone />, {
name: '数据挖掘', icon: <Cone />,
path: '/data/digging', name: '数据挖掘',
children: [ path: '/data/digging',
{ name: '线性回归', path: '/data/digging/1' }, children: [
{ name: '逻辑回归', path: '/data/digging/2' }, { name: '线性回归', path: '/data/digging/1' },
{ name: '决策树', path: '/data/digging/3' }, { name: '逻辑回归', path: '/data/digging/2' },
{ name: '随机森林', path: '/data/digging/4' }, { name: '决策树', path: '/data/digging/3' },
{ name: '支持向量机', path: '/data/digging/5' }, { name: '随机森林', path: '/data/digging/4' },
{ name: 'K-Means', path: '/data/digging/6' }, { name: '支持向量机', path: '/data/digging/5' },
{ name: '层次聚类', path: '/data/digging/7' }, { name: 'K-Means', path: '/data/digging/6' },
{ name: 'Apriori', path: '/data/digging/8' }, { name: '层次聚类', path: '/data/digging/7' },
{ name: 'FP-Growth', path: '/data/digging/9' }, { name: 'Apriori', path: '/data/digging/8' },
{ name: 'Holt-Winters', path: '/data/digging/10' }, { name: 'FP-Growth', path: '/data/digging/9' },
], { name: 'Holt-Winters', path: '/data/digging/10' },
}, ],
{ },
icon: <ChartArea />, {
name: '数据可视化组件', icon: <ChartArea />,
path: '/data/chart', name: '数据可视化组件',
children: [ path: '/data/chart',
{ name: '柱状图', path: '/data/chart/bar' }, children: [
{ name: '折线图', path: '/data/chart/2' }, { name: '柱状图', path: '/data/chart/bar' },
{ name: '饼状图', path: '/data/chart/3' }, { name: '折线图', path: '/data/chart/2' },
{ name: '雷达图', path: '/data/chart/4' }, { name: '饼状图', path: '/data/chart/3' },
{ name: '散点图', path: '/data/chart/5' }, { name: '雷达图', path: '/data/chart/4' },
{ name: '气泡图', path: '/data/chart/6' }, { name: '散点图', path: '/data/chart/5' },
{ name: '词云', path: '/data/chart/7' }, { name: '气泡图', path: '/data/chart/6' },
{ name: '地图', path: '/data/chart/8' }, { name: '词云', path: '/data/chart/7' },
{ name: '指标卡', path: '/data/chart/9' }, { name: '地图', path: '/data/chart/8' },
{ name: '漏斗图', path: '/data/chart/10' }, { name: '指标卡', path: '/data/chart/9' },
{ name: '直方图', path: '/data/chart/11' }, { name: '漏斗图', path: '/data/chart/10' },
{ name: '表格', path: '/data/chart/12' }, { name: '直方图', path: '/data/chart/11' },
{ name: '帕累托图', path: '/data/chart/13' }, { name: '表格', path: '/data/chart/12' },
{ name: '矩形树图', path: '/data/chart/14' }, { name: '帕累托图', path: '/data/chart/13' },
], { name: '矩形树图', path: '/data/chart/14' },
}, ],
{ },
icon: <Wallpaper />, {
name: '数据可视化大屏', icon: <Wallpaper />,
path: '/data/screen', name: '数据可视化大屏',
}, path: '/data/screen',
] },
]
}, [])
useEffect(() => {
// 根据当前路径计算需要展开的菜单项
const calculateOpenKeys = (menus: MyMenuItem[]): string[] => {
for (const menu of menus) {
if (menu.children) {
if (menu.children.some((child) => child.path === location.pathname)) {
return [menu.path]
}
const result = calculateOpenKeys(menu.children)
if (result.length > 0) {
return [menu.path, ...result]
}
}
}
return []
}
setOpenKeys(calculateOpenKeys(menus))
}, [location.pathname, menus])
const menusToMenuItems = (menus: MyMenuItem[]): MenuItem[] => { const menusToMenuItems = (menus: MyMenuItem[]): MenuItem[] => {
return menus.map((item) => { return menus.map((item) => {
...@@ -165,7 +187,14 @@ export default function DataLayout() { ...@@ -165,7 +187,14 @@ export default function DataLayout() {
<span onClick={toggleCollapsed}>{collapsed ? <CircleArrowRight /> : <CircleArrowLeft />}</span> <span onClick={toggleCollapsed}>{collapsed ? <CircleArrowRight /> : <CircleArrowLeft />}</span>
</div> </div>
<div className="data-layout-sidebar-nav"> <div className="data-layout-sidebar-nav">
<Menu items={items} mode="inline" inlineCollapsed={collapsed} selectedKeys={selectedKeys} /> <Menu
items={items}
mode="inline"
inlineCollapsed={collapsed}
selectedKeys={selectedKeys}
openKeys={openKeys}
onOpenChange={setOpenKeys}
/>
</div> </div>
</div> </div>
<div className="data-layout-container"> <div className="data-layout-container">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论