前后端登录注册连接成功
Change-Id: Ib5f9282fe7217b3363e542ce5c4e1c0d32619dcb
diff --git a/src/views/torrent/TorrentDetailView.vue b/src/views/torrent/TorrentDetailView.vue
index 941ebd1..c8ee498 100644
--- a/src/views/torrent/TorrentDetailView.vue
+++ b/src/views/torrent/TorrentDetailView.vue
@@ -1,862 +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;
- }
-}
+<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
index f3231da..1ae9f4b 100644
--- a/src/views/torrent/TorrentsView.vue
+++ b/src/views/torrent/TorrentsView.vue
@@ -1,479 +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;
- }
- }
-}
+<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
index d99b446..80c3660 100644
--- a/src/views/torrent/UploadView.vue
+++ b/src/views/torrent/UploadView.vue
@@ -1,506 +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%;
- }
- }
-}
+<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