blob: a3f2d83447cfed58e322fa7fd6ccd8b78358852b [file] [log] [blame]
2081595154f846f912025-06-04 17:35:21 +08001<template>
2 <div class="home-page">
3 <div class="home-container">
4 <div class="welcome-section">
5 <div class="welcome-card">
6 <div class="welcome-header">
7 <div class="user-avatar">
8 <el-icon size="48" color="#667eea"><UserFilled /></el-icon>
9 </div>
10 <h1 class="welcome-title">🎉 欢迎来到 PT Tracker</h1>
11 <p class="welcome-subtitle" v-if="userInfo.username">
12 欢迎回来,<strong>{{ userInfo.username }}</strong>
13 </p>
14 <p class="login-time" v-if="userInfo.loginTime">
15 登录时间:{{ formatTime(userInfo.loginTime) }}
16 </p>
17 </div>
18
19 <div class="feature-grid">
20 <div class="feature-item">
21 <el-icon size="32" color="#67c23a"><Download /></el-icon>
22 <h3>高速下载</h3>
23 <p>享受极速下载体验</p>
24 </div>
25 <div class="feature-item">
26 <el-icon size="32" color="#e6a23c"><Upload /></el-icon>
27 <h3>资源分享</h3>
28 <p>分享优质资源内容</p>
29 </div>
30 <div class="feature-item">
31 <el-icon size="32" color="#f56c6c"><ChatDotRound /></el-icon>
32 <h3>社区交流</h3>
33 <p>与志同道合的朋友交流</p>
34 </div>
35 </div>
36
37 <div class="action-buttons">
38 <el-button type="primary" size="large" :icon="Search">
39 浏览种子
40 </el-button>
41 <el-button type="success" size="large" :icon="Plus">
42 上传资源
43 </el-button>
44 <el-button type="info" size="large" :icon="Setting">
45 个人设置
46 </el-button>
47 <el-button type="danger" size="large" :icon="SwitchButton" @click="handleLogout">
48 退出登录
49 </el-button>
50 </div>
51 </div>
52 </div>
53 </div>
54 </div>
55</template>
56
57<script>
58import { ref, onMounted } from 'vue'
59import { useRouter } from 'vue-router'
60import { ElMessage, ElMessageBox } from 'element-plus'
61import {
62 UserFilled,
63 Download,
64 Upload,
65 ChatDotRound,
66 Search,
67 Plus,
68 Setting,
69 SwitchButton
70} from '@element-plus/icons-vue'
71
72export default {
73 name: 'HomeView',
74 components: {
75 UserFilled
76 },
77 setup() {
78 const router = useRouter()
79 const userInfo = ref({
80 username: '',
81 loginTime: ''
82 })
83
84 // 获取用户信息
85 onMounted(() => {
86 userInfo.value = {
87 username: localStorage.getItem('username') || '用户',
88 loginTime: localStorage.getItem('loginTime') || ''
89 }
90 })
91
92 // 格式化时间
93 const formatTime = (timeString) => {
94 if (!timeString) return ''
95 const date = new Date(timeString)
96 return date.toLocaleString('zh-CN', {
97 year: 'numeric',
98 month: '2-digit',
99 day: '2-digit',
100 hour: '2-digit',
101 minute: '2-digit'
102 })
103 }
104
105 // 退出登录
106 const handleLogout = async () => {
107 try {
108 await ElMessageBox.confirm(
109 '确定要退出登录吗?',
110 '提示',
111 {
112 confirmButtonText: '确定',
113 cancelButtonText: '取消',
114 type: 'warning'
115 }
116 )
117
118 // 清除登录信息
119 localStorage.removeItem('isLoggedIn')
120 localStorage.removeItem('username')
121 localStorage.removeItem('loginTime')
122 localStorage.removeItem('rememberLogin')
123
124 ElMessage.success('已安全退出')
125 router.push('/login')
126
127 } catch {
128 // 用户取消退出
129 }
130 }
131
132 return {
133 userInfo,
134 formatTime,
135 handleLogout,
136 Search,
137 Plus,
138 Setting,
139 SwitchButton,
140 Download,
141 Upload,
142 ChatDotRound
143 }
144 }
145}
146</script>
147
148<style lang="scss" scoped>
149.home-page {
150 min-height: 100vh;
151 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
152 display: flex;
153 align-items: center;
154 justify-content: center;
155 padding: 20px;
156}
157
158.home-container {
159 width: 100%;
160 max-width: 800px;
161}
162
163.welcome-section {
164 .welcome-card {
165 background: rgba(255, 255, 255, 0.95);
166 backdrop-filter: blur(10px);
167 border-radius: 20px;
168 padding: 60px 40px;
169 box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1);
170 border: 1px solid rgba(255, 255, 255, 0.2);
171 text-align: center;
172
173 .welcome-header {
174 margin-bottom: 40px;
175
176 .user-avatar {
177 margin-bottom: 20px;
178 }
179
180 .welcome-title {
181 font-size: 36px;
182 font-weight: 700;
183 color: #2c3e50;
184 margin-bottom: 12px;
185 letter-spacing: -0.5px;
186 }
187
188 .welcome-subtitle {
189 font-size: 18px;
190 color: #667eea;
191 margin-bottom: 8px;
192 font-weight: 500;
193
194 strong {
195 color: #2c3e50;
196 }
197 }
198
199 .login-time {
200 font-size: 14px;
201 color: #909399;
202 margin: 0;
203 }
204 }
205
206 .feature-grid {
207 display: grid;
208 grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
209 gap: 30px;
210 margin-bottom: 40px;
211
212 .feature-item {
213 background: #f8f9fa;
214 padding: 30px 20px;
215 border-radius: 12px;
216 transition: all 0.3s ease;
217
218 &:hover {
219 transform: translateY(-5px);
220 box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
221 }
222
223 h3 {
224 font-size: 18px;
225 color: #2c3e50;
226 margin: 16px 0 8px 0;
227 font-weight: 600;
228 }
229
230 p {
231 font-size: 14px;
232 color: #7f8c8d;
233 margin: 0;
234 line-height: 1.5;
235 }
236 }
237 }
238
239 .action-buttons {
240 display: grid;
241 grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
242 gap: 16px;
243
244 .el-button {
245 height: 48px;
246 font-size: 15px;
247 font-weight: 500;
248 border-radius: 10px;
249
250 :deep(.el-icon) {
251 margin-right: 8px;
252 }
253 }
254 }
255 }
256}
257
258// 响应式设计
259@media (max-width: 768px) {
260 .home-page {
261 padding: 16px;
262 }
263
264 .welcome-card {
265 padding: 40px 24px !important;
266
267 .welcome-header .welcome-title {
268 font-size: 28px;
269 }
270
271 .feature-grid {
272 grid-template-columns: 1fr;
273 gap: 20px;
274 }
275
276 .action-buttons {
277 grid-template-columns: 1fr;
278 gap: 12px;
279 }
280 }
281}
282</style>