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

@@ -158,16 +158,16 @@ onMounted(() => {
/>
<VerticalNavLink
:item="{
title: '站点管理',
icon: 'mdi-web',
to: '/site',
title: '插件',
icon: 'mdi-apps',
to: '/plugin',
}"
/>
<VerticalNavLink
:item="{
title: '插件',
icon: 'mdi-apps',
to: '/plugin',
title: '站点管理',
icon: 'mdi-web',
to: '/site',
}"
/>
<VerticalNavLink

View File

@@ -1,8 +1,8 @@
<script lang="ts" setup>
import AccountSettingAccount from "@/views/account-setting/AccountSettingAccount.vue";
import AccountSettingFilter from "@/views/account-setting/AccountSettingFilter.vue";
import AccountSettingNotification from "@/views/account-setting/AccountSettingNotification.vue";
import AccountSettingSystem from "@/views/account-setting/AccountSettingSystem.vue";
import AccountSettingRule from "@/views/account-setting/AccountSettingRule.vue";
import AccountSettingSite from "@/views/account-setting/AccountSettingSite.vue";
import AccountSettingWords from "@/views/account-setting/AccountSettingWords.vue";
import { useRoute } from "vue-router";
@@ -13,7 +13,7 @@ const activeTab = ref(route.params.tab);
// tabs
const tabs = [
{ title: "用户", icon: "mdi-account", tab: "account" },
{ title: "站点", icon: "mdi-sitemap", tab: "system" },
{ title: "站点", icon: "mdi-web", tab: "site" },
{ title: "规则", icon: "mdi-filter-cog", tab: "filter" },
{ title: "通知", icon: "mdi-bell", tab: "notification" },
{ title: "自定义词表", icon: "mdi-file-word-box", tab: "words" },
@@ -37,13 +37,13 @@ const tabs = [
</VWindowItem>
<!-- System -->
<VWindowItem value="system">
<AccountSettingSystem />
<VWindowItem value="site">
<AccountSettingSite />
</VWindowItem>
<!-- Notification -->
<VWindowItem value="filter">
<AccountSettingFilter />
<AccountSettingRule />
</VWindowItem>
<!-- Notification -->

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>