hookehuyr

add 错误处理页

......@@ -30,12 +30,9 @@ axios.interceptors.response.use(
if (error.response) {
switch (error.response.status) {
case 401:
if (window.location.hostname === 'localhost') {
window.location.href = '../login.html';
} else {
let h = window.location.origin + '/' + _.split(window.location.pathname, '/', 2)[1] + '/login.html';
window.location.href = error.response.data.hasOwnProperty('content') ? error.response.data.content : h;
}
router.replace({
path: '/error401'
})
break;
case 404:
router.replace({
......
......@@ -20,6 +20,20 @@ export default new Router({
}
},
{
path: '/error',
component: r => {
require(['./views/error/404'], r)
},
name: '错误页面404'
},
{
path: '/error401',
component: r => {
require(['./views/error/401'], r)
},
name: '错误页面401'
},
{
path: '/',
component: r => {
require(['./views/Home'], r)
......
......@@ -35,6 +35,16 @@
<p v-if="side_show" style="margin-left: 10px;">牛讲师</p>
</mu-button>
<mu-list slot="content">
<mu-list-item button @click="menuClick('404')">
<mu-list-item-content>
<mu-list-item-title>404</mu-list-item-title>
</mu-list-item-content>
</mu-list-item>
<mu-list-item button @click="menuClick('401')">
<mu-list-item-content>
<mu-list-item-title>401</mu-list-item-title>
</mu-list-item-content>
</mu-list-item>
<mu-list-item button @click="menuClick('exit')">
<mu-list-item-content>
<mu-list-item-title>退出</mu-list-item-title>
......@@ -121,6 +131,12 @@ export default {
menuClick (v) {
// 下拉菜单项选中
this.menu_open = false;
if (v === '404') {
this.$router.push('/error')
}
if (v === '401') {
this.$router.push('/error401')
}
if (v === 'exit') {
this.$router.push('/login')
}
......
<template>
<!-- <div class="errPage-container"> -->
<mu-container>
<div class="errPage-container">
<mu-button @click="back" color="primary">
<mu-icon left value="chevron_left"></mu-icon>
返回
</mu-button>
<mu-row>
<mu-col span="6">
<h1 class="text-jumbo text-ginormous">Oops!</h1>
<h2>你没有权限去该页面</h2>
<h6>如有不满请联系你领导</h6>
<div class="">
<p>或者你可以去: </p>
<mu-button @click="goHome" color="primary">重新登陆</mu-button>
</div>
</mu-col>
<mu-col span="6">
<img :src="errGif" width="313" height="428" alt="">
</mu-col>
</mu-row>
</div>
</mu-container>
<!-- <el-dialog title="随便看" v-model="dialogVisible" size="large">
<img class="pan-img" :src="ewizardClap">
</el-dialog> -->
<!-- </div> -->
</template>
<script>
import errGif from '../../assets/images/401.gif';
export default {
name: 'Error401Page',
data () {
return {
errGif: errGif + '?' + +new Date(),
ewizardClap: 'https://wpimg.wallstcn.com/007ef517-bafd-4066-aae4-6883632d9646',
dialogVisible: false
}
},
mounted () {
$('body').css('background', '#FFFFFF')
},
methods: {
back () {
this.$router.go(-1)
},
goHome () {
location.href = './#/login'
}
}
};
</script>
<style lang="less">
body {
background: #ffffff;
}
.errPage-container {
margin: 100px auto;
background-color: white;
.pan-back-btn {
background: #20a0ff;
color: #fff;
}
.pan-gif {
margin: 0 auto;
display: block;
}
.pan-img{
display: block;
margin: 0 auto;
}
.text-jumbo {
font-size: 60px;
font-weight: 700;
color: #484848;
}
.list-unstyled {
font-size: 14px;
li {
padding-bottom: 5px;
list-style: none;
}
}
}
</style>
<template>
<mu-container>
<div class="wscn-http404">
<div class="pic-404">
<img class="pic-404__parent" src="../../assets/images/404.png" alt="404">
<img class="pic-404__child left" src="../../assets/images/404_cloud.png" alt="404">
<img class="pic-404__child mid" src="../../assets/images/404_cloud.png" alt="404">
<img class="pic-404__child right" src="../../assets/images/404_cloud.png" alt="404">
</div>
<div class="bullshit">
<div class="bullshit__oops">OOPS!</div>
<!-- <div class="bullshit__info">版权所有<a class='link-type' href='https://wallstreetcn.com' target='_blank'>华尔街见闻</a></div> -->
<div class="bullshit__headline">{{ message }}</div>
<div class="bullshit__info">请检查您输入的网址是否正确,请点击以下按钮返回主页或者发送错误报告</div>
<a @click="goHome()" class="bullshit__return-home">返回首页</a>
</div>
</div>
</mu-container>
</template>
<script>
export default {
name: 'Error404Page',
mounted () {
$('body').css('background', 'rgb(240, 242, 245)')
},
computed: {
message () {
return '这个页面你不能进......'
}
},
methods: {
goHome () {
location.href = '/'
}
}
}
</script>
<style lang="less" scoped>
.wscn-http404 {
position: relative;
width: 1200px;
margin: 20px auto 60px;
padding: 0 100px;
overflow: hidden;
.pic-404 {
position: relative;
float: left;
width: 600px;
padding: 150px 0;
overflow: hidden;
&__parent {
width: 100%;
}
&__child {
position: absolute;
&.left {
width: 80px;
top: 17px;
left: 220px;
opacity: 0;
animation-name: cloudLeft;
animation-duration: 2s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 1s;
}
&.mid {
width: 46px;
top: 10px;
left: 420px;
opacity: 0;
animation-name: cloudMid;
animation-duration: 2s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 1.2s;
}
&.right {
width: 62px;
top: 100px;
left: 500px;
opacity: 0;
animation-name: cloudRight;
animation-duration: 2s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 1s;
}
@keyframes cloudLeft {
0% {
top: 17px;
left: 220px;
opacity: 0;
}
20% {
top: 33px;
left: 188px;
opacity: 1;
}
80% {
top: 81px;
left: 92px;
opacity: 1;
}
100% {
top: 97px;
left: 60px;
opacity: 0;
}
}
@keyframes cloudMid {
0% {
top: 10px;
left: 420px;
opacity: 0;
}
20% {
top: 40px;
left: 360px;
opacity: 1;
}
70% {
top: 130px;
left: 180px;
opacity: 1;
}
100% {
top: 160px;
left: 120px;
opacity: 0;
}
}
@keyframes cloudRight {
0% {
top: 100px;
left: 500px;
opacity: 0;
}
20% {
top: 120px;
left: 460px;
opacity: 1;
}
80% {
top: 180px;
left: 340px;
opacity: 1;
}
100% {
top: 200px;
left: 300px;
opacity: 0;
}
}
}
}
.bullshit {
position: relative;
float: left;
width: 300px;
padding: 150px 0;
overflow: hidden;
&__oops {
font-size: 32px;
font-weight: bold;
line-height: 40px;
color: #1482f0;
opacity: 0;
margin-bottom: 20px;
animation-name: slideUp;
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
&__headline {
font-size: 20px;
line-height: 24px;
color: #1482f0;
opacity: 0;
margin-bottom: 10px;
animation-name: slideUp;
animation-duration: 0.5s;
animation-delay: 0.1s;
animation-fill-mode: forwards;
}
&__info {
font-size: 13px;
line-height: 21px;
color: grey;
opacity: 0;
margin-bottom: 30px;
animation-name: slideUp;
animation-duration: 0.5s;
animation-delay: 0.2s;
animation-fill-mode: forwards;
}
&__return-home {
display: block;
float: left;
width: 110px;
height: 36px;
background: #1482f0;
border-radius: 100px;
text-align: center;
color: #ffffff;
opacity: 0;
font-size: 14px;
line-height: 36px;
cursor: pointer;
animation-name: slideUp;
animation-duration: 0.5s;
animation-delay: 0.3s;
animation-fill-mode: forwards;
}
@keyframes slideUp {
0% {
transform: translateY(60px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
}
}
</style>
<template lang="html">
<div class="Absolute-Center" style="color: gray;">
<img :src="bgImg" alt="">
<div style="margin-top: 20px;">
<span style="margin-right: 10px;">抱歉 ! 您访问的页面出错了</span>
<router-link to="/">返回首页</router-link>
</div>
</div>
</template>
<script>
export default {
name: 'ErrorPage',
data () {
return {
bgImg: require('../../assets/images/404_1.png')
}
}
}
</script>
<style>
body {
background-color: white;
}
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
text-align: center;
}
</style>