File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ import Connection from './connection';
2525import Team from './team' ;
2626import Setting from '@/blocks/Setting' ;
2727
28+ // ----- utils -----
29+ import { generateUrl } from '@/utils/url' ;
30+
2831import styles from './index.less' ;
2932import { useUpdateEffect } from '@/hooks' ;
3033
@@ -68,7 +71,9 @@ function MainPage() {
6871 const [ navConfig , setNavConfig ] = useState < INavItem [ ] > ( initNavConfig ) ;
6972 const [ userInfo , setUserInfo ] = useState < ILoginUser > ( ) ;
7073 const mainPageActiveTab = useMainStore ( ( state ) => state . mainPageActiveTab ) ;
71- const [ activeNavKey , setActiveNavKey ] = useState < string > ( window . location . pathname . split ( '/' ) [ 1 ] || mainPageActiveTab ) ;
74+ const [ activeNavKey , setActiveNavKey ] = useState < string > (
75+ __ENV__ === 'desktop' ? mainPageActiveTab : window . location . pathname . split ( '/' ) [ 1 ] || mainPageActiveTab ,
76+ ) ;
7277
7378 useEffect ( ( ) => {
7479 handleInitPage ( ) ;
@@ -88,7 +93,7 @@ function MainPage() {
8893 navConfig [ activeIndex ] . isLoad = true ;
8994 setNavConfig ( [ ...navConfig ] ) ;
9095 // 桌面端跳转这里应该要换TODO:
91- const href = window . location . origin + '/' + activeNavKey ;
96+ const href = generateUrl ( activeNavKey ) ;
9297 window . history . pushState ( { } , '' , href ) ;
9398 }
9499 } , [ activeNavKey ] ) ;
Original file line number Diff line number Diff line change @@ -73,3 +73,16 @@ export function formatParams(obj: { [key: string]: any }) {
7373 } ) ;
7474 return params . toString ( ) ;
7575}
76+
77+ /**
78+ * 生成url
79+ * @param key
80+ * @returns
81+ */
82+
83+ export function generateUrl ( key : string ) {
84+ if ( __ENV__ === 'desktop' ) {
85+ return window . location . href + '/#/' + key ;
86+ }
87+ return window . location . origin + '/' + key ;
88+ }
You can’t perform that action at this time.
0 commit comments