Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
an-plus-hr-ai
Project
Project
Details
Activity
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
anjia-hr
an-plus-hr-ai
Commits
5e5f9568
Commit
5e5f9568
authored
Sep 17, 2026
by
刘斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 去掉默认首页,改为用户权限的第一个页面
parent
b9f1ac5d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
14 deletions
+51
-14
model.d.ts
frontend/src/api/system/dept/model.d.ts
+1
-1
guard.ts
frontend/src/router/guard.ts
+47
-8
auth.ts
frontend/src/stores/auth.ts
+2
-4
dept-drawer.vue
frontend/src/views/system/dept/dept-drawer.vue
+1
-1
No files found.
frontend/src/api/system/dept/model.d.ts
View file @
5e5f9568
...
@@ -12,7 +12,7 @@ export interface Dept {
...
@@ -12,7 +12,7 @@ export interface Dept {
// leader: string;
// leader: string;
// phone: string;
// phone: string;
// email: string;
// email: string;
status
:
string
;
status
:
number
;
// delFlag: string;
// delFlag: string;
parentName
?:
string
;
parentName
?:
string
;
children
?:
Dept
[];
children
?:
Dept
[];
...
...
frontend/src/router/guard.ts
View file @
5e5f9568
import
type
{
MenuRecordRaw
}
from
'@/types'
;
import
type
{
Router
}
from
'vue-router'
;
import
type
{
Router
}
from
'vue-router'
;
import
{
LOGIN_PATH
}
from
'@/constants'
;
import
{
LOGIN_PATH
}
from
'@/constants'
;
...
@@ -8,6 +10,26 @@ import { startProgress, stopProgress } from '@/utils';
...
@@ -8,6 +10,26 @@ import { startProgress, stopProgress } from '@/utils';
import
{
generateAccess
}
from
'./access'
;
import
{
generateAccess
}
from
'./access'
;
/**
* 从菜单列表中获取第一个可见的叶子页面路径
*/
function
getFirstVisibleMenuPath
(
menus
:
MenuRecordRaw
[]):
string
|
undefined
{
for
(
const
menu
of
menus
)
{
if
(
menu
.
show
===
false
)
{
continue
;
}
if
(
menu
.
children
&&
menu
.
children
.
length
>
0
)
{
const
childPath
=
getFirstVisibleMenuPath
(
menu
.
children
);
if
(
childPath
)
{
return
childPath
;
}
}
else
{
return
menu
.
path
;
}
}
return
undefined
;
}
/**
/**
* 通用守卫配置
* 通用守卫配置
* @param router
* @param router
...
@@ -51,10 +73,18 @@ function setupAccessGuard(router: Router) {
...
@@ -51,10 +73,18 @@ function setupAccessGuard(router: Router) {
// 基本路由,这些路由不需要进入权限拦截
// 基本路由,这些路由不需要进入权限拦截
if
(
coreRouteNames
.
includes
(
to
.
name
as
string
))
{
if
(
coreRouteNames
.
includes
(
to
.
name
as
string
))
{
if
(
to
.
path
===
LOGIN_PATH
&&
accessStore
.
accessToken
)
{
if
(
to
.
path
===
LOGIN_PATH
&&
accessStore
.
accessToken
)
{
return
decodeURIComponent
(
const
firstMenuPath
=
getFirstVisibleMenuPath
(
accessStore
.
accessMenus
);
(
to
.
query
?.
redirect
as
string
)
||
const
redirect
=
to
.
query
?.
redirect
userStore
.
userInfo
?.
homePath
||
?
decodeURIComponent
(
to
.
query
.
redirect
as
string
)
preferences
.
app
.
defaultHomePath
,
:
undefined
;
// 当 redirect 为根路径 '/' 时,直接使用菜单路径或默认首页,避免根路由二次重定向
if
(
redirect
&&
redirect
!==
'/'
)
{
return
redirect
;
}
return
(
userStore
.
userInfo
?.
homePath
||
firstMenuPath
||
preferences
.
app
.
defaultHomePath
);
);
}
}
return
true
;
return
true
;
...
@@ -108,13 +138,22 @@ function setupAccessGuard(router: Router) {
...
@@ -108,13 +138,22 @@ function setupAccessGuard(router: Router) {
accessStore
.
setAccessMenus
(
accessibleMenus
);
accessStore
.
setAccessMenus
(
accessibleMenus
);
accessStore
.
setAccessRoutes
(
accessibleRoutes
);
accessStore
.
setAccessRoutes
(
accessibleRoutes
);
accessStore
.
setIsAccessChecked
(
true
);
accessStore
.
setIsAccessChecked
(
true
);
const
redirectPath
=
(
from
.
query
.
redirect
??
const
firstMenuPath
=
getFirstVisibleMenuPath
(
accessibleMenus
);
const
decodedRedirect
=
from
.
query
.
redirect
?
decodeURIComponent
(
from
.
query
.
redirect
as
string
)
:
undefined
;
// 当 redirect 为根路径 '/' 时,视为无效重定向,使用默认逻辑
const
redirectPath
=
(
(
decodedRedirect
&&
decodedRedirect
!==
'/'
?
decodedRedirect
:
undefined
)
??
(
to
.
path
===
preferences
.
app
.
defaultHomePath
(
to
.
path
===
preferences
.
app
.
defaultHomePath
?
userInfo
.
homePath
||
preferences
.
app
.
defaultHomePath
?
userInfo
.
homePath
||
firstMenuPath
||
preferences
.
app
.
defaultHomePath
:
to
.
fullPath
))
as
string
;
:
to
.
fullPath
)
)
as
string
;
return
{
return
{
...
router
.
resolve
(
decodeURIComponent
(
redirectPath
)
),
...
router
.
resolve
(
redirectPath
),
replace
:
true
,
replace
:
true
,
};
};
});
});
...
...
frontend/src/stores/auth.ts
View file @
5e5f9568
...
@@ -10,7 +10,6 @@ import {
...
@@ -10,7 +10,6 @@ import {
UnauthorizedException
,
UnauthorizedException
,
}
from
'@/api/helper'
;
}
from
'@/api/helper'
;
import
{
LOGIN_PATH
}
from
'@/constants'
;
import
{
LOGIN_PATH
}
from
'@/constants'
;
import
{
preferences
}
from
'@/core/preferences'
;
import
{
$t
}
from
'@/locales'
;
import
{
$t
}
from
'@/locales'
;
import
{
defineStore
}
from
'pinia'
;
import
{
defineStore
}
from
'pinia'
;
...
@@ -58,9 +57,8 @@ export const useAuthStore = defineStore('auth', () => {
...
@@ -58,9 +57,8 @@ export const useAuthStore = defineStore('auth', () => {
if
(
accessStore
.
loginExpired
)
{
if
(
accessStore
.
loginExpired
)
{
accessStore
.
setLoginExpired
(
false
);
accessStore
.
setLoginExpired
(
false
);
}
else
{
}
else
{
onSuccess
// 跳转到根路径,由路由守卫统一重定向到用户有权限的第一个页面
?
await
onSuccess
?.()
onSuccess
?
await
onSuccess
?.()
:
await
router
.
push
(
'/'
);
:
await
router
.
push
(
preferences
.
app
.
defaultHomePath
);
}
}
if
(
userInfo
?.
realName
)
{
if
(
userInfo
?.
realName
)
{
...
...
frontend/src/views/system/dept/dept-drawer.vue
View file @
5e5f9568
...
@@ -50,7 +50,7 @@ function getDefaultValues(): FormData {
...
@@ -50,7 +50,7 @@ function getDefaultValues(): FormData {
orderNum
:
1
,
orderNum
:
1
,
parentId
:
0
,
parentId
:
0
,
// phone: '',
// phone: '',
status
:
'0'
,
status
:
1
,
};
};
}
}
...
...
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