Skip to content

Commit 84b3980

Browse files
authored
refactor: 优化路由及分页 (#330)
fix #328
1 parent 71851ae commit 84b3980

File tree

7 files changed

+19
-31
lines changed

7 files changed

+19
-31
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ENV = 'development'
22

3-
VUE_APP_BASE_URL = 'http://localhost:5000/'
3+
VUE_APP_BASE_URL = 'http://127.0.0.1:5000/'

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
VUE_APP_BASE_URL = 'http://localhost:5000/'
3+
VUE_APP_BASE_URL = 'http://127.0.0.1:5000/'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lin-cms",
3-
"version": "0.3.5",
3+
"version": "0.3.6",
44
"private": true,
55
"scripts": {
66
"serve": "node script/plugin-get-config.js && vue-cli-service serve",

src/component/base/table/lin-table.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
layout="prev, pager, next"
5656
:page-size="pagination.pageSize ? pagination.pageSize : 10"
5757
:total="pagination.pageTotal ? pagination.pageTotal : null"
58+
:current-page="pagination.currentPage ? pagination.currentPage : 1"
5859
@current-change="currentChange"
5960
></el-pagination>
6061
</div>

src/component/layout/side-bar.vue

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,12 @@
7777
</el-submenu>
7878

7979
<!-- 一级else -->
80-
<el-menu-item
81-
class="subMenuContent"
82-
:index="idMap[item.name]"
83-
@click="goto(item.path)"
84-
v-else
85-
:key="idMap[item.name]"
86-
>
87-
<i v-if="!filterIcon(item.icon)" :class="item.icon"></i> <img v-else :src="item.icon" class="imgIcon" />
88-
<span slot="title">{{ item.title }}</span>
89-
</el-menu-item>
80+
<router-link :to="item.path" :key="item.name" v-else>
81+
<el-menu-item class="subMenuContent" :index="idMap[item.name]" :key="idMap[item.name]">
82+
<i v-if="!filterIcon(item.icon)" :class="item.icon"></i> <img v-else :src="item.icon" class="imgIcon" />
83+
<span slot="title">{{ item.title }}</span>
84+
</el-menu-item>
85+
</router-link>
9086
</template>
9187
</el-menu>
9288
</div>
@@ -118,7 +114,6 @@ export default {
118114
default: false,
119115
},
120116
},
121-
created() {},
122117
mounted() {
123118
this.eventBus.$on('removeSidebarSearch', () => {
124119
this.showSidebarSearch = false
@@ -130,11 +125,6 @@ export default {
130125
})
131126
},
132127
methods: {
133-
goto(path) {
134-
this.$router.push({
135-
path,
136-
})
137-
},
138128
filterIcon(icon) {
139129
return icon.indexOf('/') !== -1
140130
},
@@ -151,10 +141,6 @@ export default {
151141
}, 200)
152142
},
153143
search(val) {
154-
// if (!val) {
155-
// this.showSearchList = false
156-
// return
157-
// }
158144
this.groups = []
159145
160146
// 深度遍历配置树, 摘取叶子节点作为路由部分

src/config/error-code.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
const errorCode = {
22
777: '前端错误码未定义',
33
999: '服务器未知错误',
4-
10000: '认证失败',
4+
10000: '未携带令牌',
55
10020: '资源不存在',
66
10030: '参数错误',
7-
10040: 'assessToken令牌失效',
8-
10050: 'assessToken令牌过期',
7+
10041: 'assessToken损坏',
8+
10042: 'refreshToken损坏',
9+
10051: 'assessToken过期',
10+
10052: 'refreshToken过期',
911
10060: '字段重复',
1012
10070: '不可操作',
11-
10100: 'refreshToken异常',
1213
}
1314

1415
export default errorCode

src/lin/plugin/axios.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ _axios.interceptors.response.use(
116116
return new Promise(async (resolve, reject) => {
117117
const { url } = res.config
118118

119-
// refresh_token 异常,直接登出
120-
if (code === 10000 || code === 10100) {
119+
// refreshToken相关,直接登出
120+
if (code === 10000 || code === 10042 || code === 10052) {
121121
setTimeout(() => {
122122
store.dispatch('loginOut')
123123
const { origin } = window.location
124124
window.location.href = origin
125125
}, 1500)
126126
return resolve(null)
127127
}
128-
// 令牌相关,刷新令牌
129-
if (code === 10040 || code === 10041 || code === 10050 || code === 10051) {
128+
// assessToken相关,刷新令牌
129+
if (code === 10041 || code === 10051) {
130130
const cache = {}
131131
if (cache.url !== url) {
132132
cache.url = url

0 commit comments

Comments
 (0)