diff --git a/src/router/index.ts b/src/router/index.ts index a0dbdaca..7d195ce2 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -24,16 +24,6 @@ export const constantRoutes: RouteRecordRaw[] = [ name: 'Dashboard', meta: { title: 'dashboard', icon: 'homepage', affix: true }, }, - { - path: '401', - component: () => import('@/views/error-page/401.vue'), - meta: { hidden: true }, - }, - { - path: '404', - component: () => import('@/views/error-page/404.vue'), - meta: { hidden: true }, - }, ], }, ]; @@ -52,7 +42,16 @@ const router = createRouter({ * 重置路由 */ export function resetRouter() { - router.replace({ path: '/login' }); + router.replace({ path: '/dashboard' }); } +// 重定向到首页的守卫 +router.beforeEach((to, from, next) => { + if (to.matched.length === 0) { + //如果未匹配到路由 + from.name ? next({ name: from.name }) : next({ path: '/' }); + } else { + next(); + } +}); export default router; diff --git a/src/views/error-page/401.vue b/src/views/error-page/401.vue deleted file mode 100644 index e34b93d8..00000000 --- a/src/views/error-page/401.vue +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - diff --git a/src/views/error-page/404.vue b/src/views/error-page/404.vue deleted file mode 100644 index b95dab94..00000000 --- a/src/views/error-page/404.vue +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index aab9c03c..511a0ae0 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -143,6 +143,7 @@ const save = () => { }; const save_close = () => { formmat_form_data(form.value); + window.close(); }; const formmat_form_data = (data: diy_data_item) => { const clone_form = cloneDeep(data);