Skip to content

Commit

Permalink
feat(components): 增加错误页组件,美化原有错误页
Browse files Browse the repository at this point in the history
  • Loading branch information
chansee97 committed Aug 18, 2022
1 parent 6ed4a16 commit 025410c
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/assets/svg/error-403.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/svg/error-404.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/svg/error-500.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/components/common/ErrorTip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div class="flex-col-center h-800px">
<img v-if="type === '403'" src="@/assets/svg/error-403.svg" alt="" class="w-1/3" />
<img v-if="type === '404'" src="@/assets/svg/error-404.svg" alt="" class="w-1/3" />
<img v-if="type === '500'" src="@/assets/svg/error-500.svg" alt="" class="w-1/3" />
<n-button type="primary" @click="toRoot">回到首页</n-button>
</div>
</template>

<script setup lang="ts">
import { useAppRouter } from '@/hook';
type TipType = '403' | '404' | '500';
defineProps<{
/** 异常类型 403 404 500 */
type: TipType;
}>();
const { toRoot } = useAppRouter();
</script>

<style lang="scss" scoped></style>
2 changes: 1 addition & 1 deletion src/layouts/components/sider/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<script setup lang="ts">
import { useAppStore } from '@/store';
import { useAppRouter } from '@/hook';
const appStore = useAppStore();
const { toRoot } = useAppRouter();
const appStore = useAppStore();
</script>

<style scoped></style>
2 changes: 1 addition & 1 deletion src/router/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const constantRoutes = [
name: 'no-permission',
component: () => import('@/views/error/not-permission/index.vue'),
meta: {
title: '无权限',
title: '用户无权限',
icon: 'icon-park-outline:error',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useAppStore = defineStore('app-store', {
* @param {number} delay - 延迟毫秒数
* @return {*}
*/
async reloadPage(delay = 100) {
async reloadPage(delay = 600) {
this.loadFlag = false;
await nextTick();
if (delay) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/error/not-found/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>404</div>
<ErrorTip type="404" />
</template>

<script setup lang="ts"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/views/error/not-permission/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>403</div>
<ErrorTip type="403" />
</template>

<script setup lang="ts"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/views/error/service-error/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>500</div>
<ErrorTip type="500" />
</template>

<script setup lang="ts"></script>
Expand Down

0 comments on commit 025410c

Please sign in to comment.