Commit e64da9e7 authored by XieZhiXiong's avatar XieZhiXiong

feat: 完善首页侧边栏交互;添加默认跳转srm采购商首页逻辑

parent 5d627558
......@@ -16,6 +16,7 @@ import LRU from '@/utils/lru';
import { getMemberLoginReget } from './services/MemberV2Api';
import { getManagePaasSiteEnableMultiTenancy } from './services/ManageV2Api';
import { GlobalConfig } from './global/config';
import defaultHomePath from './utils/defaultHomePath';
const recent = new LRU(6);
recent.init();
......@@ -49,6 +50,7 @@ const whiteLists = [
// 登录后的路由白名单
const loginWhiteList = [
'/memberCenter/home',
'/memberCenter/home/index',
'/memberCenter/editMySelf'
]
......@@ -168,7 +170,7 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
console.log(pathname, 'pathname')
if (userLoginLists.includes(pathname)) {
// 当登录过, 并且尝试访问登录相关页面, 需重定向到首页
history.replace('/memberCenter/home')
history.replace(defaultHomePath())
return;
}
......
......@@ -33,3 +33,13 @@ export const SRM_HOME_TODO = {
'/memberCenter/afterService': '售后中心',
'/memberCenter/logisticsAbility': '物流中心',
};
/**
* src采购商首页路径
*/
export const SRM_PURCHASER_HOME_PATH = '/memberCenter/home/srmPurchaser';
/**
* 首页路径
*/
export const HOME_PATH = '/memberCenter/home/index';
\ No newline at end of file
......@@ -17,6 +17,7 @@ import MenuSlider from './components/MenuSlider'
import { getMatchMenu } from '@umijs/route-utils';
import { useGlobal } from '@/models/useGlobal';
import { MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons';
import { HOME_PATH, SRM_PURCHASER_HOME_PATH } from '@/constants/home';
export interface BasicLayoutProps extends ProLayoutProps {
breadcrumbNameMap: {
......@@ -60,7 +61,9 @@ const defaultFooterDom = (
/>
);
const DEFAULT_COLLAPSED_LIST = ["/memberCenter/noAuth"];
const HOME_PAGE_LIST = [HOME_PATH, SRM_PURCHASER_HOME_PATH];
const OTHER_PAGE_LIST = ["/memberCenter/noAuth"];
const DEFAULT_COLLAPSED_LIST = [...HOME_PAGE_LIST, ...OTHER_PAGE_LIST];
const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const {
......@@ -76,11 +79,11 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const [selectedKeys, setSelectedKeys] = useState<string[] | undefined>([]);
// 获取全局状态
const [globalState, globalDispatch] = useGlobal();
// const isHome = location.pathname === '/memberCenter/home'
// const isHome = location.pathname === HOME_PATH
const isHome = false
const handleMenuCollapse = (payload: boolean): void => {
if (DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
if (OTHER_PAGE_LIST.includes(location.pathname)) {
return;
}
setCollapsed(payload)
......@@ -168,7 +171,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
</Link>
)}
collapsed={collapsed}
collapsedButtonRender={(flag) => (DEFAULT_COLLAPSED_LIST.includes(location.pathname) ? null : flag ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />)}
collapsedButtonRender={(flag) => (OTHER_PAGE_LIST.includes(location.pathname) ? null : flag ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />)}
onCollapse={handleMenuCollapse}
disableContentMargin={currentRouter?.noMargin !== undefined}
breadcrumbRender={(routers = []) => [
......
......@@ -11,6 +11,7 @@ import { GlobalConfig } from '@/global/config'
import styles from '../styles/MenuSlider.less'
import { getRouters } from '@/utils/auth';
import { isDev } from '@/constants';
import defaultHomePath from '@/utils/defaultHomePath';
const { Sider } = Layout
const { SubMenu } = Menu;
......@@ -102,7 +103,7 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => {
return <>
<OuterSider {...props} />
<Sider theme="light" className={styles.menu_sider} width={props.collapseState ? 0 : 200} collapsedWidth={props.collapseState ? 0 : 80} collapsed={props.collapseState}>
<Link to={`/`} className={styles.logo}>
<Link to={defaultHomePath()} className={styles.logo}>
<img src={GlobalConfig.global.siteInfo.logo} />
</Link>
<div className={styles.menuTitle}>
......
......@@ -8,6 +8,7 @@ import { observer, inject } from 'mobx-react';
import CustomIcon from './CustomIcon';
import Icon from '@ant-design/icons';
import { ReactComponent as DefaultAvatar } from '@/assets/imgs/default_avatar.svg';
import defaultHomePath from '@/utils/defaultHomePath';
const { Sider } = Layout
export interface OuterSiderProps {
......@@ -56,7 +57,7 @@ const OuterSider: React.FC<OuterSiderProps> = observer((props) => {
return <>
<Sider collapsed={true} collapsedWidth={64} className={styles.wrapperSilder}>
<div className={styles.userPic}>
<Link to="/memberCenter/home">
<Link to={defaultHomePath()}>
{
props.UserStore.avatar
? <img src={props.UserStore.avatar} className={styles.avatar} />
......
......@@ -15,6 +15,7 @@ import { SOCKET_URL, PLATFORM_DOMAIN } from '@/constants';
import { GlobalConfig } from '@/global/config';
import { usePurchaseBidStore } from '@/store/purchaseBid';
import defaultHomePath from '@/utils/defaultHomePath';
// export type SiderTheme = 'light' | 'dark';
// export interface GlobalHeaderRightProps extends Partial<ConnectProps> {
......@@ -110,7 +111,7 @@ const GlobalHeaderRight: React.FC<{ SiteStore?: any, isHome: boolean }> = (props
return (
<div className={className}>
<div>
<Link to={"/memberCenter/home"} className={styles.container} style={isHome ? cacheStyle.isHome : {}}>
<Link to={defaultHomePath()} className={styles.container} style={isHome ? cacheStyle.isHome : {}}>
{
isHome && (
<img src={GlobalConfig.global.siteInfo.logo} style={cacheStyle.iamge} />
......
......@@ -4,6 +4,7 @@ import { CaretDownOutlined } from '@ant-design/icons';
import { getAuth, getCookieAuth, setAuth, setRouters } from '@/utils/auth';
import { postMemberLoginSwitchrole } from '@/services/MemberV2Api';
import { useIntl } from 'umi'
import defaultHomePath from '@/utils/defaultHomePath';
interface MemberRole {
memberRoleId: number;
......@@ -49,7 +50,7 @@ const Roles: React.FC = () => {
setAuth(res.data);
setRouters(res.data.auth);
setTimeout(() => {
window.location.replace('/memberCenter/home');
window.location.replace(defaultHomePath());
}, 800);
}).finally(() => {
msg();
......
......@@ -10,6 +10,7 @@ import NiceForm from '@/components/NiceForm';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { getAuth, setAuth } from '@/utils/auth';
import defaultHomePath from '@/utils/defaultHomePath';
import { initDetailSchema } from './schema';
import AreaSelect from '../../../components/AreaSelect';
import {
......@@ -262,7 +263,7 @@ const MemberForm: React.FC<MemberFormProps> = ({
} as any);
setUnsaved(false);
setTimeout(() => {
history.push('/memberCenter/home');
history.push(defaultHomePath());
}, 800);
}).finally(() => {
msg();
......
......@@ -45,7 +45,6 @@
&-content {
margin-left: -@margin-md;
padding-bottom: @padding-md / 2;
}
&-group {
......
......@@ -10,6 +10,7 @@ import NiceForm from '@/components/NiceForm';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { getAuth, setAuth } from '@/utils/auth';
import defaultHomePath from '@/utils/defaultHomePath';
import { initDetailSchema } from './schema';
import AreaSelect from '../../../components/AreaSelect';
import {
......@@ -262,7 +263,7 @@ const MemberForm: React.FC<MemberFormProps> = ({
} as any);
setUnsaved(false);
setTimeout(() => {
history.push('/memberCenter/home');
history.push(defaultHomePath());
}, 800);
}).finally(() => {
msg();
......
......@@ -11,6 +11,8 @@ import { setAuth, setRouters } from '@/utils/auth';
import { encryptedByAES, Base64 } from '@/utils/cryptoAes';
import { setUserCookie } from '@/utils/siteCookie';
import { omit } from '@/utils';
import defaultHomePath from '@/utils/defaultHomePath';
const intl = getIntl();
const LoginWrap: React.FC = () => {
const { redirect } = history.location.query
......@@ -33,7 +35,7 @@ const LoginWrap: React.FC = () => {
if (redirect) {
window.location.replace(decodeURIComponent(Base64.decode(redirect)))
} else {
window.location.replace('/memberCenter/home')
window.location.replace(defaultHomePath())
}
} else {
setLoginLoading(false)
......
......@@ -4,6 +4,8 @@ import { getIntl, history } from 'umi';
import { setAuth, setRouters } from '@/utils/auth';
import QRCode from 'qrcode';
import { postMemberLoginAuthUrl, postMemberLoginInfo } from '@/services/MemberV2Api';
import defaultHomePath from '@/utils/defaultHomePath';
const intl = getIntl();
const ScanLoginWrap: React.FC = () => {
const { redirect } = history.location.query
......@@ -70,7 +72,7 @@ const ScanLoginWrap: React.FC = () => {
if (redirect) {
window.location.replace(decodeURIComponent(atob(redirect)))
} else {
window.location.replace('/memberCenter/home')
window.location.replace(defaultHomePath())
}
console.log(redirect, 'redirect')
clearTimeout(timer.current)
......
......@@ -143,7 +143,8 @@ export const removeAuth = () => {
const HOME_URL = [
'/',
'/memberCenter/home'
'/memberCenter/home',
'/memberCenter/home/index',
]
export const asyncRouter = async (routeLists: {b: string[], u: string}[], routes: any[]) => {
......
import { SRM_PURCHASER_HOME_PATH, HOME_PATH } from '@/constants/home';
import { getAuth } from "./auth";
/**
* @description 返回默认首页路径,如果用户菜单中存在 srm采购商首页 则返回,否则返回之前的首页
* @returns 默认首页路径
*/
const defaultHomePath = (): string => {
const userAuth = getAuth();
if (userAuth.urls.includes(SRM_PURCHASER_HOME_PATH)) {
return SRM_PURCHASER_HOME_PATH;
}
return HOME_PATH;
};
export default defaultHomePath;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment