diff --git a/ui/src/config/router.js b/ui/src/config/router.js index ae1f7545c13..26d4da246fd 100644 --- a/ui/src/config/router.js +++ b/ui/src/config/router.js @@ -80,11 +80,21 @@ export function generateRouterMap (section) { map.children.push(route) } } else { + map.component = section.component ? section.component : AutogenView map.hideChildrenInMenu = true map.children = [{ path: '/' + section.name + '/:id', actions: section.actions ? section.actions : [], - component: section.viewComponent ? section.viewComponent : section.component + meta: { + title: section.title, + keepAlive: true, + icon: section.icon, + permission: section.permission, + params: section.params ? section.params : {}, + actions: section.actions ? section.actions : [], + viewComponent: section.viewComponent + }, + component: section.viewComponent ? section.viewComponent : AutogenView }] } diff --git a/ui/src/utils/request.js b/ui/src/utils/request.js index eef7cd37574..7abaa1f4af4 100644 --- a/ui/src/utils/request.js +++ b/ui/src/utils/request.js @@ -30,6 +30,10 @@ const err = (error) => { }) } } + if (error.response.status === 404) { + notification.error({ message: 'Not Found', description: 'Resource not found' }) + this.$router.push({ path: '/exception/404' }) + } } return Promise.reject(error) } diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 8a74e2528c0..943431e7ecf 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -335,7 +335,6 @@ export default { params['page'] = this.page params['pagesize'] = this.pageSize api(this.apiName, params).then(json => { - this.loading = false var responseName var objectName for (const key in json) { @@ -364,6 +363,17 @@ export default { } else { this.resource = {} } + }).catch(error => { + // handle error + this.$notification['error']({ + message: 'Request Failed', + description: error.response.headers['x-description'] + }) + if (error.response.status === 431) { + this.$router.push({ path: '/exception/404' }) + } + }).finally(f => { + this.loading = false }) }, onSearch (value) {