feat:移除了弹窗,服务器添加sls

This commit is contained in:
2026-09-08 22:39:45 +08:00
commit 6a295f9a7a
4082 changed files with 1322534 additions and 0 deletions

View File

@ -0,0 +1,49 @@
import type { Ref } from 'vue'
import { computed, ref, watch } from 'vue'
import type { ContentItem } from '../types'
export function useContentSelection(
items: Ref<ContentItem[]>,
getItemId: (item: ContentItem) => string,
) {
const selectedIds = ref<string[]>([])
const selectedItems = computed(() => {
const selectedIdSet = new Set(selectedIds.value)
const seenIds = new Set<string>()
const result: ContentItem[] = []
for (const item of items.value) {
const id = getItemId(item)
if (selectedIdSet.has(id) && !seenIds.has(id)) {
seenIds.add(id)
result.push(item)
}
}
return result
})
watch(
() => items.value.map(getItemId),
(newIds) => {
if (selectedIds.value.length === 0) return
const validIds = new Set(newIds)
const pruned = selectedIds.value.filter((id) => validIds.has(id))
if (pruned.length !== selectedIds.value.length) {
selectedIds.value = pruned
}
},
)
function clearSelection() {
selectedIds.value = []
}
function removeFromSelection(id: string) {
selectedIds.value = selectedIds.value.filter((i) => i !== id)
}
return { selectedIds, selectedItems, clearSelection, removeFromSelection }
}