From 20615ae0a367d0519b64d967912a75a768252614 Mon Sep 17 00:00:00 2001 From: zhengw <247276359@qq.com> Date: Tue, 24 Feb 2026 13:45:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(core):=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E4=BE=9D=E8=B5=96=E5=92=8C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 react-router-dom 依赖,因项目不再使用路由功能 - 移除未使用的 isArray 导入,统一使用 toArray 进行数组转换 - 移除未使用的 useNavigate 和 useSearchParams 钩子 - 从 commonUtils 中移除未使用的通知和模态框工具函数 - 更新 NavMenu 组件中菜单项的处理逻辑,使用 toArray 替代 isArray 检查 - 移除 Header 中的时间戳显示,并更新侧边栏样式配置 - 调整 Sider 组件的宽度设置,优化响应式布局 - 移除 HashRouter 包装器,简化应用启动流程 - 添加自定义 CSS 样式以改进侧边栏触发器的高度 --- package.json | 1 - public/favicon.ico | Bin 0 -> 4286 bytes public/vite.svg | 1 - src/components/SiderMenu/NavMenu.tsx | 35 +++++++++++++-------------- src/index.css | 5 ++++ src/layouts/AppLayout.tsx | 13 +++++----- src/main.tsx | 5 +--- src/pages/Company/List/index.tsx | 2 -- src/pages/User/List/index.tsx | 4 +-- src/utils/commonUtils.ts | 33 ------------------------- 10 files changed, 32 insertions(+), 67 deletions(-) create mode 100644 public/favicon.ico delete mode 100644 public/vite.svg diff --git a/package.json b/package.json index 1b88958..844fc3c 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "qs": "^6.14.1", "react": "^19.2.3", "react-dom": "^19.2.3", - "react-router-dom": "^6.30.3", "valtio": "^2.3.0", "zustand": "^5.0.9" }, diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..047c9d007a8a0b30bf080f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l^G+hGa17Z zr(jQI48aaf{W*Qa^`UBH>P%|ykgn+@g#RBu^Cjh6XT2fxmQwRt|)8Ps4(p%!xrwOUfBS@1EV z7E>DOEr1zwvtVwPbks|w7Hb;xtEiz9x!7+Na**HDH3v0R)ND?rCahbnKu;<)n$v2& zYG0nO1-H(!n6#EGsuf^fOlquk*2U1Xi0W*aKsIu+k&}&_Y^t|qQ62VmmW8o>oh37N zPJ?`H>@3b%7a_KQbmk1ynMZZ#r^%X5`X0cpqDJe24Gq@cu(vuE8Fkhy(%6=e2DNL< z@U6>8ZN*xM*;bIcdj)B2%cvHpu`GoJgfqy|^(-e1_G=K+LYEd=)#yWG&Boa*^pQzA z+ajvBVy@tC1b<_9s-@krUM@Tz4ee`lbk=N_u4f7AW`PSlJp$)as_9-%HTD&B3mk%9 z-JL_XVtO9rXs}mpLmW`|EF&$T0b(_9zP5V_)!Q+@o`v9D08JUB#=X~@S3mq4Q_yg$ zV@*!AX~~@$@Ymp+&VhbVr^b;(8UgkkQae`CE&Gpvl~_L>vuebJylO$G19Nafx1hnk zoU~YL9m}ZBo<&X0h0u|P`Oa%ow>|mr`%U1U{TQr8Os(a~SE?;JRhsTq4s~~~qqcXo zL)-fd@M9p)rtQnKX&g`6YT?)RJ#EwVJ_)R{)jFT*(e*v$sB;32Ctz1O8hW2_Xzhg_9fntPXBsqbF(vUzATGs`DfpGdTLKqQjsM56e;!oLb0Komzb5D&-%U{i+8Z-D+G kil=|ZAQF5W{N_ICg!2MKM5rJV?L} \ No newline at end of file diff --git a/src/components/SiderMenu/NavMenu.tsx b/src/components/SiderMenu/NavMenu.tsx index 5c66a74..efcb2f1 100644 --- a/src/components/SiderMenu/NavMenu.tsx +++ b/src/components/SiderMenu/NavMenu.tsx @@ -5,7 +5,7 @@ import { asideMenuConfig } from '@/configs/menuConfig'; import { getHash, navigate } from '@/router/routerUtils'; import { useAuthStore } from '@/store/AuthStore'; import { useCompanyStore } from '@/store/CompanyStore'; -import { isArray, toArray } from '@/utils/common'; +import { toArray } from '@/utils/common'; interface IProps { onCallback?: () => void; @@ -32,23 +32,23 @@ const NavMenu: React.FC = (props) => { label: itemName, title: itemName, }; - if (isArray(item.children)) { - obj.children = []; - item.children?.forEach((el: any) => { - // ! 添加权限判断 - if (!el.hideInMenu && (!el.auth || (auth && el.auth.split(',').some((key: string) => auth?.[key.trim()])))) { - if (!el.auth && (company.staff_type == '3' || company.staff_type == '4')) { - // - } else { - const elName = el.name; - if (el.target && el.path) { - newWindowUrl[el.path] = { target: el.target }; - } - obj.children.push({ key: el.path, icon: el.icon, label: elName, title: elName }); + + obj.children = []; + toArray(item.children).forEach((el: any) => { + // ! 添加权限判断 + if (!el.hideInMenu && (!el.auth || (auth && el.auth.split(',').some((key: string) => auth?.[key.trim()])))) { + if (!el.auth && (company.staff_type == '3' || company.staff_type == '4')) { + // + } else { + const elName = el.name; + if (el.target && el.path) { + newWindowUrl[el.path] = { target: el.target }; } + obj.children.push({ key: el.path, icon: el.icon, label: elName, title: elName }); } - }); - } + } + }); + if (obj.children.length) { arr.push(obj); } @@ -101,10 +101,9 @@ const NavMenu: React.FC = (props) => { onOpenChange={(openKeys) => { setOpenKeys(openKeys); }} - // style={{ width: '100%' }} + inlineIndent={window.dfConfig.isPhone ? undefined : 16} selectedKeys={[hash]} openKeys={openKeys} - // key={`${openKeys[0]}_${lo.pathname}`} mode='inline' items={menuOptions} /> diff --git a/src/index.css b/src/index.css index 758ed6f..be52efa 100644 --- a/src/index.css +++ b/src/index.css @@ -8,3 +8,8 @@ body { min-height: 100vh; } } + +.cf-sider .ant-layout-sider-trigger { + height: 34px; + line-height: 34px; +} diff --git a/src/layouts/AppLayout.tsx b/src/layouts/AppLayout.tsx index 4aae76a..a8c1c0e 100644 --- a/src/layouts/AppLayout.tsx +++ b/src/layouts/AppLayout.tsx @@ -61,7 +61,7 @@ const AppLayout = () => { ) : (
{DefaultERPName}
)} - {Date.now()} + {/* {Date.now()} */}
@@ -70,23 +70,24 @@ const AppLayout = () => { {isPhone ? null : ( { // setCollapsed(collapsed); // }} style={{ background: '#fff', overflow: 'auto', - // height: `calc(100vh - ${headerHeight}px)`, + height: `calc(100vh - ${headerHeight}px)`, position: 'sticky', // zIndex: 1000, left: 0, - // top: headerHeight, + top: headerHeight, }} - width={200} + width={180} // width={window?.dfConfig?.language == 'zh-cn' ? 100 : 240} // collapsed={collapsed} - // collapsedWidth={60} + collapsedWidth={60} > {/* */} diff --git a/src/main.tsx b/src/main.tsx index 52bb540..f329669 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,12 +1,9 @@ import { createRoot } from 'react-dom/client'; import './index.css'; -import { HashRouter } from 'react-router-dom'; import App from './App.tsx'; createRoot(document.getElementById('root')!).render( // - - , - , + , // , ); diff --git a/src/pages/Company/List/index.tsx b/src/pages/Company/List/index.tsx index 0302dd3..b1adbd2 100644 --- a/src/pages/Company/List/index.tsx +++ b/src/pages/Company/List/index.tsx @@ -1,7 +1,6 @@ import { Button, DatePicker, Input, Select } from 'antd'; import { stringify } from 'qs'; import { useEffect, useRef, useState } from 'react'; -import { useNavigate } from 'react-router-dom'; import { FormItemPlugin, FormPlugin } from '@/components/FormPlugin'; import { GapBox } from '@/components/GapBox'; import PageContainerPlugin from '@/components/PageContainer/PageContainerPlugin'; @@ -34,7 +33,6 @@ const CompanyListForm: React.FC = () => { const [ajaxData, setAjaxData] = useState({ count: 0, data: [] }); const [showMoreSearch, setShowMoreSearch] = useState(false); const CompanyEditModalRef = useRef(null); - const nav = useNavigate(); const { loading: userLoading, request: userRequest } = useRequest(CompanyServices.getCompanyList, { onSuccessCodeZero: (res) => { diff --git a/src/pages/User/List/index.tsx b/src/pages/User/List/index.tsx index 963d0cb..013262a 100644 --- a/src/pages/User/List/index.tsx +++ b/src/pages/User/List/index.tsx @@ -1,7 +1,6 @@ import { Button, DatePicker, Input, Select } from 'antd'; import { stringify } from 'qs'; import { useEffect, useRef, useState } from 'react'; -import { useSearchParams } from 'react-router-dom'; import { FormItemPlugin, FormPlugin } from '@/components/FormPlugin'; import { GapBox } from '@/components/GapBox'; import PageContainerPlugin from '@/components/PageContainer/PageContainerPlugin'; @@ -14,6 +13,7 @@ import { stateOptions, userSex, userState } from '@/configs/usersConfig'; import type { IAjaxDataBase, IParamsBase } from '@/interfaces/common'; import CompanySelect from '@/pages/Company/List/components/CompanySelect'; import { type IUserEditModalType, UserEditModal } from '@/pages/User/List/components/UserEditModal'; +import { getURLSearchParams } from '@/router/routerUtils'; import { UserServices } from '@/services/UserServices'; import { useAuthStore } from '@/store/AuthStore'; import { tableFixedByPhone, toArray } from '@/utils/common'; @@ -38,7 +38,7 @@ const UserListForm: React.FC = () => { const [ajaxData, setAjaxData] = useState({ count: 0, data: [] }); const [showMoreSearch, setShowMoreSearch] = useState(false); const UserEditModalRef = useRef(null); - const [searchParams] = useSearchParams(); + const searchParams = getURLSearchParams(); const company_id = searchParams.get('company_id'); const [params, setParams] = useState({ curr_page: 1, page_count: 20, company_id }); diff --git a/src/utils/commonUtils.ts b/src/utils/commonUtils.ts index f8428fd..0b02fc9 100644 --- a/src/utils/commonUtils.ts +++ b/src/utils/commonUtils.ts @@ -62,39 +62,6 @@ export const navigateBackIfEmpty = (dataLength: number, curr_page: number, page: /** 检测支持语言 */ export const checkSupportLanguage = (lang?: string | null) => (lang && ['zh-cn', 'en'].includes(lang) ? lang : 'zh-cn'); -// export const notificationFun = (option: { -// title?: React.ReactNode; -// type?: 'info' | 'success' | 'warning' | 'error' | 'normal'; -// content?: React.ReactNode; -// }) => { -// const { title = t('系统提示'), type = 'success' } = option; -// Notification[type]({ -// title: title, -// content: option.content || '', -// }); -// }; - -// export const modalFun = (option: { -// title?: React.ReactNode; -// type?: 'info' | 'success' | 'warning' | 'error' | 'confirm'; -// content?: React.ReactNode; -// onOk: (e?: MouseEvent) => Promise; -// okText?: string; -// okButtonProps?: ButtonProps; -// }) => { -// const { title = t('系统提示'), type = 'confirm', onOk } = option; -// Modal[type]({ -// title: title, -// content: option.content || '', -// okButtonProps: { -// autoFocus: true, -// ...option.okButtonProps, -// }, -// onOk: onOk, -// okText: option.okText, -// }); -// }; - /** 笛卡尔积 */ export const cartesianProduct = (...arrays: any[]) => { let result: any[] = [];