diff --git a/src/components/common/sidebar/SidebarFooter.tsx b/src/components/common/sidebar/SidebarFooter.tsx
index c3b7666..c7fec43 100644
--- a/src/components/common/sidebar/SidebarFooter.tsx
+++ b/src/components/common/sidebar/SidebarFooter.tsx
@@ -1,6 +1,6 @@
import React from 'react'
import Icon from '@ant-design/icons'
-import { getLoginStatus, getUsername, logout } from '@/utils/auth'
+import { getLoginStatus, getNickName, logout } from '@/utils/auth'
import { getRedirectUrl } from '@/utils/common'
import { notification } from 'antd'
import { COLOR_ERROR } from '@/constants/common.constants.ts'
@@ -11,7 +11,7 @@ const SidebarFooter: React.FC = () => {
const location = useLocation()
const navigate = useNavigate()
const [exiting, setExiting] = useState(false)
- const [username, setUsername] = useState('')
+ const [nickName, setNickName] = useState('')
const handleClickAvatar = () => {
if (getLoginStatus()) {
@@ -42,8 +42,8 @@ const SidebarFooter: React.FC = () => {
useEffect(() => {
if (getLoginStatus()) {
- void getUsername().then((username) => {
- setUsername(username)
+ void getNickName().then((nickName) => {
+ setNickName(nickName)
})
}
}, [loginStatus])
@@ -60,7 +60,7 @@ const SidebarFooter: React.FC = () => {
- {username}
+ {nickName}
{
description: (
<>
- 你好 {user.username}
+ 你好 {user.userInfo.nickName}
diff --git a/src/router/home.tsx b/src/router/home.tsx
index 50792a6..b0b7067 100644
--- a/src/router/home.tsx
+++ b/src/router/home.tsx
@@ -3,6 +3,7 @@ import React from 'react'
const home: RouteJsonObject[] = [
{
path: '',
+ absolutePath: '/',
id: 'home',
component: React.lazy(() => import('@/pages/home')),
name: '主页',
@@ -17,6 +18,7 @@ const home: RouteJsonObject[] = [
},
{
path: '/tools',
+ absolutePath: '/tools',
id: 'url-tools',
children: [
{
diff --git a/src/router/index.tsx b/src/router/index.tsx
index c570281..9e683e1 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -39,17 +39,20 @@ const root: RouteJsonObject[] = [
component: React.lazy(() => import('@/AuthRoute')),
children: [
{
- path: '/login',
+ path: 'login',
+ absolutePath: '/login',
id: 'login',
component: React.lazy(() => import('@/pages/Login'))
},
{
- path: '/loading',
+ path: 'loading',
+ absolutePath: '/loading',
id: 'loading',
component: React.lazy(() => import('@/components/common/LoadingMask'))
},
{
- path: '/tools',
+ path: 'tools',
+ absolutePath: '/tools',
id: 'toolsFramework',
component: React.lazy(() => import('@/pages/ToolsFramework')),
children: setTitle(tools, '氮工具'),
@@ -57,7 +60,8 @@ const root: RouteJsonObject[] = [
auth: false
},
{
- path: '/user',
+ path: 'user',
+ absolutePath: '/user',
id: 'userFramework',
component: React.lazy(() => import('@/pages/UserFramework')),
children: setTitle(user, '个人中心'),
@@ -66,6 +70,7 @@ const root: RouteJsonObject[] = [
},
{
path: '',
+ absolutePath: '/',
id: 'homeFramework',
component: React.lazy(() => import('@/pages/HomeFramework')),
children: home
diff --git a/src/router/tools.tsx b/src/router/tools.tsx
index 89a38ff..d771fa7 100644
--- a/src/router/tools.tsx
+++ b/src/router/tools.tsx
@@ -3,6 +3,7 @@ import React from 'react'
export const tools: RouteJsonObject[] = [
{
path: '',
+ absolutePath: '/tools',
id: 'tools',
component: React.lazy(() => import('@/pages/tools')),
icon: React.lazy(() => import('~icons/fatweb/home.jsx')),
@@ -12,6 +13,7 @@ export const tools: RouteJsonObject[] = [
},
{
path: 'all',
+ absolutePath: '/tools/all',
id: 'tools-all',
component: React.lazy(() => import('@/pages/tools')),
name: '全部工具',
@@ -22,6 +24,7 @@ export const tools: RouteJsonObject[] = [
},
{
path: 'translation',
+ absolutePath: '/tools/translation',
id: 'tools-translation',
component: React.lazy(() => import('@/pages/tools/Translation')),
name: '翻译',
diff --git a/src/utils/auth.ts b/src/utils/auth.ts
index c73a7f2..78cc186 100644
--- a/src/utils/auth.ts
+++ b/src/utils/auth.ts
@@ -54,12 +54,45 @@ export const requestUserInfo = async () => {
})
}
+export const getNickName = async () => {
+ const user = await getUserInfo()
+
+ return user.userInfo.nickName
+}
+
export const getUsername = async () => {
const user = await getUserInfo()
return user.username
}
+export const getPermissionPath = (): string[] => {
+ const s = getLocalStorage(STORAGE_USER_INFO_KEY)
+ if (s === null) {
+ return []
+ }
+
+ const user = JSON.parse(s) as UserWithInfoVo
+ const paths: string[] = []
+ user.menus.forEach((menu) => {
+ paths.join(menu.url)
+ })
+
+ return paths
+}
+
+export const getAuthRoute = (route: RouteJsonObject[]): RouteJsonObject[] => {
+ return route.map((value) => {
+ if (value.auth) {
+ value.path
+ }
+ if (value.children) {
+ value.children = getAuthRoute(value.children)
+ }
+ return value
+ })
+}
+
export const getCaptchaSrc = () => {
captcha = getCaptcha(300, 150, 4)
return captcha.base64Src