基本功能实现
Change-Id: I4fb8dfa2eed093c13d7c1e4304c4b4d012512ba9
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index a3f2d83..c4e0ec7 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -1,55 +1,208 @@
<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>
+ <!-- 用户信息和导航 -->
+ <header class="site-header">
+ <div class="header-content">
+ <div class="logo-section">
+ <h2 class="site-logo">🚀 PT Tracker</h2>
</div>
-
- <div class="feature-grid">
- <div class="feature-item">
- <el-icon size="32" color="#67c23a"><Download /></el-icon>
- <h3>高速下载</h3>
- <p>享受极速下载体验</p>
+ <div class="user-section">
+ <div class="user-stats">
+ <div class="stat-item">
+ <span class="stat-label">上传:</span>
+ <span class="stat-value">{{ userStats.uploaded }}</span>
+ </div>
+ <div class="stat-item">
+ <span class="stat-label">下载:</span>
+ <span class="stat-value">{{ userStats.downloaded }}</span>
+ </div>
+ <div class="stat-item">
+ <span class="stat-label">分享率:</span>
+ <span class="stat-value ratio" :class="getRatioClass(userStats.ratio)">
+ {{ userStats.ratio }}
+ </span>
+ </div>
</div>
- <div class="feature-item">
- <el-icon size="32" color="#e6a23c"><Upload /></el-icon>
- <h3>资源分享</h3>
- <p>分享优质资源内容</p>
+ <div class="user-info">
+ <el-avatar :size="40" :icon="UserFilled" />
+ <span class="username">{{ userInfo.username }}</span>
+ <el-dropdown @command="handleUserCommand">
+ <el-icon class="dropdown-icon"><ArrowDown /></el-icon>
+ <template #dropdown>
+ <el-dropdown-menu>
+ <el-dropdown-item command="profile">个人资料</el-dropdown-item>
+ <el-dropdown-item command="settings">设置</el-dropdown-item>
+ <el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
+ </el-dropdown-menu>
+ </template>
+ </el-dropdown>
</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>
+ </header>
+
+ <!-- 主要内容区域 -->
+ <main class="main-content">
+ <!-- 统计概览 -->
+ <section class="stats-overview">
+ <div class="stats-grid">
+ <div class="stat-card">
+ <div class="stat-icon">
+ <el-icon size="32" color="#67c23a"><Download /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ siteStats.totalTorrents }}</h3>
+ <p>种子总数</p>
+ </div>
+ </div>
+ <div class="stat-card">
+ <div class="stat-icon">
+ <el-icon size="32" color="#409eff"><User /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ siteStats.totalUsers }}</h3>
+ <p>注册用户</p>
+ </div>
+ </div>
+ <div class="stat-card">
+ <div class="stat-icon">
+ <el-icon size="32" color="#f56c6c"><Upload /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ siteStats.totalSize }}</h3>
+ <p>数据总量</p>
+ </div>
+ </div>
+ </div>
+ </section>
+
+ <!-- 快速操作 -->
+ <section class="quick-actions">
+ <h2 class="section-title">快速操作</h2>
+ <div class="action-grid">
+ <div class="action-card" @click="navigateTo('/torrents')">
+ <el-icon size="48" color="#409eff"><Search /></el-icon>
+ <h3>浏览种子</h3>
+ <p>搜索和浏览所有可用的种子资源</p>
+ </div>
+ <div class="action-card" @click="navigateTo('/upload')">
+ <el-icon size="48" color="#67c23a"><Upload /></el-icon>
+ <h3>上传资源</h3>
+ <p>分享你的资源,为社区做贡献</p>
+ </div>
+ <div class="action-card" @click="navigateTo('/forum')">
+ <el-icon size="48" color="#e6a23c"><ChatDotRound /></el-icon>
+ <h3>论坛交流</h3>
+ <p>与其他用户交流讨论</p>
+ </div>
+ <div class="action-card" @click="navigateTo('/rankings')">
+ <el-icon size="48" color="#f56c6c"><TrophyBase /></el-icon>
+ <h3>排行榜</h3>
+ <p>查看用户和资源排行</p>
+ </div>
+ </div>
+ </section>
+
+ <!-- 最新种子 -->
+ <section class="latest-torrents">
+ <div class="section-header">
+ <h2 class="section-title">最新种子</h2>
+ <el-button type="primary" text @click="navigateTo('/torrents')">
+ 查看更多 <el-icon><ArrowRight /></el-icon>
+ </el-button>
+ </div>
+ <div class="torrents-list">
+ <div
+ v-for="torrent in latestTorrents"
+ :key="torrent.id"
+ class="torrent-item"
+ @click="navigateTo(`/torrent/${torrent.id}`)"
+ >
+ <div class="torrent-info">
+ <div class="torrent-category">
+ <el-tag :type="getCategoryType(torrent.category)" size="small">
+ {{ torrent.category }}
+ </el-tag>
+ </div>
+ <h4 class="torrent-title">{{ torrent.title }}</h4>
+ <div class="torrent-meta">
+ <span class="meta-item">
+ <el-icon><User /></el-icon>
+ {{ torrent.uploader }}
+ </span>
+ <span class="meta-item">
+ <el-icon><Clock /></el-icon>
+ {{ formatTime(torrent.uploadTime) }}
+ </span>
+ <span class="meta-item">
+ <el-icon><Coin /></el-icon>
+ {{ torrent.size }}
+ </span>
+ </div>
+ </div>
+ <div class="torrent-stats">
+ <div class="stat-group">
+ <span class="stat-number seeders">{{ torrent.seeders }}</span>
+ <span class="stat-label">做种</span>
+ </div>
+ <div class="stat-group">
+ <span class="stat-number leechers">{{ torrent.leechers }}</span>
+ <span class="stat-label">下载</span>
+ </div>
+ <div class="stat-group">
+ <span class="stat-number">{{ torrent.downloads }}</span>
+ <span class="stat-label">完成</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </section>
+
+ <!-- 个人活动 -->
+ <section class="user-activity">
+ <h2 class="section-title">我的活动</h2>
+ <div class="activity-grid">
+ <div class="activity-card">
+ <h3>我的种子</h3>
+ <div class="activity-stats">
+ <div class="activity-item">
+ <span class="activity-label">正在做种:</span>
+ <span class="activity-value">{{ userActivity.seeding }}</span>
+ </div>
+ <div class="activity-item">
+ <span class="activity-label">正在下载:</span>
+ <span class="activity-value">{{ userActivity.downloading }}</span>
+ </div>
+ <div class="activity-item">
+ <span class="activity-label">已上传:</span>
+ <span class="activity-value">{{ userActivity.uploaded }}</span>
+ </div>
+ </div>
+ <el-button type="primary" size="small" @click="navigateTo('/my-torrents')">
+ 查看详情
+ </el-button>
+ </div>
+
+ <div class="activity-card">
+ <h3>邀请管理</h3>
+ <div class="activity-stats">
+ <div class="activity-item">
+ <span class="activity-label">可用邀请:</span>
+ <span class="activity-value">{{ userActivity.invitations }}</span>
+ </div>
+ <div class="activity-item">
+ <span class="activity-label">已邀请:</span>
+ <span class="activity-value">{{ userActivity.invited }}</span>
+ </div>
+ </div>
+ <el-button type="success" size="small" @click="navigateTo('/invitations')">
+ 管理邀请
+ </el-button>
+ </div>
+ </div>
+ </section>
+ </main>
</div>
</div>
</template>
@@ -60,49 +213,154 @@
import { ElMessage, ElMessageBox } from 'element-plus'
import {
UserFilled,
+ ArrowDown,
Download,
Upload,
ChatDotRound,
Search,
- Plus,
- Setting,
- SwitchButton
+ User,
+ Connection,
+ TrophyBase,
+ ArrowRight,
+ Clock,
+ Coin
} from '@element-plus/icons-vue'
export default {
name: 'HomeView',
components: {
- UserFilled
+ UserFilled,
+ ArrowDown
},
setup() {
const router = useRouter()
+
const userInfo = ref({
username: '',
loginTime: ''
})
- // 获取用户信息
+ const userStats = ref({
+ uploaded: '128.5 GB',
+ downloaded: '45.2 GB',
+ ratio: '2.84'
+ })
+
+ const siteStats = ref({
+ totalTorrents: '12,458',
+ totalUsers: '8,924',
+ onlineUsers: '342',
+ totalSize: '45.2 TB'
+ })
+
+ const userActivity = ref({
+ seeding: 15,
+ downloading: 3,
+ uploaded: 8,
+ invitations: 5,
+ invited: 12
+ })
+
+ const latestTorrents = ref([
+ {
+ id: 1,
+ title: '[4K蓝光原盘] 阿凡达:水之道 Avatar: The Way of Water (2022)',
+ category: '电影',
+ uploader: 'MovieMaster',
+ uploadTime: '2025-06-03T10:30:00',
+ size: '85.6 GB',
+ seeders: 128,
+ leechers: 45,
+ downloads: 892
+ },
+ {
+ id: 2,
+ title: '[FLAC] Taylor Swift - Midnights (Deluxe Edition) [2022]',
+ category: '音乐',
+ uploader: 'MusicLover',
+ uploadTime: '2025-06-03T09:15:00',
+ size: '1.2 GB',
+ seeders: 67,
+ leechers: 12,
+ downloads: 456
+ },
+ {
+ id: 3,
+ title: '[合集] Adobe Creative Suite 2025 完整版',
+ category: '软件',
+ uploader: 'TechGuru',
+ uploadTime: '2025-06-03T08:45:00',
+ size: '12.8 GB',
+ seeders: 234,
+ leechers: 89,
+ downloads: 1205
+ }
+ ])
+
onMounted(() => {
userInfo.value = {
username: localStorage.getItem('username') || '用户',
loginTime: localStorage.getItem('loginTime') || ''
}
+
+ // 模拟获取用户数据
+ fetchUserData()
})
- // 格式化时间
+ const fetchUserData = () => {
+ // 这里应该是API调用,现在使用模拟数据
+ console.log('获取用户数据...')
+ }
+
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 now = new Date()
+ const diff = now - date
+ const hours = Math.floor(diff / (1000 * 60 * 60))
+
+ if (hours < 1) return '刚刚'
+ if (hours < 24) return `${hours}小时前`
+ const days = Math.floor(hours / 24)
+ return `${days}天前`
}
- // 退出登录
+ const getRatioClass = (ratio) => {
+ const r = parseFloat(ratio)
+ if (r >= 2) return 'excellent'
+ if (r >= 1) return 'good'
+ return 'warning'
+ }
+
+ const getCategoryType = (category) => {
+ const types = {
+ '电影': 'primary',
+ '音乐': 'success',
+ '软件': 'warning',
+ '游戏': 'danger',
+ '电视剧': 'info'
+ }
+ return types[category] || 'default'
+ }
+
+ const navigateTo = (path) => {
+ router.push(path)
+ }
+
+ const handleUserCommand = async (command) => {
+ switch (command) {
+ case 'profile':
+ navigateTo('/profile')
+ break
+ case 'settings':
+ navigateTo('/settings')
+ break
+ case 'logout':
+ await handleLogout()
+ break
+ }
+ }
+
const handleLogout = async () => {
try {
await ElMessageBox.confirm(
@@ -115,7 +373,6 @@
}
)
- // 清除登录信息
localStorage.removeItem('isLoggedIn')
localStorage.removeItem('username')
localStorage.removeItem('loginTime')
@@ -131,15 +388,26 @@
return {
userInfo,
+ userStats,
+ siteStats,
+ userActivity,
+ latestTorrents,
formatTime,
+ getRatioClass,
+ getCategoryType,
+ navigateTo,
+ handleUserCommand,
handleLogout,
- Search,
- Plus,
- Setting,
- SwitchButton,
Download,
Upload,
- ChatDotRound
+ ChatDotRound,
+ Search,
+ User,
+ Connection,
+ TrophyBase,
+ ArrowRight,
+ Clock,
+ Coin
}
}
}
@@ -149,106 +417,323 @@
.home-page {
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 20px;
+ padding: 0;
}
.home-container {
- width: 100%;
- max-width: 800px;
+ max-width: 1200px;
+ margin: 0 auto;
+ background: #fff;
+ min-height: 100vh;
}
-.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;
+// 网站头部
+.site-header {
+ background: #fff;
+ box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
+ position: sticky;
+ top: 0;
+ z-index: 100;
+
+ .header-content {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px 24px;
- .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;
+ .logo-section {
+ .site-logo {
margin: 0;
+ font-size: 24px;
+ font-weight: bold;
+ color: #667eea;
}
}
- .feature-grid {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: 30px;
- margin-bottom: 40px;
+ .user-section {
+ display: flex;
+ align-items: center;
+ gap: 24px;
- .feature-item {
- background: #f8f9fa;
- padding: 30px 20px;
- border-radius: 12px;
- transition: all 0.3s ease;
+ .user-stats {
+ display: flex;
+ gap: 16px;
- &:hover {
- transform: translateY(-5px);
- box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
+ .stat-item {
+ font-size: 14px;
+
+ .stat-label {
+ color: #909399;
+ margin-right: 4px;
+ }
+
+ .stat-value {
+ font-weight: 600;
+ color: #2c3e50;
+
+ &.ratio {
+ &.excellent { color: #67c23a; }
+ &.good { color: #e6a23c; }
+ &.warning { color: #f56c6c; }
+ }
+ }
+ }
+ }
+
+ .user-info {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ cursor: pointer;
+
+ .username {
+ font-weight: 500;
+ color: #2c3e50;
}
+ .dropdown-icon {
+ color: #909399;
+ transition: transform 0.3s ease;
+
+ &:hover {
+ transform: rotate(180deg);
+ }
+ }
+ }
+ }
+ }
+}
+
+// 主要内容
+.main-content {
+ padding: 24px;
+}
+
+.section-title {
+ font-size: 20px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin-bottom: 16px;
+}
+
+.section-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 16px;
+}
+
+// 统计概览
+.stats-overview {
+ margin-bottom: 32px;
+
+ .stats-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ gap: 16px;
+
+ .stat-card {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+ border: 1px solid #f0f0f0;
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ transition: all 0.3s ease;
+
+ &:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
+ }
+
+ .stat-info {
h3 {
- font-size: 18px;
+ font-size: 24px;
+ font-weight: bold;
color: #2c3e50;
- margin: 16px 0 8px 0;
- font-weight: 600;
+ margin: 0 0 4px 0;
}
p {
font-size: 14px;
- color: #7f8c8d;
+ color: #909399;
margin: 0;
- line-height: 1.5;
}
}
}
+ }
+}
+
+// 快速操作
+.quick-actions {
+ margin-bottom: 32px;
+
+ .action-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
+ gap: 20px;
- .action-buttons {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
- gap: 16px;
+ .action-card {
+ background: #fff;
+ border-radius: 12px;
+ padding: 32px 24px;
+ text-align: center;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+ border: 1px solid #f0f0f0;
+ cursor: pointer;
+ transition: all 0.3s ease;
- .el-button {
- height: 48px;
- font-size: 15px;
- font-weight: 500;
- border-radius: 10px;
+ &:hover {
+ transform: translateY(-4px);
+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
+ }
+
+ h3 {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 16px 0 8px 0;
+ }
+
+ p {
+ font-size: 14px;
+ color: #7f8c8d;
+ line-height: 1.5;
+ margin: 0;
+ }
+ }
+ }
+}
+
+// 最新种子
+.latest-torrents {
+ margin-bottom: 32px;
+
+ .torrents-list {
+ background: #fff;
+ border-radius: 12px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+ border: 1px solid #f0f0f0;
+ overflow: hidden;
+
+ .torrent-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 20px 24px;
+ border-bottom: 1px solid #f5f5f5;
+ cursor: pointer;
+ transition: background-color 0.3s ease;
+
+ &:hover {
+ background-color: #f8f9fa;
+ }
+
+ &:last-child {
+ border-bottom: none;
+ }
+
+ .torrent-info {
+ flex: 1;
- :deep(.el-icon) {
- margin-right: 8px;
+ .torrent-category {
+ margin-bottom: 8px;
+ }
+
+ .torrent-title {
+ font-size: 16px;
+ font-weight: 500;
+ color: #2c3e50;
+ margin: 0 0 8px 0;
+ line-height: 1.4;
+ }
+
+ .torrent-meta {
+ display: flex;
+ gap: 16px;
+
+ .meta-item {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ font-size: 12px;
+ color: #909399;
+
+ .el-icon {
+ font-size: 12px;
+ }
+ }
+ }
+ }
+
+ .torrent-stats {
+ display: flex;
+ gap: 24px;
+
+ .stat-group {
+ text-align: center;
+
+ .stat-number {
+ display: block;
+ font-size: 16px;
+ font-weight: 600;
+
+ &.seeders { color: #67c23a; }
+ &.leechers { color: #f56c6c; }
+ }
+
+ .stat-label {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+ }
+ }
+ }
+}
+
+// 用户活动
+.user-activity {
+ .activity-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
+ gap: 20px;
+
+ .activity-card {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+ border: 1px solid #f0f0f0;
+
+ h3 {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 16px 0;
+ }
+
+ .activity-stats {
+ margin-bottom: 16px;
+
+ .activity-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 8px 0;
+
+ .activity-label {
+ font-size: 14px;
+ color: #7f8c8d;
+ }
+
+ .activity-value {
+ font-size: 14px;
+ font-weight: 600;
+ color: #2c3e50;
+ }
}
}
}
@@ -257,25 +742,35 @@
// 响应式设计
@media (max-width: 768px) {
- .home-page {
+ .header-content {
+ flex-direction: column;
+ gap: 16px;
+
+ .user-stats {
+ flex-direction: column;
+ gap: 8px;
+ text-align: center;
+ }
+ }
+
+ .main-content {
padding: 16px;
}
- .welcome-card {
- padding: 40px 24px !important;
+ .stats-grid,
+ .action-grid,
+ .activity-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .torrent-item {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 16px;
- .welcome-header .welcome-title {
- font-size: 28px;
- }
-
- .feature-grid {
- grid-template-columns: 1fr;
- gap: 20px;
- }
-
- .action-buttons {
- grid-template-columns: 1fr;
- gap: 12px;
+ .torrent-stats {
+ width: 100%;
+ justify-content: space-around;
}
}
}
diff --git a/src/views/auth/ProfileView.vue b/src/views/auth/ProfileView.vue
new file mode 100644
index 0000000..e1e2544
--- /dev/null
+++ b/src/views/auth/ProfileView.vue
@@ -0,0 +1,1343 @@
+<template>
+ <div class="profile-page">
+ <div class="page-container">
+ <!-- 个人信息卡片 -->
+ <div class="profile-header">
+ <div class="user-avatar-section">
+ <div class="avatar-container">
+ <el-avatar :size="120" :src="userProfile.avatar">
+ {{ userProfile.username.charAt(0).toUpperCase() }}
+ </el-avatar>
+ <el-button
+ type="primary"
+ size="small"
+ class="change-avatar-btn"
+ @click="showAvatarDialog = true"
+ >
+ 更换头像
+ </el-button>
+ </div>
+
+ <div class="user-basic-info">
+ <h1 class="username">{{ userProfile.username }}</h1>
+ <div class="user-title">
+ <el-tag :type="getUserTitleType(userProfile.userLevel)" size="large">
+ {{ userProfile.userTitle }}
+ </el-tag>
+ </div>
+ <div class="join-info">
+ <el-icon><Calendar /></el-icon>
+ <span>加入时间:{{ formatDate(userProfile.joinDate) }}</span>
+ </div>
+ <div class="last-login">
+ <el-icon><Clock /></el-icon>
+ <span>最后登录:{{ formatTime(userProfile.lastLogin) }}</span>
+ </div>
+ </div>
+ </div>
+
+ <div class="user-stats-overview">
+ <div class="stats-grid">
+ <div class="stat-card">
+ <div class="stat-icon upload">
+ <el-icon size="32"><Upload /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ userProfile.stats.uploaded }}</h3>
+ <p>上传量</p>
+ </div>
+ </div>
+
+ <div class="stat-card">
+ <div class="stat-icon download">
+ <el-icon size="32"><Download /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ userProfile.stats.downloaded }}</h3>
+ <p>下载量</p>
+ </div>
+ </div>
+
+ <div class="stat-card">
+ <div class="stat-icon ratio" :class="getRatioClass(userProfile.stats.ratio)">
+ <el-icon size="32"><TrendCharts /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ userProfile.stats.ratio }}</h3>
+ <p>分享率</p>
+ </div>
+ </div>
+
+ <div class="stat-card">
+ <div class="stat-icon points">
+ <el-icon size="32"><Star /></el-icon>
+ </div>
+ <div class="stat-info">
+ <h3>{{ userProfile.stats.points }}</h3>
+ <p>积分</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 详细信息选项卡 -->
+ <div class="profile-content">
+ <el-tabs v-model="activeTab" type="border-card">
+ <!-- 个人信息 -->
+ <el-tab-pane label="个人信息" name="info">
+ <div class="info-section">
+ <el-form
+ ref="profileFormRef"
+ :model="editProfile"
+ :rules="profileRules"
+ label-width="120px"
+ size="large"
+ >
+ <div class="form-section">
+ <h3>基本信息</h3>
+ <el-form-item label="用户名">
+ <el-input v-model="editProfile.username" disabled>
+ <template #suffix>
+ <el-tooltip content="用户名不可修改">
+ <el-icon><QuestionFilled /></el-icon>
+ </el-tooltip>
+ </template>
+ </el-input>
+ </el-form-item>
+
+ <el-form-item label="邮箱地址" prop="email">
+ <el-input v-model="editProfile.email" type="email" />
+ </el-form-item>
+
+ <el-form-item label="真实姓名" prop="realName">
+ <el-input v-model="editProfile.realName" placeholder="可选填写" />
+ </el-form-item>
+
+ <el-form-item label="所在地区">
+ <el-cascader
+ v-model="editProfile.location"
+ :options="locationOptions"
+ placeholder="请选择地区"
+ clearable
+ />
+ </el-form-item>
+ </div>
+
+ <div class="form-section">
+ <h3>个人介绍</h3>
+ <el-form-item label="个人签名">
+ <el-input
+ v-model="editProfile.signature"
+ type="textarea"
+ :rows="3"
+ maxlength="200"
+ show-word-limit
+ placeholder="介绍一下自己吧..."
+ />
+ </el-form-item>
+
+ <el-form-item label="个人网站">
+ <el-input v-model="editProfile.website" placeholder="https://" />
+ </el-form-item>
+
+ <el-form-item label="兴趣爱好">
+ <div class="interests-input">
+ <el-tag
+ v-for="interest in editProfile.interests"
+ :key="interest"
+ closable
+ @close="removeInterest(interest)"
+ class="interest-tag"
+ >
+ {{ interest }}
+ </el-tag>
+ <el-input
+ v-if="interestInputVisible"
+ ref="interestInputRef"
+ v-model="interestInputValue"
+ size="small"
+ @keyup.enter="addInterest"
+ @blur="addInterest"
+ style="width: 120px;"
+ />
+ <el-button
+ v-else
+ size="small"
+ @click="showInterestInput"
+ >
+ + 添加兴趣
+ </el-button>
+ </div>
+ </el-form-item>
+ </div>
+
+ <div class="form-section">
+ <h3>隐私设置</h3>
+ <el-form-item label="邮箱公开">
+ <el-switch v-model="editProfile.emailPublic" />
+ <span class="setting-tip">是否在个人资料中显示邮箱</span>
+ </el-form-item>
+
+ <el-form-item label="统计公开">
+ <el-switch v-model="editProfile.statsPublic" />
+ <span class="setting-tip">是否公开上传下载统计</span>
+ </el-form-item>
+
+ <el-form-item label="活动记录">
+ <el-switch v-model="editProfile.activityPublic" />
+ <span class="setting-tip">是否公开活动记录</span>
+ </el-form-item>
+ </div>
+
+ <div class="form-actions">
+ <el-button @click="resetProfile">重置</el-button>
+ <el-button type="primary" @click="saveProfile" :loading="saving">
+ 保存修改
+ </el-button>
+ </div>
+ </el-form>
+ </div>
+ </el-tab-pane>
+
+ <!-- 数据统计 -->
+ <el-tab-pane label="数据统计" name="stats">
+ <div class="stats-section">
+ <div class="stats-overview">
+ <div class="overview-grid">
+ <div class="overview-card">
+ <h3>上传统计</h3>
+ <div class="stat-details">
+ <div class="detail-item">
+ <span class="label">总上传量:</span>
+ <span class="value">{{ userProfile.detailedStats.totalUploaded }}</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">上传种子:</span>
+ <span class="value">{{ userProfile.detailedStats.uploadedTorrents }} 个</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">平均大小:</span>
+ <span class="value">{{ userProfile.detailedStats.avgUploadSize }}</span>
+ </div>
+ </div>
+ </div>
+
+ <div class="overview-card">
+ <h3>下载统计</h3>
+ <div class="stat-details">
+ <div class="detail-item">
+ <span class="label">总下载量:</span>
+ <span class="value">{{ userProfile.detailedStats.totalDownloaded }}</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">下载种子:</span>
+ <span class="value">{{ userProfile.detailedStats.downloadedTorrents }} 个</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">完成种子:</span>
+ <span class="value">{{ userProfile.detailedStats.completedTorrents }} 个</span>
+ </div>
+ </div>
+ </div>
+
+ <div class="overview-card">
+ <h3>做种统计</h3>
+ <div class="stat-details">
+ <div class="detail-item">
+ <span class="label">正在做种:</span>
+ <span class="value">{{ userProfile.detailedStats.seeding }} 个</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">做种时间:</span>
+ <span class="value">{{ userProfile.detailedStats.seedingTime }}</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">做种排名:</span>
+ <span class="value">第 {{ userProfile.detailedStats.seedingRank }} 名</span>
+ </div>
+ </div>
+ </div>
+
+ <div class="overview-card">
+ <h3>积分记录</h3>
+ <div class="stat-details">
+ <div class="detail-item">
+ <span class="label">当前积分:</span>
+ <span class="value">{{ userProfile.stats.points }}</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">累计获得:</span>
+ <span class="value">{{ userProfile.detailedStats.totalEarnedPoints }}</span>
+ </div>
+ <div class="detail-item">
+ <span class="label">累计消费:</span>
+ <span class="value">{{ userProfile.detailedStats.totalSpentPoints }}</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 数据图表 -->
+ <div class="charts-section">
+ <div class="chart-card">
+ <h3>上传下载趋势</h3>
+ <div class="chart-placeholder">
+ <el-icon size="48" color="#e4e7ed"><TrendCharts /></el-icon>
+ <p>图表功能开发中...</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </el-tab-pane>
+
+ <!-- 我的种子 -->
+ <el-tab-pane label="我的种子" name="torrents">
+ <div class="torrents-section">
+ <div class="section-header">
+ <h3>我上传的种子</h3>
+ <el-button type="primary" :icon="Upload" @click="$router.push('/upload')">
+ 上传新种子
+ </el-button>
+ </div>
+
+ <el-table :data="userTorrents" stripe>
+ <el-table-column label="种子名称" min-width="300">
+ <template #default="{ row }">
+ <div class="torrent-info">
+ <el-tag :type="getCategoryType(row.category)" size="small">
+ {{ getCategoryName(row.category) }}
+ </el-tag>
+ <span class="torrent-title">{{ row.title }}</span>
+ </div>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="大小" prop="size" width="100" />
+ <el-table-column label="做种" prop="seeders" width="80" align="center" />
+ <el-table-column label="下载" prop="leechers" width="80" align="center" />
+ <el-table-column label="完成" prop="downloads" width="80" align="center" />
+ <el-table-column label="上传时间" width="120">
+ <template #default="{ row }">
+ {{ formatDate(row.uploadTime) }}
+ </template>
+ </el-table-column>
+
+ <el-table-column label="操作" width="120" align="center">
+ <template #default="{ row }">
+ <el-button
+ type="primary"
+ size="small"
+ @click="$router.push(`/torrent/${row.id}`)"
+ >
+ 查看
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <div class="pagination-wrapper">
+ <el-pagination
+ v-model:current-page="torrentsPage"
+ :page-size="10"
+ :total="userTorrents.length"
+ layout="prev, pager, next"
+ small
+ />
+ </div>
+ </div>
+ </el-tab-pane>
+
+ <!-- 活动记录 -->
+ <el-tab-pane label="活动记录" name="activity">
+ <div class="activity-section">
+ <div class="activity-filters">
+ <el-select v-model="activityFilter" placeholder="活动类型">
+ <el-option label="全部活动" value="" />
+ <el-option label="上传种子" value="upload" />
+ <el-option label="下载种子" value="download" />
+ <el-option label="论坛发帖" value="post" />
+ <el-option label="积分变动" value="points" />
+ </el-select>
+ </div>
+
+ <div class="activity-timeline">
+ <el-timeline>
+ <el-timeline-item
+ v-for="activity in filteredActivities"
+ :key="activity.id"
+ :timestamp="formatTime(activity.time)"
+ :type="getActivityType(activity.type)"
+ >
+ <div class="activity-content">
+ <div class="activity-header">
+ <el-icon>
+ <component :is="getActivityIcon(activity.type)" />
+ </el-icon>
+ <span class="activity-title">{{ activity.title }}</span>
+ </div>
+ <div class="activity-description">{{ activity.description }}</div>
+ </div>
+ </el-timeline-item>
+ </el-timeline>
+ </div>
+ </div>
+ </el-tab-pane>
+
+ <!-- 安全设置 -->
+ <el-tab-pane label="安全设置" name="security">
+ <div class="security-section">
+ <div class="security-card">
+ <h3>修改密码</h3>
+ <el-form
+ ref="passwordFormRef"
+ :model="passwordForm"
+ :rules="passwordRules"
+ label-width="120px"
+ >
+ <el-form-item label="当前密码" prop="currentPassword">
+ <el-input
+ v-model="passwordForm.currentPassword"
+ type="password"
+ show-password
+ placeholder="请输入当前密码"
+ />
+ </el-form-item>
+
+ <el-form-item label="新密码" prop="newPassword">
+ <el-input
+ v-model="passwordForm.newPassword"
+ type="password"
+ show-password
+ placeholder="请输入新密码"
+ />
+ </el-form-item>
+
+ <el-form-item label="确认密码" prop="confirmPassword">
+ <el-input
+ v-model="passwordForm.confirmPassword"
+ type="password"
+ show-password
+ placeholder="请再次输入新密码"
+ />
+ </el-form-item>
+
+ <el-form-item>
+ <el-button type="primary" @click="changePassword" :loading="changingPassword">
+ 修改密码
+ </el-button>
+ </el-form-item>
+ </el-form>
+ </div>
+
+ <div class="security-card">
+ <h3>登录记录</h3>
+ <el-table :data="loginHistory" stripe>
+ <el-table-column label="登录时间" width="180">
+ <template #default="{ row }">
+ {{ formatDateTime(row.time) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="IP地址" prop="ip" width="150" />
+ <el-table-column label="设备信息" prop="device" />
+ <el-table-column label="登录结果" width="100">
+ <template #default="{ row }">
+ <el-tag :type="row.success ? 'success' : 'danger'" size="small">
+ {{ row.success ? '成功' : '失败' }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ </div>
+ </el-tab-pane>
+ </el-tabs>
+ </div>
+ </div>
+
+ <!-- 更换头像对话框 -->
+ <el-dialog v-model="showAvatarDialog" title="更换头像" width="400px">
+ <div class="avatar-upload">
+ <el-upload
+ ref="avatarUploadRef"
+ :auto-upload="false"
+ :limit="1"
+ accept="image/*"
+ :on-change="handleAvatarChange"
+ list-type="picture-card"
+ class="avatar-uploader"
+ >
+ <el-icon><Plus /></el-icon>
+ </el-upload>
+ <div class="upload-tips">
+ <p>支持 JPG、PNG 格式</p>
+ <p>建议尺寸 200x200 像素</p>
+ <p>文件大小不超过 2MB</p>
+ </div>
+ </div>
+
+ <template #footer>
+ <el-button @click="showAvatarDialog = false">取消</el-button>
+ <el-button type="primary" @click="uploadAvatar" :loading="uploadingAvatar">
+ 上传头像
+ </el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, computed, onMounted, nextTick } from 'vue'
+import { useRouter } from 'vue-router'
+import { ElMessage } from 'element-plus'
+import {
+ Calendar,
+ Clock,
+ Upload,
+ Download,
+ TrendCharts,
+ Star,
+ QuestionFilled,
+ Plus,
+ ChatDotRound,
+ Flag,
+ Coin
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'ProfileView',
+ setup() {
+ const router = useRouter()
+ const profileFormRef = ref(null)
+ const passwordFormRef = ref(null)
+ const avatarUploadRef = ref(null)
+ const interestInputRef = ref(null)
+
+ const activeTab = ref('info')
+ const showAvatarDialog = ref(false)
+ const saving = ref(false)
+ const changingPassword = ref(false)
+ const uploadingAvatar = ref(false)
+ const interestInputVisible = ref(false)
+ const interestInputValue = ref('')
+ const activityFilter = ref('')
+ const torrentsPage = ref(1)
+
+ const userProfile = ref({
+ username: 'MovieExpert',
+ email: 'movieexpert@example.com',
+ realName: '',
+ avatar: '',
+ userLevel: 5,
+ userTitle: '资深会员',
+ joinDate: '2023-01-15T10:00:00',
+ lastLogin: '2025-06-03T14:30:00',
+ location: ['北京市', '朝阳区'],
+ signature: '热爱电影,分享快乐!',
+ website: 'https://movieblog.com',
+ interests: ['电影', '音乐', '科技', '摄影'],
+ emailPublic: false,
+ statsPublic: true,
+ activityPublic: true,
+ stats: {
+ uploaded: '256.8 GB',
+ downloaded: '89.6 GB',
+ ratio: '2.87',
+ points: '15,680'
+ },
+ detailedStats: {
+ totalUploaded: '256.8 GB',
+ uploadedTorrents: 45,
+ avgUploadSize: '5.7 GB',
+ totalDownloaded: '89.6 GB',
+ downloadedTorrents: 123,
+ completedTorrents: 118,
+ seeding: 32,
+ seedingTime: '1,245 小时',
+ seedingRank: 86,
+ totalEarnedPoints: '28,940',
+ totalSpentPoints: '13,260'
+ }
+ })
+
+ const editProfile = reactive({
+ username: '',
+ email: '',
+ realName: '',
+ location: [],
+ signature: '',
+ website: '',
+ interests: [],
+ emailPublic: false,
+ statsPublic: true,
+ activityPublic: true
+ })
+
+ const passwordForm = reactive({
+ currentPassword: '',
+ newPassword: '',
+ confirmPassword: ''
+ })
+
+ const profileRules = {
+ email: [
+ { required: true, message: '请输入邮箱地址', trigger: 'blur' },
+ { type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' }
+ ]
+ }
+
+ const passwordRules = {
+ currentPassword: [
+ { required: true, message: '请输入当前密码', trigger: 'blur' }
+ ],
+ newPassword: [
+ { required: true, message: '请输入新密码', trigger: 'blur' },
+ { min: 6, message: '密码长度至少6个字符', trigger: 'blur' }
+ ],
+ confirmPassword: [
+ { required: true, message: '请确认新密码', trigger: 'blur' },
+ {
+ validator: (rule, value, callback) => {
+ if (value !== passwordForm.newPassword) {
+ callback(new Error('两次输入的密码不一致'))
+ } else {
+ callback()
+ }
+ },
+ trigger: 'blur'
+ }
+ ]
+ }
+
+ const locationOptions = [
+ {
+ value: '北京市',
+ label: '北京市',
+ children: [
+ { value: '朝阳区', label: '朝阳区' },
+ { value: '海淀区', label: '海淀区' },
+ { value: '丰台区', label: '丰台区' }
+ ]
+ },
+ {
+ value: '上海市',
+ label: '上海市',
+ children: [
+ { value: '浦东新区', label: '浦东新区' },
+ { value: '黄浦区', label: '黄浦区' },
+ { value: '静安区', label: '静安区' }
+ ]
+ }
+ ]
+
+ const userTorrents = ref([
+ {
+ id: 1,
+ title: '[4K蓝光原盘] 阿凡达:水之道',
+ category: 'movie',
+ size: '85.6 GB',
+ seeders: 45,
+ leechers: 12,
+ downloads: 234,
+ uploadTime: '2025-05-15T10:00:00'
+ },
+ {
+ id: 2,
+ title: '[FLAC] 古典音乐合集',
+ category: 'music',
+ size: '2.3 GB',
+ seeders: 23,
+ leechers: 5,
+ downloads: 89,
+ uploadTime: '2025-04-20T15:30:00'
+ }
+ ])
+
+ const activities = ref([
+ {
+ id: 1,
+ type: 'upload',
+ title: '上传种子',
+ description: '上传了《阿凡达:水之道》4K蓝光原盘',
+ time: '2025-06-03T10:30:00'
+ },
+ {
+ id: 2,
+ type: 'download',
+ title: '下载种子',
+ description: '下载了《星际穿越》IMAX版本',
+ time: '2025-06-02T14:20:00'
+ },
+ {
+ id: 3,
+ type: 'post',
+ title: '发布主题',
+ description: '在电影讨论区发布了新主题',
+ time: '2025-06-01T16:45:00'
+ },
+ {
+ id: 4,
+ type: 'points',
+ title: '积分变动',
+ description: '做种奖励获得 +50 积分',
+ time: '2025-05-31T09:15:00'
+ }
+ ])
+
+ const loginHistory = ref([
+ {
+ time: '2025-06-03T14:30:00',
+ ip: '192.168.1.100',
+ device: 'Windows 11 / Chrome 120',
+ success: true
+ },
+ {
+ time: '2025-06-02T09:15:00',
+ ip: '192.168.1.100',
+ device: 'Windows 11 / Chrome 120',
+ success: true
+ },
+ {
+ time: '2025-06-01T22:30:00',
+ ip: '192.168.1.100',
+ device: 'Android / Chrome Mobile',
+ success: true
+ }
+ ])
+
+ const filteredActivities = computed(() => {
+ if (!activityFilter.value) return activities.value
+ return activities.value.filter(activity => activity.type === activityFilter.value)
+ })
+
+ onMounted(() => {
+ loadUserProfile()
+ })
+
+ const loadUserProfile = () => {
+ // 加载用户资料到编辑表单
+ Object.assign(editProfile, {
+ username: userProfile.value.username,
+ email: userProfile.value.email,
+ realName: userProfile.value.realName,
+ location: userProfile.value.location,
+ signature: userProfile.value.signature,
+ website: userProfile.value.website,
+ interests: [...userProfile.value.interests],
+ emailPublic: userProfile.value.emailPublic,
+ statsPublic: userProfile.value.statsPublic,
+ activityPublic: userProfile.value.activityPublic
+ })
+ }
+
+ const formatDate = (dateString) => {
+ const date = new Date(dateString)
+ return date.toLocaleDateString('zh-CN')
+ }
+
+ const formatTime = (timeString) => {
+ const date = new Date(timeString)
+ const now = new Date()
+ const diff = now - date
+ const hours = Math.floor(diff / (1000 * 60 * 60))
+
+ if (hours < 1) return '刚刚'
+ if (hours < 24) return `${hours}小时前`
+ const days = Math.floor(hours / 24)
+ if (days < 7) return `${days}天前`
+
+ return date.toLocaleDateString('zh-CN')
+ }
+
+ const formatDateTime = (dateString) => {
+ const date = new Date(dateString)
+ return date.toLocaleString('zh-CN')
+ }
+
+ const getUserTitleType = (level) => {
+ if (level >= 8) return 'danger' // 管理员
+ if (level >= 6) return 'warning' // 资深会员
+ if (level >= 4) return 'success' // 正式会员
+ if (level >= 2) return 'info' // 初级会员
+ return 'default' // 新手
+ }
+
+ const getRatioClass = (ratio) => {
+ const r = parseFloat(ratio)
+ if (r >= 2) return 'excellent'
+ if (r >= 1) return 'good'
+ return 'warning'
+ }
+
+ const getCategoryType = (category) => {
+ const types = {
+ 'movie': 'primary',
+ 'tv': 'info',
+ 'music': 'success',
+ 'software': 'warning',
+ 'game': 'danger'
+ }
+ return types[category] || 'default'
+ }
+
+ const getCategoryName = (category) => {
+ const names = {
+ 'movie': '电影',
+ 'tv': '电视剧',
+ 'music': '音乐',
+ 'software': '软件',
+ 'game': '游戏'
+ }
+ return names[category] || category
+ }
+
+ const getActivityType = (type) => {
+ const types = {
+ 'upload': 'success',
+ 'download': 'primary',
+ 'post': 'warning',
+ 'points': 'info'
+ }
+ return types[type] || 'primary'
+ }
+
+ const getActivityIcon = (type) => {
+ const icons = {
+ 'upload': 'Upload',
+ 'download': 'Download',
+ 'post': 'ChatDotRound',
+ 'points': 'Coin'
+ }
+ return icons[type] || 'Star'
+ }
+
+ const showInterestInput = () => {
+ interestInputVisible.value = true
+ nextTick(() => {
+ interestInputRef.value?.focus()
+ })
+ }
+
+ const addInterest = () => {
+ const interest = interestInputValue.value.trim()
+ if (interest && !editProfile.interests.includes(interest)) {
+ editProfile.interests.push(interest)
+ }
+ interestInputVisible.value = false
+ interestInputValue.value = ''
+ }
+
+ const removeInterest = (interest) => {
+ const index = editProfile.interests.indexOf(interest)
+ if (index > -1) {
+ editProfile.interests.splice(index, 1)
+ }
+ }
+
+ const saveProfile = async () => {
+ try {
+ await profileFormRef.value?.validate()
+
+ saving.value = true
+
+ // 模拟保存过程
+ await new Promise(resolve => setTimeout(resolve, 1500))
+
+ // 更新用户资料
+ Object.assign(userProfile.value, editProfile)
+
+ ElMessage.success('个人资料保存成功')
+
+ } catch (error) {
+ console.error('表单验证失败:', error)
+ } finally {
+ saving.value = false
+ }
+ }
+
+ const resetProfile = () => {
+ loadUserProfile()
+ ElMessage.info('已重置为原始数据')
+ }
+
+ const changePassword = async () => {
+ try {
+ await passwordFormRef.value?.validate()
+
+ changingPassword.value = true
+
+ // 模拟密码修改过程
+ await new Promise(resolve => setTimeout(resolve, 1500))
+
+ // 重置表单
+ passwordFormRef.value?.resetFields()
+ Object.assign(passwordForm, {
+ currentPassword: '',
+ newPassword: '',
+ confirmPassword: ''
+ })
+
+ ElMessage.success('密码修改成功')
+
+ } catch (error) {
+ console.error('表单验证失败:', error)
+ } finally {
+ changingPassword.value = false
+ }
+ }
+
+ const handleAvatarChange = (file) => {
+ const isImage = file.raw.type.startsWith('image/')
+ const isLt2M = file.raw.size / 1024 / 1024 < 2
+
+ if (!isImage) {
+ ElMessage.error('只能上传图片文件!')
+ return false
+ }
+ if (!isLt2M) {
+ ElMessage.error('图片大小不能超过 2MB!')
+ return false
+ }
+
+ return true
+ }
+
+ const uploadAvatar = async () => {
+ const files = avatarUploadRef.value?.uploadFiles
+ if (!files || files.length === 0) {
+ ElMessage.warning('请选择头像文件')
+ return
+ }
+
+ uploadingAvatar.value = true
+ try {
+ // 模拟上传过程
+ await new Promise(resolve => setTimeout(resolve, 2000))
+
+ // 更新头像URL
+ userProfile.value.avatar = URL.createObjectURL(files[0].raw)
+
+ ElMessage.success('头像上传成功')
+ showAvatarDialog.value = false
+ avatarUploadRef.value?.clearFiles()
+
+ } catch (error) {
+ ElMessage.error('头像上传失败')
+ } finally {
+ uploadingAvatar.value = false
+ }
+ }
+
+ return {
+ activeTab,
+ showAvatarDialog,
+ saving,
+ changingPassword,
+ uploadingAvatar,
+ interestInputVisible,
+ interestInputValue,
+ activityFilter,
+ torrentsPage,
+ userProfile,
+ editProfile,
+ passwordForm,
+ profileRules,
+ passwordRules,
+ locationOptions,
+ userTorrents,
+ filteredActivities,
+ loginHistory,
+ profileFormRef,
+ passwordFormRef,
+ avatarUploadRef,
+ interestInputRef,
+ formatDate,
+ formatTime,
+ formatDateTime,
+ getUserTitleType,
+ getRatioClass,
+ getCategoryType,
+ getCategoryName,
+ getActivityType,
+ getActivityIcon,
+ showInterestInput,
+ addInterest,
+ removeInterest,
+ saveProfile,
+ resetProfile,
+ changePassword,
+ handleAvatarChange,
+ uploadAvatar,
+ Calendar,
+ Clock,
+ Upload,
+ Download,
+ TrendCharts,
+ Star,
+ QuestionFilled,
+ Plus,
+ ChatDotRound,
+ Flag,
+ Coin
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.profile-page {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 24px;
+ background: #f5f5f5;
+ min-height: 100vh;
+}
+
+.profile-header {
+ background: #fff;
+ border-radius: 12px;
+ padding: 32px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 32px;
+
+ .user-avatar-section {
+ display: flex;
+ gap: 24px;
+
+ .avatar-container {
+ text-align: center;
+
+ .change-avatar-btn {
+ margin-top: 12px;
+ }
+ }
+
+ .user-basic-info {
+ flex: 1;
+
+ .username {
+ font-size: 28px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 12px 0;
+ }
+
+ .user-title {
+ margin-bottom: 16px;
+ }
+
+ .join-info, .last-login {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 14px;
+ color: #7f8c8d;
+ margin-bottom: 8px;
+ }
+ }
+ }
+
+ .user-stats-overview {
+ .stats-grid {
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: 16px;
+
+ .stat-card {
+ background: #f8f9fa;
+ border-radius: 8px;
+ padding: 20px;
+ display: flex;
+ align-items: center;
+ gap: 16px;
+
+ .stat-icon {
+ width: 48px;
+ height: 48px;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ &.upload { background: rgba(103, 194, 58, 0.1); color: #67c23a; }
+ &.download { background: rgba(64, 158, 255, 0.1); color: #409eff; }
+ &.ratio {
+ &.excellent { background: rgba(103, 194, 58, 0.1); color: #67c23a; }
+ &.good { background: rgba(230, 162, 60, 0.1); color: #e6a23c; }
+ &.warning { background: rgba(245, 108, 108, 0.1); color: #f56c6c; }
+ }
+ &.points { background: rgba(245, 108, 108, 0.1); color: #f56c6c; }
+ }
+
+ .stat-info {
+ h3 {
+ font-size: 20px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 4px 0;
+ }
+
+ p {
+ font-size: 14px;
+ color: #7f8c8d;
+ margin: 0;
+ }
+ }
+ }
+ }
+ }
+}
+
+.profile-content {
+ background: #fff;
+ border-radius: 12px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ :deep(.el-tabs__content) {
+ padding: 24px;
+ }
+}
+
+.info-section {
+ .form-section {
+ margin-bottom: 32px;
+
+ h3 {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 20px 0;
+ padding-bottom: 8px;
+ border-bottom: 2px solid #f0f0f0;
+ }
+ }
+
+ .interests-input {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ align-items: center;
+
+ .interest-tag {
+ margin: 0;
+ }
+ }
+
+ .setting-tip {
+ margin-left: 12px;
+ font-size: 12px;
+ color: #909399;
+ }
+
+ .form-actions {
+ text-align: center;
+ margin-top: 32px;
+
+ .el-button {
+ margin: 0 8px;
+ min-width: 100px;
+ }
+ }
+}
+
+.stats-section {
+ .stats-overview {
+ margin-bottom: 32px;
+
+ .overview-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
+ gap: 20px;
+
+ .overview-card {
+ background: #f8f9fa;
+ border-radius: 8px;
+ padding: 24px;
+
+ h3 {
+ font-size: 16px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 16px 0;
+ }
+
+ .stat-details {
+ .detail-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 12px;
+
+ .label {
+ font-size: 14px;
+ color: #7f8c8d;
+ }
+
+ .value {
+ font-size: 14px;
+ font-weight: 600;
+ color: #2c3e50;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ .charts-section {
+ .chart-card {
+ background: #f8f9fa;
+ border-radius: 8px;
+ padding: 24px;
+
+ h3 {
+ font-size: 16px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 20px 0;
+ }
+
+ .chart-placeholder {
+ text-align: center;
+ padding: 60px 0;
+ color: #909399;
+
+ p {
+ margin: 12px 0 0 0;
+ }
+ }
+ }
+ }
+}
+
+.torrents-section {
+ .section-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 20px;
+
+ h3 {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0;
+ }
+ }
+
+ .torrent-info {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+
+ .torrent-title {
+ font-weight: 500;
+ }
+ }
+
+ .pagination-wrapper {
+ margin-top: 16px;
+ text-align: center;
+ }
+}
+
+.activity-section {
+ .activity-filters {
+ margin-bottom: 24px;
+
+ .el-select {
+ width: 150px;
+ }
+ }
+
+ .activity-timeline {
+ .activity-content {
+ .activity-header {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 8px;
+
+ .activity-title {
+ font-weight: 600;
+ color: #2c3e50;
+ }
+ }
+
+ .activity-description {
+ font-size: 14px;
+ color: #7f8c8d;
+ line-height: 1.5;
+ }
+ }
+ }
+}
+
+.security-section {
+ .security-card {
+ background: #f8f9fa;
+ border-radius: 8px;
+ padding: 24px;
+ margin-bottom: 24px;
+
+ h3 {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 20px 0;
+ }
+ }
+}
+
+.avatar-upload {
+ text-align: center;
+
+ .avatar-uploader {
+ margin-bottom: 16px;
+ }
+
+ .upload-tips {
+ font-size: 12px;
+ color: #909399;
+
+ p {
+ margin: 4px 0;
+ }
+ }
+}
+
+@media (max-width: 768px) {
+ .profile-page {
+ padding: 16px;
+ }
+
+ .profile-header {
+ grid-template-columns: 1fr;
+ gap: 24px;
+
+ .user-avatar-section {
+ flex-direction: column;
+ text-align: center;
+ }
+
+ .user-stats-overview .stats-grid {
+ grid-template-columns: 1fr;
+ }
+ }
+
+ .stats-overview .overview-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .torrents-section .section-header {
+ flex-direction: column;
+ gap: 16px;
+ align-items: flex-start;
+ }
+}
+</style>
\ No newline at end of file
diff --git a/src/views/forum/ForumSectionView.vue b/src/views/forum/ForumSectionView.vue
new file mode 100644
index 0000000..a8e7306
--- /dev/null
+++ b/src/views/forum/ForumSectionView.vue
@@ -0,0 +1,1008 @@
+<template>
+ <div class="section-page">
+ <div class="page-container">
+ <!-- 面包屑导航 -->
+ <div class="breadcrumb">
+ <el-breadcrumb separator="/">
+ <el-breadcrumb-item :to="{ path: '/forum' }">论坛首页</el-breadcrumb-item>
+ <el-breadcrumb-item>{{ sectionInfo.name }}</el-breadcrumb-item>
+ </el-breadcrumb>
+ </div>
+
+ <!-- 版块信息 -->
+ <div class="section-header">
+ <div class="section-info">
+ <div class="section-icon">
+ <el-icon size="48" :color="sectionInfo.color">
+ <component :is="sectionInfo.icon" />
+ </el-icon>
+ </div>
+ <div class="section-details">
+ <h1 class="section-name">{{ sectionInfo.name }}</h1>
+ <p class="section-description">{{ sectionInfo.description }}</p>
+ <div class="section-stats">
+ <div class="stat-item">
+ <el-icon><ChatDotRound /></el-icon>
+ <span>{{ sectionInfo.topics }} 主题</span>
+ </div>
+ <div class="stat-item">
+ <el-icon><Comment /></el-icon>
+ <span>{{ sectionInfo.replies }} 回复</span>
+ </div>
+ <div class="stat-item">
+ <el-icon><User /></el-icon>
+ <span>{{ sectionInfo.members }} 成员</span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="section-actions">
+ <el-button type="primary" :icon="Edit" @click="showNewTopicDialog = true">
+ 发布新主题
+ </el-button>
+ </div>
+ </div>
+
+ <!-- 筛选和搜索 -->
+ <div class="filter-section">
+ <div class="filter-left">
+ <el-input
+ v-model="searchQuery"
+ placeholder="搜索主题..."
+ :prefix-icon="Search"
+ @keyup.enter="handleSearch"
+ clearable
+ style="width: 300px;"
+ />
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
+ </div>
+
+ <div class="filter-right">
+ <el-select v-model="sortBy" placeholder="排序方式" @change="handleFilter">
+ <el-option label="最新回复" value="last_reply" />
+ <el-option label="发布时间" value="create_time" />
+ <el-option label="回复数量" value="replies" />
+ <el-option label="浏览次数" value="views" />
+ </el-select>
+
+ <el-select v-model="filterType" placeholder="主题类型" @change="handleFilter">
+ <el-option label="全部主题" value="" />
+ <el-option label="置顶主题" value="pinned" />
+ <el-option label="热门主题" value="hot" />
+ <el-option label="精华主题" value="featured" />
+ </el-select>
+ </div>
+ </div>
+
+ <!-- 置顶主题 -->
+ <div v-if="pinnedTopics.length > 0" class="pinned-topics">
+ <h3 class="section-title">置顶主题</h3>
+ <div class="topics-list">
+ <div
+ v-for="topic in pinnedTopics"
+ :key="topic.id"
+ class="topic-item pinned"
+ @click="navigateToTopic(topic.id)"
+ >
+ <div class="topic-status">
+ <el-icon class="pin-icon"><Top /></el-icon>
+ </div>
+
+ <div class="topic-content">
+ <div class="topic-header">
+ <h4 class="topic-title">{{ topic.title }}</h4>
+ <div class="topic-tags">
+ <el-tag type="warning" size="small">置顶</el-tag>
+ <el-tag v-if="topic.hot" type="danger" size="small">热门</el-tag>
+ <el-tag v-if="topic.featured" type="success" size="small">精华</el-tag>
+ </div>
+ </div>
+
+ <div class="topic-meta">
+ <div class="author-info">
+ <el-avatar :size="24">{{ topic.author.charAt(0) }}</el-avatar>
+ <span class="author-name">{{ topic.author }}</span>
+ <span class="create-time">{{ formatTime(topic.createTime) }}</span>
+ </div>
+
+ <div class="topic-stats">
+ <span class="stat-item">
+ <el-icon><View /></el-icon>
+ {{ topic.views }}
+ </span>
+ <span class="stat-item">
+ <el-icon><Comment /></el-icon>
+ {{ topic.replies }}
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <div class="last-reply">
+ <div v-if="topic.lastReply" class="reply-info">
+ <div class="reply-author">{{ topic.lastReply.author }}</div>
+ <div class="reply-time">{{ formatTime(topic.lastReply.time) }}</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 普通主题列表 -->
+ <div class="normal-topics">
+ <div class="section-header">
+ <h3 class="section-title">主题列表</h3>
+ <div class="results-info">
+ 共 {{ totalTopics }} 个主题
+ </div>
+ </div>
+
+ <div class="topics-list" v-loading="loading">
+ <div
+ v-for="topic in topics"
+ :key="topic.id"
+ class="topic-item"
+ @click="navigateToTopic(topic.id)"
+ >
+ <div class="topic-status">
+ <el-icon v-if="topic.hasNewReplies" class="new-icon" color="#f56c6c">
+ <ChatDotRound />
+ </el-icon>
+ <el-icon v-else class="normal-icon" color="#909399">
+ <ChatLineRound />
+ </el-icon>
+ </div>
+
+ <div class="topic-content">
+ <div class="topic-header">
+ <h4 class="topic-title">{{ topic.title }}</h4>
+ <div class="topic-tags">
+ <el-tag v-if="topic.hot" type="danger" size="small">热门</el-tag>
+ <el-tag v-if="topic.featured" type="success" size="small">精华</el-tag>
+ <el-tag v-if="topic.closed" type="info" size="small">已关闭</el-tag>
+ </div>
+ </div>
+
+ <div class="topic-meta">
+ <div class="author-info">
+ <el-avatar :size="24">{{ topic.author.charAt(0) }}</el-avatar>
+ <span class="author-name">{{ topic.author }}</span>
+ <span class="create-time">{{ formatTime(topic.createTime) }}</span>
+ </div>
+
+ <div class="topic-stats">
+ <span class="stat-item">
+ <el-icon><View /></el-icon>
+ {{ topic.views }}
+ </span>
+ <span class="stat-item">
+ <el-icon><Comment /></el-icon>
+ {{ topic.replies }}
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <div class="last-reply">
+ <div v-if="topic.lastReply" class="reply-info">
+ <div class="reply-author">{{ topic.lastReply.author }}</div>
+ <div class="reply-time">{{ formatTime(topic.lastReply.time) }}</div>
+ </div>
+ <div v-else class="no-reply">暂无回复</div>
+ </div>
+ </div>
+
+ <div v-if="topics.length === 0 && !loading" class="no-topics">
+ 暂无主题,快来发布第一个主题吧!
+ </div>
+ </div>
+
+ <!-- 分页 -->
+ <div class="pagination-wrapper">
+ <el-pagination
+ v-model:current-page="currentPage"
+ v-model:page-size="pageSize"
+ :page-sizes="[20, 50, 100]"
+ :total="totalTopics"
+ layout="total, sizes, prev, pager, next, jumper"
+ @size-change="handleSizeChange"
+ @current-change="handleCurrentChange"
+ />
+ </div>
+ </div>
+ </div>
+
+ <!-- 发布新主题对话框 -->
+ <el-dialog
+ v-model="showNewTopicDialog"
+ title="发布新主题"
+ width="600px"
+ :before-close="handleCloseDialog"
+ >
+ <el-form
+ ref="topicFormRef"
+ :model="newTopic"
+ :rules="topicRules"
+ label-width="80px"
+ >
+ <el-form-item label="主题标题" prop="title">
+ <el-input
+ v-model="newTopic.title"
+ placeholder="请输入主题标题"
+ maxlength="100"
+ show-word-limit
+ />
+ </el-form-item>
+
+ <el-form-item label="主题标签">
+ <div class="tags-input">
+ <el-tag
+ v-for="tag in newTopic.tags"
+ :key="tag"
+ closable
+ @close="removeTopicTag(tag)"
+ >
+ {{ tag }}
+ </el-tag>
+ <el-input
+ v-if="tagInputVisible"
+ ref="tagInputRef"
+ v-model="tagInputValue"
+ size="small"
+ @keyup.enter="addTopicTag"
+ @blur="addTopicTag"
+ style="width: 100px;"
+ />
+ <el-button
+ v-else
+ size="small"
+ @click="showTagInput"
+ >
+ + 添加标签
+ </el-button>
+ </div>
+ </el-form-item>
+
+ <el-form-item label="主题内容" prop="content">
+ <el-input
+ v-model="newTopic.content"
+ type="textarea"
+ :rows="8"
+ placeholder="请输入主题内容..."
+ maxlength="5000"
+ show-word-limit
+ />
+ </el-form-item>
+
+ <el-form-item label="主题选项">
+ <el-checkbox-group v-model="newTopic.options">
+ <el-checkbox label="hot">申请热门</el-checkbox>
+ <el-checkbox label="featured">申请精华</el-checkbox>
+ </el-checkbox-group>
+ </el-form-item>
+ </el-form>
+
+ <template #footer>
+ <el-button @click="handleCloseDialog">取消</el-button>
+ <el-button type="primary" @click="submitNewTopic" :loading="submitting">
+ 发布主题
+ </el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, onMounted, nextTick } from 'vue'
+import { useRoute, useRouter } from 'vue-router'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import {
+ Edit,
+ Search,
+ ChatDotRound,
+ Comment,
+ User,
+ View,
+ Top,
+ ChatLineRound,
+ Film,
+ Headphones,
+ Monitor,
+ GamePad,
+ Bell,
+ QuestionFilled
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'ForumSectionView',
+ setup() {
+ const route = useRoute()
+ const router = useRouter()
+ const topicFormRef = ref(null)
+ const tagInputRef = ref(null)
+
+ const loading = ref(false)
+ const showNewTopicDialog = ref(false)
+ const submitting = ref(false)
+ const tagInputVisible = ref(false)
+ const tagInputValue = ref('')
+
+ const searchQuery = ref('')
+ const sortBy = ref('last_reply')
+ const filterType = ref('')
+ const currentPage = ref(1)
+ const pageSize = ref(20)
+ const totalTopics = ref(0)
+
+ const sectionInfo = ref({
+ id: 1,
+ name: '电影讨论',
+ description: '分享和讨论电影资源,交流观影心得',
+ icon: 'Film',
+ color: '#409eff',
+ topics: 3256,
+ replies: 18934,
+ members: 1234
+ })
+
+ const newTopic = reactive({
+ title: '',
+ content: '',
+ tags: [],
+ options: []
+ })
+
+ const topicRules = {
+ title: [
+ { required: true, message: '请输入标题', trigger: 'blur' },
+ { min: 5, max: 100, message: '标题长度在 5 到 100 个字符', trigger: 'blur' }
+ ],
+ content: [
+ { required: true, message: '请输入内容', trigger: 'blur' },
+ { min: 10, max: 5000, message: '内容长度在 10 到 5000 个字符', trigger: 'blur' }
+ ]
+ }
+
+ const pinnedTopics = ref([
+ {
+ id: 1,
+ title: '【公告】本版块发帖规则和注意事项',
+ author: 'Admin',
+ createTime: '2025-05-01T10:00:00',
+ views: 5678,
+ replies: 23,
+ hot: false,
+ featured: true,
+ lastReply: {
+ author: 'User123',
+ time: '2025-06-02T15:30:00'
+ }
+ }
+ ])
+
+ const topics = ref([
+ {
+ id: 2,
+ title: '2024年度最佳科幻电影推荐榜单',
+ author: 'SciFiFan',
+ createTime: '2025-06-03T10:30:00',
+ views: 1234,
+ replies: 45,
+ hot: true,
+ featured: false,
+ closed: false,
+ hasNewReplies: true,
+ lastReply: {
+ author: 'MovieLover',
+ time: '2025-06-03T14:25:00'
+ }
+ },
+ {
+ id: 3,
+ title: '阿凡达2:水之道 观影感受分享',
+ author: 'Avatar2Fan',
+ createTime: '2025-06-02T16:45:00',
+ views: 892,
+ replies: 67,
+ hot: false,
+ featured: true,
+ closed: false,
+ hasNewReplies: false,
+ lastReply: {
+ author: 'CinemaExpert',
+ time: '2025-06-03T12:10:00'
+ }
+ },
+ {
+ id: 4,
+ title: '求推荐几部好看的悬疑电影',
+ author: 'SuspenseLover',
+ createTime: '2025-06-01T09:20:00',
+ views: 456,
+ replies: 23,
+ hot: false,
+ featured: false,
+ closed: false,
+ hasNewReplies: true,
+ lastReply: {
+ author: 'ThrillerFan',
+ time: '2025-06-03T11:45:00'
+ }
+ }
+ ])
+
+ onMounted(() => {
+ const sectionId = route.params.id
+ fetchSectionData(sectionId)
+ })
+
+ const fetchSectionData = async (id) => {
+ loading.value = true
+ try {
+ // 模拟API调用
+ console.log('获取版块数据:', id)
+
+ // 根据版块ID设置不同的版块信息
+ const sections = {
+ 1: { name: '电影讨论', description: '分享和讨论电影资源,交流观影心得', icon: 'Film', color: '#409eff' },
+ 2: { name: '音乐分享', description: '音乐资源分享,音乐制作技术交流', icon: 'Headphones', color: '#67c23a' },
+ 3: { name: '软件技术', description: '软件资源分享,技术问题讨论', icon: 'Monitor', color: '#e6a23c' },
+ 4: { name: '游戏天地', description: '游戏资源分享,游戏攻略讨论', icon: 'GamePad', color: '#f56c6c' },
+ 5: { name: '站务公告', description: '网站公告,规则说明,意见建议', icon: 'Bell', color: '#909399' },
+ 6: { name: '新手求助', description: '新手问题解答,使用教程分享', icon: 'QuestionFilled', color: '#606266' }
+ }
+
+ const sectionData = sections[id] || sections[1]
+ sectionInfo.value = {
+ id: parseInt(id),
+ ...sectionData,
+ topics: 3256,
+ replies: 18934,
+ members: 1234
+ }
+
+ totalTopics.value = 156
+
+ } catch (error) {
+ ElMessage.error('获取版块数据失败')
+ } finally {
+ loading.value = false
+ }
+ }
+
+ const formatTime = (timeString) => {
+ const date = new Date(timeString)
+ const now = new Date()
+ const diff = now - date
+ const hours = Math.floor(diff / (1000 * 60 * 60))
+
+ if (hours < 1) return '刚刚'
+ if (hours < 24) return `${hours}小时前`
+ const days = Math.floor(hours / 24)
+ if (days < 7) return `${days}天前`
+
+ return date.toLocaleDateString('zh-CN', {
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit'
+ })
+ }
+
+ const navigateToTopic = (topicId) => {
+ router.push(`/forum/topic/${topicId}`)
+ }
+
+ const handleSearch = () => {
+ currentPage.value = 1
+ fetchTopics()
+ }
+
+ const handleFilter = () => {
+ currentPage.value = 1
+ fetchTopics()
+ }
+
+ const fetchTopics = async () => {
+ loading.value = true
+ try {
+ // 模拟API调用
+ await new Promise(resolve => setTimeout(resolve, 500))
+ console.log('获取主题列表:', { searchQuery: searchQuery.value, sortBy: sortBy.value, filterType: filterType.value })
+ } catch (error) {
+ ElMessage.error('获取主题列表失败')
+ } finally {
+ loading.value = false
+ }
+ }
+
+ const handleSizeChange = (size) => {
+ pageSize.value = size
+ currentPage.value = 1
+ fetchTopics()
+ }
+
+ const handleCurrentChange = (page) => {
+ currentPage.value = page
+ fetchTopics()
+ }
+
+ const showTagInput = () => {
+ tagInputVisible.value = true
+ nextTick(() => {
+ tagInputRef.value?.focus()
+ })
+ }
+
+ const addTopicTag = () => {
+ const tag = tagInputValue.value.trim()
+ if (tag && !newTopic.tags.includes(tag)) {
+ newTopic.tags.push(tag)
+ }
+ tagInputVisible.value = false
+ tagInputValue.value = ''
+ }
+
+ const removeTopicTag = (tag) => {
+ const index = newTopic.tags.indexOf(tag)
+ if (index > -1) {
+ newTopic.tags.splice(index, 1)
+ }
+ }
+
+ const handleCloseDialog = () => {
+ if (newTopic.title || newTopic.content) {
+ ElMessageBox.confirm(
+ '确定要关闭吗?未保存的内容将会丢失。',
+ '提示',
+ {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }
+ ).then(() => {
+ resetForm()
+ showNewTopicDialog.value = false
+ }).catch(() => {
+ // 用户取消
+ })
+ } else {
+ resetForm()
+ showNewTopicDialog.value = false
+ }
+ }
+
+ const submitNewTopic = async () => {
+ try {
+ await topicFormRef.value?.validate()
+
+ submitting.value = true
+
+ // 模拟提交过程
+ await new Promise(resolve => setTimeout(resolve, 1500))
+
+ ElMessage.success('主题发布成功!')
+ resetForm()
+ showNewTopicDialog.value = false
+
+ // 刷新主题列表
+ fetchTopics()
+
+ } catch (error) {
+ console.error('表单验证失败:', error)
+ } finally {
+ submitting.value = false
+ }
+ }
+
+ const resetForm = () => {
+ topicFormRef.value?.resetFields()
+ newTopic.title = ''
+ newTopic.content = ''
+ newTopic.tags = []
+ newTopic.options = []
+ }
+
+ return {
+ loading,
+ showNewTopicDialog,
+ submitting,
+ tagInputVisible,
+ tagInputValue,
+ searchQuery,
+ sortBy,
+ filterType,
+ currentPage,
+ pageSize,
+ totalTopics,
+ sectionInfo,
+ pinnedTopics,
+ topics,
+ newTopic,
+ topicRules,
+ topicFormRef,
+ tagInputRef,
+ formatTime,
+ navigateToTopic,
+ handleSearch,
+ handleFilter,
+ handleSizeChange,
+ handleCurrentChange,
+ showTagInput,
+ addTopicTag,
+ removeTopicTag,
+ handleCloseDialog,
+ submitNewTopic,
+ Edit,
+ Search,
+ ChatDotRound,
+ Comment,
+ User,
+ View,
+ Top,
+ ChatLineRound,
+ Film,
+ Headphones,
+ Monitor,
+ GamePad,
+ Bell,
+ QuestionFilled
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.section-page {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 24px;
+ background: #f5f5f5;
+ min-height: 100vh;
+}
+
+.breadcrumb {
+ margin-bottom: 16px;
+}
+
+.section-header {
+ background: #fff;
+ border-radius: 12px;
+ padding: 32px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 24px;
+
+ .section-info {
+ display: flex;
+ align-items: center;
+ gap: 20px;
+ flex: 1;
+
+ .section-details {
+ .section-name {
+ font-size: 28px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 8px 0;
+ }
+
+ .section-description {
+ font-size: 16px;
+ color: #7f8c8d;
+ margin: 0 0 16px 0;
+ }
+
+ .section-stats {
+ display: flex;
+ gap: 24px;
+
+ .stat-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 14px;
+ color: #606266;
+ }
+ }
+ }
+ }
+
+ .section-actions {
+ flex-shrink: 0;
+ }
+}
+
+.filter-section {
+ background: #fff;
+ border-radius: 12px;
+ padding: 20px 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 20px;
+
+ .filter-left {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ }
+
+ .filter-right {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+
+ .el-select {
+ width: 120px;
+ }
+ }
+}
+
+.pinned-topics, .normal-topics {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .section-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 20px;
+ background: none;
+ padding: 0;
+ box-shadow: none;
+
+ .section-title {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0;
+ }
+
+ .results-info {
+ font-size: 14px;
+ color: #909399;
+ }
+ }
+}
+
+.topics-list {
+ .topic-item {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ padding: 16px;
+ border: 1px solid #f0f0f0;
+ border-radius: 8px;
+ margin-bottom: 12px;
+ cursor: pointer;
+ transition: all 0.3s ease;
+
+ &:hover {
+ background: #f8f9fa;
+ border-color: #409eff;
+ transform: translateX(2px);
+ }
+
+ &.pinned {
+ background: linear-gradient(90deg, #fff7e6 0%, #fff 100%);
+ border-color: #e6a23c;
+ }
+
+ .topic-status {
+ width: 32px;
+ text-align: center;
+
+ .pin-icon {
+ color: #e6a23c;
+ }
+
+ .new-icon {
+ animation: pulse 2s infinite;
+ }
+ }
+
+ .topic-content {
+ flex: 1;
+
+ .topic-header {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ margin-bottom: 8px;
+
+ .topic-title {
+ font-size: 16px;
+ font-weight: 500;
+ color: #2c3e50;
+ margin: 0;
+ flex: 1;
+
+ &:hover {
+ color: #409eff;
+ }
+ }
+
+ .topic-tags {
+ .el-tag {
+ margin-left: 4px;
+ }
+ }
+ }
+
+ .topic-meta {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .author-info {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+
+ .author-name {
+ font-size: 14px;
+ font-weight: 500;
+ color: #606266;
+ }
+
+ .create-time {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+
+ .topic-stats {
+ display: flex;
+ gap: 16px;
+
+ .stat-item {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+ }
+ }
+
+ .last-reply {
+ width: 150px;
+ text-align: right;
+
+ .reply-info {
+ .reply-author {
+ font-size: 14px;
+ font-weight: 500;
+ color: #606266;
+ margin-bottom: 4px;
+ }
+
+ .reply-time {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+
+ .no-reply {
+ font-size: 12px;
+ color: #c0c4cc;
+ }
+ }
+ }
+
+ .no-topics {
+ text-align: center;
+ color: #909399;
+ padding: 60px 0;
+ font-size: 16px;
+ }
+}
+
+.pagination-wrapper {
+ margin-top: 24px;
+ text-align: center;
+}
+
+.tags-input {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ align-items: center;
+
+ .el-tag {
+ margin: 0;
+ }
+}
+
+@keyframes pulse {
+ 0% {
+ transform: scale(1);
+ }
+ 50% {
+ transform: scale(1.1);
+ }
+ 100% {
+ transform: scale(1);
+ }
+}
+
+@media (max-width: 768px) {
+ .section-page {
+ padding: 16px;
+ }
+
+ .section-header {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 16px;
+
+ .section-info {
+ flex-direction: column;
+ text-align: center;
+
+ .section-stats {
+ justify-content: center;
+ }
+ }
+
+ .section-actions {
+ width: 100%;
+ text-align: center;
+ }
+ }
+
+ .filter-section {
+ flex-direction: column;
+ gap: 16px;
+
+ .filter-left, .filter-right {
+ width: 100%;
+ justify-content: center;
+ }
+
+ .filter-right {
+ .el-select {
+ width: 140px;
+ }
+ }
+ }
+
+ .topic-item {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 12px;
+
+ .topic-status {
+ align-self: flex-start;
+ }
+
+ .topic-content {
+ width: 100%;
+
+ .topic-meta {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 8px;
+ }
+ }
+
+ .last-reply {
+ width: 100%;
+ text-align: left;
+ }
+ }
+}
+</style>
\ No newline at end of file
diff --git a/src/views/forum/ForumTopicView.vue b/src/views/forum/ForumTopicView.vue
new file mode 100644
index 0000000..027083f
--- /dev/null
+++ b/src/views/forum/ForumTopicView.vue
@@ -0,0 +1,933 @@
+<template>
+ <div class="topic-detail-page">
+ <div class="page-container">
+ <!-- 面包屑导航 -->
+ <div class="breadcrumb">
+ <el-breadcrumb separator="/">
+ <el-breadcrumb-item :to="{ path: '/forum' }">论坛首页</el-breadcrumb-item>
+ <el-breadcrumb-item :to="{ path: `/forum/section/${topic.sectionId}` }">
+ {{ topic.sectionName }}
+ </el-breadcrumb-item>
+ <el-breadcrumb-item>{{ topic.title }}</el-breadcrumb-item>
+ </el-breadcrumb>
+ </div>
+
+ <!-- 主题信息 -->
+ <div class="topic-header">
+ <div class="topic-info">
+ <div class="topic-title-row">
+ <h1 class="topic-title">{{ topic.title }}</h1>
+ <div class="topic-status">
+ <el-tag v-if="topic.pinned" type="warning" size="small">置顶</el-tag>
+ <el-tag v-if="topic.hot" type="danger" size="small">热门</el-tag>
+ <el-tag v-if="topic.closed" type="info" size="small">已关闭</el-tag>
+ </div>
+ </div>
+
+ <div class="topic-tags">
+ <el-tag
+ v-for="tag in topic.tags"
+ :key="tag"
+ size="small"
+ type="info"
+ effect="plain"
+ >
+ {{ tag }}
+ </el-tag>
+ </div>
+
+ <div class="topic-meta">
+ <div class="author-info">
+ <el-avatar :size="32">{{ topic.author.charAt(0) }}</el-avatar>
+ <div class="author-details">
+ <span class="author-name">{{ topic.author }}</span>
+ <span class="post-time">发表于 {{ formatDateTime(topic.createTime) }}</span>
+ </div>
+ </div>
+
+ <div class="topic-stats">
+ <div class="stat-item">
+ <el-icon><View /></el-icon>
+ <span>{{ topic.views }} 浏览</span>
+ </div>
+ <div class="stat-item">
+ <el-icon><Comment /></el-icon>
+ <span>{{ topic.replies }} 回复</span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="topic-actions">
+ <el-button
+ v-if="!topic.closed"
+ type="primary"
+ :icon="Edit"
+ @click="showReplyDialog = true"
+ >
+ 回复主题
+ </el-button>
+ <el-dropdown @command="handleTopicAction">
+ <el-button :icon="More">
+ 更多 <el-icon class="el-icon--right"><ArrowDown /></el-icon>
+ </el-button>
+ <template #dropdown>
+ <el-dropdown-menu>
+ <el-dropdown-item command="favorite">
+ {{ isFavorited ? '取消收藏' : '收藏主题' }}
+ </el-dropdown-item>
+ <el-dropdown-item command="share">分享主题</el-dropdown-item>
+ <el-dropdown-item command="report" divided>举报主题</el-dropdown-item>
+ </el-dropdown-menu>
+ </template>
+ </el-dropdown>
+ </div>
+ </div>
+
+ <!-- 主题内容和回复列表 -->
+ <div class="posts-container">
+ <!-- 主楼 -->
+ <div class="post-item main-post">
+ <div class="post-header">
+ <div class="floor-number">#1</div>
+ <div class="post-author">
+ <el-avatar :size="48">{{ topic.author.charAt(0) }}</el-avatar>
+ <div class="author-info">
+ <span class="author-name">{{ topic.author }}</span>
+ <span class="author-title">{{ topic.authorTitle || '会员' }}</span>
+ <div class="author-stats">
+ <span>帖子: {{ topic.authorPosts || 0 }}</span>
+ <span>声望: {{ topic.authorReputation || 0 }}</span>
+ </div>
+ </div>
+ </div>
+ <div class="post-time">
+ {{ formatDateTime(topic.createTime) }}
+ </div>
+ </div>
+
+ <div class="post-content">
+ <div class="content-text" v-html="formatContent(topic.content)"></div>
+ </div>
+
+ <div class="post-actions">
+ <el-button type="text" size="small" @click="likePost(topic.id)">
+ <el-icon><Like /></el-icon>
+ {{ topic.likes || 0 }}
+ </el-button>
+ <el-button type="text" size="small" @click="quotePost(topic)">
+ <el-icon><ChatDotRound /></el-icon>
+ 引用
+ </el-button>
+ <el-button type="text" size="small" @click="reportPost(topic.id)">
+ <el-icon><Flag /></el-icon>
+ 举报
+ </el-button>
+ </div>
+ </div>
+
+ <!-- 回复列表 -->
+ <div
+ v-for="(reply, index) in replies"
+ :key="reply.id"
+ class="post-item reply-post"
+ >
+ <div class="post-header">
+ <div class="floor-number">#{{ index + 2 }}</div>
+ <div class="post-author">
+ <el-avatar :size="48">{{ reply.author.charAt(0) }}</el-avatar>
+ <div class="author-info">
+ <span class="author-name">{{ reply.author }}</span>
+ <span class="author-title">{{ reply.authorTitle || '会员' }}</span>
+ <div class="author-stats">
+ <span>帖子: {{ reply.authorPosts || 0 }}</span>
+ <span>声望: {{ reply.authorReputation || 0 }}</span>
+ </div>
+ </div>
+ </div>
+ <div class="post-time">
+ {{ formatDateTime(reply.createTime) }}
+ </div>
+ </div>
+
+ <div class="post-content">
+ <div v-if="reply.quotedPost" class="quoted-content">
+ <div class="quote-header">
+ <el-icon><ChatDotRound /></el-icon>
+ <span>{{ reply.quotedPost.author }} 发表于 {{ formatDateTime(reply.quotedPost.time) }}</span>
+ </div>
+ <div class="quote-text">{{ reply.quotedPost.content }}</div>
+ </div>
+ <div class="content-text" v-html="formatContent(reply.content)"></div>
+ </div>
+
+ <div class="post-actions">
+ <el-button type="text" size="small" @click="likePost(reply.id)">
+ <el-icon><Like /></el-icon>
+ {{ reply.likes || 0 }}
+ </el-button>
+ <el-button type="text" size="small" @click="quotePost(reply)">
+ <el-icon><ChatDotRound /></el-icon>
+ 引用
+ </el-button>
+ <el-button type="text" size="small" @click="reportPost(reply.id)">
+ <el-icon><Flag /></el-icon>
+ 举报
+ </el-button>
+ </div>
+ </div>
+ </div>
+
+ <!-- 分页 -->
+ <div class="pagination-wrapper">
+ <el-pagination
+ v-model:current-page="currentPage"
+ v-model:page-size="pageSize"
+ :page-sizes="[10, 20, 50]"
+ :total="totalReplies"
+ layout="total, sizes, prev, pager, next, jumper"
+ @size-change="handleSizeChange"
+ @current-change="handleCurrentChange"
+ />
+ </div>
+
+ <!-- 快速回复 -->
+ <div v-if="!topic.closed" class="quick-reply">
+ <h3>快速回复</h3>
+ <el-input
+ v-model="quickReplyContent"
+ type="textarea"
+ :rows="4"
+ placeholder="输入你的回复..."
+ maxlength="2000"
+ show-word-limit
+ />
+ <div class="quick-reply-actions">
+ <el-button @click="clearQuickReply">清空</el-button>
+ <el-button type="primary" @click="submitQuickReply" :loading="submittingReply">
+ 发表回复
+ </el-button>
+ </div>
+ </div>
+ </div>
+
+ <!-- 回复对话框 -->
+ <el-dialog
+ v-model="showReplyDialog"
+ title="回复主题"
+ width="700px"
+ :before-close="handleCloseReplyDialog"
+ >
+ <el-form
+ ref="replyFormRef"
+ :model="replyForm"
+ :rules="replyRules"
+ label-width="80px"
+ >
+ <el-form-item v-if="quotedContent" label="引用内容">
+ <div class="quoted-preview">
+ <div class="quote-header">
+ <span>{{ quotedContent.author }}</span>
+ </div>
+ <div class="quote-content">{{ quotedContent.content }}</div>
+ <el-button type="text" size="small" @click="clearQuote">
+ 清除引用
+ </el-button>
+ </div>
+ </el-form-item>
+
+ <el-form-item label="回复内容" prop="content">
+ <el-input
+ v-model="replyForm.content"
+ type="textarea"
+ :rows="8"
+ placeholder="请输入回复内容..."
+ maxlength="5000"
+ show-word-limit
+ />
+ </el-form-item>
+ </el-form>
+
+ <template #footer>
+ <el-button @click="handleCloseReplyDialog">取消</el-button>
+ <el-button type="primary" @click="submitReply" :loading="submittingReply">
+ 发表回复
+ </el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, onMounted } from 'vue'
+import { useRoute, useRouter } from 'vue-router'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import {
+ Edit,
+ More,
+ View,
+ Comment,
+ Like,
+ ChatDotRound,
+ Flag,
+ ArrowDown
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'ForumTopicView',
+ setup() {
+ const route = useRoute()
+ const router = useRouter()
+ const replyFormRef = ref(null)
+
+ const showReplyDialog = ref(false)
+ const submittingReply = ref(false)
+ const isFavorited = ref(false)
+ const currentPage = ref(1)
+ const pageSize = ref(20)
+ const totalReplies = ref(0)
+ const quickReplyContent = ref('')
+ const quotedContent = ref(null)
+
+ const topic = ref({
+ id: 1,
+ title: '2024年度最佳PT站点推荐与对比分析',
+ sectionId: 1,
+ sectionName: '站务讨论',
+ author: 'PTExpert',
+ authorTitle: '资深会员',
+ authorPosts: 1256,
+ authorReputation: 2890,
+ createTime: '2025-06-01T10:30:00',
+ content: `
+ <p>大家好,作为一个使用PT站点多年的老用户,我想和大家分享一下2024年各大PT站点的使用体验和对比分析。</p>
+
+ <h3>评测标准</h3>
+ <ul>
+ <li>资源丰富度:种子数量、更新速度、稀有资源</li>
+ <li>用户体验:界面设计、功能完善度、响应速度</li>
+ <li>社区氛围:用户活跃度、互帮互助程度</li>
+ <li>规则友好性:考核难度、分享率要求、保种要求</li>
+ </ul>
+
+ <h3>推荐站点</h3>
+ <p>经过综合评测,以下几个站点值得推荐:</p>
+ <ol>
+ <li><strong>站点A</strong>:资源最全,更新最快,适合影视爱好者</li>
+ <li><strong>站点B</strong>:音乐资源丰富,无损居多,音质发烧友首选</li>
+ <li><strong>站点C</strong>:软件资源全面,更新及时,开发者必备</li>
+ </ol>
+
+ <p>具体的详细评测报告我会在后续回复中逐一介绍,欢迎大家讨论和补充!</p>
+ `,
+ views: 2856,
+ replies: 147,
+ likes: 89,
+ tags: ['PT站点', '推荐', '对比'],
+ pinned: true,
+ hot: true,
+ closed: false
+ })
+
+ const replies = ref([
+ {
+ id: 2,
+ author: 'MovieLover88',
+ authorTitle: '影视达人',
+ authorPosts: 567,
+ authorReputation: 1234,
+ createTime: '2025-06-01T11:15:00',
+ content: '感谢楼主的详细分析!特别期待站点A的详细评测,最近正在寻找好的影视资源站点。',
+ likes: 12
+ },
+ {
+ id: 3,
+ author: 'TechGuru',
+ authorTitle: '技术专家',
+ authorPosts: 890,
+ authorReputation: 2156,
+ createTime: '2025-06-01T12:30:00',
+ content: '站点C确实不错,软件资源很全面。不过楼主能不能也评测一下游戏类的PT站点?',
+ likes: 8,
+ quotedPost: {
+ author: 'PTExpert',
+ time: '2025-06-01T10:30:00',
+ content: '站点C:软件资源全面,更新及时,开发者必备'
+ }
+ }
+ ])
+
+ const replyForm = reactive({
+ content: ''
+ })
+
+ const replyRules = {
+ content: [
+ { required: true, message: '请输入回复内容', trigger: 'blur' },
+ { min: 5, max: 5000, message: '内容长度在 5 到 5000 个字符', trigger: 'blur' }
+ ]
+ }
+
+ onMounted(() => {
+ const topicId = route.params.id
+ fetchTopicDetail(topicId)
+ })
+
+ const fetchTopicDetail = async (id) => {
+ try {
+ console.log('获取主题详情:', id)
+ totalReplies.value = 147
+ } catch (error) {
+ ElMessage.error('获取主题详情失败')
+ router.back()
+ }
+ }
+
+ const formatDateTime = (dateString) => {
+ const date = new Date(dateString)
+ return date.toLocaleString('zh-CN', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit'
+ })
+ }
+
+ const formatContent = (content) => {
+ return content.replace(/\n/g, '<br>')
+ }
+
+ const handleTopicAction = (command) => {
+ switch (command) {
+ case 'favorite':
+ isFavorited.value = !isFavorited.value
+ ElMessage.success(isFavorited.value ? '已收藏' : '已取消收藏')
+ break
+ case 'share':
+ navigator.clipboard.writeText(window.location.href)
+ ElMessage.success('链接已复制到剪贴板')
+ break
+ case 'report':
+ reportPost(topic.value.id)
+ break
+ }
+ }
+
+ const likePost = (postId) => {
+ if (postId === topic.value.id) {
+ topic.value.likes = (topic.value.likes || 0) + 1
+ } else {
+ const reply = replies.value.find(r => r.id === postId)
+ if (reply) {
+ reply.likes = (reply.likes || 0) + 1
+ }
+ }
+ ElMessage.success('点赞成功')
+ }
+
+ const quotePost = (post) => {
+ quotedContent.value = {
+ author: post.author,
+ content: post.content.replace(/<[^>]*>/g, '').substring(0, 100) + '...',
+ time: post.createTime
+ }
+ showReplyDialog.value = true
+ }
+
+ const reportPost = async (postId) => {
+ try {
+ await ElMessageBox.prompt('请说明举报原因', '举报内容', {
+ confirmButtonText: '提交举报',
+ cancelButtonText: '取消',
+ inputType: 'textarea',
+ inputPlaceholder: '请详细说明举报原因...'
+ })
+
+ ElMessage.success('举报已提交,我们会尽快处理')
+ } catch {
+ // 用户取消
+ }
+ }
+
+ const clearQuote = () => {
+ quotedContent.value = null
+ }
+
+ const handleCloseReplyDialog = () => {
+ if (replyForm.content) {
+ ElMessageBox.confirm(
+ '确定要关闭吗?未保存的内容将会丢失。',
+ '提示',
+ {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }
+ ).then(() => {
+ resetReplyForm()
+ showReplyDialog.value = false
+ }).catch(() => {
+ // 用户取消
+ })
+ } else {
+ resetReplyForm()
+ showReplyDialog.value = false
+ }
+ }
+
+ const submitReply = async () => {
+ try {
+ await replyFormRef.value?.validate()
+
+ submittingReply.value = true
+
+ await new Promise(resolve => setTimeout(resolve, 1500))
+
+ const newReply = {
+ id: Date.now(),
+ author: localStorage.getItem('username') || '用户',
+ authorTitle: '会员',
+ authorPosts: 0,
+ authorReputation: 0,
+ createTime: new Date().toISOString(),
+ content: replyForm.content,
+ likes: 0,
+ quotedPost: quotedContent.value
+ }
+
+ replies.value.push(newReply)
+ topic.value.replies += 1
+
+ ElMessage.success('回复发表成功!')
+ resetReplyForm()
+ showReplyDialog.value = false
+
+ } catch (error) {
+ console.error('表单验证失败:', error)
+ } finally {
+ submittingReply.value = false
+ }
+ }
+
+ const submitQuickReply = async () => {
+ if (!quickReplyContent.value.trim()) {
+ ElMessage.warning('请输入回复内容')
+ return
+ }
+
+ submittingReply.value = true
+ try {
+ await new Promise(resolve => setTimeout(resolve, 1000))
+
+ const newReply = {
+ id: Date.now(),
+ author: localStorage.getItem('username') || '用户',
+ authorTitle: '会员',
+ authorPosts: 0,
+ authorReputation: 0,
+ createTime: new Date().toISOString(),
+ content: quickReplyContent.value,
+ likes: 0
+ }
+
+ replies.value.push(newReply)
+ topic.value.replies += 1
+ quickReplyContent.value = ''
+
+ ElMessage.success('回复发表成功!')
+ } catch (error) {
+ ElMessage.error('发表回复失败')
+ } finally {
+ submittingReply.value = false
+ }
+ }
+
+ const clearQuickReply = () => {
+ quickReplyContent.value = ''
+ }
+
+ const resetReplyForm = () => {
+ replyFormRef.value?.resetFields()
+ replyForm.content = ''
+ quotedContent.value = null
+ }
+
+ const handleSizeChange = (size) => {
+ pageSize.value = size
+ currentPage.value = 1
+ }
+
+ const handleCurrentChange = (page) => {
+ currentPage.value = page
+ }
+
+ return {
+ showReplyDialog,
+ submittingReply,
+ isFavorited,
+ currentPage,
+ pageSize,
+ totalReplies,
+ quickReplyContent,
+ quotedContent,
+ topic,
+ replies,
+ replyForm,
+ replyRules,
+ replyFormRef,
+ formatDateTime,
+ formatContent,
+ handleTopicAction,
+ likePost,
+ quotePost,
+ reportPost,
+ clearQuote,
+ handleCloseReplyDialog,
+ submitReply,
+ submitQuickReply,
+ clearQuickReply,
+ handleSizeChange,
+ handleCurrentChange,
+ Edit,
+ More,
+ View,
+ Comment,
+ Like,
+ ChatDotRound,
+ Flag,
+ ArrowDown
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.topic-detail-page {
+ max-width: 1000px;
+ margin: 0 auto;
+ padding: 24px;
+ background: #f5f5f5;
+ min-height: 100vh;
+}
+
+.breadcrumb {
+ margin-bottom: 16px;
+}
+
+.topic-header {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+ gap: 24px;
+
+ .topic-info {
+ flex: 1;
+
+ .topic-title-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ margin-bottom: 12px;
+
+ .topic-title {
+ font-size: 24px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0;
+ flex: 1;
+ }
+
+ .topic-status {
+ .el-tag {
+ margin-left: 8px;
+ }
+ }
+ }
+
+ .topic-tags {
+ margin-bottom: 16px;
+
+ .el-tag {
+ margin-right: 8px;
+ }
+ }
+
+ .topic-meta {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .author-info {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+
+ .author-details {
+ .author-name {
+ display: block;
+ font-weight: 600;
+ color: #2c3e50;
+ font-size: 14px;
+ }
+
+ .post-time {
+ display: block;
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+ }
+
+ .topic-stats {
+ display: flex;
+ gap: 16px;
+
+ .stat-item {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ font-size: 14px;
+ color: #7f8c8d;
+ }
+ }
+ }
+ }
+
+ .topic-actions {
+ display: flex;
+ gap: 12px;
+ flex-shrink: 0;
+ }
+}
+
+.posts-container {
+ .post-item {
+ background: #fff;
+ border-radius: 12px;
+ margin-bottom: 16px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+ overflow: hidden;
+
+ &.main-post {
+ border-left: 4px solid #409eff;
+ }
+
+ .post-header {
+ background: #f8f9fa;
+ padding: 16px 24px;
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ border-bottom: 1px solid #f0f0f0;
+
+ .floor-number {
+ background: #409eff;
+ color: white;
+ padding: 4px 8px;
+ border-radius: 4px;
+ font-size: 12px;
+ font-weight: 600;
+ min-width: 32px;
+ text-align: center;
+ }
+
+ .post-author {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ flex: 1;
+
+ .author-info {
+ .author-name {
+ display: block;
+ font-weight: 600;
+ color: #2c3e50;
+ font-size: 14px;
+ }
+
+ .author-title {
+ display: block;
+ font-size: 12px;
+ color: #67c23a;
+ margin-bottom: 4px;
+ }
+
+ .author-stats {
+ font-size: 11px;
+ color: #909399;
+
+ span {
+ margin-right: 12px;
+ }
+ }
+ }
+ }
+
+ .post-time {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+
+ .post-content {
+ padding: 24px;
+
+ .quoted-content {
+ background: #f5f7fa;
+ border-left: 4px solid #e4e7ed;
+ padding: 12px 16px;
+ margin-bottom: 16px;
+ border-radius: 0 4px 4px 0;
+
+ .quote-header {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 12px;
+ color: #909399;
+ margin-bottom: 8px;
+ }
+
+ .quote-text {
+ font-size: 14px;
+ color: #606266;
+ line-height: 1.5;
+ }
+ }
+
+ .content-text {
+ line-height: 1.6;
+ color: #2c3e50;
+
+ :deep(h3) {
+ color: #2c3e50;
+ font-size: 18px;
+ font-weight: 600;
+ margin: 20px 0 12px 0;
+ }
+
+ :deep(p) {
+ margin-bottom: 12px;
+ }
+
+ :deep(ul), :deep(ol) {
+ margin: 12px 0;
+ padding-left: 20px;
+
+ li {
+ margin-bottom: 8px;
+ }
+ }
+ }
+ }
+
+ .post-actions {
+ padding: 12px 24px;
+ border-top: 1px solid #f0f0f0;
+ background: #fafafa;
+
+ .el-button {
+ margin-right: 16px;
+
+ .el-icon {
+ margin-right: 4px;
+ }
+ }
+ }
+ }
+}
+
+.pagination-wrapper {
+ text-align: center;
+ margin: 24px 0;
+}
+
+.quick-reply {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ h3 {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 16px 0;
+ }
+
+ .quick-reply-actions {
+ margin-top: 12px;
+ text-align: right;
+
+ .el-button {
+ margin-left: 12px;
+ }
+ }
+}
+
+.quoted-preview {
+ background: #f5f7fa;
+ border: 1px solid #e4e7ed;
+ border-radius: 4px;
+ padding: 12px;
+
+ .quote-header {
+ font-size: 12px;
+ color: #909399;
+ margin-bottom: 8px;
+ }
+
+ .quote-content {
+ font-size: 14px;
+ color: #606266;
+ margin-bottom: 8px;
+ line-height: 1.5;
+ }
+}
+
+@media (max-width: 768px) {
+ .topic-detail-page {
+ padding: 16px;
+ }
+
+ .topic-header {
+ flex-direction: column;
+ align-items: flex-start;
+
+ .topic-actions {
+ width: 100%;
+ justify-content: flex-end;
+ }
+ }
+
+ .post-header {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 12px;
+
+ .floor-number {
+ align-self: flex-start;
+ }
+ }
+
+ .post-content {
+ padding: 16px;
+ }
+
+ .post-actions {
+ padding: 12px 16px;
+
+ .el-button {
+ margin-right: 8px;
+ margin-bottom: 8px;
+ }
+ }
+}
+</style>
\ No newline at end of file
diff --git a/src/views/forum/ForumView.vue b/src/views/forum/ForumView.vue
new file mode 100644
index 0000000..e4fa0f9
--- /dev/null
+++ b/src/views/forum/ForumView.vue
@@ -0,0 +1,978 @@
+<template>
+ <div class="forum-page">
+ <div class="page-container">
+ <!-- 论坛头部 -->
+ <div class="forum-header">
+ <div class="header-content">
+ <h1>社区论坛</h1>
+ <p class="header-description">与其他用户交流讨论,分享经验心得</p>
+ <div class="header-actions">
+ <el-button type="primary" :icon="Edit" @click="showNewTopicDialog = true">
+ 发布新帖
+ </el-button>
+ </div>
+ </div>
+ </div>
+
+ <!-- 论坛统计 -->
+ <div class="forum-stats">
+ <div class="stats-grid">
+ <div class="stat-item">
+ <el-icon size="32" color="#409eff"><ChatDotRound /></el-icon>
+ <div class="stat-info">
+ <h3>{{ forumStats.totalTopics }}</h3>
+ <p>主题总数</p>
+ </div>
+ </div>
+ <div class="stat-item">
+ <el-icon size="32" color="#67c23a"><Comment /></el-icon>
+ <div class="stat-info">
+ <h3>{{ forumStats.totalReplies }}</h3>
+ <p>回复总数</p>
+ </div>
+ </div>
+ <div class="stat-item">
+ <el-icon size="32" color="#e6a23c"><User /></el-icon>
+ <div class="stat-info">
+ <h3>{{ forumStats.activeUsers }}</h3>
+ <p>活跃用户</p>
+ </div>
+ </div>
+ <div class="stat-item">
+ <el-icon size="32" color="#f56c6c"><View /></el-icon>
+ <div class="stat-info">
+ <h3>{{ forumStats.todayPosts }}</h3>
+ <p>今日发帖</p>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 版块列表 -->
+ <div class="forum-sections">
+ <h2 class="section-title">论坛版块</h2>
+ <div class="sections-list">
+ <div
+ v-for="section in forumSections"
+ :key="section.id"
+ class="section-card"
+ @click="navigateToSection(section.id)"
+ >
+ <div class="section-icon">
+ <el-icon size="48" :color="section.color">
+ <component :is="section.icon" />
+ </el-icon>
+ </div>
+ <div class="section-info">
+ <h3 class="section-name">{{ section.name }}</h3>
+ <p class="section-description">{{ section.description }}</p>
+ <div class="section-stats">
+ <span class="stat">{{ section.topics }} 主题</span>
+ <span class="stat">{{ section.replies }} 回复</span>
+ </div>
+ </div>
+ <div class="section-latest">
+ <div v-if="section.latestTopic" class="latest-topic">
+ <p class="topic-title">{{ section.latestTopic.title }}</p>
+ <div class="topic-meta">
+ <span class="author">{{ section.latestTopic.author }}</span>
+ <span class="time">{{ formatTime(section.latestTopic.time) }}</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 热门主题 -->
+ <div class="hot-topics">
+ <div class="section-header">
+ <h2 class="section-title">热门主题</h2>
+ <el-button type="primary" text @click="$router.push('/forum/topics')">
+ 查看全部 <el-icon><ArrowRight /></el-icon>
+ </el-button>
+ </div>
+ <div class="topics-list">
+ <div
+ v-for="topic in hotTopics"
+ :key="topic.id"
+ class="topic-item"
+ @click="navigateToTopic(topic.id)"
+ >
+ <div class="topic-content">
+ <div class="topic-header">
+ <h4 class="topic-title">{{ topic.title }}</h4>
+ <div class="topic-tags">
+ <el-tag
+ v-for="tag in topic.tags"
+ :key="tag"
+ size="small"
+ type="info"
+ >
+ {{ tag }}
+ </el-tag>
+ </div>
+ </div>
+ <div class="topic-meta">
+ <div class="author-info">
+ <el-avatar :size="24">{{ topic.author.charAt(0) }}</el-avatar>
+ <span class="author-name">{{ topic.author }}</span>
+ </div>
+ <div class="topic-stats">
+ <span class="stat-item">
+ <el-icon><View /></el-icon>
+ {{ topic.views }}
+ </span>
+ <span class="stat-item">
+ <el-icon><Comment /></el-icon>
+ {{ topic.replies }}
+ </span>
+ <span class="time">{{ formatTime(topic.lastReply) }}</span>
+ </div>
+ </div>
+ </div>
+ <div class="topic-status">
+ <el-tag v-if="topic.pinned" type="warning" size="small">置顶</el-tag>
+ <el-tag v-if="topic.hot" type="danger" size="small">热门</el-tag>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 最新回复 -->
+ <div class="recent-replies">
+ <h2 class="section-title">最新回复</h2>
+ <div class="replies-list">
+ <div
+ v-for="reply in recentReplies"
+ :key="reply.id"
+ class="reply-item"
+ @click="navigateToTopic(reply.topicId)"
+ >
+ <div class="reply-avatar">
+ <el-avatar :size="40">{{ reply.author.charAt(0) }}</el-avatar>
+ </div>
+ <div class="reply-content">
+ <div class="reply-header">
+ <span class="reply-author">{{ reply.author }}</span>
+ <span class="reply-action">回复了主题</span>
+ <span class="topic-title">{{ reply.topicTitle }}</span>
+ </div>
+ <div class="reply-text">{{ reply.content }}</div>
+ <div class="reply-time">{{ formatTime(reply.time) }}</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 发布新帖对话框 -->
+ <el-dialog
+ v-model="showNewTopicDialog"
+ title="发布新主题"
+ width="600px"
+ :before-close="handleCloseDialog"
+ >
+ <el-form
+ ref="topicFormRef"
+ :model="newTopic"
+ :rules="topicRules"
+ label-width="80px"
+ >
+ <el-form-item label="版块" prop="sectionId">
+ <el-select v-model="newTopic.sectionId" placeholder="选择版块">
+ <el-option
+ v-for="section in forumSections"
+ :key="section.id"
+ :label="section.name"
+ :value="section.id"
+ />
+ </el-select>
+ </el-form-item>
+
+ <el-form-item label="标题" prop="title">
+ <el-input
+ v-model="newTopic.title"
+ placeholder="请输入主题标题"
+ maxlength="100"
+ show-word-limit
+ />
+ </el-form-item>
+
+ <el-form-item label="标签">
+ <div class="tags-input">
+ <el-tag
+ v-for="tag in newTopic.tags"
+ :key="tag"
+ closable
+ @close="removeTopicTag(tag)"
+ >
+ {{ tag }}
+ </el-tag>
+ <el-input
+ v-if="tagInputVisible"
+ ref="tagInputRef"
+ v-model="tagInputValue"
+ size="small"
+ @keyup.enter="addTopicTag"
+ @blur="addTopicTag"
+ style="width: 100px;"
+ />
+ <el-button
+ v-else
+ size="small"
+ @click="showTagInput"
+ >
+ + 添加标签
+ </el-button>
+ </div>
+ </el-form-item>
+
+ <el-form-item label="内容" prop="content">
+ <el-input
+ v-model="newTopic.content"
+ type="textarea"
+ :rows="8"
+ placeholder="请输入主题内容..."
+ maxlength="5000"
+ show-word-limit
+ />
+ </el-form-item>
+ </el-form>
+
+ <template #footer>
+ <el-button @click="handleCloseDialog">取消</el-button>
+ <el-button type="primary" @click="submitNewTopic" :loading="submitting">
+ 发布主题
+ </el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, onMounted, nextTick } from 'vue'
+import { useRouter } from 'vue-router'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import {
+ Edit,
+ ChatDotRound,
+ Comment,
+ User,
+ View,
+ ArrowRight,
+ Film,
+ Headphones,
+ Monitor,
+ GamePad,
+ ChatLineRound,
+ QuestionFilled,
+ Bell
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'ForumView',
+ setup() {
+ const router = useRouter()
+ const topicFormRef = ref(null)
+ const tagInputRef = ref(null)
+
+ const showNewTopicDialog = ref(false)
+ const submitting = ref(false)
+ const tagInputVisible = ref(false)
+ const tagInputValue = ref('')
+
+ const forumStats = reactive({
+ totalTopics: '15,268',
+ totalReplies: '89,456',
+ activeUsers: '2,341',
+ todayPosts: '156'
+ })
+
+ const newTopic = reactive({
+ sectionId: '',
+ title: '',
+ content: '',
+ tags: []
+ })
+
+ const topicRules = {
+ sectionId: [
+ { required: true, message: '请选择版块', trigger: 'change' }
+ ],
+ title: [
+ { required: true, message: '请输入标题', trigger: 'blur' },
+ { min: 5, max: 100, message: '标题长度在 5 到 100 个字符', trigger: 'blur' }
+ ],
+ content: [
+ { required: true, message: '请输入内容', trigger: 'blur' },
+ { min: 10, max: 5000, message: '内容长度在 10 到 5000 个字符', trigger: 'blur' }
+ ]
+ }
+
+ const forumSections = ref([
+ {
+ id: 1,
+ name: '电影讨论',
+ description: '分享和讨论电影资源,交流观影心得',
+ icon: 'Film',
+ color: '#409eff',
+ topics: 3256,
+ replies: 18934,
+ latestTopic: {
+ title: '2024年最佳科幻电影推荐',
+ author: 'MovieFan',
+ time: '2025-06-03T14:30:00'
+ }
+ },
+ {
+ id: 2,
+ name: '音乐分享',
+ description: '音乐资源分享,音乐制作技术交流',
+ icon: 'Headphones',
+ color: '#67c23a',
+ topics: 1892,
+ replies: 9567,
+ latestTopic: {
+ title: '无损音乐格式对比分析',
+ author: 'AudioExpert',
+ time: '2025-06-03T13:45:00'
+ }
+ },
+ {
+ id: 3,
+ name: '软件技术',
+ description: '软件资源分享,技术问题讨论',
+ icon: 'Monitor',
+ color: '#e6a23c',
+ topics: 2134,
+ replies: 12456,
+ latestTopic: {
+ title: 'Adobe 2025 新功能体验分享',
+ author: 'TechGuru',
+ time: '2025-06-03T12:20:00'
+ }
+ },
+ {
+ id: 4,
+ name: '游戏天地',
+ description: '游戏资源分享,游戏攻略讨论',
+ icon: 'GamePad',
+ color: '#f56c6c',
+ topics: 1567,
+ replies: 8234,
+ latestTopic: {
+ title: '年度游戏大作盘点',
+ author: 'GameMaster',
+ time: '2025-06-03T11:50:00'
+ }
+ },
+ {
+ id: 5,
+ name: '站务公告',
+ description: '网站公告,规则说明,意见建议',
+ icon: 'Bell',
+ color: '#909399',
+ topics: 234,
+ replies: 1567,
+ latestTopic: {
+ title: '网站维护通知',
+ author: 'Admin',
+ time: '2025-06-03T10:00:00'
+ }
+ },
+ {
+ id: 6,
+ name: '新手求助',
+ description: '新手问题解答,使用教程分享',
+ icon: 'QuestionFilled',
+ color: '#606266',
+ topics: 456,
+ replies: 2890,
+ latestTopic: {
+ title: '新手如何提高分享率?',
+ author: 'Newbie123',
+ time: '2025-06-03T09:30:00'
+ }
+ }
+ ])
+
+ const hotTopics = ref([
+ {
+ id: 1,
+ title: '2024年度最佳PT站点推荐与对比分析',
+ author: 'PTExpert',
+ views: 2856,
+ replies: 147,
+ lastReply: '2025-06-03T14:25:00',
+ tags: ['PT站点', '推荐', '对比'],
+ pinned: true,
+ hot: true
+ },
+ {
+ id: 2,
+ title: '如何安全高效地使用BT下载工具',
+ author: 'SafeDownloader',
+ views: 1932,
+ replies: 89,
+ lastReply: '2025-06-03T13:50:00',
+ tags: ['BT工具', '安全', '教程'],
+ hot: true
+ },
+ {
+ id: 3,
+ title: '分享率提升技巧与经验总结',
+ author: 'SeedMaster',
+ views: 1654,
+ replies: 76,
+ lastReply: '2025-06-03T12:40:00',
+ tags: ['分享率', '技巧', '经验']
+ }
+ ])
+
+ const recentReplies = ref([
+ {
+ id: 1,
+ author: 'MovieLover88',
+ topicId: 1,
+ topicTitle: '阿凡达2观影感受分享',
+ content: '画面效果确实震撼,特别是水下的场景...',
+ time: '2025-06-03T14:45:00'
+ },
+ {
+ id: 2,
+ author: 'TechEnthusiast',
+ topicId: 2,
+ topicTitle: '最新版Photoshop使用技巧',
+ content: '新的AI功能确实很强大,大大提高了工作效率...',
+ time: '2025-06-03T14:30:00'
+ },
+ {
+ id: 3,
+ author: 'GameFan2024',
+ topicId: 3,
+ topicTitle: '赛博朋克2077最新更新体验',
+ content: '修复了很多bug,现在游戏体验好多了...',
+ time: '2025-06-03T14:15:00'
+ }
+ ])
+
+ onMounted(() => {
+ // 初始化论坛数据
+ })
+
+ const formatTime = (timeString) => {
+ const date = new Date(timeString)
+ const now = new Date()
+ const diff = now - date
+ const hours = Math.floor(diff / (1000 * 60 * 60))
+
+ if (hours < 1) return '刚刚'
+ if (hours < 24) return `${hours}小时前`
+ const days = Math.floor(hours / 24)
+ return `${days}天前`
+ }
+
+ const navigateToSection = (sectionId) => {
+ router.push(`/forum/section/${sectionId}`)
+ }
+
+ const navigateToTopic = (topicId) => {
+ router.push(`/forum/topic/${topicId}`)
+ }
+
+ const showTagInput = () => {
+ tagInputVisible.value = true
+ nextTick(() => {
+ tagInputRef.value?.focus()
+ })
+ }
+
+ const addTopicTag = () => {
+ const tag = tagInputValue.value.trim()
+ if (tag && !newTopic.tags.includes(tag)) {
+ newTopic.tags.push(tag)
+ }
+ tagInputVisible.value = false
+ tagInputValue.value = ''
+ }
+
+ const removeTopicTag = (tag) => {
+ const index = newTopic.tags.indexOf(tag)
+ if (index > -1) {
+ newTopic.tags.splice(index, 1)
+ }
+ }
+
+ const handleCloseDialog = () => {
+ if (newTopic.title || newTopic.content) {
+ ElMessageBox.confirm(
+ '确定要关闭吗?未保存的内容将会丢失。',
+ '提示',
+ {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }
+ ).then(() => {
+ resetForm()
+ showNewTopicDialog.value = false
+ }).catch(() => {
+ // 用户取消
+ })
+ } else {
+ resetForm()
+ showNewTopicDialog.value = false
+ }
+ }
+
+ const submitNewTopic = async () => {
+ try {
+ await topicFormRef.value?.validate()
+
+ submitting.value = true
+
+ // 模拟提交过程
+ await new Promise(resolve => setTimeout(resolve, 1500))
+
+ ElMessage.success('主题发布成功!')
+ resetForm()
+ showNewTopicDialog.value = false
+
+ // 跳转到新创建的主题页面
+ router.push('/forum/topic/new')
+
+ } catch (error) {
+ console.error('表单验证失败:', error)
+ } finally {
+ submitting.value = false
+ }
+ }
+
+ const resetForm = () => {
+ topicFormRef.value?.resetFields()
+ newTopic.sectionId = ''
+ newTopic.title = ''
+ newTopic.content = ''
+ newTopic.tags = []
+ }
+
+ return {
+ showNewTopicDialog,
+ submitting,
+ tagInputVisible,
+ tagInputValue,
+ topicFormRef,
+ tagInputRef,
+ forumStats,
+ forumSections,
+ hotTopics,
+ recentReplies,
+ newTopic,
+ topicRules,
+ formatTime,
+ navigateToSection,
+ navigateToTopic,
+ showTagInput,
+ addTopicTag,
+ removeTopicTag,
+ handleCloseDialog,
+ submitNewTopic,
+ Edit,
+ ChatDotRound,
+ Comment,
+ User,
+ View,
+ ArrowRight,
+ Film,
+ Headphones,
+ Monitor,
+ GamePad,
+ Bell,
+ QuestionFilled
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.forum-page {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 24px;
+ background: #f5f5f5;
+ min-height: 100vh;
+}
+
+.forum-header {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ border-radius: 12px;
+ padding: 48px 32px;
+ margin-bottom: 24px;
+ color: white;
+ text-align: center;
+
+ h1 {
+ font-size: 36px;
+ font-weight: 600;
+ margin: 0 0 12px 0;
+ }
+
+ .header-description {
+ font-size: 18px;
+ margin: 0 0 24px 0;
+ opacity: 0.9;
+ }
+}
+
+.forum-stats {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .stats-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ gap: 24px;
+
+ .stat-item {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+
+ .stat-info {
+ h3 {
+ font-size: 24px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 4px 0;
+ }
+
+ p {
+ font-size: 14px;
+ color: #7f8c8d;
+ margin: 0;
+ }
+ }
+ }
+ }
+}
+
+.forum-sections {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .section-title {
+ font-size: 20px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 20px 0;
+ }
+
+ .sections-list {
+ .section-card {
+ display: flex;
+ align-items: center;
+ gap: 20px;
+ padding: 20px;
+ border: 1px solid #f0f0f0;
+ border-radius: 8px;
+ margin-bottom: 12px;
+ cursor: pointer;
+ transition: all 0.3s ease;
+
+ &:hover {
+ background: #f8f9fa;
+ border-color: #409eff;
+ transform: translateX(4px);
+ }
+
+ .section-info {
+ flex: 1;
+
+ .section-name {
+ font-size: 18px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 8px 0;
+ }
+
+ .section-description {
+ font-size: 14px;
+ color: #7f8c8d;
+ margin: 0 0 12px 0;
+ }
+
+ .section-stats {
+ display: flex;
+ gap: 16px;
+
+ .stat {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+ }
+
+ .section-latest {
+ width: 200px;
+
+ .latest-topic {
+ .topic-title {
+ font-size: 14px;
+ color: #2c3e50;
+ margin: 0 0 8px 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ }
+
+ .topic-meta {
+ font-size: 12px;
+ color: #909399;
+
+ .author {
+ margin-right: 8px;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+.hot-topics {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .section-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 20px;
+
+ .section-title {
+ font-size: 20px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0;
+ }
+ }
+
+ .topics-list {
+ .topic-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px;
+ border: 1px solid #f0f0f0;
+ border-radius: 8px;
+ margin-bottom: 12px;
+ cursor: pointer;
+ transition: all 0.3s ease;
+
+ &:hover {
+ background: #f8f9fa;
+ border-color: #409eff;
+ }
+
+ .topic-content {
+ flex: 1;
+
+ .topic-header {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ margin-bottom: 8px;
+
+ .topic-title {
+ font-size: 16px;
+ font-weight: 500;
+ color: #2c3e50;
+ margin: 0;
+ }
+
+ .topic-tags {
+ .el-tag {
+ margin-right: 4px;
+ }
+ }
+ }
+
+ .topic-meta {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .author-info {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+
+ .author-name {
+ font-size: 14px;
+ color: #7f8c8d;
+ }
+ }
+
+ .topic-stats {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ font-size: 12px;
+ color: #909399;
+
+ .stat-item {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ }
+ }
+ }
+ }
+
+ .topic-status {
+ .el-tag {
+ margin-left: 8px;
+ }
+ }
+ }
+ }
+}
+
+.recent-replies {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .section-title {
+ font-size: 20px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 20px 0;
+ }
+
+ .replies-list {
+ .reply-item {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding: 16px;
+ border: 1px solid #f0f0f0;
+ border-radius: 8px;
+ margin-bottom: 12px;
+ cursor: pointer;
+ transition: all 0.3s ease;
+
+ &:hover {
+ background: #f8f9fa;
+ border-color: #409eff;
+ }
+
+ .reply-content {
+ flex: 1;
+
+ .reply-header {
+ font-size: 14px;
+ margin-bottom: 8px;
+
+ .reply-author {
+ font-weight: 600;
+ color: #2c3e50;
+ }
+
+ .reply-action {
+ color: #7f8c8d;
+ margin: 0 4px;
+ }
+
+ .topic-title {
+ color: #409eff;
+ font-weight: 500;
+ }
+ }
+
+ .reply-text {
+ font-size: 14px;
+ color: #5a6c7d;
+ margin-bottom: 8px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ }
+
+ .reply-time {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+ }
+ }
+}
+</style>
+
+.tags-input {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ align-items: center;
+
+ .el-tag {
+ margin: 0;
+ }
+}
+
+@media (max-width: 768px) {
+ .forum-page {
+ padding: 16px;
+ }
+
+ .forum-header {
+ padding: 32px 24px;
+
+ h1 {
+ font-size: 28px;
+ }
+
+ .header-description {
+ font-size: 16px;
+ }
+ }
+
+ .stats-grid {
+ grid-template-columns: repeat(2, 1fr);
+ }
+
+ .section-card {
+ flex-direction: column;
+ text-align: center;
+
+ .section-latest {
+ width: 100%;
+ margin-top: 16px;
+ }
+ }
+
+ .topic-item {
+ flex-direction: column;
+ align-items: flex-start;
+
+ .topic-status {
+ margin-top: 12px;
+ align-self: flex-end;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/views/torrent/TorrentDetailView.vue b/src/views/torrent/TorrentDetailView.vue
new file mode 100644
index 0000000..941ebd1
--- /dev/null
+++ b/src/views/torrent/TorrentDetailView.vue
@@ -0,0 +1,862 @@
+<template>
+ <div class="torrent-detail-page">
+ <div class="page-container">
+ <!-- 返回按钮 -->
+ <div class="back-button">
+ <el-button :icon="ArrowLeft" @click="$router.back()">
+ 返回列表
+ </el-button>
+ </div>
+
+ <!-- 种子基本信息 -->
+ <div class="torrent-header">
+ <div class="header-content">
+ <div class="torrent-cover">
+ <el-image
+ :src="torrentInfo.coverImage || '/default-cover.jpg'"
+ :alt="torrentInfo.title"
+ fit="cover"
+ class="cover-image"
+ >
+ <template #error>
+ <div class="image-placeholder">
+ <el-icon size="48"><Picture /></el-icon>
+ <span>暂无封面</span>
+ </div>
+ </template>
+ </el-image>
+ </div>
+
+ <div class="torrent-info">
+ <div class="category-tag">
+ <el-tag :type="getCategoryType(torrentInfo.category)" size="large">
+ {{ getCategoryName(torrentInfo.category) }}
+ </el-tag>
+ <el-tag v-if="torrentInfo.subcategory" type="info" size="small">
+ {{ torrentInfo.subcategory }}
+ </el-tag>
+ </div>
+
+ <h1 class="torrent-title">{{ torrentInfo.title }}</h1>
+
+ <div class="torrent-tags">
+ <el-tag
+ v-for="tag in torrentInfo.tags"
+ :key="tag"
+ size="small"
+ effect="plain"
+ >
+ {{ tag }}
+ </el-tag>
+ </div>
+
+ <div class="torrent-meta">
+ <div class="meta-item">
+ <el-icon><User /></el-icon>
+ <span>上传者:{{ torrentInfo.uploader }}</span>
+ </div>
+ <div class="meta-item">
+ <el-icon><Clock /></el-icon>
+ <span>上传时间:{{ formatDateTime(torrentInfo.uploadTime) }}</span>
+ </div>
+ <div class="meta-item">
+ <el-icon><Document /></el-icon>
+ <span>文件大小:{{ torrentInfo.size }}</span>
+ </div>
+ <div class="meta-item">
+ <el-icon><Files /></el-icon>
+ <span>文件数量:{{ torrentInfo.fileCount }} 个</span>
+ </div>
+ </div>
+
+ <div class="torrent-stats">
+ <div class="stat-item seeders">
+ <span class="stat-number">{{ torrentInfo.seeders }}</span>
+ <span class="stat-label">做种</span>
+ </div>
+ <div class="stat-item leechers">
+ <span class="stat-number">{{ torrentInfo.leechers }}</span>
+ <span class="stat-label">下载</span>
+ </div>
+ <div class="stat-item downloads">
+ <span class="stat-number">{{ torrentInfo.downloads }}</span>
+ <span class="stat-label">完成</span>
+ </div>
+ </div>
+
+ <div class="action-buttons">
+ <el-button
+ type="primary"
+ size="large"
+ :icon="Download"
+ @click="handleDownload"
+ :loading="downloading"
+ >
+ {{ downloading ? '准备中...' : '下载种子' }}
+ </el-button>
+ <el-button
+ type="success"
+ size="large"
+ :icon="Star"
+ @click="handleFavorite"
+ >
+ {{ isFavorited ? '已收藏' : '收藏' }}
+ </el-button>
+ <el-button
+ type="warning"
+ size="large"
+ :icon="Flag"
+ @click="handleReport"
+ >
+ 举报
+ </el-button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- 详细信息选项卡 -->
+ <div class="detail-tabs">
+ <el-tabs v-model="activeTab" type="border-card">
+ <!-- 种子描述 -->
+ <el-tab-pane label="详细描述" name="description">
+ <div class="description-content">
+ <div v-if="torrentInfo.description" v-html="formatDescription(torrentInfo.description)"></div>
+ <div v-else class="no-description">暂无详细描述</div>
+ </div>
+ </el-tab-pane>
+
+ <!-- 文件列表 -->
+ <el-tab-pane label="文件列表" name="files" lazy>
+ <div class="files-list">
+ <el-table :data="torrentInfo.files" stripe>
+ <el-table-column label="文件名" prop="name" min-width="400">
+ <template #default="{ row }">
+ <div class="file-name">
+ <el-icon v-if="row.type === 'folder'"><Folder /></el-icon>
+ <el-icon v-else><Document /></el-icon>
+ <span>{{ row.name }}</span>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column label="大小" prop="size" width="120" align="right" />
+ <el-table-column label="路径" prop="path" min-width="300" />
+ </el-table>
+ </div>
+ </el-tab-pane>
+
+ <!-- 用户活动 -->
+ <el-tab-pane label="用户活动" name="activity">
+ <div class="activity-section">
+ <div class="activity-stats">
+ <div class="stats-grid">
+ <div class="stat-card">
+ <h3>做种用户</h3>
+ <p class="stat-number">{{ torrentInfo.seeders }}</p>
+ </div>
+ <div class="stat-card">
+ <h3>下载用户</h3>
+ <p class="stat-number">{{ torrentInfo.leechers }}</p>
+ </div>
+ <div class="stat-card">
+ <h3>完成用户</h3>
+ <p class="stat-number">{{ torrentInfo.downloads }}</p>
+ </div>
+ </div>
+ </div>
+
+ <div class="user-lists">
+ <el-tabs v-model="activityTab" type="card">
+ <el-tab-pane label="做种用户" name="seeders">
+ <el-table :data="seedersList" max-height="400">
+ <el-table-column label="用户" prop="username" />
+ <el-table-column label="上传量" prop="uploaded" />
+ <el-table-column label="下载量" prop="downloaded" />
+ <el-table-column label="分享率" prop="ratio" />
+ <el-table-column label="做种时间" prop="seedTime" />
+ </el-table>
+ </el-tab-pane>
+
+ <el-tab-pane label="下载用户" name="leechers">
+ <el-table :data="leechersList" max-height="400">
+ <el-table-column label="用户" prop="username" />
+ <el-table-column label="进度" prop="progress">
+ <template #default="{ row }">
+ <el-progress :percentage="row.progress" :stroke-width="6" />
+ </template>
+ </el-table-column>
+ <el-table-column label="下载速度" prop="downloadSpeed" />
+ <el-table-column label="剩余时间" prop="eta" />
+ </el-table>
+ </el-tab-pane>
+ </el-tabs>
+ </div>
+ </div>
+ </el-tab-pane>
+
+ <!-- 评论区 -->
+ <el-tab-pane label="评论" name="comments">
+ <div class="comments-section">
+ <!-- 发表评论 -->
+ <div class="comment-form">
+ <el-input
+ v-model="newComment"
+ type="textarea"
+ :rows="4"
+ placeholder="发表你的评论..."
+ maxlength="500"
+ show-word-limit
+ />
+ <div class="comment-actions">
+ <el-button type="primary" @click="submitComment" :loading="submittingComment">
+ 发表评论
+ </el-button>
+ </div>
+ </div>
+
+ <!-- 评论列表 -->
+ <div class="comments-list">
+ <div
+ v-for="comment in comments"
+ :key="comment.id"
+ class="comment-item"
+ >
+ <div class="comment-avatar">
+ <el-avatar :size="40">{{ comment.username.charAt(0) }}</el-avatar>
+ </div>
+ <div class="comment-content">
+ <div class="comment-header">
+ <span class="comment-username">{{ comment.username }}</span>
+ <span class="comment-time">{{ formatDateTime(comment.time) }}</span>
+ </div>
+ <div class="comment-text">{{ comment.content }}</div>
+ <div class="comment-actions">
+ <el-button type="text" size="small" @click="likeComment(comment.id)">
+ <el-icon><Like /></el-icon>
+ {{ comment.likes || 0 }}
+ </el-button>
+ <el-button type="text" size="small" @click="replyComment(comment.id)">
+ 回复
+ </el-button>
+ </div>
+ </div>
+ </div>
+
+ <div v-if="comments.length === 0" class="no-comments">
+ 暂无评论,快来发表第一条评论吧!
+ </div>
+ </div>
+ </div>
+ </el-tab-pane>
+ </el-tabs>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import { ref, onMounted } from 'vue'
+import { useRoute, useRouter } from 'vue-router'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import {
+ ArrowLeft,
+ Download,
+ Star,
+ Flag,
+ User,
+ Clock,
+ Document,
+ Files,
+ Picture,
+ Folder,
+ Like
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'TorrentDetailView',
+ setup() {
+ const route = useRoute()
+ const router = useRouter()
+
+ const activeTab = ref('description')
+ const activityTab = ref('seeders')
+ const downloading = ref(false)
+ const isFavorited = ref(false)
+ const submittingComment = ref(false)
+ const newComment = ref('')
+
+ const torrentInfo = ref({
+ id: 1,
+ title: '[4K蓝光原盘] 阿凡达:水之道 Avatar: The Way of Water (2022)',
+ category: 'movie',
+ subcategory: '科幻片',
+ uploader: 'MovieMaster',
+ uploadTime: '2025-06-03T10:30:00',
+ size: '85.6 GB',
+ fileCount: 125,
+ seeders: 128,
+ leechers: 45,
+ downloads: 892,
+ coverImage: 'https://example.com/avatar2-cover.jpg',
+ tags: ['4K', '蓝光原盘', '科幻', '詹姆斯·卡梅隆'],
+ description: `
+ <h3>影片信息</h3>
+ <p><strong>片名:</strong>阿凡达:水之道 / Avatar: The Way of Water</p>
+ <p><strong>年份:</strong>2022</p>
+ <p><strong>导演:</strong>詹姆斯·卡梅隆</p>
+ <p><strong>主演:</strong>萨姆·沃辛顿 / 佐伊·索尔达娜 / 西格妮·韦弗</p>
+ <p><strong>类型:</strong>科幻 / 动作 / 冒险</p>
+ <p><strong>制片国家/地区:</strong>美国</p>
+ <p><strong>语言:</strong>英语</p>
+ <p><strong>上映日期:</strong>2022-12-16</p>
+ <p><strong>片长:</strong>192分钟</p>
+
+ <h3>影片简介</h3>
+ <p>杰克·萨利和奈蒂莉组建了家庭,他们的孩子也逐渐成长。当危险威胁到他们时,杰克和奈蒂莉必须为彼此而战,为家庭而战,为生存而战。</p>
+
+ <h3>技术规格</h3>
+ <ul>
+ <li>视频:4K UHD 2160p / HEVC / HDR10</li>
+ <li>音频:Dolby Atmos TrueHD 7.1 / DTS-HD MA 7.1</li>
+ <li>字幕:中文 / 英文</li>
+ <li>片源:4K UHD 蓝光原盘</li>
+ </ul>
+
+ <h3>下载说明</h3>
+ <p>本资源为4K蓝光原盘,保持了最高的画质和音质。建议使用支持4K播放的设备观看。</p>
+ `,
+ files: [
+ { name: 'BDMV', type: 'folder', size: '85.6 GB', path: '/' },
+ { name: 'CERTIFICATE', type: 'folder', size: '2.1 MB', path: '/' },
+ { name: 'Avatar.The.Way.of.Water.2022.2160p.UHD.Blu-ray.x265.HDR.Atmos-DETAIL.mkv', type: 'file', size: '32.8 GB', path: '/BDMV/STREAM/' },
+ { name: 'Avatar.The.Way.of.Water.2022.Extras.mkv', type: 'file', size: '12.4 GB', path: '/BDMV/STREAM/' }
+ ]
+ })
+
+ const seedersList = ref([
+ { username: 'SeedMaster', uploaded: '2.5 TB', downloaded: '850 GB', ratio: '3.02', seedTime: '15天' },
+ { username: 'MovieFan88', uploaded: '1.8 TB', downloaded: '1.2 TB', ratio: '1.50', seedTime: '8天' },
+ { username: 'CinemaLover', uploaded: '3.2 TB', downloaded: '900 GB', ratio: '3.56', seedTime: '22天' }
+ ])
+
+ const leechersList = ref([
+ { username: 'NewUser123', progress: 65, downloadSpeed: '15.2 MB/s', eta: '2小时15分' },
+ { username: 'MovieSeeker', progress: 23, downloadSpeed: '8.7 MB/s', eta: '8小时32分' },
+ { username: 'FilmCollector', progress: 89, downloadSpeed: '22.1 MB/s', eta: '45分钟' }
+ ])
+
+ const comments = ref([
+ {
+ id: 1,
+ username: 'MovieReviewer',
+ content: '画质非常棒!4K HDR效果惊艳,水下场景美不胜收。感谢分享!',
+ time: '2025-06-03T12:00:00',
+ likes: 15
+ },
+ {
+ id: 2,
+ username: 'CinemaExpert',
+ content: '音效也很棒,Dolby Atmos的环绕效果让人身临其境。推荐大家下载!',
+ time: '2025-06-03T11:30:00',
+ likes: 8
+ }
+ ])
+
+ onMounted(() => {
+ const torrentId = route.params.id
+ fetchTorrentDetail(torrentId)
+ })
+
+ const fetchTorrentDetail = async (id) => {
+ try {
+ // 模拟API调用
+ console.log('获取种子详情:', id)
+ // 这里应该调用真实的API
+ } catch (error) {
+ ElMessage.error('获取种子详情失败')
+ router.back()
+ }
+ }
+
+ const formatDateTime = (dateString) => {
+ const date = new Date(dateString)
+ return date.toLocaleString('zh-CN', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit'
+ })
+ }
+
+ const formatDescription = (description) => {
+ // 简单的HTML清理,实际项目中应该使用专门的库
+ return description.replace(/\n/g, '<br>')
+ }
+
+ const getCategoryType = (category) => {
+ const types = {
+ 'movie': 'primary',
+ 'tv': 'info',
+ 'music': 'success',
+ 'software': 'warning',
+ 'game': 'danger'
+ }
+ return types[category] || 'default'
+ }
+
+ const getCategoryName = (category) => {
+ const names = {
+ 'movie': '电影',
+ 'tv': '电视剧',
+ 'music': '音乐',
+ 'software': '软件',
+ 'game': '游戏'
+ }
+ return names[category] || category
+ }
+
+ const handleDownload = async () => {
+ downloading.value = true
+ try {
+ // 模拟下载准备过程
+ await new Promise(resolve => setTimeout(resolve, 1500))
+
+ // 实际项目中这里应该下载.torrent文件
+ const link = document.createElement('a')
+ link.href = '#' // 实际的种子文件下载链接
+ link.download = `${torrentInfo.value.title}.torrent`
+ link.click()
+
+ ElMessage.success('种子文件下载完成')
+ } catch (error) {
+ ElMessage.error('下载失败,请稍后重试')
+ } finally {
+ downloading.value = false
+ }
+ }
+
+ const handleFavorite = () => {
+ isFavorited.value = !isFavorited.value
+ ElMessage.success(isFavorited.value ? '已添加到收藏' : '已取消收藏')
+ }
+
+ const handleReport = async () => {
+ try {
+ await ElMessageBox.prompt('请说明举报原因', '举报内容', {
+ confirmButtonText: '提交举报',
+ cancelButtonText: '取消',
+ inputType: 'textarea',
+ inputPlaceholder: '请详细说明举报原因...'
+ })
+
+ ElMessage.success('举报已提交,我们会尽快处理')
+ } catch {
+ // 用户取消
+ }
+ }
+
+ const submitComment = async () => {
+ if (!newComment.value.trim()) {
+ ElMessage.warning('请输入评论内容')
+ return
+ }
+
+ submittingComment.value = true
+ try {
+ // 模拟提交评论
+ await new Promise(resolve => setTimeout(resolve, 1000))
+
+ const comment = {
+ id: Date.now(),
+ username: localStorage.getItem('username') || '用户',
+ content: newComment.value,
+ time: new Date().toISOString(),
+ likes: 0
+ }
+
+ comments.value.unshift(comment)
+ newComment.value = ''
+
+ ElMessage.success('评论发表成功')
+ } catch (error) {
+ ElMessage.error('发表评论失败')
+ } finally {
+ submittingComment.value = false
+ }
+ }
+
+ const likeComment = (commentId) => {
+ const comment = comments.value.find(c => c.id === commentId)
+ if (comment) {
+ comment.likes = (comment.likes || 0) + 1
+ ElMessage.success('点赞成功')
+ }
+ }
+
+ const replyComment = (commentId) => {
+ // 实现回复功能
+ ElMessage.info('回复功能开发中...')
+ }
+
+ return {
+ activeTab,
+ activityTab,
+ downloading,
+ isFavorited,
+ submittingComment,
+ newComment,
+ torrentInfo,
+ seedersList,
+ leechersList,
+ comments,
+ formatDateTime,
+ formatDescription,
+ getCategoryType,
+ getCategoryName,
+ handleDownload,
+ handleFavorite,
+ handleReport,
+ submitComment,
+ likeComment,
+ replyComment,
+ ArrowLeft,
+ Download,
+ Star,
+ Flag,
+ User,
+ Clock,
+ Document,
+ Files,
+ Picture,
+ Folder,
+ Like
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.torrent-detail-page {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 24px;
+ background: #f5f5f5;
+ min-height: 100vh;
+}
+
+.back-button {
+ margin-bottom: 16px;
+}
+
+.torrent-header {
+ background: #fff;
+ border-radius: 12px;
+ padding: 32px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .header-content {
+ display: flex;
+ gap: 32px;
+
+ .torrent-cover {
+ flex-shrink: 0;
+
+ .cover-image {
+ width: 200px;
+ height: 280px;
+ border-radius: 8px;
+ object-fit: cover;
+ }
+
+ .image-placeholder {
+ width: 200px;
+ height: 280px;
+ background: #f5f5f5;
+ border-radius: 8px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ color: #999;
+
+ span {
+ margin-top: 8px;
+ font-size: 14px;
+ }
+ }
+ }
+
+ .torrent-info {
+ flex: 1;
+
+ .category-tag {
+ margin-bottom: 16px;
+
+ .el-tag {
+ margin-right: 8px;
+ }
+ }
+
+ .torrent-title {
+ font-size: 28px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 16px 0;
+ line-height: 1.3;
+ }
+
+ .torrent-tags {
+ margin-bottom: 20px;
+
+ .el-tag {
+ margin: 0 8px 8px 0;
+ }
+ }
+
+ .torrent-meta {
+ margin-bottom: 20px;
+
+ .meta-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 8px;
+ color: #7f8c8d;
+ font-size: 14px;
+
+ .el-icon {
+ color: #909399;
+ }
+ }
+ }
+
+ .torrent-stats {
+ display: flex;
+ gap: 32px;
+ margin-bottom: 24px;
+
+ .stat-item {
+ text-align: center;
+
+ .stat-number {
+ display: block;
+ font-size: 24px;
+ font-weight: 600;
+ margin-bottom: 4px;
+
+ &.seeders { color: #67c23a; }
+ &.leechers { color: #f56c6c; }
+ &.downloads { color: #409eff; }
+ }
+
+ .stat-label {
+ font-size: 14px;
+ color: #909399;
+ }
+ }
+ }
+
+ .action-buttons {
+ display: flex;
+ gap: 12px;
+ flex-wrap: wrap;
+ }
+ }
+ }
+}
+
+.detail-tabs {
+ background: #fff;
+ border-radius: 12px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ :deep(.el-tabs__content) {
+ padding: 24px;
+ }
+
+ .description-content {
+ line-height: 1.6;
+
+ :deep(h3) {
+ color: #2c3e50;
+ font-size: 18px;
+ font-weight: 600;
+ margin: 24px 0 12px 0;
+
+ &:first-child {
+ margin-top: 0;
+ }
+ }
+
+ :deep(p) {
+ margin-bottom: 12px;
+ color: #5a6c7d;
+ }
+
+ :deep(ul) {
+ margin: 12px 0;
+ padding-left: 20px;
+
+ li {
+ margin-bottom: 8px;
+ color: #5a6c7d;
+ }
+ }
+
+ .no-description {
+ text-align: center;
+ color: #909399;
+ padding: 40px 0;
+ }
+ }
+
+ .files-list {
+ .file-name {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+
+ .el-icon {
+ color: #909399;
+ }
+ }
+ }
+
+ .activity-section {
+ .activity-stats {
+ margin-bottom: 24px;
+
+ .stats-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
+ gap: 16px;
+
+ .stat-card {
+ background: #f8f9fa;
+ padding: 20px;
+ border-radius: 8px;
+ text-align: center;
+
+ h3 {
+ font-size: 14px;
+ color: #909399;
+ margin: 0 0 8px 0;
+ }
+
+ .stat-number {
+ font-size: 24px;
+ font-weight: 600;
+ color: #2c3e50;
+ }
+ }
+ }
+ }
+ }
+
+ .comments-section {
+ .comment-form {
+ margin-bottom: 32px;
+
+ .comment-actions {
+ margin-top: 12px;
+ text-align: right;
+ }
+ }
+
+ .comments-list {
+ .comment-item {
+ display: flex;
+ gap: 16px;
+ margin-bottom: 24px;
+ padding-bottom: 24px;
+ border-bottom: 1px solid #f0f0f0;
+
+ &:last-child {
+ border-bottom: none;
+ margin-bottom: 0;
+ padding-bottom: 0;
+ }
+
+ .comment-content {
+ flex: 1;
+
+ .comment-header {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ margin-bottom: 8px;
+
+ .comment-username {
+ font-weight: 600;
+ color: #2c3e50;
+ }
+
+ .comment-time {
+ font-size: 12px;
+ color: #909399;
+ }
+ }
+
+ .comment-text {
+ color: #5a6c7d;
+ line-height: 1.5;
+ margin-bottom: 12px;
+ }
+
+ .comment-actions {
+ .el-button {
+ padding: 0;
+ margin-right: 16px;
+
+ .el-icon {
+ margin-right: 4px;
+ }
+ }
+ }
+ }
+ }
+
+ .no-comments {
+ text-align: center;
+ color: #909399;
+ padding: 40px 0;
+ }
+ }
+ }
+}
+
+// 响应式设计
+@media (max-width: 768px) {
+ .torrent-detail-page {
+ padding: 16px;
+ }
+
+ .torrent-header .header-content {
+ flex-direction: column;
+ text-align: center;
+
+ .torrent-cover {
+ align-self: center;
+ }
+
+ .torrent-stats {
+ justify-content: center;
+ }
+
+ .action-buttons {
+ justify-content: center;
+ }
+ }
+
+ .activity-section .stats-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .comment-item {
+ flex-direction: column;
+ gap: 12px;
+ }
+}
+</style>
\ No newline at end of file
diff --git a/src/views/torrent/TorrentsView.vue b/src/views/torrent/TorrentsView.vue
new file mode 100644
index 0000000..f3231da
--- /dev/null
+++ b/src/views/torrent/TorrentsView.vue
@@ -0,0 +1,479 @@
+<template>
+ <div class="torrents-page">
+ <div class="page-header">
+ <h1>种子资源</h1>
+ <div class="header-actions">
+ <el-button type="primary" :icon="Upload" @click="$router.push('/upload')">
+ 上传种子
+ </el-button>
+ </div>
+ </div>
+
+ <!-- 搜索和筛选 -->
+ <div class="search-section">
+ <div class="search-bar">
+ <el-input
+ v-model="searchQuery"
+ placeholder="搜索种子..."
+ :prefix-icon="Search"
+ size="large"
+ @keyup.enter="handleSearch"
+ clearable
+ />
+ <el-button type="primary" size="large" @click="handleSearch">
+ 搜索
+ </el-button>
+ </div>
+
+ <div class="filters">
+ <el-select v-model="selectedCategory" placeholder="分类" @change="handleFilter">
+ <el-option label="全部" value="" />
+ <el-option label="电影" value="movie" />
+ <el-option label="电视剧" value="tv" />
+ <el-option label="音乐" value="music" />
+ <el-option label="软件" value="software" />
+ <el-option label="游戏" value="game" />
+ </el-select>
+
+ <el-select v-model="sortBy" placeholder="排序方式" @change="handleFilter">
+ <el-option label="上传时间" value="upload_time" />
+ <el-option label="文件大小" value="size" />
+ <el-option label="做种数" value="seeders" />
+ <el-option label="下载数" value="leechers" />
+ <el-option label="完成数" value="downloads" />
+ </el-select>
+
+ <el-radio-group v-model="sortOrder" @change="handleFilter">
+ <el-radio-button label="desc">降序</el-radio-button>
+ <el-radio-button label="asc">升序</el-radio-button>
+ </el-radio-group>
+ </div>
+ </div>
+
+ <!-- 种子列表 -->
+ <div class="torrents-list">
+ <div class="list-header">
+ <span class="results-count">共找到 {{ totalCount }} 个种子</span>
+ </div>
+
+ <el-table
+ :data="torrents"
+ v-loading="loading"
+ @row-click="handleRowClick"
+ stripe
+ class="torrents-table"
+ >
+ <el-table-column label="分类" width="80">
+ <template #default="{ row }">
+ <el-tag :type="getCategoryType(row.category)" size="small">
+ {{ getCategoryName(row.category) }}
+ </el-tag>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="种子信息" min-width="400">
+ <template #default="{ row }">
+ <div class="torrent-info">
+ <h4 class="torrent-title">{{ row.title }}</h4>
+ <div class="torrent-meta">
+ <span class="uploader">
+ <el-icon><User /></el-icon>
+ {{ row.uploader }}
+ </span>
+ <span class="upload-time">
+ <el-icon><Clock /></el-icon>
+ {{ formatTime(row.uploadTime) }}
+ </span>
+ <span class="file-size">
+ <el-icon><Document /></el-icon>
+ {{ row.size }}
+ </span>
+ </div>
+ </div>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="做种" width="80" align="center">
+ <template #default="{ row }">
+ <span class="seeders">{{ row.seeders }}</span>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="下载" width="80" align="center">
+ <template #default="{ row }">
+ <span class="leechers">{{ row.leechers }}</span>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="完成" width="80" align="center">
+ <template #default="{ row }">
+ <span>{{ row.downloads }}</span>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="操作" width="120" align="center">
+ <template #default="{ row }">
+ <el-button
+ type="primary"
+ size="small"
+ :icon="Download"
+ @click.stop="handleDownload(row)"
+ >
+ 下载
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <!-- 分页 -->
+ <div class="pagination-wrapper">
+ <el-pagination
+ v-model:current-page="currentPage"
+ v-model:page-size="pageSize"
+ :page-sizes="[20, 50, 100]"
+ :total="totalCount"
+ layout="total, sizes, prev, pager, next, jumper"
+ @size-change="handleSizeChange"
+ @current-change="handleCurrentChange"
+ />
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import { ref, onMounted, watch } from 'vue'
+import { useRouter, useRoute } from 'vue-router'
+import { ElMessage } from 'element-plus'
+import {
+ Search,
+ Upload,
+ Download,
+ User,
+ Clock,
+ Document
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'TorrentsView',
+ setup() {
+ const router = useRouter()
+ const route = useRoute()
+
+ const loading = ref(false)
+ const searchQuery = ref('')
+ const selectedCategory = ref('')
+ const sortBy = ref('upload_time')
+ const sortOrder = ref('desc')
+ const currentPage = ref(1)
+ const pageSize = ref(20)
+ const totalCount = ref(0)
+
+ const torrents = ref([
+ {
+ id: 1,
+ title: '[4K蓝光原盘] 阿凡达:水之道 Avatar: The Way of Water (2022)',
+ category: 'movie',
+ uploader: 'MovieMaster',
+ uploadTime: '2025-06-03T10:30:00',
+ size: '85.6 GB',
+ seeders: 128,
+ leechers: 45,
+ downloads: 892
+ },
+ {
+ id: 2,
+ title: '[FLAC] Taylor Swift - Midnights (Deluxe Edition) [2022]',
+ category: 'music',
+ uploader: 'MusicLover',
+ uploadTime: '2025-06-03T09:15:00',
+ size: '1.2 GB',
+ seeders: 67,
+ leechers: 12,
+ downloads: 456
+ },
+ {
+ id: 3,
+ title: '[合集] Adobe Creative Suite 2025 完整版',
+ category: 'software',
+ uploader: 'TechGuru',
+ uploadTime: '2025-06-03T08:45:00',
+ size: '12.8 GB',
+ seeders: 234,
+ leechers: 89,
+ downloads: 1205
+ }
+ ])
+
+ onMounted(() => {
+ // 从URL参数初始化搜索条件
+ if (route.query.q) {
+ searchQuery.value = route.query.q
+ }
+ if (route.query.category) {
+ selectedCategory.value = route.query.category
+ }
+
+ fetchTorrents()
+ })
+
+ const fetchTorrents = async () => {
+ loading.value = true
+ try {
+ // 模拟API调用
+ await new Promise(resolve => setTimeout(resolve, 1000))
+ totalCount.value = 156
+ } catch (error) {
+ ElMessage.error('获取种子列表失败')
+ } finally {
+ loading.value = false
+ }
+ }
+
+ const handleSearch = () => {
+ currentPage.value = 1
+ updateURL()
+ fetchTorrents()
+ }
+
+ const handleFilter = () => {
+ currentPage.value = 1
+ updateURL()
+ fetchTorrents()
+ }
+
+ const updateURL = () => {
+ const query = {}
+ if (searchQuery.value) query.q = searchQuery.value
+ if (selectedCategory.value) query.category = selectedCategory.value
+ if (sortBy.value !== 'upload_time') query.sort = sortBy.value
+ if (sortOrder.value !== 'desc') query.order = sortOrder.value
+ if (currentPage.value > 1) query.page = currentPage.value
+
+ router.replace({ query })
+ }
+
+ const handleRowClick = (row) => {
+ router.push(`/torrent/${row.id}`)
+ }
+
+ const handleDownload = (row) => {
+ ElMessage.success(`开始下载: ${row.title}`)
+ // 这里实现下载逻辑
+ }
+
+ const handleSizeChange = (size) => {
+ pageSize.value = size
+ currentPage.value = 1
+ fetchTorrents()
+ }
+
+ const handleCurrentChange = (page) => {
+ currentPage.value = page
+ updateURL()
+ fetchTorrents()
+ }
+
+ const formatTime = (timeString) => {
+ const date = new Date(timeString)
+ const now = new Date()
+ const diff = now - date
+ const hours = Math.floor(diff / (1000 * 60 * 60))
+
+ if (hours < 1) return '刚刚'
+ if (hours < 24) return `${hours}小时前`
+ const days = Math.floor(hours / 24)
+ return `${days}天前`
+ }
+
+ const getCategoryType = (category) => {
+ const types = {
+ 'movie': 'primary',
+ 'tv': 'info',
+ 'music': 'success',
+ 'software': 'warning',
+ 'game': 'danger'
+ }
+ return types[category] || 'default'
+ }
+
+ const getCategoryName = (category) => {
+ const names = {
+ 'movie': '电影',
+ 'tv': '电视剧',
+ 'music': '音乐',
+ 'software': '软件',
+ 'game': '游戏'
+ }
+ return names[category] || category
+ }
+
+ return {
+ loading,
+ searchQuery,
+ selectedCategory,
+ sortBy,
+ sortOrder,
+ currentPage,
+ pageSize,
+ totalCount,
+ torrents,
+ handleSearch,
+ handleFilter,
+ handleRowClick,
+ handleDownload,
+ handleSizeChange,
+ handleCurrentChange,
+ formatTime,
+ getCategoryType,
+ getCategoryName,
+ Search,
+ Upload,
+ Download,
+ User,
+ Clock,
+ Document
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.torrents-page {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 24px;
+}
+
+.page-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 24px;
+
+ h1 {
+ font-size: 28px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0;
+ }
+}
+
+.search-section {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ margin-bottom: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .search-bar {
+ display: flex;
+ gap: 12px;
+ margin-bottom: 16px;
+
+ .el-input {
+ flex: 1;
+ }
+ }
+
+ .filters {
+ display: flex;
+ gap: 16px;
+ flex-wrap: wrap;
+ align-items: center;
+
+ .el-select {
+ width: 120px;
+ }
+ }
+}
+
+.torrents-list {
+ background: #fff;
+ border-radius: 12px;
+ padding: 24px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .list-header {
+ margin-bottom: 16px;
+
+ .results-count {
+ font-size: 14px;
+ color: #909399;
+ }
+ }
+
+ .torrents-table {
+ .torrent-info {
+ .torrent-title {
+ font-size: 16px;
+ font-weight: 500;
+ color: #2c3e50;
+ margin: 0 0 8px 0;
+ line-height: 1.4;
+ cursor: pointer;
+
+ &:hover {
+ color: #409eff;
+ }
+ }
+
+ .torrent-meta {
+ display: flex;
+ gap: 16px;
+ font-size: 12px;
+ color: #909399;
+
+ span {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ }
+ }
+ }
+
+ .seeders {
+ color: #67c23a;
+ font-weight: 600;
+ }
+
+ .leechers {
+ color: #f56c6c;
+ font-weight: 600;
+ }
+ }
+
+ .pagination-wrapper {
+ margin-top: 24px;
+ text-align: center;
+ }
+}
+
+@media (max-width: 768px) {
+ .torrents-page {
+ padding: 16px;
+ }
+
+ .page-header {
+ flex-direction: column;
+ gap: 16px;
+ align-items: flex-start;
+ }
+
+ .filters {
+ flex-direction: column;
+ align-items: flex-start;
+
+ .el-select {
+ width: 100%;
+ }
+ }
+
+ .torrents-table {
+ :deep(.el-table__header),
+ :deep(.el-table__body) {
+ font-size: 12px;
+ }
+ }
+}
+</style>
\ No newline at end of file
diff --git a/src/views/torrent/UploadView.vue b/src/views/torrent/UploadView.vue
new file mode 100644
index 0000000..d99b446
--- /dev/null
+++ b/src/views/torrent/UploadView.vue
@@ -0,0 +1,506 @@
+<template>
+ <div class="upload-page">
+ <div class="page-header">
+ <h1>上传种子</h1>
+ <p class="page-description">分享你的资源,为社区做贡献</p>
+ </div>
+
+ <div class="upload-form">
+ <el-form
+ ref="uploadFormRef"
+ :model="uploadForm"
+ :rules="formRules"
+ label-width="120px"
+ size="large"
+ >
+ <!-- 种子文件上传 -->
+ <el-form-item label="种子文件" prop="torrentFile" required>
+ <el-upload
+ ref="torrentUploadRef"
+ :auto-upload="false"
+ :limit="1"
+ accept=".torrent"
+ :on-change="handleTorrentChange"
+ :on-remove="handleTorrentRemove"
+ :before-upload="beforeTorrentUpload"
+ drag
+ class="torrent-upload"
+ >
+ <el-icon class="el-icon--upload"><UploadFilled /></el-icon>
+ <div class="el-upload__text">
+ 将 .torrent 文件拖到此处,或<em>点击上传</em>
+ </div>
+ <template #tip>
+ <div class="el-upload__tip">
+ 只能上传 .torrent 文件,且不超过 10MB
+ </div>
+ </template>
+ </el-upload>
+ </el-form-item>
+
+ <!-- 基本信息 -->
+ <el-form-item label="资源标题" prop="title" required>
+ <el-input
+ v-model="uploadForm.title"
+ placeholder="请输入资源标题"
+ maxlength="200"
+ show-word-limit
+ />
+ </el-form-item>
+
+ <el-form-item label="资源分类" prop="category" required>
+ <el-select v-model="uploadForm.category" placeholder="请选择分类">
+ <el-option label="电影" value="movie" />
+ <el-option label="电视剧" value="tv" />
+ <el-option label="音乐" value="music" />
+ <el-option label="软件" value="software" />
+ <el-option label="游戏" value="game" />
+ <el-option label="电子书" value="ebook" />
+ <el-option label="其他" value="other" />
+ </el-select>
+ </el-form-item>
+
+ <el-form-item label="子分类" prop="subcategory">
+ <el-select v-model="uploadForm.subcategory" placeholder="请选择子分类">
+ <el-option
+ v-for="sub in getSubcategories(uploadForm.category)"
+ :key="sub.value"
+ :label="sub.label"
+ :value="sub.value"
+ />
+ </el-select>
+ </el-form-item>
+
+ <!-- 详细描述 -->
+ <el-form-item label="资源描述" prop="description">
+ <el-input
+ v-model="uploadForm.description"
+ type="textarea"
+ :rows="6"
+ placeholder="请详细描述资源内容,包括格式、质量、语言等信息"
+ maxlength="2000"
+ show-word-limit
+ />
+ </el-form-item>
+
+ <!-- 标签 -->
+ <el-form-item label="标签">
+ <div class="tags-input">
+ <el-tag
+ v-for="tag in uploadForm.tags"
+ :key="tag"
+ closable
+ @close="removeTag(tag)"
+ class="tag-item"
+ >
+ {{ tag }}
+ </el-tag>
+ <el-input
+ v-if="tagInputVisible"
+ ref="tagInputRef"
+ v-model="tagInputValue"
+ size="small"
+ @keyup.enter="addTag"
+ @blur="addTag"
+ class="tag-input"
+ />
+ <el-button
+ v-else
+ size="small"
+ @click="showTagInput"
+ class="add-tag-btn"
+ >
+ + 添加标签
+ </el-button>
+ </div>
+ </el-form-item>
+
+ <!-- 封面图片 -->
+ <el-form-item label="封面图片">
+ <el-upload
+ ref="imageUploadRef"
+ :auto-upload="false"
+ :limit="1"
+ accept="image/*"
+ :on-change="handleImageChange"
+ :on-remove="handleImageRemove"
+ list-type="picture-card"
+ class="image-upload"
+ >
+ <el-icon><Plus /></el-icon>
+ <template #tip>
+ <div class="el-upload__tip">
+ 支持 JPG、PNG 格式,建议尺寸 300x400,不超过 5MB
+ </div>
+ </template>
+ </el-upload>
+ </el-form-item>
+
+ <!-- 高级选项 -->
+ <el-form-item>
+ <el-collapse>
+ <el-collapse-item title="高级选项" name="advanced">
+ <el-form-item label="免费时间">
+ <el-select v-model="uploadForm.freeTime" placeholder="选择免费时间">
+ <el-option label="永久免费" value="forever" />
+ <el-option label="24小时" value="24h" />
+ <el-option label="48小时" value="48h" />
+ <el-option label="7天" value="7d" />
+ <el-option label="30天" value="30d" />
+ </el-select>
+ </el-form-item>
+
+ <el-form-item label="匿名上传">
+ <el-switch v-model="uploadForm.anonymous" />
+ <span class="form-tip">开启后将不显示上传者信息</span>
+ </el-form-item>
+
+ <el-form-item label="允许HR">
+ <el-switch v-model="uploadForm.allowHR" />
+ <span class="form-tip">允许此种子参与HR考核</span>
+ </el-form-item>
+ </el-collapse-item>
+ </el-collapse>
+ </el-form-item>
+
+ <!-- 提交按钮 -->
+ <el-form-item>
+ <div class="submit-buttons">
+ <el-button @click="resetForm">重置</el-button>
+ <el-button type="primary" @click="submitForm" :loading="uploading">
+ {{ uploading ? '上传中...' : '提交种子' }}
+ </el-button>
+ </div>
+ </el-form-item>
+ </el-form>
+ </div>
+ </div>
+</template>
+
+<script>
+import { ref, reactive, nextTick } from 'vue'
+import { useRouter } from 'vue-router'
+import { ElMessage } from 'element-plus'
+import {
+ UploadFilled,
+ Plus
+} from '@element-plus/icons-vue'
+
+export default {
+ name: 'UploadView',
+ setup() {
+ const router = useRouter()
+ const uploadFormRef = ref(null)
+ const torrentUploadRef = ref(null)
+ const imageUploadRef = ref(null)
+ const tagInputRef = ref(null)
+
+ const uploading = ref(false)
+ const tagInputVisible = ref(false)
+ const tagInputValue = ref('')
+
+ const uploadForm = reactive({
+ torrentFile: null,
+ title: '',
+ category: '',
+ subcategory: '',
+ description: '',
+ tags: [],
+ coverImage: null,
+ freeTime: '',
+ anonymous: false,
+ allowHR: true
+ })
+
+ const formRules = {
+ title: [
+ { required: true, message: '请输入资源标题', trigger: 'blur' },
+ { min: 5, max: 200, message: '标题长度在 5 到 200 个字符', trigger: 'blur' }
+ ],
+ category: [
+ { required: true, message: '请选择资源分类', trigger: 'change' }
+ ],
+ description: [
+ { min: 10, max: 2000, message: '描述长度在 10 到 2000 个字符', trigger: 'blur' }
+ ]
+ }
+
+ const subcategories = {
+ movie: [
+ { label: '动作片', value: 'action' },
+ { label: '喜剧片', value: 'comedy' },
+ { label: '科幻片', value: 'scifi' },
+ { label: '恐怖片', value: 'horror' },
+ { label: '剧情片', value: 'drama' }
+ ],
+ tv: [
+ { label: '美剧', value: 'us' },
+ { label: '国产剧', value: 'cn' },
+ { label: '日韩剧', value: 'asia' },
+ { label: '英剧', value: 'uk' },
+ { label: '纪录片', value: 'documentary' }
+ ],
+ music: [
+ { label: '流行音乐', value: 'pop' },
+ { label: '古典音乐', value: 'classical' },
+ { label: '摇滚音乐', value: 'rock' },
+ { label: '电子音乐', value: 'electronic' },
+ { label: '其他', value: 'other' }
+ ],
+ software: [
+ { label: '操作系统', value: 'os' },
+ { label: '办公软件', value: 'office' },
+ { label: '开发工具', value: 'dev' },
+ { label: '设计软件', value: 'design' },
+ { label: '其他', value: 'other' }
+ ],
+ game: [
+ { label: 'PC游戏', value: 'pc' },
+ { label: '主机游戏', value: 'console' },
+ { label: '手机游戏', value: 'mobile' },
+ { label: '其他', value: 'other' }
+ ]
+ }
+
+ const getSubcategories = (category) => {
+ return subcategories[category] || []
+ }
+
+ const handleTorrentChange = (file) => {
+ uploadForm.torrentFile = file.raw
+ // 这里可以解析torrent文件获取基本信息
+ parseTorrentFile(file.raw)
+ }
+
+ const handleTorrentRemove = () => {
+ uploadForm.torrentFile = null
+ }
+
+ const beforeTorrentUpload = (file) => {
+ const isTorrent = file.type === 'application/x-bittorrent' || file.name.endsWith('.torrent')
+ const isLt10M = file.size / 1024 / 1024 < 10
+
+ if (!isTorrent) {
+ ElMessage.error('只能上传 .torrent 文件!')
+ return false
+ }
+ if (!isLt10M) {
+ ElMessage.error('种子文件大小不能超过 10MB!')
+ return false
+ }
+ return true
+ }
+
+ const parseTorrentFile = (file) => {
+ // 这里应该实现torrent文件解析
+ // 可以使用 parse-torrent 库
+ console.log('解析种子文件:', file.name)
+
+ // 模拟解析结果自动填入表单
+ if (!uploadForm.title) {
+ uploadForm.title = file.name.replace('.torrent', '')
+ }
+ }
+
+ const handleImageChange = (file) => {
+ uploadForm.coverImage = file.raw
+ }
+
+ const handleImageRemove = () => {
+ uploadForm.coverImage = null
+ }
+
+ const showTagInput = () => {
+ tagInputVisible.value = true
+ nextTick(() => {
+ tagInputRef.value?.focus()
+ })
+ }
+
+ const addTag = () => {
+ const tag = tagInputValue.value.trim()
+ if (tag && !uploadForm.tags.includes(tag)) {
+ uploadForm.tags.push(tag)
+ }
+ tagInputVisible.value = false
+ tagInputValue.value = ''
+ }
+
+ const removeTag = (tag) => {
+ const index = uploadForm.tags.indexOf(tag)
+ if (index > -1) {
+ uploadForm.tags.splice(index, 1)
+ }
+ }
+
+ const submitForm = async () => {
+ if (!uploadForm.torrentFile) {
+ ElMessage.error('请上传种子文件')
+ return
+ }
+
+ try {
+ await uploadFormRef.value?.validate()
+
+ uploading.value = true
+
+ // 模拟上传过程
+ await new Promise(resolve => setTimeout(resolve, 2000))
+
+ ElMessage.success('种子上传成功!')
+ router.push('/torrents')
+
+ } catch (error) {
+ console.error('表单验证失败:', error)
+ } finally {
+ uploading.value = false
+ }
+ }
+
+ const resetForm = () => {
+ uploadFormRef.value?.resetFields()
+ uploadForm.torrentFile = null
+ uploadForm.coverImage = null
+ uploadForm.tags = []
+ torrentUploadRef.value?.clearFiles()
+ imageUploadRef.value?.clearFiles()
+ }
+
+ return {
+ uploadFormRef,
+ torrentUploadRef,
+ imageUploadRef,
+ tagInputRef,
+ uploading,
+ tagInputVisible,
+ tagInputValue,
+ uploadForm,
+ formRules,
+ getSubcategories,
+ handleTorrentChange,
+ handleTorrentRemove,
+ beforeTorrentUpload,
+ handleImageChange,
+ handleImageRemove,
+ showTagInput,
+ addTag,
+ removeTag,
+ submitForm,
+ resetForm,
+ UploadFilled,
+ Plus
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+.upload-page {
+ max-width: 800px;
+ margin: 0 auto;
+ padding: 24px;
+}
+
+.page-header {
+ text-align: center;
+ margin-bottom: 32px;
+
+ h1 {
+ font-size: 28px;
+ font-weight: 600;
+ color: #2c3e50;
+ margin: 0 0 8px 0;
+ }
+
+ .page-description {
+ font-size: 16px;
+ color: #7f8c8d;
+ margin: 0;
+ }
+}
+
+.upload-form {
+ background: #fff;
+ border-radius: 12px;
+ padding: 32px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
+
+ .torrent-upload {
+ width: 100%;
+
+ :deep(.el-upload-dragger) {
+ width: 100%;
+ height: 180px;
+ border: 2px dashed #d9d9d9;
+ border-radius: 8px;
+
+ &:hover {
+ border-color: #409eff;
+ }
+ }
+ }
+
+ .tags-input {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ align-items: center;
+
+ .tag-item {
+ margin: 0;
+ }
+
+ .tag-input {
+ width: 100px;
+ }
+
+ .add-tag-btn {
+ border: 1px dashed #d9d9d9;
+ color: #999;
+
+ &:hover {
+ border-color: #409eff;
+ color: #409eff;
+ }
+ }
+ }
+
+ .image-upload {
+ :deep(.el-upload--picture-card) {
+ width: 148px;
+ height: 148px;
+ }
+ }
+
+ .form-tip {
+ margin-left: 8px;
+ font-size: 12px;
+ color: #909399;
+ }
+
+ .submit-buttons {
+ display: flex;
+ gap: 16px;
+ justify-content: center;
+ margin-top: 24px;
+ }
+}
+
+@media (max-width: 768px) {
+ .upload-page {
+ padding: 16px;
+ }
+
+ .upload-form {
+ padding: 24px 16px;
+ }
+
+ .submit-buttons {
+ flex-direction: column;
+
+ .el-button {
+ width: 100%;
+ }
+ }
+}
+</style>
\ No newline at end of file