Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
罗鑫霖
/
vion-tools
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0bd6bf4a
authored
Apr 19, 2024
by
李乾广
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加路由跳转判断
1 parent
88d55b53
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
2 deletions
src/router/index.js
src/views/error-page/404.vue
src/router/index.js
View file @
0bd6bf4
import
{
createRouter
,
createWebHashHistory
}
from
'vue-router'
import
*
as
Cookies
from
'js-cookie'
const
menuRoute
=
[
{
path
:
'/Main'
,
...
...
@@ -91,6 +91,12 @@ const route = [
redirect
:
'/Main/SnapshotCluster'
,
},
{
path
:
'/404'
,
name
:
'404'
,
component
:
()
=>
import
(
'@/views/error-page/404'
)
},
{
path
:
'/test'
,
component
:
()
=>
import
(
"@/views/Test/Test.vue"
),
},
...
...
@@ -103,5 +109,12 @@ const router = createRouter(
routes
:
route
}
)
// 全局路由守卫
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
if
((
Cookies
.
get
(
'userrole_type'
)
&&
Cookies
.
get
(
'userrole_type'
)
==-
1
)
||
to
.
path
==
'/404'
)
{
next
();
}
else
{
router
.
push
(
'/404'
);
}
});
export
default
router
src/views/error-page/404.vue
0 → 100644
View file @
0bd6bf4
<
template
>
<div
class=
"error-container"
>
<h1>
404
</h1>
<p>
<strong>
File not found
</strong>
</p>
<p>
The site configured at this address does not contain the requested file.
</p>
<p>
<router-link
to=
"/"
class=
"back-link"
>
Back to Home
</router-link>
</p>
</div>
</
template
>
<
script
>
export
default
{
}
</
script
>
<
style
scoped
>
.error-container
{
margin
:
50px
auto
40px
auto
;
width
:
600px
;
text-align
:
center
;
}
h1
{
width
:
800px
;
position
:
relative
;
left
:
-100px
;
letter-spacing
:
-1px
;
line-height
:
60px
;
font-size
:
60px
;
font-weight
:
100
;
margin
:
0
0
50px
0
;
text-shadow
:
0
1px
0
#fff
;
}
p
{
color
:
rgba
(
0
,
0
,
0
,
0.5
);
margin
:
20px
0
;
line-height
:
1.6
;
}
.back-link
{
color
:
#3BB8FF
;
text-decoration
:
none
;
}
</
style
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment