edu/admin/src/views/error/components/error.vue

58 lines
1.3 KiB
Vue
Raw Normal View History

2022-04-08 02:42:44 +00:00
<template>
<div class="error">
<div>
<slot name="content">
<div class="error-code">{{ code }}</div>
</slot>
<div class="text-lg text-tx-secondary mt-7 mb-7">{{ title }}</div>
2022-08-12 10:44:09 +00:00
<el-button v-if="showBtn" type="primary" @click="router.go(-1)">
2022-04-08 02:42:44 +00:00
{{ second }} 秒后返回上一页
</el-button>
</div>
</div>
</template>
2022-08-12 10:44:09 +00:00
<script lang="ts" setup>
import { onUnmounted, ref } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({
code: String,
title: String,
showBtn: {
type: Boolean,
default: true
}
})
let timer: any = null
const second = ref(5)
const router = useRouter()
props.showBtn &&
(timer = setInterval(() => {
if (second.value === 0) {
2022-04-08 02:42:44 +00:00
clearInterval(timer)
2022-08-12 10:44:09 +00:00
router.go(-1)
} else {
second.value--
2022-04-08 02:42:44 +00:00
}
2022-08-12 10:44:09 +00:00
}, 1000))
onUnmounted(() => {
timer && clearInterval(timer)
2022-04-08 02:42:44 +00:00
})
</script>
<style lang="scss" scoped>
.error {
text-align: center;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
.error-code {
2022-08-12 10:44:09 +00:00
@apply text-primary;
2022-04-08 02:42:44 +00:00
font-size: 150px;
}
.el-button {
width: 176px;
}
}
</style>