NotFound.vue 2.56 KB
<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <!-- 404 图标 -->
      <div class="not-found-icon">
        <svg viewBox="0 0 200 200" class="w-32 h-32 text-gray-300">
          <circle cx="100" cy="100" r="90" fill="none" stroke="currentColor" stroke-width="4"/>
          <text x="100" y="120" text-anchor="middle" font-size="48" font-weight="bold" fill="currentColor">404</text>
        </svg>
      </div>
      
      <!-- 错误信息 -->
      <div class="not-found-text">
        <h1 class="text-2xl font-bold text-gray-800 mb-2">页面不存在</h1>
        <p class="text-gray-600 mb-8">抱歉,您访问的页面不存在或已被删除</p>
      </div>
      
      <!-- 操作按钮 -->
      <div class="not-found-actions space-y-4">
        <van-button 
          type="primary" 
          round 
          block 
          @click="goHome"
          class="mb-4"
        >
          返回首页
        </van-button>
        
        <van-button 
          plain 
          round 
          block 
          @click="goBack"
        >
          返回上页
        </van-button>
      </div>
      
      <!-- 建议链接 -->
      <div class="suggested-links mt-8">
        <p class="text-sm text-gray-500 mb-4">您可能想要访问:</p>
        <div class="space-y-2">
          <van-cell 
            title="首页" 
            is-link 
            @click="$router.push('/')"
            icon="home-o"
          />
          <van-cell 
            title="组件演示" 
            is-link 
            @click="$router.push('/demo')"
            icon="apps-o"
          />
          <van-cell 
            title="关于我们" 
            is-link 
            @click="$router.push('/about')"
            icon="info-o"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

// 返回首页
const goHome = () => {
  router.push('/')
}

// 返回上一页
const goBack = () => {
  if (window.history.length > 1) {
    router.back()
  } else {
    router.push('/')
  }
}
</script>

<style scoped>
.not-found-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.not-found-content {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.not-found-icon {
  margin-bottom: 2rem;
}

.suggested-links {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
</style>