种子浏览加分类接口

Change-Id: I91f625061a3ad6f73a203fc63d59d25f9daf7854
diff --git a/src/views/torrent/TorrentsView.vue b/src/views/torrent/TorrentsView.vue
index e02971e..28b73f1 100644
--- a/src/views/torrent/TorrentsView.vue
+++ b/src/views/torrent/TorrentsView.vue
@@ -28,14 +28,13 @@
       <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-option
+            v-for="category in categories"
+            :key="category.id"
+            :label="category.name"
+            :value="category.slug"
+          />
         </el-select>
-        
-        
       </div>
     </div>
 
@@ -167,7 +166,7 @@
   Clock,
   Document
 } from '@element-plus/icons-vue'
-import { searchTorrents } from '@/api/torrent'
+import { searchTorrents, getCategories } from '@/api/torrent'
 
 export default {
   name: 'TorrentsView',
@@ -186,6 +185,7 @@
     const totalPages = ref(0)
     
     const torrents = ref([])
+    const categories = ref([])
     
     onMounted(() => {
       // 从URL参数初始化搜索条件
@@ -199,6 +199,7 @@
         currentPage.value = parseInt(route.query.page)
       }
       
+      fetchCategories()
       fetchTorrents()
     })
     
@@ -207,6 +208,7 @@
       try {
         const searchParams = {
           keyword: searchQuery.value || '', // 搜索关键词
+          //category: selectedCategory.value || '',
           page: currentPage.value - 1,      // 后端页码从0开始
           entriesPerPage: pageSize.value    // 每页显示数量
         }
@@ -244,6 +246,20 @@
       }
     }
     
+    const fetchCategories = async () => {
+      try {
+        const response = await getCategories()
+        if (response && Array.isArray(response)) {
+          categories.value = response
+        } else {
+          console.error('获取分类列表失败: 响应格式错误', response)
+        }
+      } catch (error) {
+        console.error('获取分类列表失败:', error)
+        ElMessage.error('获取分类列表失败')
+      }
+    }
+    
     const handleSearch = () => {
       currentPage.value = 1
       updateURL()
@@ -318,15 +334,15 @@
     }
     
     const getCategoryType = (category) => {
-      if (!category) return 'default'
+      if (!category) return ''
       const types = {
         'os': 'primary',
         'movie': 'success',
-        'tv': 'info',
+        'db': 'info',
         'music': 'warning',
         'software': 'danger'
       }
-      return types[category.slug] || 'default'
+      return types[category.slug] || ''
     }
     
     return {
@@ -339,6 +355,7 @@
       pageSize,
       totalCount,
       torrents,
+      categories,
       handleSearch,
       handleFilter,
       handleRowClick,