80a3ae8d
xingyu
feat: add vue3(el...
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
interface ErrorMap {
url: string
message: string
buttonText: string
}
const { t } = useI18n()
const errorMap: {
[key: string]: ErrorMap
} = {
'404': {
url: pageError,
message: t('error.pageError'),
buttonText: t('error.returnToHome')
},
'500': {
url: networkError,
message: t('error.networkError'),
buttonText: t('error.returnToHome')
},
'403': {
url: noPermission,
message: t('error.noPermission'),
buttonText: t('error.returnToHome')
}
}
const props = defineProps({
type: propTypes.string.validate((v: string) => ['404', '500', '403'].includes(v)).def('404')
})
const emit = defineEmits(['errorClick'])
const btnClick = () => {
emit('errorClick', props.type)
}
</script>
<template>
<div class="flex justify-center">
<div class="text-center">
<img width="350" :src="errorMap[type].url" alt="" />
<div class="text-14px text-[var(--el-color-info)]">{{ errorMap[type].message }}</div>
<div class="mt-20px">
<ElButton type="primary" @click="btnClick">{{ errorMap[type].buttonText }}</ElButton>
</div>
</div>
</div>
</template>
|