This commit is contained in:
jxxghp
2023-07-19 12:30:28 +08:00
parent 063d7fea8b
commit 98c9e84712
4 changed files with 81 additions and 72 deletions

View File

@@ -16,6 +16,15 @@ interface FilterCard {
//
const $toast = useToast();
//
const selectedTorrentPriority = ref<string>("seeder");
//
const TorrentPriorityItems = [
{ title: "站点优先", value: "site" },
{ title: "做种数优先", value: "seeder" },
];
//
const queryCustomFilters = async () => {
try {
@@ -37,6 +46,18 @@ const queryCustomFilters = async () => {
}
};
//
const queryTorrentPriority = async () => {
try {
const result: { [key: string]: any } = await api.get(
"system/setting/TorrentsPriority"
);
selectedTorrentPriority.value = result.data?.value;
} catch (error) {
console.log(error);
}
};
//
const saveCustomFilters = async () => {
try {
@@ -64,6 +85,24 @@ const saveCustomFilters = async () => {
}
};
//
const saveTorrentPriority = async () => {
try {
//
const result: { [key: string]: any } = await api.post(
"system/setting/TorrentsPriority",
selectedTorrentPriority.value
);
if (result.success) {
$toast.success("优先规则保存成功");
} else {
$toast.error("优先规则保存失败!");
}
} catch (error) {
console.log(error);
}
};
//
const filterCards = ref<FilterCard[]>([]);
@@ -78,10 +117,20 @@ const updateFilterCardValue = (pri: string, rules: string[]) => {
//
const filterCardClose = (pri: string) => {
//
filterCards.value = filterCards.value.filter((card) => card.pri !== pri);
filterCards.value.forEach((card, index) => {
card.pri = (index + 1).toString();
});
const index = filterCards.value.findIndex((card) => card.pri === pri);
if (index !== -1) {
// 使 splice
const updatedCards = [...filterCards.value];
updatedCards.splice(index, 1);
//
updatedCards.forEach((card, i) => {
card.pri = (i + 1).toString();
});
// filterCards.value
filterCards.value = updatedCards;
}
};
//
@@ -95,6 +144,7 @@ const addFilterCard = () => {
};
onMounted(() => {
queryTorrentPriority();
queryCustomFilters();
});
</script>
@@ -126,6 +176,21 @@ onMounted(() => {
</VCardItem>
</VCard>
</VCol>
<VCol cols="12">
<VCard title="下载优先规则">
<VCardText>
<VSelect
v-model="selectedTorrentPriority"
:items="TorrentPriorityItems"
label="优先规则"
outlined
></VSelect>
</VCardText>
<VCardItem>
<VBtn type="submit" @click="saveTorrentPriority"> 保存 </VBtn>
</VCardItem>
</VCard>
</VCol>
</VRow>
</template>
<style type="scss">

View File

@@ -21,15 +21,6 @@ const resetSitesText = ref("重置站点数据");
//
const resetSitesDisabled = ref(false);
//
const TorrentPriorityItems = [
{ title: "站点优先", value: "site" },
{ title: "做种数优先", value: "seeder" },
];
//
const selectedTorrentPriority = ref<string>("seeder");
//
const querySites = async () => {
try {
@@ -52,18 +43,6 @@ const querySelectedSites = async () => {
}
};
//
const queryTorrentPriority = async () => {
try {
const result: { [key: string]: any } = await api.get(
"system/setting/TorrentsPriority"
);
selectedTorrentPriority.value = result.data?.value;
} catch (error) {
console.log(error);
}
};
//
const saveSelectedSites = async () => {
try {
@@ -82,24 +61,6 @@ const saveSelectedSites = async () => {
}
};
//
const saveTorrentPriority = async () => {
try {
//
const result: { [key: string]: any } = await api.post(
"system/setting/TorrentsPriority",
selectedTorrentPriority.value
);
if (result.success) {
$toast.success("优先规则保存成功");
} else {
$toast.error("优先规则保存失败!");
}
} catch (error) {
console.log(error);
}
};
//
const resetSites = async () => {
try {
@@ -109,7 +70,6 @@ const resetSites = async () => {
if (result.success) {
$toast.success("站点重置成功请等待CookieCloud同步完成");
querySites();
queryTorrentPriority();
} else {
$toast.error("站点重置失败!");
}
@@ -122,7 +82,6 @@ const resetSites = async () => {
onMounted(() => {
querySites();
queryTorrentPriority();
});
</script>
@@ -151,21 +110,6 @@ onMounted(() => {
</VCardItem>
</VCard>
</VCol>
<VCol cols="12">
<VCard title="优先规则">
<VCardText>
<VSelect
v-model="selectedTorrentPriority"
:items="TorrentPriorityItems"
label="下载优先规则"
outlined
></VSelect>
</VCardText>
<VCardItem>
<VBtn type="submit" @click="saveTorrentPriority"> 保存 </VBtn>
</VCardItem>
</VCard>
</VCol>
<VCol cols="12">
<VCard title="站点重置">
<VCardText>