@yyp92-cli/template-react-pc 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@ import type { MenuProps } from 'antd';
|
|
|
4
4
|
import {useNavigate, useLocation} from 'react-router-dom'
|
|
5
5
|
import {ComponentMap} from '@/router/router'
|
|
6
6
|
import { menusStore } from '@/store/menus'
|
|
7
|
+
import { localCache } from '@/utils'
|
|
8
|
+
import { LOGIN_TOKEN } from '@/global/constants'
|
|
7
9
|
|
|
8
10
|
import styles from './index.module.scss'
|
|
9
11
|
|
|
@@ -44,12 +46,19 @@ export const Side: React.FC<SideProps> = () => {
|
|
|
44
46
|
const newPathname = pathname.slice(1)
|
|
45
47
|
|
|
46
48
|
if (newPathname === '') {
|
|
47
|
-
const
|
|
48
|
-
const selectedKey = menus[0]?.children?.[0]?.key
|
|
49
|
+
const token = localCache.getCache(LOGIN_TOKEN)
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (token) {
|
|
52
|
+
const openKey = menus[0]?.key
|
|
53
|
+
const selectedKey = menus[0]?.children?.[0]?.key
|
|
54
|
+
|
|
55
|
+
setOpenKeys([openKey])
|
|
56
|
+
setSelectedKeys([selectedKey])
|
|
57
|
+
navigate(`/${menus[0]?.key}/${menus[0]?.children?.[0]?.key}`)
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
navigate('/login')
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
else {
|
|
55
64
|
const pathnameList = newPathname.split('/')
|
|
@@ -4,6 +4,8 @@ import type { MenuProps } from 'antd';
|
|
|
4
4
|
import {useNavigate, useLocation} from 'react-router-dom'
|
|
5
5
|
import {ComponentMap} from '@/router/router'
|
|
6
6
|
import { menusStore } from '@/store/menus'
|
|
7
|
+
import { localCache } from '@/utils'
|
|
8
|
+
import { LOGIN_TOKEN } from '@/global/constants'
|
|
7
9
|
|
|
8
10
|
import styles from './index.module.scss'
|
|
9
11
|
|
|
@@ -44,12 +46,19 @@ export const Side: React.FC<SideProps> = ({}) => {
|
|
|
44
46
|
const newPathname = pathname.slice(1)
|
|
45
47
|
|
|
46
48
|
if (newPathname === '') {
|
|
47
|
-
const
|
|
48
|
-
const selectedKey = menus[0]?.children?.[0]?.key
|
|
49
|
+
const token = localCache.getCache(LOGIN_TOKEN)
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (token) {
|
|
52
|
+
const openKey = menus[0]?.key
|
|
53
|
+
const selectedKey = menus[0]?.children?.[0]?.key
|
|
54
|
+
|
|
55
|
+
// setOpenKeys([openKey])
|
|
56
|
+
setSelectedKeys([selectedKey])
|
|
57
|
+
navigate(`/${menus[0]?.key}/${menus[0]?.children?.[0]?.key}`)
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
navigate('/login')
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
else {
|
|
55
64
|
const pathnameList = newPathname.split('/')
|