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
2024-11-21 17:10:59 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
be5088677d3283ebbf97063bcebaac1fbac77a72
be508867
1 parent
822e97b5
✨ feat: 路由拦截有cookie的表单进行判断操作
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
src/router.js
src/router.js
View file @
be50886
/*
* @Date: 2022-05-26 13:57:28
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 202
2-06-29 21:36:59
* @FilePath: /
tswj
/src/router.js
* @LastEditTime: 202
4-11-21 17:08:22
* @FilePath: /
data-table
/src/router.js
* @Description: 文件描述
*/
import
{
createRouter
,
createWebHashHistory
}
from
'vue-router'
;
import
RootRoute
from
'./route.js'
;
import
asyncRoutesArr
from
"./mock/routes"
import
generateRoutes
from
'./utils/generateRoute'
import
{
showConfirmDialog
}
from
"vant"
;
import
Cookies
from
'js-cookie'
;
import
{
styleColor
}
from
"@/constant.js"
;
// TAG: 路由配置表
/**
...
...
@@ -48,7 +51,26 @@ router.beforeEach((to, from, next) => {
next
({
...
to
.
redirectedFrom
,
replace
:
true
});
},
1000
);
}
else
{
next
()
if
(
to
.
query
.
page_type
===
'add'
)
{
// 表单为新增状态, 检查是否有未完成的表单信息
const
existingCookie
=
Cookies
.
get
(
to
.
query
.
code
);
if
(
existingCookie
)
{
showConfirmDialog
({
title
:
'温馨提示'
,
message
:
'您还未完成的表单,是否继续?'
,
confirmButtonColor
:
styleColor
.
baseColor
,
cancelButtonText
:
'删除'
})
.
then
(()
=>
{
// 通过后把数据绑定上去
next
();
})
.
catch
(()
=>
{
// 删除cookie
Cookies
.
remove
(
to
.
query
.
code
);
next
();
});
}
}
else
{
next
()
}
}
})
...
...
Please
register
or
login
to post a comment