Skip to content

Commit

Permalink
fix ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Dec 30, 2023
1 parent d0aada1 commit 750f4bc
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 29 deletions.
File renamed without changes.
38 changes: 38 additions & 0 deletions src/@core/utils/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('、')
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()

Expand Down
4 changes: 0 additions & 4 deletions src/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/util/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/views/discover/TorrentCardListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<Context>
Expand Down
12 changes: 6 additions & 6 deletions src/views/discover/TorrentRowListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ onMounted(() => {
<VListItemTitle>没有附合当前过滤条件的资源。</VListItemTitle>
</VListItem>
</VList>
<v-virtual-scroll lines="three" class="rounded" :items="dataList" height="calc(100vh - 156px)">
<template #default="{ item }">
<TorrentItem :torrent="item" />
</template>
</v-virtual-scroll>
<TorrentItem
v-for="(item, index) in dataList"
:key="`${index}_${item.torrent_info.title}_${item.torrent_info.site}`"
:torrent="item"
/>
</VCol>
<VCol xl="2" md="3" class="d-none d-md-block">
<VList lines="one" class="rounded" height="calc(100vh - 156px)">
<VList lines="one" class="rounded">
<VListSubheader v-if="siteFilterOptions.length > 0">
站点
</VListSubheader>
Expand Down
28 changes: 12 additions & 16 deletions src/views/subscribe/FullCalendarView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<CalendarOptions> = ref({
Expand All @@ -33,7 +33,7 @@ const calendarOptions: Ref<CalendarOptions> = ref({
events: [],
})
async function eventsHander(subscribe: Subscribe | Rss) {
async function eventsHander(subscribe: Subscribe) {
// 如果是电影直接返回
if (subscribe.type === '电影') {
// 调用API查询TMDB详情
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand All @@ -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)
}
Expand Down Expand Up @@ -148,11 +146,8 @@ onMounted(() => {
<VCardSubtitle class="pa-1 px-2 font-bold break-words whitespace-break-spaces">
{{ arg.event.title }}
</VCardSubtitle>
<VCardText class="pa-0 px-2">
{{ arg.event.extendedProps.len }}集
</VCardText>
<VCardText class="pa-0 px-2 break-words">
{{ arg.event.extendedProps.subtitle }}
<VCardText v-if="arg.event.extendedProps.subtitle" class="pa-0 px-2 break-words">
第{{ arg.event.extendedProps.subtitle }}集
</VCardText>
</div>
</div>
Expand All @@ -178,8 +173,9 @@ onMounted(() => {
<VChip
v-if="arg.event.extendedProps.len > 1"
variant="elevated"
size="mini"
class="absolute right-0.5 top-0.5 bg-opacity-80 shadow-md text-white font-bold border-purple-600 bg-purple-600"
color="primary"
size="x-small"
class="absolute right-0 top-0"
>
{{ arg.event.extendedProps.len }}
</VChip>
Expand Down

0 comments on commit 750f4bc

Please sign in to comment.