feat(push,terminal): 推送搜索历史5条与终端中间搜索
推送页独立 combobox 历史(MySQL push_search,上限5);终端空态搜索回中间卡片,右侧栏仅列表。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,14 +1,45 @@
|
||||
import { ref, computed, type Ref } from 'vue'
|
||||
import { categoryDisplayLabel } from '@/composables/useServerCategories'
|
||||
import { useServerSearchHistory } from '@/composables/useServerSearchHistory'
|
||||
import { fetchPagePerPage } from '@/utils/paginatedFetch'
|
||||
import type { PushServerItem } from './types'
|
||||
|
||||
const PUSH_SEARCH_HISTORY = 5
|
||||
|
||||
export function usePushServers(pushStatus: Ref<Record<number, string>>) {
|
||||
const servers = ref<PushServerItem[]>([])
|
||||
const serversLoading = ref(false)
|
||||
const serverSearch = ref('')
|
||||
const selectedIds = ref<Set<number>>(new Set())
|
||||
|
||||
const { items: pushSearchHistory, loadHistoryOnly, record: recordPushSearch } =
|
||||
useServerSearchHistory('push')
|
||||
|
||||
const serverSearchHistory = computed(() =>
|
||||
pushSearchHistory.value.slice(0, PUSH_SEARCH_HISTORY),
|
||||
)
|
||||
|
||||
function commitServerSearch() {
|
||||
void recordPushSearch(serverSearch.value)
|
||||
}
|
||||
|
||||
function onServerSearchUpdate(val: string | null) {
|
||||
serverSearch.value = val ?? ''
|
||||
if (val == null || val === '') {
|
||||
void recordPushSearch('')
|
||||
return
|
||||
}
|
||||
const picked = String(val).trim()
|
||||
if (pushSearchHistory.value.includes(picked)) {
|
||||
serverSearch.value = picked
|
||||
void recordPushSearch(picked)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSearchHistory() {
|
||||
await loadHistoryOnly()
|
||||
}
|
||||
|
||||
let refreshTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
async function loadServers(silent = false) {
|
||||
@@ -113,12 +144,16 @@ export function usePushServers(pushStatus: Ref<Record<number, string>>) {
|
||||
servers,
|
||||
serversLoading,
|
||||
serverSearch,
|
||||
serverSearchHistory,
|
||||
selectedIds,
|
||||
pushStatus,
|
||||
filteredServers,
|
||||
selectAll,
|
||||
serversByCategory,
|
||||
loadServers,
|
||||
loadSearchHistory,
|
||||
commitServerSearch,
|
||||
onServerSearchUpdate,
|
||||
startAutoRefresh,
|
||||
stopAutoRefresh,
|
||||
isCategoryAllSelected,
|
||||
|
||||
Reference in New Issue
Block a user