mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-07-18 19:11:42 +08:00
fix: refine subscribe mode selection (#501)
* fix(subscribe): refine subscribe mode selection * fix(subscribe): prompt mode for single existing season
This commit is contained in:
@@ -9,6 +9,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { qualityOptions, resolutionOptions, effectOptions } from '@/api/constants'
|
||||
import { useUserStore } from '@/stores'
|
||||
import { buildUserPermissionContext, hasPermission } from '@/utils/permission'
|
||||
import { formatSeason } from '@/@core/utils/formatters'
|
||||
// i18n
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
@@ -96,6 +97,13 @@ const seasonItems = ref(
|
||||
})),
|
||||
)
|
||||
|
||||
function getSubscribeDisplayName() {
|
||||
const name = subscribeForm.value.name || ''
|
||||
const season = subscribeForm.value.season
|
||||
if (season === null || season === undefined) return name
|
||||
return `${name} ${formatSeason(season.toString())}`
|
||||
}
|
||||
|
||||
// 剧集组选项属性
|
||||
function episodeGroupItemProps(item: { title: string; subtitle: string }) {
|
||||
return {
|
||||
@@ -158,11 +166,11 @@ async function updateSubscribeInfo() {
|
||||
const result: { [key: string]: any } = await api.put('subscribe/', subscribeForm.value)
|
||||
// 提示
|
||||
if (result.success) {
|
||||
$toast.success(`${subscribeForm.value.name} 更新成功!`)
|
||||
$toast.success(`${getSubscribeDisplayName()} 更新成功!`)
|
||||
// 通知父组件刷新
|
||||
emit('save')
|
||||
} else {
|
||||
$toast.error(`${subscribeForm.value.name} 更新失败:${result.message}!`)
|
||||
$toast.error(`${getSubscribeDisplayName()} 更新失败:${result.message}!`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -258,7 +266,7 @@ async function removeSubscribe() {
|
||||
const result: { [key: string]: any } = await api.delete(`subscribe/${props.subid}`)
|
||||
|
||||
if (result.success) {
|
||||
$toast.success(`订阅 ${subscribeForm.value.name} 已取消!`)
|
||||
$toast.success(`订阅 ${getSubscribeDisplayName()} 已取消!`)
|
||||
// 通知父组件刷新
|
||||
emit('remove')
|
||||
}
|
||||
@@ -317,10 +325,7 @@ onMounted(() => {
|
||||
{{ props.default ? t('dialog.subscribeEdit.titleDefault') : t('dialog.subscribeEdit.titleEdit') }}
|
||||
</VCardTitle>
|
||||
<VCardSubtitle v-if="!props.default">
|
||||
{{ subscribeForm.name }}
|
||||
<span v-if="subscribeForm.season">
|
||||
{{ t('dialog.subscribeEdit.seasonFormat', { number: subscribeForm.season }) }}
|
||||
</span>
|
||||
{{ getSubscribeDisplayName() }}
|
||||
</VCardSubtitle>
|
||||
<VCardSubtitle v-else>
|
||||
{{ props.type }}
|
||||
|
||||
62
src/components/dialog/SubscribeModeDialog.vue
Normal file
62
src/components/dialog/SubscribeModeDialog.vue
Normal file
@@ -0,0 +1,62 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
type SubscribeMode = 'normal' | 'best_version' | 'best_version_full'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue?: boolean
|
||||
type?: string
|
||||
modes?: SubscribeMode[]
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'choose', mode: SubscribeMode): void
|
||||
(e: 'close'): void
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const modeItems = computed<SubscribeMode[]>(() =>
|
||||
props.modes?.length
|
||||
? props.modes
|
||||
: props.type === '电视剧'
|
||||
? ['normal', 'best_version', 'best_version_full']
|
||||
: ['normal', 'best_version'],
|
||||
)
|
||||
|
||||
const optionMeta: Record<SubscribeMode, { icon: string; title: string }> = {
|
||||
normal: {
|
||||
icon: 'mdi-plus-circle-outline',
|
||||
title: t('dialog.subscribeMode.normal'),
|
||||
},
|
||||
best_version: {
|
||||
icon: 'mdi-refresh',
|
||||
title: props.type === '电视剧' ? t('dialog.subscribeMode.bestVersionEpisode') : t('dialog.subscribeMode.bestVersion'),
|
||||
},
|
||||
best_version_full: {
|
||||
icon: 'mdi-shimmer',
|
||||
title: t('dialog.subscribeMode.bestVersionFull'),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VDialog :model-value="modelValue" max-width="28rem" @update:model-value="emit('update:modelValue', $event)">
|
||||
<VCard>
|
||||
<VCardTitle class="text-lg font-weight-bold px-5 pt-5">
|
||||
{{ t('dialog.subscribeMode.title') }}
|
||||
</VCardTitle>
|
||||
<VList class="py-2">
|
||||
<VListItem
|
||||
v-for="mode in modeItems"
|
||||
:key="mode"
|
||||
:prepend-icon="optionMeta[mode].icon"
|
||||
:title="optionMeta[mode].title"
|
||||
@click="emit('choose', mode)"
|
||||
/>
|
||||
</VList>
|
||||
<VDialogCloseBtn @click="emit('close')" />
|
||||
</VCard>
|
||||
</VDialog>
|
||||
</template>
|
||||
Reference in New Issue
Block a user