mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
add 订阅编辑
This commit is contained in:
@@ -2,3 +2,6 @@ import { ValidationRule } from 'vuetify/types/services/validation'
|
|||||||
|
|
||||||
// 必输校验
|
// 必输校验
|
||||||
export const requiredValidator: ValidationRule = (value: any) => !!value || '此项为必填项'
|
export const requiredValidator: ValidationRule = (value: any) => !!value || '此项为必填项'
|
||||||
|
|
||||||
|
// 数字校验
|
||||||
|
export const numberValidator: ValidationRule = (value: any) => !isNaN(value) || '请输入数字'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { requiredValidator } from "@/@validators";
|
import { numberValidator, requiredValidator } from "@/@validators";
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
import { Site } from "@/api/types";
|
import { Site } from "@/api/types";
|
||||||
import { useToast } from "vue-toast-notification";
|
import { useToast } from "vue-toast-notification";
|
||||||
@@ -324,14 +324,14 @@ onMounted(() => {
|
|||||||
<VCardText>
|
<VCardText>
|
||||||
<VForm @submit.prevent="() => {}">
|
<VForm @submit.prevent="() => {}">
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol cols="6">
|
<VCol cols="12" md="6">
|
||||||
<VTextField
|
<VTextField
|
||||||
v-model="siteForm.url"
|
v-model="siteForm.url"
|
||||||
label="站点地址"
|
label="站点地址"
|
||||||
:rules="[requiredValidator]"
|
:rules="[requiredValidator]"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="3">
|
<VCol cols="12" md="3">
|
||||||
<VSelect
|
<VSelect
|
||||||
v-model="siteForm.pri"
|
v-model="siteForm.pri"
|
||||||
label="优先级"
|
label="优先级"
|
||||||
@@ -339,7 +339,7 @@ onMounted(() => {
|
|||||||
:rules="[requiredValidator]"
|
:rules="[requiredValidator]"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="3">
|
<VCol cols="12" md="3">
|
||||||
<VSelect v-model="siteForm.is_active" :items="statusItems" label="状态" />
|
<VSelect v-model="siteForm.is_active" :items="statusItems" label="状态" />
|
||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
@@ -352,21 +352,33 @@ onMounted(() => {
|
|||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol cols="4">
|
<VCol cols="12" md="4">
|
||||||
<VTextField v-model="siteForm.limit_interval" label="单位周期(秒)" />
|
<VTextField
|
||||||
|
v-model="siteForm.limit_interval"
|
||||||
|
label="单位周期(秒)"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="4">
|
<VCol cols="12" md="4">
|
||||||
<VTextField v-model="siteForm.limit_seconds" label="访问次数" />
|
<VTextField
|
||||||
|
v-model="siteForm.limit_seconds"
|
||||||
|
label="访问次数"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="4">
|
<VCol cols="12" md="4">
|
||||||
<VTextField v-model="siteForm.limit_seconds" label="访问间隔(秒)" />
|
<VTextField
|
||||||
|
v-model="siteForm.limit_seconds"
|
||||||
|
label="访问间隔(秒)"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol cols="6">
|
<VCol cols="12" md="6">
|
||||||
<VSwitch v-model="siteForm.proxy" label="代理" />
|
<VSwitch v-model="siteForm.proxy" label="代理" />
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="6">
|
<VCol cols="12" md="6">
|
||||||
<VSwitch v-model="siteForm.render" label="仿真" />
|
<VSwitch v-model="siteForm.render" label="仿真" />
|
||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { calculateTimeDifference } from "@/@core/utils";
|
import { calculateTimeDifference } from "@/@core/utils";
|
||||||
import { formatSeason } from "@/@core/utils/formatters";
|
import { formatSeason } from "@/@core/utils/formatters";
|
||||||
|
import { numberValidator } from "@/@validators";
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
import { Subscribe } from "@/api/types";
|
import { Subscribe } from "@/api/types";
|
||||||
import { useToast } from "vue-toast-notification";
|
import { useToast } from "vue-toast-notification";
|
||||||
@@ -19,6 +20,9 @@ const cardState = ref(true);
|
|||||||
// 图片是否加载完成
|
// 图片是否加载完成
|
||||||
const imageLoaded = ref(false);
|
const imageLoaded = ref(false);
|
||||||
|
|
||||||
|
// 订阅弹窗
|
||||||
|
const subscribeInfoDialog = ref(false);
|
||||||
|
|
||||||
// 上一次更新时间
|
// 上一次更新时间
|
||||||
const lastUpdateText = ref(
|
const lastUpdateText = ref(
|
||||||
`${
|
`${
|
||||||
@@ -95,6 +99,22 @@ const searchSubscribe = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 调用API修改订阅
|
||||||
|
const updateSubscribeInfo = async () => {
|
||||||
|
subscribeInfoDialog.value = false;
|
||||||
|
try {
|
||||||
|
const result: { [key: string]: any } = await api.put(`subscribe`, subscribeForm);
|
||||||
|
// 提示
|
||||||
|
if (result.success) {
|
||||||
|
$toast.success(`${props.media?.name} 更新成功!`);
|
||||||
|
} else {
|
||||||
|
$toast.error(`${props.media?.name} 更新失败:${result.message}!`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 弹出菜单
|
// 弹出菜单
|
||||||
const dropdownItems = ref([
|
const dropdownItems = ref([
|
||||||
{
|
{
|
||||||
@@ -102,6 +122,9 @@ const dropdownItems = ref([
|
|||||||
value: 1,
|
value: 1,
|
||||||
props: {
|
props: {
|
||||||
prependIcon: "mdi-file-edit-outline",
|
prependIcon: "mdi-file-edit-outline",
|
||||||
|
click: () => {
|
||||||
|
subscribeInfoDialog.value = true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -122,6 +145,23 @@ const dropdownItems = ref([
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 订阅编辑表单
|
||||||
|
const subscribeForm = reactive({
|
||||||
|
id: props.media?.id,
|
||||||
|
// 搜索关键字
|
||||||
|
keyword: props.media?.keyword,
|
||||||
|
// 过滤规则
|
||||||
|
filter: props.media?.filter,
|
||||||
|
// 包含
|
||||||
|
include: props.media?.include,
|
||||||
|
// 排除
|
||||||
|
exclude: props.media?.exclude,
|
||||||
|
// 总集数
|
||||||
|
total_episode: props.media?.total_episode,
|
||||||
|
// 开始集数
|
||||||
|
start_episode: props.media?.start_episode,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -222,4 +262,53 @@ const dropdownItems = ref([
|
|||||||
color="success"
|
color="success"
|
||||||
/>
|
/>
|
||||||
</VCard>
|
</VCard>
|
||||||
|
<!-- 订阅编辑弹窗 -->
|
||||||
|
<VDialog v-model="subscribeInfoDialog" max-width="1000" persistent>
|
||||||
|
<!-- Dialog Content -->
|
||||||
|
<VCard :title="`编辑订阅 - ${props.media?.name}`">
|
||||||
|
<VCardText>
|
||||||
|
<VForm @submit.prevent="() => {}">
|
||||||
|
<VRow>
|
||||||
|
<VCol cols="12" md="6">
|
||||||
|
<VTextField v-model="subscribeForm.keyword" label="搜索关键词" />
|
||||||
|
</VCol>
|
||||||
|
<VCol cols="12" md="3" v-if="props.media?.type == '电视剧'">
|
||||||
|
<VTextField
|
||||||
|
v-model="subscribeForm.total_episode"
|
||||||
|
label="总集数"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
<VCol cols="12" md="3" v-if="props.media?.type == '电视剧'">
|
||||||
|
<VTextField
|
||||||
|
v-model="subscribeForm.start_episode"
|
||||||
|
label="开始集数"
|
||||||
|
:rules="[numberValidator]"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
<VRow>
|
||||||
|
<VCol cols="12" md="6">
|
||||||
|
<VTextField
|
||||||
|
v-model="subscribeForm.include"
|
||||||
|
label="包含(关键字、正则式)"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
<VCol cols="12" md="6">
|
||||||
|
<VTextField
|
||||||
|
v-model="subscribeForm.exclude"
|
||||||
|
label="排除(关键字、正则式)"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
</VForm>
|
||||||
|
</VCardText>
|
||||||
|
|
||||||
|
<VCardActions>
|
||||||
|
<VBtn @click="subscribeInfoDialog = false"> 取消 </VBtn>
|
||||||
|
<VSpacer />
|
||||||
|
<VBtn @click="updateSubscribeInfo"> 确定 </VBtn>
|
||||||
|
</VCardActions>
|
||||||
|
</VCard>
|
||||||
|
</VDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user