Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
intelligent_qp_manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
intelligent_qp_manager
Commits
c09a8dd5
Commit
c09a8dd5
authored
Oct 16, 2024
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态路由相关问题修改
parent
589f06b7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
19 deletions
+40
-19
pageEnum.ts
src/enums/pageEnum.ts
+1
-1
permissionGuard.ts
src/router/guard/permissionGuard.ts
+3
-2
index.ts
src/router/routes/index.ts
+9
-9
permission.ts
src/store/modules/permission.ts
+11
-2
user.ts
src/store/modules/user.ts
+14
-2
LoginForm.vue
src/views/sys/login/LoginForm.vue
+2
-3
No files found.
src/enums/pageEnum.ts
View file @
c09a8dd5
...
...
@@ -2,7 +2,7 @@ export enum PageEnum {
// basic login path
BASE_LOGIN
=
'/login'
,
// basic home path
BASE_HOME
=
'/
system/user
'
,
BASE_HOME
=
'/
dashboard
'
,
// error page path
ERROR_PAGE
=
'/exception'
,
// error log page path
...
...
src/router/guard/permissionGuard.ts
View file @
c09a8dd5
...
...
@@ -7,17 +7,18 @@ import { useUserStoreWithOut } from '@/store/modules/user';
import
{
PAGE_NOT_FOUND_ROUTE
}
from
'@/router/routes/basic'
;
import
{
RootRoute
}
from
'@/router/routes'
;
//
import { RootRoute } from '@/router/routes';
const
LOGIN_PATH
=
PageEnum
.
BASE_LOGIN
;
const
ROOT_PATH
=
RootRoute
.
path
;
//
const ROOT_PATH = RootRoute.path;
const
whitePathList
:
PageEnum
[]
=
[
LOGIN_PATH
];
export
function
createPermissionGuard
(
router
:
Router
)
{
const
userStore
=
useUserStoreWithOut
();
const
permissionStore
=
usePermissionStoreWithOut
();
const
ROOT_PATH
=
userStore
.
getUserInfo
.
homePath
;
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
if
(
from
.
path
===
ROOT_PATH
&&
...
...
src/router/routes/index.ts
View file @
c09a8dd5
...
...
@@ -20,14 +20,14 @@ Object.keys(modules).forEach((key) => {
export
const
asyncRoutes
=
[
PAGE_NOT_FOUND_ROUTE
,
...
routeModuleList
];
// 根路由
export
const
RootRoute
:
AppRouteRecordRaw
=
{
path
:
'/'
,
name
:
'Root'
,
redirect
:
PageEnum
.
BASE_HOME
,
meta
:
{
title
:
'Root'
,
},
};
//
export const RootRoute: AppRouteRecordRaw = {
//
path: '/',
//
name: 'Root',
//
redirect: PageEnum.BASE_HOME,
//
meta: {
//
title: 'Root',
//
},
//
};
export
const
LoginRoute
:
AppRouteRecordRaw
=
{
path
:
'/login'
,
...
...
@@ -42,7 +42,7 @@ export const LoginRoute: AppRouteRecordRaw = {
// 未经许可的基本路由
export
const
basicRoutes
=
[
LoginRoute
,
RootRoute
,
//
RootRoute,
...
mainOutRoutes
,
REDIRECT_ROUTE
,
PAGE_NOT_FOUND_ROUTE
,
...
...
src/store/modules/permission.ts
View file @
c09a8dd5
...
...
@@ -242,9 +242,18 @@ export const usePermissionStore = defineStore({
// } catch (error) {
// console.error(error);
// }
console
.
log
(
'userStore.getUserInfo.data.menus'
,
userStore
.
getUserInfo
.
data
.
menus
)
routeList
=
userStore
.
getUserInfo
.
data
.
menus
routeList
=
userStore
.
getUserInfo
.
menus
const
rootPath
=
{
path
:
'/'
,
name
:
'Root'
,
redirect
:
userStore
.
getUserInfo
.
homePath
,
meta
:
{
title
:
'Root'
,
},
}
routeList
.
push
(
rootPath
)
console
.
log
(
'routeList'
,
routeList
)
// Dynamically introduce components
// 动态引入组件
routeList
=
transformObjToRoute
(
routeList
);
...
...
src/store/modules/user.ts
View file @
c09a8dd5
...
...
@@ -134,9 +134,21 @@ export const useUserStore = defineStore({
}
else
{
this
.
setRoleList
([
'ROLE_DEFAULT'
]);
}
// 获取动态路由下的第一个菜单路径
const
firstChild
=
await
this
.
getFirstChild
(
userInfo
.
data
.
menus
[
0
])
// 登陆后进入的第一个页面
userInfo
.
data
.
homePath
=
firstChild
// 设置用户信息,并存储本地缓存
this
.
setUserInfo
(
userInfo
);
return
userInfo
;
this
.
setUserInfo
(
userInfo
.
data
);
return
userInfo
.
data
;
},
/** 获取动态路由下的第一个菜单路径*/
getFirstChild
(
item
):
Promise
<
any
>
{
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
return
this
.
getFirstChild
(
item
.
children
[
0
])
}
else
{
return
item
.
path
}
},
/**
* @description: logout
...
...
src/views/sys/login/LoginForm.vue
View file @
c09a8dd5
...
...
@@ -119,7 +119,7 @@
const
rememberMe
=
ref
(
false
);
const
formData
=
reactive
({
account
:
'
vbe
n'
,
account
:
'
guanliyua
n'
,
password
:
'123456'
,
});
...
...
@@ -139,11 +139,10 @@
username
:
data
.
account
,
mode
:
'none'
,
//不要默认的错误提示
});
console
.
log
(
'11111111111111'
,
userInfo
)
if
(
userInfo
)
{
notification
.
success
({
message
:
t
(
'sys.login.loginSuccessTitle'
),
description
:
`
${
t
(
'sys.login.loginSuccessDesc'
)}
:
${
userInfo
.
data
.
user
.
name
}
`
,
description
:
`
${
t
(
'sys.login.loginSuccessDesc'
)}
:
${
userInfo
.
user
.
name
}
`
,
duration
:
3
,
});
}
...
...
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