Skip to content

Commit 9ec5176

Browse files
committed
创建,创建相关模板
1 parent bbf9025 commit 9ec5176

File tree

16 files changed

+603
-29
lines changed

16 files changed

+603
-29
lines changed

src/App.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,22 @@
66

77
<script>
88
export default {
9-
name: 'App'
9+
name: 'App',
10+
watch: {
11+
$route (val) {
12+
this.invalidRoute(val)
13+
}
14+
},
15+
methods: {
16+
invalidRoute (val) {
17+
const matched = this.$route.matched
18+
// 访问不存在的路由进入404页面
19+
if (!matched || matched.length === 0 || val.path === '/404') {
20+
this.$router.push('/404')
21+
return
22+
}
23+
}
24+
}
1025
}
1126
</script>
1227

src/components/MavonEditor/index.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ export default {
3131
data () {
3232
return {
3333
flag: 'inner', // 内 inner 外outside
34-
editorValue: '',
35-
errPlaceholder: `1. 描述你的问题
36-
2. 贴上相关代码 (请勿用图片代替代码)
37-
3. 贴上报错信息
38-
4 已经尝试过哪些方法仍然没解决 (附上相关链接)`
34+
editorValue: ''
3935
}
4036
},
4137
watch: {

src/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'mavon-editor/dist/css/index.css'
1212
import '@/common/config/errorLog' // 错误日志
1313
import '@/common/style/index.scss' // 自定义样式
1414
import prototype from '@/common/js/prototype' // 自定义方法,用于全局调用
15-
import { _getCookie, _removeCookie } from '@/common/js/storage'
15+
import { _getCookie } from '@/common/js/storage'
1616

1717
Vue.config.productionTip = false
1818

@@ -25,7 +25,7 @@ router.beforeEach((to, from, next) => {
2525
// 本地存在token,自动获取用户信息
2626
if (_getCookie('token')) {
2727
store.dispatch('user/setUserInfo').catch(() => {
28-
_removeCookie('token')
28+
// _removeCookie('token')
2929
})
3030
}
3131
next()

src/router/index.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ export const routes = [
9898
}
9999
]
100100
},
101-
{
102-
path: '/write/:type',
103-
alias: '/write',
104-
component: () => import('@/views/write/index'),
105-
name: '写文章' + +new Date(),
106-
meta: { title: '写文章' }
107-
},
108101
{
109102
path: '/search',
110103
redirect: '/search/child',
@@ -120,6 +113,26 @@ export const routes = [
120113
meta: { title: '搜索' }
121114
}
122115
]
116+
},
117+
{
118+
path: '/write',
119+
component: () => import('@/views/write/index'),
120+
name: '写文章' + +new Date(),
121+
meta: { title: '写文章' }
122+
},
123+
{
124+
path: '/401',
125+
name: '401',
126+
hidden: true,
127+
meta: { title: '401', icon: '' },
128+
component: () => import('@/views/errorPage/401')
129+
},
130+
{
131+
path: '/404',
132+
name: '404',
133+
hidden: true,
134+
meta: { title: '404', icon: '' },
135+
component: () => import('@/views/errorPage/404')
123136
}
124137
]
125138

src/views/errorPage/401.vue

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<template>
2+
<div class="errPage-container">
3+
<el-button icon="arrow-left" class="pan-back-btn" @click="back">返回</el-button>
4+
<el-row>
5+
<el-col :span="12">
6+
<h1 class="text-jumbo text-ginormous text-line">Oops!</h1>
7+
<h2 class="text-line">你没有权限去该页面</h2>
8+
<h6 class="text-line">如有问题请联系管理员</h6>
9+
<ul class="list-unstyled text-line">
10+
<li>或者你可以去:</li>
11+
<li class="link-type">
12+
<router-link to="/">回首页</router-link>
13+
</li>
14+
<li class="link-type"><a href="https://www.taobao.com/">逛逛淘宝</a></li>
15+
<li class="link-type"><a href="https://github.com/">刷刷github</a></li>
16+
<li><a href="#" @click.prevent="dialogVisible=true">点我看图</a></li>
17+
</ul>
18+
</el-col>
19+
<el-col :span="12">
20+
<img :src="errGif" width="313" height="428" alt="Girl has dropped her ice cream.">
21+
</el-col>
22+
</el-row>
23+
<el-dialog title="随便看" :visible.sync="dialogVisible">
24+
<img class="pan-img" :src="ewizardClap">
25+
</el-dialog>
26+
</div>
27+
</template>
28+
29+
<script>
30+
import errGif from '@/views/errorPage/img/401.gif'
31+
32+
export default {
33+
name: 'Page401',
34+
data () {
35+
return {
36+
errGif: errGif + '?' + +new Date(),
37+
ewizardClap: 'https://wpimg.wallstcn.com/007ef517-bafd-4066-aae4-6883632d9646',
38+
dialogVisible: false
39+
}
40+
},
41+
methods: {
42+
back () {
43+
if (this.$route.query.noGoBack) {
44+
this.$router.push({ path: '/' })
45+
} else {
46+
this.$router.go(-2)
47+
}
48+
}
49+
}
50+
}
51+
</script>
52+
53+
<style rel="stylesheet/scss" lang="scss" scoped>
54+
.errPage-container {
55+
width: 800px;
56+
margin: 100px auto;
57+
.text-line{
58+
padding: 5px 0px;
59+
li{
60+
padding: 5px 0px;
61+
}
62+
}
63+
.pan-back-btn {
64+
background: #008489;
65+
color: #fff;
66+
border: none!important;
67+
}
68+
.pan-gif {
69+
margin: 0 auto;
70+
display: block;
71+
}
72+
.pan-img {
73+
display: block;
74+
margin: 0 auto;
75+
width: 100%;
76+
}
77+
.text-jumbo {
78+
font-size: 60px;
79+
font-weight: 700;
80+
color: #484848;
81+
}
82+
.list-unstyled {
83+
font-size: 14px;
84+
li {
85+
padding-bottom: 5px;
86+
}
87+
a {
88+
color: #008489;
89+
text-decoration: none;
90+
&:hover {
91+
text-decoration: underline;
92+
}
93+
}
94+
}
95+
}
96+
</style>

0 commit comments

Comments
 (0)