mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
fix keepalive
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<script lang='ts' setup>
|
||||
<script lang="ts" setup>
|
||||
import type { CalendarOptions, EventSourceInput } from '@fullcalendar/core'
|
||||
import dayGridPlugin from '@fullcalendar/daygrid'
|
||||
import interactionPlugin from '@fullcalendar/interaction'
|
||||
@@ -8,6 +8,13 @@ import type { Ref } from 'vue'
|
||||
import type { MediaInfo, Subscribe, TmdbEpisode } from '@/api/types'
|
||||
import api from '@/api'
|
||||
import { formatEp, parseDate } from '@/@core/utils/formatters'
|
||||
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
|
||||
|
||||
// 进度框
|
||||
const progressDialog = ref(false)
|
||||
|
||||
// 加载中
|
||||
const loading = ref(false)
|
||||
|
||||
// 日历属性
|
||||
const calendarOptions: Ref<CalendarOptions> = ref({
|
||||
@@ -51,12 +58,9 @@ async function eventsHander(subscribe: Subscribe) {
|
||||
mediaType: subscribe.type,
|
||||
len: 1,
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 调用API查询集信息
|
||||
const episodes: TmdbEpisode[] = await api.get(
|
||||
`tmdb/${subscribe.tmdbid}/${subscribe.season}`,
|
||||
)
|
||||
const episodes: TmdbEpisode[] = await api.get(`tmdb/${subscribe.tmdbid}/${subscribe.season}`)
|
||||
|
||||
interface EpisodeInfo {
|
||||
title: string
|
||||
@@ -78,8 +82,7 @@ async function eventsHander(subscribe: Subscribe) {
|
||||
if (dictEpisode[air_date]) {
|
||||
dictEpisode[air_date].subtitle += `,${episode.episode_number}`
|
||||
dictEpisode[air_date].len++
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dictEpisode[air_date] = {
|
||||
title: subscribe.name,
|
||||
subtitle: `${episode.episode_number}`,
|
||||
@@ -100,25 +103,30 @@ async function eventsHander(subscribe: Subscribe) {
|
||||
|
||||
// 调用API查询所有订阅
|
||||
async function getSubscribes() {
|
||||
progressDialog.value = true
|
||||
try {
|
||||
// 订阅
|
||||
loading.value = true
|
||||
const subscribes: Subscribe[] = await api.get('subscribe/')
|
||||
|
||||
const subEvents = await Promise.all(
|
||||
subscribes.map(async sub => eventsHander(sub)),
|
||||
)
|
||||
|
||||
loading.value = false
|
||||
const subEvents = await Promise.all(subscribes.map(async sub => eventsHander(sub)))
|
||||
calendarOptions.value.events = subEvents.flat().filter(event => event.start) as EventSourceInput
|
||||
}
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
progressDialog.value = false
|
||||
}
|
||||
|
||||
// 页面加载时调用API查询所有订阅
|
||||
onMounted(() => {
|
||||
getSubscribes()
|
||||
})
|
||||
|
||||
onActivated(() => {
|
||||
if (!loading.value) {
|
||||
getSubscribes()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -186,9 +194,10 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
</FullCalendar>
|
||||
<ProgressDialog v-if="progressDialog" v-model="progressDialog" text="正在加载 ..." />
|
||||
</template>
|
||||
|
||||
<style lang='scss'>
|
||||
<style lang="scss">
|
||||
.v-application .fc {
|
||||
--fc-today-bg-color: rgba(var(--v-theme-on-surface), 0.04);
|
||||
--fc-border-color: rgba(var(--v-border-color), var(--v-border-opacity));
|
||||
@@ -200,7 +209,7 @@ onMounted(() => {
|
||||
|
||||
// 当天背景渐变
|
||||
.fc-day-today {
|
||||
background-image: linear-gradient(to bottom, #AF85FD ,rgba(var(--v-theme-on-surface), 0.04));
|
||||
background-image: linear-gradient(to bottom, #af85fd, rgba(var(--v-theme-on-surface), 0.04));
|
||||
}
|
||||
|
||||
.v-application .fc a {
|
||||
@@ -295,11 +304,7 @@ onMounted(() => {
|
||||
|
||||
.v-application .fc .fc-toolbar-chunk .fc-button-group .fc-button-primary,
|
||||
.v-application .fc .fc-toolbar-chunk .fc-button-group .fc-button-primary:hover,
|
||||
.v-application
|
||||
.fc
|
||||
.fc-toolbar-chunk
|
||||
.fc-button-group
|
||||
.fc-button-primary:not(.disabled):active {
|
||||
.v-application .fc .fc-toolbar-chunk .fc-button-group .fc-button-primary:not(.disabled):active {
|
||||
border-color: transparent;
|
||||
background-color: transparent;
|
||||
color: rgba(var(--v-theme-on-surface), var(--v-high-emphasis-opacity));
|
||||
@@ -323,19 +328,11 @@ onMounted(() => {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.v-application
|
||||
.fc
|
||||
.fc-toolbar-chunk:last-child
|
||||
.fc-button-group
|
||||
.fc-button:not(:last-child) {
|
||||
.v-application .fc .fc-toolbar-chunk:last-child .fc-button-group .fc-button:not(:last-child) {
|
||||
border-inline-end: 0.0625rem solid rgba(var(--v-theme-primary), var(--v-overlay-scrim-opacity));
|
||||
}
|
||||
|
||||
.v-application
|
||||
.fc
|
||||
.fc-toolbar-chunk:last-child
|
||||
.fc-button-group
|
||||
.fc-button.fc-button-active {
|
||||
.v-application .fc .fc-toolbar-chunk:last-child .fc-button-group .fc-button.fc-button-active {
|
||||
background-color: rgba(var(--v-theme-primary), var(--v-activated-opacity));
|
||||
color: rgb(var(--v-theme-primary));
|
||||
}
|
||||
@@ -371,7 +368,7 @@ onMounted(() => {
|
||||
padding-inline: 0.25rem;
|
||||
}
|
||||
|
||||
.v-application .fc tbody[role="rowgroup"] > tr > td[role="presentation"] {
|
||||
.v-application .fc tbody[role='rowgroup'] > tr > td[role='presentation'] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
@@ -400,9 +397,8 @@ onMounted(() => {
|
||||
|
||||
.v-application .fc .fc-popover {
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 14px -4px var(--v-shadow-key-umbra-opacity),
|
||||
0 4px 8px -4px var(--v-shadow-key-penumbra-opacity),
|
||||
0 4px 8px -4px var(--v-shadow-key-ambient-opacity);
|
||||
box-shadow: 0 4px 14px -4px var(--v-shadow-key-umbra-opacity), 0 4px 8px -4px var(--v-shadow-key-penumbra-opacity),
|
||||
0 4px 8px -4px var(--v-shadow-key-ambient-opacity);
|
||||
}
|
||||
|
||||
.v-application .fc .fc-popover .fc-popover-header,
|
||||
@@ -441,12 +437,7 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.v-theme--dark
|
||||
.v-application
|
||||
.fc
|
||||
.fc-toolbar-chunk
|
||||
.fc-button-group
|
||||
.fc-drawerToggler-button {
|
||||
.v-theme--dark .v-application .fc .fc-toolbar-chunk .fc-button-group .fc-drawerToggler-button {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='rgba(232,232,241,0.68)' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round' class='css-i6dzq1'%3E%3Cpath d='M3 12h18M3 6h18M3 18h18'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
// 是否刷新过
|
||||
const isRefreshed = ref(false)
|
||||
let isRefreshed = ref(false)
|
||||
|
||||
// 数据列表
|
||||
const dataList = ref<Subscribe[]>([])
|
||||
@@ -38,7 +38,9 @@ const historyDialog = ref(false)
|
||||
// 获取订阅列表数据
|
||||
async function fetchData() {
|
||||
try {
|
||||
loading.value = true
|
||||
dataList.value = await api.get('subscribe/')
|
||||
loading.value = false
|
||||
isRefreshed.value = true
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -49,10 +51,9 @@ async function fetchData() {
|
||||
const loading = ref(false)
|
||||
|
||||
// 下拉刷新
|
||||
function onRefresh() {
|
||||
loading.value = true
|
||||
fetchData()
|
||||
loading.value = false
|
||||
async function onRefresh({ done }: { done: any }) {
|
||||
await fetchData()
|
||||
done('ok')
|
||||
}
|
||||
|
||||
// 过滤数据,管理员用户显示全部,非管理员只显示自己的订阅
|
||||
@@ -75,6 +76,12 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
onActivated(async () => {
|
||||
if (!loading.value) {
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -76,13 +76,13 @@ async function fetchData({ done }: { done: any }) {
|
||||
done('ok')
|
||||
}
|
||||
} else {
|
||||
// 加载一次
|
||||
// 设置加载中
|
||||
loading.value = true
|
||||
// 请求API
|
||||
currData.value = await api.get(apipath, {
|
||||
params: getParams(),
|
||||
})
|
||||
loading.value = false
|
||||
// 标计为已请求完成
|
||||
isRefreshed.value = true
|
||||
if (currData.value.length === 0) {
|
||||
@@ -97,8 +97,6 @@ async function fetchData({ done }: { done: any }) {
|
||||
done('ok')
|
||||
}
|
||||
}
|
||||
// 取消加载中
|
||||
loading.value = false
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
// 返回加载失败
|
||||
|
||||
Reference in New Issue
Block a user