fix(push): load full server list for accurate category selection

Push page previously fetched only 200 servers by ID order, so large categories
like 机器人 showed a handful of machines. Also decouple unset-path panel from
the main category chip filter and align category labels with the servers page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nexus Agent
2026-06-09 08:12:50 +08:00
parent 664efb9ed5
commit c366ed5adc
64 changed files with 1093 additions and 17 deletions
@@ -1,5 +1,6 @@
import { ref, computed, type Ref } from 'vue'
import { http } from '@/api'
import { categoryDisplayLabel } from '@/composables/useServerCategories'
import { fetchPagePerPage } from '@/utils/paginatedFetch'
import type { PushServerItem } from './types'
export function usePushServers(pushStatus: Ref<Record<number, string>>) {
@@ -13,8 +14,8 @@ export function usePushServers(pushStatus: Ref<Record<number, string>>) {
async function loadServers(silent = false) {
if (!silent) serversLoading.value = true
try {
const res = await http.get<{ items: PushServerItem[] }>('/servers/', { per_page: 200 })
servers.value = res.items || []
const res = await fetchPagePerPage<PushServerItem>('/servers/', {}, 1, -1)
servers.value = res.items
} catch {
servers.value = []
} finally {
@@ -55,11 +56,21 @@ export function usePushServers(pushStatus: Ref<Record<number, string>>) {
const serversByCategory = computed(() => {
const groups: Record<string, PushServerItem[]> = {}
for (const s of filteredServers.value) {
const cat = s.category || '未分类'
if (!groups[cat]) groups[cat] = []
groups[cat].push(s)
const key = s.category?.trim() || 'uncategorized'
if (!groups[key]) groups[key] = []
groups[key].push(s)
}
return Object.entries(groups).map(([category, list]) => ({ category, servers: list }))
return Object.entries(groups)
.map(([category, list]) => ({
category,
label: categoryDisplayLabel(category),
servers: list,
}))
.sort((a, b) => {
if (a.category === 'uncategorized') return 1
if (b.category === 'uncategorized') return -1
return a.label.localeCompare(b.label, 'zh')
})
})
function isCategoryAllSelected(category: string): boolean {