| <template> |
| <div class="home-page"> |
| <div class="home-container"> |
| <div class="welcome-section"> |
| <div class="welcome-card"> |
| <div class="welcome-header"> |
| <div class="user-avatar"> |
| <el-icon size="48" color="#667eea"><UserFilled /></el-icon> |
| </div> |
| <h1 class="welcome-title">🎉 欢迎来到 PT Tracker</h1> |
| <p class="welcome-subtitle" v-if="userInfo.username"> |
| 欢迎回来,<strong>{{ userInfo.username }}</strong>! |
| </p> |
| <p class="login-time" v-if="userInfo.loginTime"> |
| 登录时间:{{ formatTime(userInfo.loginTime) }} |
| </p> |
| </div> |
| |
| <div class="feature-grid"> |
| <div class="feature-item"> |
| <el-icon size="32" color="#67c23a"><Download /></el-icon> |
| <h3>高速下载</h3> |
| <p>享受极速下载体验</p> |
| </div> |
| <div class="feature-item"> |
| <el-icon size="32" color="#e6a23c"><Upload /></el-icon> |
| <h3>资源分享</h3> |
| <p>分享优质资源内容</p> |
| </div> |
| <div class="feature-item"> |
| <el-icon size="32" color="#f56c6c"><ChatDotRound /></el-icon> |
| <h3>社区交流</h3> |
| <p>与志同道合的朋友交流</p> |
| </div> |
| </div> |
| |
| <div class="action-buttons"> |
| <el-button type="primary" size="large" :icon="Search"> |
| 浏览种子 |
| </el-button> |
| <el-button type="success" size="large" :icon="Plus"> |
| 上传资源 |
| </el-button> |
| <el-button type="info" size="large" :icon="Setting"> |
| 个人设置 |
| </el-button> |
| <el-button type="danger" size="large" :icon="SwitchButton" @click="handleLogout"> |
| 退出登录 |
| </el-button> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </template> |
| |
| <script> |
| import { ref, onMounted } from 'vue' |
| import { useRouter } from 'vue-router' |
| import { ElMessage, ElMessageBox } from 'element-plus' |
| import { |
| UserFilled, |
| Download, |
| Upload, |
| ChatDotRound, |
| Search, |
| Plus, |
| Setting, |
| SwitchButton |
| } from '@element-plus/icons-vue' |
| |
| export default { |
| name: 'HomeView', |
| components: { |
| UserFilled |
| }, |
| setup() { |
| const router = useRouter() |
| const userInfo = ref({ |
| username: '', |
| loginTime: '' |
| }) |
| |
| // 获取用户信息 |
| onMounted(() => { |
| userInfo.value = { |
| username: localStorage.getItem('username') || '用户', |
| loginTime: localStorage.getItem('loginTime') || '' |
| } |
| }) |
| |
| // 格式化时间 |
| const formatTime = (timeString) => { |
| if (!timeString) return '' |
| const date = new Date(timeString) |
| return date.toLocaleString('zh-CN', { |
| year: 'numeric', |
| month: '2-digit', |
| day: '2-digit', |
| hour: '2-digit', |
| minute: '2-digit' |
| }) |
| } |
| |
| // 退出登录 |
| const handleLogout = async () => { |
| try { |
| await ElMessageBox.confirm( |
| '确定要退出登录吗?', |
| '提示', |
| { |
| confirmButtonText: '确定', |
| cancelButtonText: '取消', |
| type: 'warning' |
| } |
| ) |
| |
| // 清除登录信息 |
| localStorage.removeItem('isLoggedIn') |
| localStorage.removeItem('username') |
| localStorage.removeItem('loginTime') |
| localStorage.removeItem('rememberLogin') |
| |
| ElMessage.success('已安全退出') |
| router.push('/login') |
| |
| } catch { |
| // 用户取消退出 |
| } |
| } |
| |
| return { |
| userInfo, |
| formatTime, |
| handleLogout, |
| Search, |
| Plus, |
| Setting, |
| SwitchButton, |
| Download, |
| Upload, |
| ChatDotRound |
| } |
| } |
| } |
| </script> |
| |
| <style lang="scss" scoped> |
| .home-page { |
| min-height: 100vh; |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| padding: 20px; |
| } |
| |
| .home-container { |
| width: 100%; |
| max-width: 800px; |
| } |
| |
| .welcome-section { |
| .welcome-card { |
| background: rgba(255, 255, 255, 0.95); |
| backdrop-filter: blur(10px); |
| border-radius: 20px; |
| padding: 60px 40px; |
| box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1); |
| border: 1px solid rgba(255, 255, 255, 0.2); |
| text-align: center; |
| |
| .welcome-header { |
| margin-bottom: 40px; |
| |
| .user-avatar { |
| margin-bottom: 20px; |
| } |
| |
| .welcome-title { |
| font-size: 36px; |
| font-weight: 700; |
| color: #2c3e50; |
| margin-bottom: 12px; |
| letter-spacing: -0.5px; |
| } |
| |
| .welcome-subtitle { |
| font-size: 18px; |
| color: #667eea; |
| margin-bottom: 8px; |
| font-weight: 500; |
| |
| strong { |
| color: #2c3e50; |
| } |
| } |
| |
| .login-time { |
| font-size: 14px; |
| color: #909399; |
| margin: 0; |
| } |
| } |
| |
| .feature-grid { |
| display: grid; |
| grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); |
| gap: 30px; |
| margin-bottom: 40px; |
| |
| .feature-item { |
| background: #f8f9fa; |
| padding: 30px 20px; |
| border-radius: 12px; |
| transition: all 0.3s ease; |
| |
| &:hover { |
| transform: translateY(-5px); |
| box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); |
| } |
| |
| h3 { |
| font-size: 18px; |
| color: #2c3e50; |
| margin: 16px 0 8px 0; |
| font-weight: 600; |
| } |
| |
| p { |
| font-size: 14px; |
| color: #7f8c8d; |
| margin: 0; |
| line-height: 1.5; |
| } |
| } |
| } |
| |
| .action-buttons { |
| display: grid; |
| grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); |
| gap: 16px; |
| |
| .el-button { |
| height: 48px; |
| font-size: 15px; |
| font-weight: 500; |
| border-radius: 10px; |
| |
| :deep(.el-icon) { |
| margin-right: 8px; |
| } |
| } |
| } |
| } |
| } |
| |
| // 响应式设计 |
| @media (max-width: 768px) { |
| .home-page { |
| padding: 16px; |
| } |
| |
| .welcome-card { |
| padding: 40px 24px !important; |
| |
| .welcome-header .welcome-title { |
| font-size: 28px; |
| } |
| |
| .feature-grid { |
| grid-template-columns: 1fr; |
| gap: 20px; |
| } |
| |
| .action-buttons { |
| grid-template-columns: 1fr; |
| gap: 12px; |
| } |
| } |
| } |
| </style> |