123 lines
2.4 KiB
Vue
123 lines
2.4 KiB
Vue
<script setup lang="ts">
|
||
import { computed } from 'vue'
|
||
import { useRouter } from 'vue-router'
|
||
import { ROLE_LABEL } from '@/constants'
|
||
import { HOME_BY_ROLE } from '@/router/menu'
|
||
import { useUserStore } from '@/stores/user'
|
||
|
||
const router = useRouter()
|
||
const store = useUserStore()
|
||
|
||
const home = computed(() => {
|
||
const role = store.role
|
||
return role ? HOME_BY_ROLE[role] : '/dashboard'
|
||
})
|
||
|
||
function goHome(): void {
|
||
router.replace(home.value)
|
||
}
|
||
|
||
function goBack(): void {
|
||
const back = router.options.history.state.back
|
||
if (typeof back === 'string' && back) {
|
||
router.back()
|
||
} else {
|
||
goHome()
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="error-page">
|
||
<div class="card error-card">
|
||
<div class="error-icon">
|
||
<el-icon><QuestionFilled /></el-icon>
|
||
</div>
|
||
<div class="error-code">404</div>
|
||
<h1>页面不存在</h1>
|
||
<p class="muted error-desc">
|
||
您访问的页面可能已被移除、地址输入有误,或链接已经失效。请核对地址后重试。
|
||
</p>
|
||
|
||
<div class="current-role small muted">
|
||
当前身份:{{ store.role ? ROLE_LABEL[store.role] : '未登录' }}
|
||
</div>
|
||
|
||
<div class="error-actions">
|
||
<el-button type="primary" @click="goHome">返回首页</el-button>
|
||
<el-button @click="goBack">返回上一页</el-button>
|
||
</div>
|
||
|
||
<div class="small muted error-foot">
|
||
如从业务系统跳转进入,请返回原系统重新发起访问。
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.error-page {
|
||
min-height: 100vh;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 24px 16px;
|
||
background: var(--fin-bg);
|
||
}
|
||
|
||
.error-card {
|
||
width: 100%;
|
||
max-width: 520px;
|
||
padding: 36px 34px 30px;
|
||
text-align: center;
|
||
}
|
||
|
||
.error-icon {
|
||
width: 64px;
|
||
height: 64px;
|
||
margin: 0 auto 14px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: 16px;
|
||
background: #f0f5ff;
|
||
color: var(--el-color-primary);
|
||
font-size: 30px;
|
||
}
|
||
|
||
.error-code {
|
||
font-size: 42px;
|
||
font-weight: 800;
|
||
letter-spacing: 4px;
|
||
color: var(--fin-text);
|
||
}
|
||
|
||
.error-card h1 {
|
||
margin: 4px 0 12px;
|
||
font-size: 20px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.error-desc {
|
||
margin: 0 0 10px;
|
||
font-size: 13px;
|
||
line-height: 1.8;
|
||
}
|
||
|
||
.current-role {
|
||
margin-bottom: 18px;
|
||
}
|
||
|
||
.error-actions {
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
gap: 10px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.error-foot {
|
||
margin-top: 18px;
|
||
}
|
||
</style>
|