refactor(core): 移除未使用的依赖和代码优化

- 移除 react-router-dom 依赖,因项目不再使用路由功能
- 移除未使用的 isArray 导入,统一使用 toArray 进行数组转换
- 移除未使用的 useNavigate 和 useSearchParams 钩子
- 从 commonUtils 中移除未使用的通知和模态框工具函数
- 更新 NavMenu 组件中菜单项的处理逻辑,使用 toArray 替代 isArray 检查
- 移除 Header 中的时间戳显示,并更新侧边栏样式配置
- 调整 Sider 组件的宽度设置,优化响应式布局
- 移除 HashRouter 包装器,简化应用启动流程
- 添加自定义 CSS 样式以改进侧边栏触发器的高度
This commit is contained in:
zhengw
2026-02-24 13:45:52 +08:00
parent ac3201028f
commit 20615ae0a3
10 changed files with 32 additions and 67 deletions

View File

@@ -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"
},

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -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<IProps> = (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<IProps> = (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}
/>

View File

@@ -8,3 +8,8 @@ body {
min-height: 100vh;
}
}
.cf-sider .ant-layout-sider-trigger {
height: 34px;
line-height: 34px;
}

View File

@@ -61,7 +61,7 @@ const AppLayout = () => {
) : (
<div style={{ fontWeight: 'bold', fontSize: 16 }}>{DefaultERPName}</div>
)}
{Date.now()}
{/* {Date.now()} */}
</GapBox>
<div style={{ display: 'inline-flex' }}>
<HeaderUserInfo />
@@ -70,23 +70,24 @@ const AppLayout = () => {
<Layout style={{ justifyContent: 'flex-start' }}>
{isPhone ? null : (
<Sider
// collapsible
className='cf-sider'
collapsible
// onCollapse={(collapsed: boolean) => {
// 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}
>
<NavMenu />
{/* <NavMenuCard left={100} /> */}

View File

@@ -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(
// <StrictMode>
<HashRouter>
<App />,
</HashRouter>,
<App />,
// </StrictMode>,
);

View File

@@ -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<IAjaxData>({ count: 0, data: [] });
const [showMoreSearch, setShowMoreSearch] = useState(false);
const CompanyEditModalRef = useRef<ICompanyEditModalType>(null);
const nav = useNavigate();
const { loading: userLoading, request: userRequest } = useRequest(CompanyServices.getCompanyList, {
onSuccessCodeZero: (res) => {

View File

@@ -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<IAjaxData>({ count: 0, data: [] });
const [showMoreSearch, setShowMoreSearch] = useState(false);
const UserEditModalRef = useRef<IUserEditModalType>(null);
const [searchParams] = useSearchParams();
const searchParams = getURLSearchParams();
const company_id = searchParams.get('company_id');
const [params, setParams] = useState<IParams>({ curr_page: 1, page_count: 20, company_id });

View File

@@ -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<any>;
// 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[] = [];