Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ee802d63
authored
Jul 29, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录时,直接从用户信息中,获取菜单。目的:加快首页的加载速度
parent
40a93caf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
9 deletions
+2
-9
src/api/login/index.ts
+0
-5
src/store/modules/permission.ts
+1
-4
src/store/modules/user.ts
+1
-0
No files found.
src/api/login/index.ts
View file @
ee802d63
...
...
@@ -37,11 +37,6 @@ export const getInfo = () => {
return
request
.
get
({
url
:
'/system/auth/get-permission-info'
})
}
// 路由
export
const
getAsyncRoutes
=
()
=>
{
return
request
.
get
({
url
:
'/system/auth/list-menus'
})
}
//获取登录验证码
export
const
sendSmsCode
=
(
data
:
SmsCodeVO
)
=>
{
return
request
.
post
({
url
:
'/system/auth/send-sms-code'
,
data
})
...
...
src/store/modules/permission.ts
View file @
ee802d63
...
...
@@ -3,7 +3,6 @@ import { store } from '../index'
import
{
cloneDeep
}
from
'lodash-es'
import
remainingRouter
from
'@/router/modules/remaining'
import
{
generateRoute
,
flatMultiLevelRoutes
}
from
'@/utils/routerHelper'
import
{
getAsyncRoutes
}
from
'@/api/login'
import
{
CACHE_KEY
,
useCache
}
from
'@/hooks/web/useCache'
const
{
wsCache
}
=
useCache
()
...
...
@@ -34,12 +33,10 @@ export const usePermissionStore = defineStore('permission', {
actions
:
{
async
generateRoutes
():
Promise
<
unknown
>
{
return
new
Promise
<
void
>
(
async
(
resolve
)
=>
{
// 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取
let
res
:
AppCustomRouteRecordRaw
[]
if
(
wsCache
.
get
(
CACHE_KEY
.
ROLE_ROUTERS
))
{
res
=
wsCache
.
get
(
CACHE_KEY
.
ROLE_ROUTERS
)
as
AppCustomRouteRecordRaw
[]
}
else
{
res
=
await
getAsyncRoutes
()
wsCache
.
set
(
CACHE_KEY
.
ROLE_ROUTERS
,
res
)
}
const
routerMap
:
AppRouteRecordRaw
[]
=
generateRoute
(
res
as
AppCustomRouteRecordRaw
[])
// 动态路由,404一定要放到最后面
...
...
src/store/modules/user.ts
View file @
ee802d63
...
...
@@ -58,6 +58,7 @@ export const useUserStore = defineStore('admin-user', {
this
.
user
=
userInfo
.
user
this
.
isSetUser
=
true
wsCache
.
set
(
CACHE_KEY
.
USER
,
userInfo
)
wsCache
.
set
(
CACHE_KEY
.
ROLE_ROUTERS
,
userInfo
.
menus
)
},
async
loginOut
()
{
await
loginOut
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment