mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
fix 过滤规则删除问题
This commit is contained in:
@@ -50,9 +50,6 @@ const selectFilterOptions = ref<{ [key: string]: string }[]>([
|
|||||||
{ title: '排除: 国语配音', value: ' !CNVOI ' },
|
{ title: '排除: 国语配音', value: ' !CNVOI ' },
|
||||||
{ title: '促销: 免费', value: ' FREE ' },
|
{ title: '促销: 免费', value: ' FREE ' },
|
||||||
])
|
])
|
||||||
|
|
||||||
// 已选择的过滤规则
|
|
||||||
const selectedFilters = ref<string[]>(props.rules ?? [])
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -64,7 +61,7 @@ const selectedFilters = ref<string[]>(props.rules ?? [])
|
|||||||
<VCol>
|
<VCol>
|
||||||
<VSelect
|
<VSelect
|
||||||
:key="props.pri"
|
:key="props.pri"
|
||||||
v-model="selectedFilters"
|
v-model="props.rules"
|
||||||
variant="underlined"
|
variant="underlined"
|
||||||
:items="selectFilterOptions"
|
:items="selectFilterOptions"
|
||||||
chips
|
chips
|
||||||
|
|||||||
@@ -5,15 +5,10 @@ import FilterRuleCard from '@/components/cards/FilterRuleCard.vue'
|
|||||||
|
|
||||||
// 规则卡片类型
|
// 规则卡片类型
|
||||||
interface FilterCard {
|
interface FilterCard {
|
||||||
|
|
||||||
// 优先级
|
// 优先级
|
||||||
pri: string
|
pri: string
|
||||||
|
|
||||||
// 已选规则
|
// 已选规则
|
||||||
rules: string[]
|
rules: string[]
|
||||||
|
|
||||||
// 是否可见
|
|
||||||
visible: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
@@ -48,7 +43,6 @@ async function queryCustomFilters(ruleType: string) {
|
|||||||
return {
|
return {
|
||||||
pri: (index + 1).toString(),
|
pri: (index + 1).toString(),
|
||||||
rules: group.split('&'),
|
rules: group.split('&'),
|
||||||
visible: true,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -138,23 +132,18 @@ function updateFilterCardValue2(pri: string, rules: string[]) {
|
|||||||
|
|
||||||
// 移除卡片
|
// 移除卡片
|
||||||
function filterCardClose(ruleType: string, pri: string) {
|
function filterCardClose(ruleType: string, pri: string) {
|
||||||
// 将卡片从列表中删除,并更新剩余卡片的序号
|
// 将pri对应的卡片从列表中删除,并更新剩余卡片的序号
|
||||||
const cards = ruleType === 'FilterRules' ? filterCards : filterCards2
|
const updatedCards = (ruleType === 'FilterRules' ? filterCards.value : filterCards2.value)
|
||||||
const index = cards.value.findIndex(card => card.pri === pri)
|
.filter(card => card.pri !== pri)
|
||||||
if (index !== -1) {
|
.map((card, index) => {
|
||||||
// 创建新的数组,然后使用 splice 方法来删除元素
|
card.pri = (index + 1).toString()
|
||||||
const updatedCards = [...cards.value]
|
return card
|
||||||
|
|
||||||
updatedCards.splice(index, 1)
|
|
||||||
|
|
||||||
// 更新剩余卡片的序号
|
|
||||||
updatedCards.forEach((card, i) => {
|
|
||||||
card.pri = (i + 1).toString()
|
|
||||||
})
|
})
|
||||||
|
// 更新 filterCards.value
|
||||||
// 更新 filterCards.value
|
if (ruleType === 'FilterRules')
|
||||||
cards.value = updatedCards
|
filterCards.value = updatedCards
|
||||||
}
|
else
|
||||||
|
filterCards2.value = updatedCards
|
||||||
}
|
}
|
||||||
|
|
||||||
// 增加卡片
|
// 增加卡片
|
||||||
@@ -164,7 +153,7 @@ function addFilterCard(ruleType: string) {
|
|||||||
const pri = (cards.value.length + 1).toString()
|
const pri = (cards.value.length + 1).toString()
|
||||||
|
|
||||||
// 新卡片
|
// 新卡片
|
||||||
const newCard: FilterCard = { pri, rules: [], visible: true }
|
const newCard: FilterCard = { pri, rules: [] }
|
||||||
|
|
||||||
// 添加到列表
|
// 添加到列表
|
||||||
cards.value.push(newCard)
|
cards.value.push(newCard)
|
||||||
@@ -189,7 +178,6 @@ onMounted(() => {
|
|||||||
:key="index"
|
:key="index"
|
||||||
:pri="card.pri"
|
:pri="card.pri"
|
||||||
:rules="card.rules"
|
:rules="card.rules"
|
||||||
:visible="card.visible"
|
|
||||||
@changed="updateFilterCardValue"
|
@changed="updateFilterCardValue"
|
||||||
@close="filterCardClose('FilterRules', card.pri)"
|
@close="filterCardClose('FilterRules', card.pri)"
|
||||||
/>
|
/>
|
||||||
@@ -224,7 +212,6 @@ onMounted(() => {
|
|||||||
:key="index"
|
:key="index"
|
||||||
:pri="card.pri"
|
:pri="card.pri"
|
||||||
:rules="card.rules"
|
:rules="card.rules"
|
||||||
:visible="card.visible"
|
|
||||||
@changed="updateFilterCardValue2"
|
@changed="updateFilterCardValue2"
|
||||||
@close="filterCardClose('FilterRules2', card.pri)"
|
@close="filterCardClose('FilterRules2', card.pri)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1836,6 +1836,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
||||||
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
|
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
|
||||||
|
|
||||||
|
"@types/lodash@^4.14.197":
|
||||||
|
version "4.14.198"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.198.tgz#4d27465257011aedc741a809f1269941fa2c5d4c"
|
||||||
|
integrity sha512-trNJ/vtMZYMLhfN45uLq4ShQSw0/S7xCTLLVM+WM1rmFpba/VS42jVUgaO3w/NOLiWR/09lnYk0yMaA/atdIsg==
|
||||||
|
|
||||||
"@types/mdast@^3.0.0":
|
"@types/mdast@^3.0.0":
|
||||||
version "3.0.11"
|
version "3.0.11"
|
||||||
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.11.tgz#dc130f7e7d9306124286f6d6cee40cf4d14a3dc0"
|
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.11.tgz#dc130f7e7d9306124286f6d6cee40cf4d14a3dc0"
|
||||||
|
|||||||
Reference in New Issue
Block a user