2.4.7 优化过滤 新增重置任务

This commit is contained in:
2026-04-01 13:27:27 +08:00
parent 466a853905
commit b2f9dbf2a2
11 changed files with 160 additions and 60 deletions

View File

@@ -68,7 +68,7 @@
<!-- 下拉菜单 -->
<div v-if="showLevelDropdown"
class="absolute top-full left-4 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-50 p-3 w-72">
<div class="text-xs text-gray-500 mb-2">选择接收的主播等级不选则接收全部</div>
<div class="text-xs text-gray-500 mb-2">选择接收的主播等级选则过滤掉</div>
<div class="space-y-2 max-h-60 overflow-auto">
<div v-for="parent in LEVEL_OPTIONS" :key="parent.value"
class="border border-gray-100 rounded p-2">
@@ -93,10 +93,16 @@
</div>
</div>
<div class="mt-2 pt-2 border-t border-gray-100 flex justify-between">
<button @click="updateLevelFilter(new Set())"
class="text-xs text-gray-500 hover:text-gray-700">
清空选择
</button>
<div class="flex gap-2">
<button @click="selectAllLevels()"
class="text-xs text-gray-500 hover:text-gray-700">
全选
</button>
<button @click="selectNoneLevels()"
class="text-xs text-gray-500 hover:text-gray-700">
全不选
</button>
</div>
<button @click="showLevelDropdown = false"
class="text-xs text-blue-600 hover:text-blue-700">
完成
@@ -308,7 +314,7 @@ const filters = ref({
minOnlineFans: '',
maxOnlineFans: '',
})
const maxCount = ref(100)
const maxCount = ref()
const selectedLevels = ref(new Set())
const showLevelDropdown = ref(false)
@@ -418,10 +424,15 @@ const loadConfig = async () => {
try {
const config = await window.electronAPI.getAutomationConfig()
if (config?.filters?.maxAnchorCount !== undefined) {
maxCount.value = config.filters.maxAnchorCount
// 如果后端返回 9999999前端显示为空
maxCount.value = config.filters.maxAnchorCount === 9999999 ? '' : config.filters.maxAnchorCount
}
if (config?.filters?.hostsLevelList) {
selectedLevels.value = new Set(config.filters.hostsLevelList)
// 计算反向等级列表:后端存储的是要过滤的等级,前端需要的是要显示的等级
const allLevels = LEVEL_OPTIONS.flatMap(parent => parent.children.map(child => child.value))
const excludedLevels = config.filters.hostsLevelList
const includedLevels = allLevels.filter(level => !excludedLevels.includes(level))
selectedLevels.value = new Set(includedLevels)
}
// 加载进阶票/普票过滤配置
if (config?.filters?.gold !== undefined) {
@@ -461,10 +472,21 @@ const updateLevelFilter = async (levels) => {
selectedLevels.value = levels
if (!isElectron()) return
try {
// 计算反向等级列表:前端勾选的是要显示的,后端需要的是要过滤的(不显示的)
const allLevels = LEVEL_OPTIONS.flatMap(parent => parent.children.map(child => child.value))
const includedLevels = Array.from(levels)
// 当全不选时,传给后端的是空数组(不过滤任何等级)
// 当有选择时,传给后端的是未选择的等级(过滤这些等级)
let excludedLevels = []
if (includedLevels.length > 0) {
excludedLevels = allLevels.filter(level => !includedLevels.includes(level))
}
await window.electronAPI.updateAutomationConfig({
filters: { hostsLevelList: Array.from(levels) }
filters: { hostsLevelList: excludedLevels }
})
console.log('[HostListDialog] 等级过滤已更新:', Array.from(levels))
console.log('[HostListDialog] 等级过滤已更新:', excludedLevels)
} catch (e) {
console.error('更新等级配置失败:', e)
}
@@ -493,14 +515,27 @@ const toggleParentLevel = (parentValue) => {
updateLevelFilter(newSet)
}
const selectAllLevels = () => {
// 全选所有等级
const allLevels = LEVEL_OPTIONS.flatMap(parent => parent.children.map(child => child.value))
updateLevelFilter(new Set(allLevels))
}
const selectNoneLevels = () => {
// 全不选所有等级
updateLevelFilter(new Set())
}
const updateMaxCount = async (value) => {
// value is already updated via v-model
if (!isElectron()) return
try {
// 如果不填写,传 9999999 表示无限制
const maxAnchorCount = value || 9999999
await window.electronAPI.updateAutomationConfig({
filters: { maxAnchorCount: value }
filters: { maxAnchorCount }
})
console.log('[HostListDialog] 主播数据上限已更新:', value)
console.log('[HostListDialog] 主播数据上限已更新:', maxAnchorCount)
} catch (e) {
console.error('更新配置失败:', e)
}