diff --git a/src/assets/svgs/403.svg b/src/assets/svgs/403.svg new file mode 100644 index 0000000..3fe072c --- /dev/null +++ b/src/assets/svgs/403.svg @@ -0,0 +1,5290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/svgs/404.svg b/src/assets/svgs/404.svg new file mode 100644 index 0000000..7aa73e5 --- /dev/null +++ b/src/assets/svgs/404.svg @@ -0,0 +1,5287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/svgs/500.svg b/src/assets/svgs/500.svg new file mode 100644 index 0000000..217c430 --- /dev/null +++ b/src/assets/svgs/500.svg @@ -0,0 +1,5389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/Error/index.ts b/src/components/Error/index.ts new file mode 100644 index 0000000..a52c6f9 --- /dev/null +++ b/src/components/Error/index.ts @@ -0,0 +1,3 @@ +import Error from './src/Error.vue' + +export { Error } diff --git a/src/components/Error/src/Error.vue b/src/components/Error/src/Error.vue new file mode 100644 index 0000000..8676a81 --- /dev/null +++ b/src/components/Error/src/Error.vue @@ -0,0 +1,58 @@ + + + + + + + {{ errorMap[type].message }} + + {{ errorMap[type].buttonText }} + + + + diff --git a/src/locales/en.ts b/src/locales/en.ts index 5b0f463..c824668 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -41,6 +41,12 @@ export default { delNoData: 'Please select the data to delete', delSuccess: 'Deleted successfully' }, + error: { + noPermission: `Sorry, you don't have permission to access this page.`, + pageError: 'Sorry, the page you visited does not exist.', + networkError: 'Sorry, the server reported an error.', + returnToHome: 'Return to home' + }, setting: { projectSetting: 'Project setting', theme: 'Theme', @@ -119,7 +125,8 @@ export default { examplePage: 'Example page', exampleAdd: 'Example page - add', exampleEdit: 'Example page - edit', - exampleDetail: 'Example page - detail' + exampleDetail: 'Example page - detail', + errorPage: 'Error page' }, analysis: { newUser: 'New user', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index b98c82d..dbb2883 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -41,6 +41,12 @@ export default { delNoData: '请选择需要删除的数据', delSuccess: '删除成功' }, + error: { + noPermission: `抱歉,您无权访问此页面。`, + pageError: '抱歉,您访问的页面不存在。', + networkError: '抱歉,服务器报告错误。', + returnToHome: '返回首页' + }, setting: { projectSetting: '项目配置', theme: '主题', @@ -119,7 +125,8 @@ export default { examplePage: '综合示例 - 页面', exampleAdd: '综合示例 - 新增', exampleEdit: '综合示例 - 编辑', - exampleDetail: '综合示例 - 详情' + exampleDetail: '综合示例 - 详情', + errorPage: '错误页面' }, analysis: { newUser: '新增用户', diff --git a/src/permission.ts b/src/permission.ts index f9ef5d3..d738c8d 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -27,7 +27,7 @@ router.beforeEach(async (to, from, next) => { next({ path: '/' }) } else { if (permissionStore.getIsAddRouters) { - next() + to.path === '/' ? next({ path: permissionStore.addRouters[0]?.path as string }) : next() return } await permissionStore.generateRoutes() @@ -42,7 +42,7 @@ router.beforeEach(async (to, from, next) => { } } else { if (whiteList.indexOf(to.path) !== -1) { - next() + to.path === '/' ? next({ path: permissionStore.addRouters[0]?.path as string }) : next() } else { next(`/login?redirect=${to.path}`) // 否则全部重定向到登录页 } diff --git a/src/router/index.ts b/src/router/index.ts index 1494126..014106d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -401,6 +401,43 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [ } } ] + }, + { + path: '/error', + component: Layout, + redirect: '/error/404', + name: 'Error', + meta: { + title: t('router.errorPage'), + icon: 'ci:error', + alwaysShow: true + }, + children: [ + { + path: '404', + component: () => import('@/views/Error/404.vue'), + name: '404', + meta: { + title: '404' + } + }, + { + path: '403', + component: () => import('@/views/Error/403.vue'), + name: '403', + meta: { + title: '403' + } + }, + { + path: '500', + component: () => import('@/views/Error/500.vue'), + name: '500', + meta: { + title: '500' + } + } + ] } ] diff --git a/src/views/Error/403.vue b/src/views/Error/403.vue new file mode 100644 index 0000000..46f8246 --- /dev/null +++ b/src/views/Error/403.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/views/Error/404.vue b/src/views/Error/404.vue new file mode 100644 index 0000000..e37f74d --- /dev/null +++ b/src/views/Error/404.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/views/Error/500.vue b/src/views/Error/500.vue new file mode 100644 index 0000000..cba85db --- /dev/null +++ b/src/views/Error/500.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/views/Example/Dialog/ExampleDialog.vue b/src/views/Example/Dialog/ExampleDialog.vue index 4e98498..404c790 100644 --- a/src/views/Example/Dialog/ExampleDialog.vue +++ b/src/views/Example/Dialog/ExampleDialog.vue @@ -186,7 +186,7 @@ const save = async () => { - + diff --git a/src/views/Example/Dialog/components/Write.vue b/src/views/Example/Dialog/components/Write.vue index 3221583..e59ebd0 100644 --- a/src/views/Example/Dialog/components/Write.vue +++ b/src/views/Example/Dialog/components/Write.vue @@ -1,7 +1,7 @@