wangzhibo
2026-07-16 b57020623cf0c946706573bf102e548c3a544423
1
2
3
4
5
6
7
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
    <div class="error-page">
        <div class="error-page__wrap">
            <h1 class="error-page__code">
                <span v-for="c in codes" :key="c">
                    {{ c }}
                </span>
            </h1>
            <p class="error-page__desc">{{ desc }}</p>
 
            <template v-if="user.token || isLogout">
                <div class="error-page__btns">
                    <el-button @click="home">{{ $t('返回首页') }}</el-button>
                    <el-button type="primary" @click="reLogin">{{ $t('重新登录') }}</el-button>
                </div>
            </template>
 
            <template v-else>
                <div class="error-page__btns">
                    <el-button type="primary" @click="toLogin">{{ $t('返回登录页') }}</el-button>
                </div>
            </template>
        </div>
 
        <div class="error-page__bg is-tl">
            <cl-svg name="bg" />
        </div>
 
        <div class="error-page__bg is-br">
            <cl-svg name="bg" />
        </div>
    </div>
</template>
 
<script lang="ts" setup>
defineOptions({
    name: 'error-page'
});
 
import { computed, ref } from 'vue';
import { useCool } from '/@/cool';
import { useBase } from '/$/base';
 
const props = defineProps({
    code: Number,
    desc: String
});
 
const { router } = useCool();
const { user } = useBase();
 
const isLogout = ref(false);
 
const codes = computed(() => {
    return (props.code || '').toString().split('');
});
 
function toLogin() {
    router.push('/login');
}
 
async function reLogin() {
    isLogout.value = true;
    user.logout();
}
 
function home() {
    router.push('/');
}
</script>
 
<style lang="scss" scoped>
.error-page {
    background-color: #fff;
    position: relative;
    height: 100%;
 
    &__wrap {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 100%;
        position: relative;
        z-index: 9;
    }
 
    &__bg {
        position: absolute;
        height: 100%;
        width: 50%;
        pointer-events: none;
        transform: rotate(180deg) scaleY(-1);
 
        .cl-svg {
            height: 100%;
            width: 100%;
            fill: #2c3142;
        }
 
        &.is-tl {
            left: 0;
            top: 0;
            transform: rotate(180deg) scaleY(-1);
        }
 
        &.is-br {
            top: 0;
            right: 0;
            transform: scaleY(-1);
        }
    }
 
    &__code {
        font-size: 120px;
        font-weight: normal;
        color: #6c757d;
        font-family: Consolas;
        margin-top: -40px;
        animation: dou 1s infinite linear;
        position: relative;
    }
 
    &__desc {
        font-size: 16px;
        font-weight: 400;
        color: #6c757d;
        margin-top: 30px;
    }
 
    &__btns {
        display: flex;
        margin-top: 40px;
 
        .el-button {
            margin: 0 10px;
        }
    }
}
</style>