diff --git a/src/util/dom.ts b/src/@core/utils/dom.ts similarity index 100% rename from src/util/dom.ts rename to src/@core/utils/dom.ts diff --git a/src/@core/utils/formatters.ts b/src/@core/utils/formatters.ts index b313ddd7..dd8cfefd 100644 --- a/src/@core/utils/formatters.ts +++ b/src/@core/utils/formatters.ts @@ -109,3 +109,41 @@ export function formatBytes(bytes: number, decimals = 2) { return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}` } + +// 格式化剧集列表 +export function formatEp(nums: number[]): string { + if (!nums.length) + return '' + + if (nums.length === 1) + return nums[0].toString() + + // 将数组升序排序 + nums.sort((a, b) => a - b) + const formattedRanges: string[] = [] + let start = nums[0] + let end = nums[0] + + for (let i = 1; i < nums.length; i++) { + if (nums[i] === end + 1) { + end = nums[i] + } + else { + if (start === end) + formattedRanges.push(start.toString()) + + else + formattedRanges.push(`${start.toString()}-${end.toString()}`) + + start = end = nums[i] + } + } + + if (start === end) + formattedRanges.push(start.toString()) + + else + formattedRanges.push(`${start.toString()}-${end.toString()}`) + + return formattedRanges.join('、') +} diff --git a/src/main.ts b/src/main.ts index d2d49f25..e917d889 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from 'vue' import '@/@iconify/icons-bundle' import ToastPlugin from 'vue-toast-notification' import VuetifyUseDialog from 'vuetify-use-dialog' +import { removeEl } from './@core/utils/dom' import App from '@/App.vue' import vuetify from '@/plugins/vuetify' import { loadFonts } from '@/plugins/webfontloader' @@ -11,7 +12,6 @@ import '@core/scss/template/index.scss' import '@layouts/styles/index.scss' import '@styles/styles.scss' import 'vue-toast-notification/dist/theme-bootstrap.css' -import { removeEl } from '@/util' loadFonts() diff --git a/src/styles/styles.scss b/src/styles/styles.scss index 8d65e53d..ac9c7bfd 100644 --- a/src/styles/styles.scss +++ b/src/styles/styles.scss @@ -3,10 +3,6 @@ @tailwind components; @tailwind utilities; -:root{ - font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; -} - #nprogress .bar { background: rgb(var(--v-theme-primary)) !important; top: env(safe-area-inset-top) !important; diff --git a/src/util/index.ts b/src/util/index.ts deleted file mode 100644 index 436c9b72..00000000 --- a/src/util/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dom' diff --git a/src/views/discover/TorrentCardListView.vue b/src/views/discover/TorrentCardListView.vue index 156b0508..d2b4bd6b 100644 --- a/src/views/discover/TorrentCardListView.vue +++ b/src/views/discover/TorrentCardListView.vue @@ -2,9 +2,9 @@ import _ from 'lodash' import type { Ref } from 'vue' import { ref } from 'vue' -import { useDefer } from '@/util' import type { Context } from '@/api/types' import TorrentCard from '@/components/cards/TorrentCard.vue' +import { useDefer } from '@/@core/utils/dom' interface SearchTorrent extends Context { more?: Array diff --git a/src/views/discover/TorrentRowListView.vue b/src/views/discover/TorrentRowListView.vue index aaa51a0a..bfa7eb49 100644 --- a/src/views/discover/TorrentRowListView.vue +++ b/src/views/discover/TorrentRowListView.vue @@ -106,14 +106,14 @@ onMounted(() => { 没有附合当前过滤条件的资源。 - - - + - + 站点 diff --git a/src/views/subscribe/FullCalendarView.vue b/src/views/subscribe/FullCalendarView.vue index f72d0ab8..d313b6b4 100644 --- a/src/views/subscribe/FullCalendarView.vue +++ b/src/views/subscribe/FullCalendarView.vue @@ -5,9 +5,9 @@ import interactionPlugin from '@fullcalendar/interaction' import timeGridPlugin from '@fullcalendar/timegrid' import FullCalendar from '@fullcalendar/vue3' import type { Ref } from 'vue' -import type { MediaInfo, Rss, Subscribe, TmdbEpisode } from '@/api/types' +import type { MediaInfo, Subscribe, TmdbEpisode } from '@/api/types' import api from '@/api' -import { parseDate } from '@/@core/utils/formatters' +import { formatEp, parseDate } from '@/@core/utils/formatters' // 日历属性 const calendarOptions: Ref = ref({ @@ -33,7 +33,7 @@ const calendarOptions: Ref = ref({ events: [], }) -async function eventsHander(subscribe: Subscribe | Rss) { +async function eventsHander(subscribe: Subscribe) { // 如果是电影直接返回 if (subscribe.type === '电影') { // 调用API查询TMDB详情 @@ -62,7 +62,7 @@ async function eventsHander(subscribe: Subscribe | Rss) { subtitle: string start: Date | null allDay: boolean - posterPath: string + posterPath: string | undefined mediaType: string len: number } @@ -81,7 +81,7 @@ async function eventsHander(subscribe: Subscribe | Rss) { else { dictEpisode[air_date] = { title: subscribe.name, - subtitle: `第${episode.episode_number}`, + subtitle: `${episode.episode_number}`, start: parseDate(episode.air_date || ''), allDay: false, posterPath: subscribe.poster, @@ -90,10 +90,8 @@ async function eventsHander(subscribe: Subscribe | Rss) { } } }) - for (const key in dictEpisode) { - if (dictEpisode.hasOwnProperty(key)) - dictEpisode[key].subtitle += '集' - } + for (const key in dictEpisode) + dictEpisode[key].subtitle = formatEp(dictEpisode[key].subtitle.split(',').map(Number)) return Object.values(dictEpisode) } @@ -148,11 +146,8 @@ onMounted(() => { {{ arg.event.title }} - - {{ arg.event.extendedProps.len }}集 - - - {{ arg.event.extendedProps.subtitle }} + + 第{{ arg.event.extendedProps.subtitle }}集 @@ -178,8 +173,9 @@ onMounted(() => { {{ arg.event.extendedProps.len }}