mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-06 08:06:43 +08:00
添加分享人唯一ID,支持删除订阅分享功能,并优化相关组件的事件处理
This commit is contained in:
@@ -88,6 +88,8 @@ export interface SubscribeShare {
|
|||||||
share_comment?: string
|
share_comment?: string
|
||||||
// 分享人
|
// 分享人
|
||||||
share_user?: string
|
share_user?: string
|
||||||
|
// 分享人唯一ID
|
||||||
|
share_uid?: string
|
||||||
// 订阅名称
|
// 订阅名称
|
||||||
name?: string
|
name?: string
|
||||||
// 订阅年份
|
// 订阅年份
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ const props = defineProps({
|
|||||||
media: Object as PropType<SubscribeShare>,
|
media: Object as PropType<SubscribeShare>,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 定义删除事件
|
||||||
|
const emit = defineEmits(['delete'])
|
||||||
|
|
||||||
// 从 provide 中获取全局设置
|
// 从 provide 中获取全局设置
|
||||||
const globalSettings: any = inject('globalSettings')
|
const globalSettings: any = inject('globalSettings')
|
||||||
|
|
||||||
@@ -70,8 +73,18 @@ function showForkSubscribe() {
|
|||||||
// 完成复用订阅
|
// 完成复用订阅
|
||||||
function finishForkSubscribe(subid: number) {
|
function finishForkSubscribe(subid: number) {
|
||||||
subscribeId.value = subid
|
subscribeId.value = subid
|
||||||
|
forkSubscribeDialog.value=false
|
||||||
subscribeEditDialog.value = true
|
subscribeEditDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除订阅分享时处理
|
||||||
|
function doDelete() {
|
||||||
|
forkSubscribeDialog.value=false
|
||||||
|
// 通知父组件刷新
|
||||||
|
emit('delete')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -153,7 +166,8 @@ function finishForkSubscribe(subid: number) {
|
|||||||
v-model="forkSubscribeDialog"
|
v-model="forkSubscribeDialog"
|
||||||
:media="props.media"
|
:media="props.media"
|
||||||
@close="forkSubscribeDialog = false"
|
@close="forkSubscribeDialog = false"
|
||||||
@done="finishForkSubscribe"
|
@fork="finishForkSubscribe"
|
||||||
|
@delete="doDelete"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 定义事件
|
// 定义事件
|
||||||
const emit = defineEmits(['close', 'done'])
|
const emit = defineEmits(['fork', 'delete', 'close'])
|
||||||
|
|
||||||
// 从 provide 中获取全局设置
|
// 从 provide 中获取全局设置
|
||||||
const globalSettings: any = inject('globalSettings')
|
const globalSettings: any = inject('globalSettings')
|
||||||
@@ -23,6 +23,9 @@ const $toast = useToast()
|
|||||||
// 处理中
|
// 处理中
|
||||||
const processing = ref(false)
|
const processing = ref(false)
|
||||||
|
|
||||||
|
// 删除中
|
||||||
|
const deleting = ref(false)
|
||||||
|
|
||||||
// 计算海报图片地址
|
// 计算海报图片地址
|
||||||
const posterUrl = computed(() => {
|
const posterUrl = computed(() => {
|
||||||
const url = props.media?.poster
|
const url = props.media?.poster
|
||||||
@@ -55,7 +58,7 @@ async function doFork() {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success(`${props.media?.share_title} 添加订阅成功!`)
|
$toast.success(`${props.media?.share_title} 添加订阅成功!`)
|
||||||
// 完成
|
// 完成
|
||||||
emit('done', result.data.id)
|
emit('fork', result.data.id)
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`${props.media?.share_title} 添加订阅失败:${result.message}!`)
|
$toast.error(`${props.media?.share_title} 添加订阅失败:${result.message}!`)
|
||||||
}
|
}
|
||||||
@@ -66,6 +69,34 @@ async function doFork() {
|
|||||||
doneNProgress()
|
doneNProgress()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除订阅分享
|
||||||
|
async function doDelete() {
|
||||||
|
// 开始处理
|
||||||
|
startNProgress()
|
||||||
|
try {
|
||||||
|
deleting.value = true
|
||||||
|
// 请求API
|
||||||
|
const result: { [key: string]: any } = await api.delete(`subscribe/share/${props.media?.id}`, {
|
||||||
|
params: {
|
||||||
|
share_uid: globalSettings.USER_UNIQUE_ID,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
// 订阅状态
|
||||||
|
if (result.success) {
|
||||||
|
$toast.success(`${props.media?.share_title} 取消分享成功!`)
|
||||||
|
// 完成
|
||||||
|
emit('delete', result.data.id)
|
||||||
|
} else {
|
||||||
|
$toast.error(`${props.media?.share_title} 取消分享失败:${result.message}!`)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
deleting.value = false
|
||||||
|
doneNProgress()
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VDialog max-width="40rem">
|
<VDialog max-width="40rem">
|
||||||
@@ -123,15 +154,28 @@ async function doFork() {
|
|||||||
</VListItem>
|
</VListItem>
|
||||||
</VList>
|
</VList>
|
||||||
<div class="text-center text-md-left">
|
<div class="text-center text-md-left">
|
||||||
<VBtn
|
<div>
|
||||||
color="primary"
|
<VBtn
|
||||||
:disabled="processing"
|
color="primary"
|
||||||
@click="doFork"
|
:disabled="processing"
|
||||||
prepend-icon="mdi-heart"
|
@click="doFork"
|
||||||
:loading="processing"
|
prepend-icon="mdi-heart"
|
||||||
>
|
:loading="processing"
|
||||||
添加到我的订阅
|
>
|
||||||
</VBtn>
|
添加到我的订阅
|
||||||
|
</VBtn>
|
||||||
|
<VBtn
|
||||||
|
v-if="props.media?.share_uid && props.media?.share_uid === globalSettings.USER_UNIQUE_ID"
|
||||||
|
color="error"
|
||||||
|
:disabled="deleting"
|
||||||
|
@click="doDelete"
|
||||||
|
prepend-icon="mdi-delete"
|
||||||
|
:loading="deleting"
|
||||||
|
class="ms-2"
|
||||||
|
>
|
||||||
|
取消分享
|
||||||
|
</VBtn>
|
||||||
|
</div>
|
||||||
<div class="text-xs mt-2" v-if="props.media?.count">
|
<div class="text-xs mt-2" v-if="props.media?.count">
|
||||||
<VIcon icon="mdi-fire" />共 {{ props.media?.count?.toLocaleString() }} 次复用
|
<VIcon icon="mdi-fire" />共 {{ props.media?.count?.toLocaleString() }} 次复用
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ async function fetchData({ done }: { done: any }) {
|
|||||||
done('error')
|
done('error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将数据从列表中移除
|
||||||
|
function removeData(id: number) {
|
||||||
|
dataList.value = dataList.value.filter(item => item.id !== id)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -106,7 +111,7 @@ async function fetchData({ done }: { done: any }) {
|
|||||||
<template #empty />
|
<template #empty />
|
||||||
<div v-if="dataList.length > 0" class="grid gap-4 grid-subscribe-card mx-3" tabindex="0">
|
<div v-if="dataList.length > 0" class="grid gap-4 grid-subscribe-card mx-3" tabindex="0">
|
||||||
<div v-for="data in dataList" :key="data.id">
|
<div v-for="data in dataList" :key="data.id">
|
||||||
<SubscribeShareCard :media="data" />
|
<SubscribeShareCard :media="data" @delete="removeData(data.id || 0)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NoDataFound
|
<NoDataFound
|
||||||
|
|||||||
Reference in New Issue
Block a user