From b4944d2db2e8bf282eec01e7c1adaaae6be350fc Mon Sep 17 00:00:00 2001 From: dark Date: Sun, 23 Jun 2024 15:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B8=83=E5=B1=80=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/breadcrumb/index.tsx | 22 ++++++---- src/layout/RootLayout.tsx | 88 +++++++++++++++++++------------------ src/pages/system/roles/index.tsx | 6 +-- src/pages/system/roles/style.ts | 4 +- src/store/system.ts | 2 +- src/utils/index.ts | 4 ++ 6 files changed, 70 insertions(+), 56 deletions(-) diff --git a/src/components/breadcrumb/index.tsx b/src/components/breadcrumb/index.tsx index 4bda634..6bf3cf0 100644 --- a/src/components/breadcrumb/index.tsx +++ b/src/components/breadcrumb/index.tsx @@ -7,9 +7,10 @@ import { useStyle } from './style.ts' export const PageBreadcrumb = memo((props: BreadcrumbProps & { showIcon?: boolean; + menusFlatten?: any; }) => { - const { styles }= useStyle() + const { styles } = useStyle() const nav = useNavigate() const { items = [], showIcon = true, ...other } = props @@ -36,13 +37,18 @@ export const PageBreadcrumb = memo((props: BreadcrumbProps & { { - nav({ - to: e.key - }) - } - }} - trigger={[ 'hover' ]}> + items, + onClick: (menu) => { + const info = props.menusFlatten.current?.find(item => item.path === menu.key) + if (info) { + // setOpenKeys([ info.path as string ]) + nav({ + to: info.path, + }) + } + } + }} + trigger={[ 'hover' ]}> { (!route.component || !route.path) ? {renderIcon(route.icon)}{route.name} diff --git a/src/layout/RootLayout.tsx b/src/layout/RootLayout.tsx index b137fcc..bdb7086 100644 --- a/src/layout/RootLayout.tsx +++ b/src/layout/RootLayout.tsx @@ -18,7 +18,7 @@ import type { MenuDataItem } from '@ant-design/pro-layout/es/typing' import { convertToMenu, flattenTree } from '@/utils' import { Flex, Menu, Space } from 'antd' import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons' -import { If } from 'react-if' +import { If, Then } from 'react-if' //根据menuData生成Breadcrumb所需的数据 const getBreadcrumbData = (menuData: MenuItem[], pathname: string) => { @@ -26,6 +26,7 @@ const getBreadcrumbData = (menuData: MenuItem[], pathname: string) => { const findItem = (menuData: any[], pathname: string) => { for (let i = 0; i < menuData.length; i++) { if (menuData[i].path === pathname) { + menuData[i].label ={ menuData[i].name} breadcrumbData.push(menuData[i]) return true } @@ -188,55 +189,58 @@ export default () => { > 0}> - - { - !collapsed &&
-

{currentMenu?.title}

-
- } + + + { + !collapsed &&
+

{currentMenu?.title}

+
+ } - { - setOpenKeys(keys) - }} - onClick={(menu) => { - const info = menusFlatten.current?.find(item => item.path === menu.key) - if (info) { - setOpenKeys([ info.path as string ]) - navigate({ - to: info.path, - }) - } + { + setOpenKeys(keys) + }} + onClick={(menu) => { + const info = menusFlatten.current?.find(item => item.path === menu.key) + if (info) { + // setOpenKeys([ info.path as string ]) + navigate({ + to: info.path, + }) + } - }} - items={convertToMenu((childMenuRef.current || []), (item => { - return { - ...item, - key: item.path, - label: item.title, - } - })) as any} - style={!collapsed ? { width: 210 } : {}} - /> -
{ - setCollapsed(!collapsed) - }}> - { - collapsed ? : - } -
- + }} + items={convertToMenu((childMenuRef.current || []), (item => { + return { + ...item, + key: item.path || item.meta.name, + label: item.title, + } + })) as any} + style={!collapsed ? { width: 210 } : {}} + /> +
{ + setCollapsed(!collapsed) + }}> + { + collapsed ? : + } +
+ +
diff --git a/src/pages/system/roles/index.tsx b/src/pages/system/roles/index.tsx index 1874c8b..b559a4e 100644 --- a/src/pages/system/roles/index.tsx +++ b/src/pages/system/roles/index.tsx @@ -3,7 +3,6 @@ import Switch from '@/components/switch' import { IMenu } from '@/types/system/menus' import { ActionType, - PageContainer, ProColumns, ProTable, BetaSchemaForm, ProFormColumnsType, @@ -25,6 +24,7 @@ import { Button, Form, Space, Spin, Table, Tree, Popconfirm } from 'antd' import { PlusOutlined } from '@ant-design/icons' import { menuDataAtom } from '@/store/system/menu.ts' import { getTreeCheckedStatus } from '@/utils/tree.ts' +import ListPageLayout from '@/layout/ListPageLayout.tsx' const MenuTree = (props: any) => { const { data: menuList, isLoading: menuLoading } = useAtomValue(menuDataAtom) @@ -139,7 +139,7 @@ const Roles = memo(() => { }, []) return ( - +
{ return isSuccess }} columns={columns as ProFormColumnsType[]}/> - + ) }) diff --git a/src/pages/system/roles/style.ts b/src/pages/system/roles/style.ts index 611958f..c0fb71e 100644 --- a/src/pages/system/roles/style.ts +++ b/src/pages/system/roles/style.ts @@ -14,8 +14,8 @@ export const useStyle = createStyles(({ token, css, cx, prefixCls }) => { min-width: 500px; ` const authHeight = css` - min-height: calc(100vh - 122px); - background-color: ${token.colorBgContainer}; + //min-height: calc(100vh - 122px); + //background-color: ${token.colorBgContainer}; ` return { diff --git a/src/store/system.ts b/src/store/system.ts index 3398b41..c2df969 100644 --- a/src/store/system.ts +++ b/src/store/system.ts @@ -46,6 +46,6 @@ export const getToken = () => { } export const setToken = (token: string) => { - console.log('settoken', token) + // console.log('settoken', token) updateAppData({ token }) } diff --git a/src/utils/index.ts b/src/utils/index.ts index f79f948..99014c3 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -151,9 +151,13 @@ export const unique = (arr: any[]): any[] => { } export const getValueCount = (obj: any, filterObj: any = {}) => { + // 获取对象中所有值的数量 let count = 0 for (const key in obj) { + if (['page', 'pageSize', 'pageIndex'].includes(key)){ + continue + } if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key]) { //如果是数组,则必须长度大于0 if (!filterObj?.[key]) {