Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2025-09-10 10:29:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9b3cb51096d2e8fd5d596a7584d8bc0fbad29808
9b3cb510
1 parent
b224ae2a
fix(router): 修复授权后首次访问跳过周期检查的问题
添加调试信息并优化路由守卫逻辑 当从授权页面返回时跳过周期检查 确保表单检查逻辑在跳过周期检查时正常执行
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
3 deletions
src/App.vue
src/router.js
src/views/cycle-selection.vue
src/App.vue
View file @
9b3cb51
...
...
@@ -148,6 +148,8 @@ onMounted(async () => {
if (!import.meta.env.DEV && open_auth && form_setting.wxzq_scope && record_openid) {
// 预览模式不开启
if (no_preview_model) {
// 设置标识,让路由守卫跳过首次周期检查
sessionStorage.setItem('skip_cycle_check_for_auth', 'true');
$router.replace({
path: '/auth',
query: {
...
...
src/router.js
View file @
9b3cb51
/*
* @Date: 2022-05-26 13:57:28
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-
09 10:29:5
5
* @LastEditTime: 2025-09-
10 10:26:4
5
* @FilePath: /data-table/src/router.js
* @Description: 文件描述
*/
...
...
@@ -119,15 +119,56 @@ router.beforeEach((to, from, next) => {
return
;
}
// 检查是否从授权页面返回,如果是首次访问且可能需要授权,则跳过周期检查
const
isFromAuth
=
from
.
path
===
'/auth'
;
const
skipCycleCheck
=
sessionStorage
.
getItem
(
'skip_cycle_check_for_auth'
);
// 如果不是从授权页面返回,且设置了跳过标识,则先清除标识并跳过周期检查
if
(
!
isFromAuth
&&
skipCycleCheck
===
'true'
)
{
sessionStorage
.
removeItem
(
'skip_cycle_check_for_auth'
);
// 直接执行表单检查逻辑,跳过周期检查
if
(
to
.
query
.
page_type
===
'add'
||
to
.
query
.
page_type
===
undefined
)
{
const
existingCookie
=
Cookies
.
get
(
to
.
query
.
code
);
if
(
existingCookie
&&
to
.
query
.
force_back
!==
'1'
)
{
showConfirmDialog
({
title
:
'温馨提示'
,
message
:
'您还未完成的表单,是否继续?'
,
confirmButtonColor
:
styleColor
.
baseColor
,
cancelButtonText
:
'删除'
,
closeOnPopstate
:
false
,
})
.
then
(()
=>
{
next
();
})
.
catch
(()
=>
{
Cookies
.
remove
(
to
.
query
.
code
);
next
();
});
}
else
{
next
();
}
}
else
{
next
();
}
return
;
}
// 异步检查周期选择
checkCycleSelection
(
to
).
then
(
needsCycleSelection
=>
{
if
(
needsCycleSelection
)
{
// 保存目标路由到sessionStorage
sessionStorage
.
setItem
(
'cycle_target_route'
,
JSON
.
stringify
(
{
const
targetRoute
=
{
path
:
to
.
path
,
query
:
to
.
query
,
params
:
to
.
params
}));
};
// 调试信息:检查保存的路由对象
console
.
log
(
'保存到sessionStorage的目标路由:'
,
targetRoute
);
console
.
log
(
'目标路由查询参数:'
,
targetRoute
.
query
);
console
.
log
(
'目标路由code参数:'
,
targetRoute
.
query
.
code
);
sessionStorage
.
setItem
(
'cycle_target_route'
,
JSON
.
stringify
(
targetRoute
));
// 直接跳转,不使用next
router
.
push
({
path
:
'/cycle-selection'
,
...
...
src/views/cycle-selection.vue
View file @
9b3cb51
...
...
@@ -150,6 +150,12 @@ const getCycleList = async (form_code) => {
if (targetRoute) {
sessionStorage.removeItem('cycle_target_route');
const route = JSON.parse(targetRoute);
// 调试信息:检查不需要周期选择时的路由对象
console.log('不需要周期选择时的路由对象:', route);
console.log('不需要周期选择时的查询参数:', route.query);
console.log('不需要周期选择时的code参数:', route.query.code);
// 检查是否需要显示未完成表单弹框
checkUnfinishedForm(route);
} else {
...
...
@@ -176,6 +182,12 @@ const confirmCycleSelection = () => {
x_cycle: selectedCycle.value,
cycle_selected: '1'
};
// 调试信息:检查route对象内容
console.log('周期选择后的路由对象:', route);
console.log('查询参数:', route.query);
console.log('code参数:', route.query.code);
// 清除临时存储
sessionStorage.removeItem('cycle_target_route');
...
...
Please
register
or
login
to post a comment