优化 MediaCard 和 SearchSiteDialog 组件,移除全选功能并调整已选择站点的逻辑

This commit is contained in:
jxxghp
2025-04-04 09:39:04 +08:00
parent c5e62cc8e4
commit 7ae3e402cf
2 changed files with 7 additions and 11 deletions

View File

@@ -88,15 +88,6 @@ const searchMenuShow = ref(false)
// 选择站点对话框
const chooseSiteDialog = ref(false)
// 全选/全不选
function checkAllSitesorNot() {
if (selectedSites.value.length === allSites.value.length) {
selectedSites.value = []
} else {
selectedSites.value = allSites.value.map(item => item.id)
}
}
// 查询所有站点
async function querySites() {
try {
@@ -113,7 +104,6 @@ async function querySites() {
async function querySelectedSites() {
try {
const result: { [key: string]: any } = await api.get('system/setting/IndexerSites')
selectedSites.value = result.data?.value ?? []
} catch (error) {
console.log(error)

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { Site, Plugin, Subscribe } from '@/api/types'
import { PropType } from 'vue'
import { popScopeId, PropType } from 'vue'
const props = defineProps({
sites: {
@@ -23,6 +23,12 @@ const siteFilter = ref('')
// 已选择站点
const selectedSites = ref<any[]>(props.selected || [])
watchEffect(() => {
if (!selectedSites.value && props.selected){
selectedSites.value = props.selected
}
})
// 全选/全不选按钮文字
const checkAllText = computed(() => {
return selectedSites.value.length < props.sites?.length ? '选择全部' : '取消全选'