refactor(core): 移除未使用的依赖和代码优化
- 移除 react-router-dom 依赖,因项目不再使用路由功能 - 移除未使用的 isArray 导入,统一使用 toArray 进行数组转换 - 移除未使用的 useNavigate 和 useSearchParams 钩子 - 从 commonUtils 中移除未使用的通知和模态框工具函数 - 更新 NavMenu 组件中菜单项的处理逻辑,使用 toArray 替代 isArray 检查 - 移除 Header 中的时间戳显示,并更新侧边栏样式配置 - 调整 Sider 组件的宽度设置,优化响应式布局 - 移除 HashRouter 包装器,简化应用启动流程 - 添加自定义 CSS 样式以改进侧边栏触发器的高度
This commit is contained in:
@@ -27,7 +27,6 @@
|
|||||||
"qs": "^6.14.1",
|
"qs": "^6.14.1",
|
||||||
"react": "^19.2.3",
|
"react": "^19.2.3",
|
||||||
"react-dom": "^19.2.3",
|
"react-dom": "^19.2.3",
|
||||||
"react-router-dom": "^6.30.3",
|
|
||||||
"valtio": "^2.3.0",
|
"valtio": "^2.3.0",
|
||||||
"zustand": "^5.0.9"
|
"zustand": "^5.0.9"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -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 |
@@ -5,7 +5,7 @@ import { asideMenuConfig } from '@/configs/menuConfig';
|
|||||||
import { getHash, navigate } from '@/router/routerUtils';
|
import { getHash, navigate } from '@/router/routerUtils';
|
||||||
import { useAuthStore } from '@/store/AuthStore';
|
import { useAuthStore } from '@/store/AuthStore';
|
||||||
import { useCompanyStore } from '@/store/CompanyStore';
|
import { useCompanyStore } from '@/store/CompanyStore';
|
||||||
import { isArray, toArray } from '@/utils/common';
|
import { toArray } from '@/utils/common';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
onCallback?: () => void;
|
onCallback?: () => void;
|
||||||
@@ -32,23 +32,23 @@ const NavMenu: React.FC<IProps> = (props) => {
|
|||||||
label: itemName,
|
label: itemName,
|
||||||
title: itemName,
|
title: itemName,
|
||||||
};
|
};
|
||||||
if (isArray(item.children)) {
|
|
||||||
obj.children = [];
|
obj.children = [];
|
||||||
item.children?.forEach((el: any) => {
|
toArray(item.children).forEach((el: any) => {
|
||||||
// ! 添加权限判断
|
// ! 添加权限判断
|
||||||
if (!el.hideInMenu && (!el.auth || (auth && el.auth.split(',').some((key: string) => auth?.[key.trim()])))) {
|
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')) {
|
if (!el.auth && (company.staff_type == '3' || company.staff_type == '4')) {
|
||||||
//
|
//
|
||||||
} else {
|
} else {
|
||||||
const elName = el.name;
|
const elName = el.name;
|
||||||
if (el.target && el.path) {
|
if (el.target && el.path) {
|
||||||
newWindowUrl[el.path] = { target: el.target };
|
newWindowUrl[el.path] = { target: el.target };
|
||||||
}
|
|
||||||
obj.children.push({ key: el.path, icon: el.icon, label: elName, title: elName });
|
|
||||||
}
|
}
|
||||||
|
obj.children.push({ key: el.path, icon: el.icon, label: elName, title: elName });
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (obj.children.length) {
|
if (obj.children.length) {
|
||||||
arr.push(obj);
|
arr.push(obj);
|
||||||
}
|
}
|
||||||
@@ -101,10 +101,9 @@ const NavMenu: React.FC<IProps> = (props) => {
|
|||||||
onOpenChange={(openKeys) => {
|
onOpenChange={(openKeys) => {
|
||||||
setOpenKeys(openKeys);
|
setOpenKeys(openKeys);
|
||||||
}}
|
}}
|
||||||
// style={{ width: '100%' }}
|
inlineIndent={window.dfConfig.isPhone ? undefined : 16}
|
||||||
selectedKeys={[hash]}
|
selectedKeys={[hash]}
|
||||||
openKeys={openKeys}
|
openKeys={openKeys}
|
||||||
// key={`${openKeys[0]}_${lo.pathname}`}
|
|
||||||
mode='inline'
|
mode='inline'
|
||||||
items={menuOptions}
|
items={menuOptions}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,3 +8,8 @@ body {
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cf-sider .ant-layout-sider-trigger {
|
||||||
|
height: 34px;
|
||||||
|
line-height: 34px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const AppLayout = () => {
|
|||||||
) : (
|
) : (
|
||||||
<div style={{ fontWeight: 'bold', fontSize: 16 }}>{DefaultERPName}</div>
|
<div style={{ fontWeight: 'bold', fontSize: 16 }}>{DefaultERPName}</div>
|
||||||
)}
|
)}
|
||||||
{Date.now()}
|
{/* {Date.now()} */}
|
||||||
</GapBox>
|
</GapBox>
|
||||||
<div style={{ display: 'inline-flex' }}>
|
<div style={{ display: 'inline-flex' }}>
|
||||||
<HeaderUserInfo />
|
<HeaderUserInfo />
|
||||||
@@ -70,23 +70,24 @@ const AppLayout = () => {
|
|||||||
<Layout style={{ justifyContent: 'flex-start' }}>
|
<Layout style={{ justifyContent: 'flex-start' }}>
|
||||||
{isPhone ? null : (
|
{isPhone ? null : (
|
||||||
<Sider
|
<Sider
|
||||||
// collapsible
|
className='cf-sider'
|
||||||
|
collapsible
|
||||||
// onCollapse={(collapsed: boolean) => {
|
// onCollapse={(collapsed: boolean) => {
|
||||||
// setCollapsed(collapsed);
|
// setCollapsed(collapsed);
|
||||||
// }}
|
// }}
|
||||||
style={{
|
style={{
|
||||||
background: '#fff',
|
background: '#fff',
|
||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
// height: `calc(100vh - ${headerHeight}px)`,
|
height: `calc(100vh - ${headerHeight}px)`,
|
||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
// zIndex: 1000,
|
// zIndex: 1000,
|
||||||
left: 0,
|
left: 0,
|
||||||
// top: headerHeight,
|
top: headerHeight,
|
||||||
}}
|
}}
|
||||||
width={200}
|
width={180}
|
||||||
// width={window?.dfConfig?.language == 'zh-cn' ? 100 : 240}
|
// width={window?.dfConfig?.language == 'zh-cn' ? 100 : 240}
|
||||||
// collapsed={collapsed}
|
// collapsed={collapsed}
|
||||||
// collapsedWidth={60}
|
collapsedWidth={60}
|
||||||
>
|
>
|
||||||
<NavMenu />
|
<NavMenu />
|
||||||
{/* <NavMenuCard left={100} /> */}
|
{/* <NavMenuCard left={100} /> */}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import { HashRouter } from 'react-router-dom';
|
|
||||||
import App from './App.tsx';
|
import App from './App.tsx';
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
// <StrictMode>
|
// <StrictMode>
|
||||||
<HashRouter>
|
<App />,
|
||||||
<App />,
|
|
||||||
</HashRouter>,
|
|
||||||
// </StrictMode>,
|
// </StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Button, DatePicker, Input, Select } from 'antd';
|
import { Button, DatePicker, Input, Select } from 'antd';
|
||||||
import { stringify } from 'qs';
|
import { stringify } from 'qs';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { FormItemPlugin, FormPlugin } from '@/components/FormPlugin';
|
import { FormItemPlugin, FormPlugin } from '@/components/FormPlugin';
|
||||||
import { GapBox } from '@/components/GapBox';
|
import { GapBox } from '@/components/GapBox';
|
||||||
import PageContainerPlugin from '@/components/PageContainer/PageContainerPlugin';
|
import PageContainerPlugin from '@/components/PageContainer/PageContainerPlugin';
|
||||||
@@ -34,7 +33,6 @@ const CompanyListForm: React.FC = () => {
|
|||||||
const [ajaxData, setAjaxData] = useState<IAjaxData>({ count: 0, data: [] });
|
const [ajaxData, setAjaxData] = useState<IAjaxData>({ count: 0, data: [] });
|
||||||
const [showMoreSearch, setShowMoreSearch] = useState(false);
|
const [showMoreSearch, setShowMoreSearch] = useState(false);
|
||||||
const CompanyEditModalRef = useRef<ICompanyEditModalType>(null);
|
const CompanyEditModalRef = useRef<ICompanyEditModalType>(null);
|
||||||
const nav = useNavigate();
|
|
||||||
|
|
||||||
const { loading: userLoading, request: userRequest } = useRequest(CompanyServices.getCompanyList, {
|
const { loading: userLoading, request: userRequest } = useRequest(CompanyServices.getCompanyList, {
|
||||||
onSuccessCodeZero: (res) => {
|
onSuccessCodeZero: (res) => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Button, DatePicker, Input, Select } from 'antd';
|
import { Button, DatePicker, Input, Select } from 'antd';
|
||||||
import { stringify } from 'qs';
|
import { stringify } from 'qs';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
|
||||||
import { FormItemPlugin, FormPlugin } from '@/components/FormPlugin';
|
import { FormItemPlugin, FormPlugin } from '@/components/FormPlugin';
|
||||||
import { GapBox } from '@/components/GapBox';
|
import { GapBox } from '@/components/GapBox';
|
||||||
import PageContainerPlugin from '@/components/PageContainer/PageContainerPlugin';
|
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 type { IAjaxDataBase, IParamsBase } from '@/interfaces/common';
|
||||||
import CompanySelect from '@/pages/Company/List/components/CompanySelect';
|
import CompanySelect from '@/pages/Company/List/components/CompanySelect';
|
||||||
import { type IUserEditModalType, UserEditModal } from '@/pages/User/List/components/UserEditModal';
|
import { type IUserEditModalType, UserEditModal } from '@/pages/User/List/components/UserEditModal';
|
||||||
|
import { getURLSearchParams } from '@/router/routerUtils';
|
||||||
import { UserServices } from '@/services/UserServices';
|
import { UserServices } from '@/services/UserServices';
|
||||||
import { useAuthStore } from '@/store/AuthStore';
|
import { useAuthStore } from '@/store/AuthStore';
|
||||||
import { tableFixedByPhone, toArray } from '@/utils/common';
|
import { tableFixedByPhone, toArray } from '@/utils/common';
|
||||||
@@ -38,7 +38,7 @@ const UserListForm: React.FC = () => {
|
|||||||
const [ajaxData, setAjaxData] = useState<IAjaxData>({ count: 0, data: [] });
|
const [ajaxData, setAjaxData] = useState<IAjaxData>({ count: 0, data: [] });
|
||||||
const [showMoreSearch, setShowMoreSearch] = useState(false);
|
const [showMoreSearch, setShowMoreSearch] = useState(false);
|
||||||
const UserEditModalRef = useRef<IUserEditModalType>(null);
|
const UserEditModalRef = useRef<IUserEditModalType>(null);
|
||||||
const [searchParams] = useSearchParams();
|
const searchParams = getURLSearchParams();
|
||||||
const company_id = searchParams.get('company_id');
|
const company_id = searchParams.get('company_id');
|
||||||
const [params, setParams] = useState<IParams>({ curr_page: 1, page_count: 20, company_id });
|
const [params, setParams] = useState<IParams>({ curr_page: 1, page_count: 20, company_id });
|
||||||
|
|
||||||
|
|||||||
@@ -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 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[]) => {
|
export const cartesianProduct = (...arrays: any[]) => {
|
||||||
let result: any[] = [];
|
let result: any[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user