Merge pull request #19 from thofx/thofx_fix

This commit is contained in:
jxxghp
2023-08-12 20:35:11 +08:00
committed by GitHub
5 changed files with 150 additions and 288 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ body,
overflow: hidden; overflow: hidden;
// TODO: Use grid gutter variable here // TODO: Use grid gutter variable here
padding-block: 1.5rem; padding-block: 1.5rem;
padding-top: calc(env(safe-area-inset-top) + 70px); padding-top: calc(env(safe-area-inset-top) + 65px);
// display: flex; // display: flex;
+7 -2
View File
@@ -354,6 +354,11 @@ onMounted(() => {
</VTooltip> </VTooltip>
</VCardText> </VCardText>
<VDivider
class="opacity-75"
style="border-color: rgba(var(--v-theme-on-background), var(--v-selected-opacity))"
/>
<VCardActions> <VCardActions>
<VBtn <VBtn
v-if="!cardProps.site?.public" v-if="!cardProps.site?.public"
@@ -579,10 +584,10 @@ onMounted(() => {
page-text="{0}-{1} {2} " page-text="{0}-{1} {2} "
> >
<template #item.title="{ item }"> <template #item.title="{ item }">
<div class="text-high-emphasis"> <div class="text-high-emphasis pt-1">
{{ item.raw.title }} {{ item.raw.title }}
</div> </div>
<div class="text-sm"> <div class="text-sm my-1">
{{ item.raw.description }} {{ item.raw.description }}
</div> </div>
<VChip <VChip
+20 -6
View File
@@ -88,11 +88,25 @@
} }
@media (min-width: 640px){ @media (min-width: 640px){
.slider-title { .slider-title {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
font-size: 1.5rem; font-size: 1.5rem;
line-height: 2.25rem; line-height: 2.25rem;
}
} }
// 美化滚动条
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-thumb {
border-radius: 3px;
background: rgb(var(--v-theme-perfect-scrollbar-thumb));
-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
&:hover{
background: #a1a1a1;
}
} }
+115 -255
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { isIntersected } from '@/@core/utils' import { ref } from 'vue'
import api from '@/api' import api from '@/api'
import type { Context } from '@/api/types' import type { Context } from '@/api/types'
import TorrentCard from '@/components/cards/TorrentCard.vue' import TorrentCard from '@/components/cards/TorrentCard.vue'
@@ -15,13 +15,15 @@ const props = defineProps({
type: String, type: String,
}) })
interface SearchTorrent extends Context {
more?: Array<Context>
}
// 数据列表 // 数据列表
const dataList = ref<Context[]>([]) const dataList = ref <Array<SearchTorrent>>([])
// 分组后的数据列表 // 分组后的数据列表
const groupedDataList = computed(() => { const groupedDataList = ref<Map<string, Context[]>>()
return groupByTitleAndSize(dataList.value)
})
// 是否刷新过 // 是否刷新过
const isRefreshed = ref(false) const isRefreshed = ref(false)
@@ -60,171 +62,78 @@ const filterForm = reactive({
}) })
// 获取站点过滤选项 // 获取站点过滤选项
const getSiteFilterOptions = computed(() => { const siteFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (data.torrent_info?.site_name && !options.includes(data.torrent_info?.site_name))
options.push(data.torrent_info?.site_name)
})
return options
})
// 获取季过滤选项 // 获取季过滤选项
const getSeasonFilterOptions = computed(() => { const seasonFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (
data.meta_info.season_episode
&& !options.includes(data.meta_info.season_episode)
)
options.push(data.meta_info.season_episode)
})
return options
})
// 获取制作组过滤选项 // 获取制作组过滤选项
const getReleaseGroupFilterOptions = computed(() => { const releaseGroupFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (data.meta_info.resource_team && !options.includes(data.meta_info.resource_team))
options.push(data.meta_info.resource_team)
})
return options
})
// 获取视频编码过滤选项 // 获取视频编码过滤选项
const getVideoCodeFilterOptions = computed(() => { const videoCodeFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (data.meta_info.video_encode && !options.includes(data.meta_info.video_encode))
options.push(data.meta_info.video_encode)
})
return options
})
// 获取促销状态过滤选项 // 获取促销状态过滤选项
const getFreeStateFilterOptions = computed(() => { const freeStateFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (
data.torrent_info.volume_factor
&& !options.includes(data.torrent_info.volume_factor)
)
options.push(data.torrent_info.volume_factor)
})
return options
})
// 获取质量过滤选项 // 获取质量过滤选项
const getEditionFilterOptions = computed(() => { const editionFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (data.meta_info.edition && !options.includes(data.meta_info.edition))
options.push(data.meta_info.edition)
})
return options
})
// 获取分辨率过滤选项 // 获取分辨率过滤选项
const getResolutionFilterOptions = computed(() => { const resolutionFilterOptions = ref<Array<string>>([])
const options: string[] = []
dataList.value.forEach((data) => {
if (data.meta_info.resource_pix && !options.includes(data.meta_info.resource_pix))
options.push(data.meta_info.resource_pix)
})
return options
})
// 按过滤项过滤卡片 // 按过滤项过滤卡片
// eslint-disable-next-line sonarjs/cognitive-complexity watchEffect(() => {
function filterTorrentsCard(data: Context) { // 清空数据
// 当前分组的所有数据 dataList.value.splice(0)
const items: Context[]
= groupedDataList.value.get(`${data.torrent_info.title}_${data.torrent_info.size}`)
?? []
// 站点名称、促销状态 const match = (filter: Array<string>, value: string | undefined) =>
const site_names = [] filter.length === 0 || (value && filter.includes(value))
const volume_factors = []
for (const { torrent_info } of items) {
site_names.push(torrent_info.site_name)
volume_factors.push(torrent_info.volume_factor)
}
const { meta_info } = data groupedDataList.value?.forEach((value) => {
if (value.length > 0) {
const matchData = value.filter((data) => {
const { meta_info, torrent_info } = data
// 季、制作组、视频编码
const { season_episode, resource_team, video_encode } = meta_info
return (
// 站点过滤
match(filterForm.site, torrent_info.site_name)
// 促销状态过滤
&& match(filterForm.freeState, torrent_info.volume_factor)
// 季过滤
&& match(filterForm.season, season_episode)
// 制作组过滤
&& match(filterForm.releaseGroup, resource_team)
// 视频编码过滤
&& match(filterForm.videoCode, video_encode)
// 分辨率过滤
&& match(filterForm.resolution, meta_info.resource_pix)
// 质量过滤
&& match(filterForm.edition, meta_info.edition)
)
})
if (matchData.length > 0) {
const firstData = matchData[0] as SearchTorrent
if (matchData.length > 1)
firstData.more = matchData.slice(1)
// 季、制作组、视频编码 dataList.value.push(firstData)
const { season_episode, resource_team, video_encode } = meta_info }
}
// 站点过滤 })
if (filterForm.site.length > 0 && !isIntersected(filterForm.site, site_names)) })
return false
// 促销状态过滤
if (
filterForm.freeState.length > 0
&& !isIntersected(filterForm.freeState, volume_factors)
)
return false
// 季过滤
if (filterForm.season.length > 0 && !filterForm.season.includes(season_episode))
return false
// 制作组过滤
if (
filterForm.releaseGroup.length > 0
&& !filterForm.releaseGroup.includes(resource_team || '')
)
return false
// 视频编码过滤
if (
filterForm.videoCode.length > 0
&& !filterForm.videoCode.includes(video_encode || '')
)
return false
// 分辨率过滤
if (
filterForm.resolution.length > 0
&& !filterForm.resolution.includes(meta_info.resource_pix || '')
)
return false
// 质量过滤
return !(filterForm.edition.length > 0 && !filterForm.edition.includes(meta_info.edition))
}
// 获取订阅列表数据 // 获取订阅列表数据
async function fetchData() { async function fetchData(): Promise<Array<Context>> {
try { try {
let searchData: Array<Context>
const keyword = props.keyword ?? '' const keyword = props.keyword ?? ''
const mtype = props.type ?? '' const mtype = props.type ?? ''
if (!keyword) { if (!keyword) {
// 查询上次搜索结果 // 查询上次搜索结果
dataList.value = await api.get('search/last') searchData = await api.get('search/last')
} }
else { else {
startLoadingProgress() startLoadingProgress()
const qualify = props.keyword?.startsWith('tmdb:') || props.keyword?.startsWith('douban:')
// 优先按TMDBID精确查询 // 优先按TMDBID精确查询
if (props.keyword?.startsWith('tmdb:') || props.keyword?.startsWith('douban:')) { if (qualify) {
dataList.value = await api.get(`search/media/${props.keyword}`, { searchData = await api.get(`search/media/${props.keyword}`, {
params: { params: {
mtype, mtype,
}, },
@@ -232,51 +141,57 @@ async function fetchData() {
} }
else { else {
// 按标题模糊查询 // 按标题模糊查询
dataList.value = await api.get(`search/title/${props.keyword}`) searchData = await api.get(`search/title/${props.keyword}`)
} }
stopLoadingProgress() stopLoadingProgress()
} }
isRefreshed.value = true isRefreshed.value = true
return Promise.resolve(searchData)
} }
catch (error) { catch (error) {
console.error(error) console.error(error)
return Promise.reject(error)
} }
} }
// 按标题和大小分组 function initData() {
function groupByTitleAndSize(contextArray: Context[]): Map<string, Context[]> { // load data
const groupMap = new Map<string, Context[]>() fetchData().then((data) => {
const groupMap = new Map<string, Context[]>()
for (const context of contextArray) { data.forEach((item) => {
const { torrent_info } = context const { torrent_info } = item
const key = `${torrent_info.title}_${torrent_info.size}` // init options
initOptions(item)
if (groupMap.has(key)) { // group data
// 已存在相同标题和大小的分组,将当前上下文信息添加到分组中 const key = `${torrent_info.title}_${torrent_info.size}`
const group = groupMap.get(key) if (groupMap.has(key)) {
// 已存在相同标题和大小的分组,将当前上下文信息添加到分组中
group?.push(context) const group = groupMap.get(key)
} group?.push(item)
else { }
// 创建新的分组,并将当前上下文信息添加到分组中 else {
groupMap.set(key, [context]) // 创建新的分组,并将当前上下文信息添加到分组中
} groupMap.set(key, [item])
} }
})
return groupMap groupedDataList.value = groupMap
}
// 获取每个分组的第一个数据
const getFirstContexts = computed(() => {
const firstContexts: Context[] = []
groupedDataList.value.forEach((group) => {
if (group.length > 0)
firstContexts.push(group[0])
}) })
}
return firstContexts function initOptions(data: Context) {
}) const { torrent_info, meta_info } = data
const optionValue = (options: Array<string>, value: string | undefined) => {
value && !options.includes(value) && options.push(value)
}
optionValue(siteFilterOptions.value, torrent_info?.site_name)
optionValue(seasonFilterOptions.value, meta_info?.season_episode)
optionValue(releaseGroupFilterOptions.value, meta_info?.resource_team)
optionValue(videoCodeFilterOptions.value, meta_info?.video_encode)
optionValue(freeStateFilterOptions.value, torrent_info?.volume_factor)
optionValue(editionFilterOptions.value, meta_info?.edition)
optionValue(resolutionFilterOptions.value, meta_info?.resource_pix)
}
// 使用SSE监听加载进度 // 使用SSE监听加载进度
function startLoadingProgress() { function startLoadingProgress() {
@@ -302,20 +217,16 @@ function stopLoadingProgress() {
} }
// 加载时获取数据 // 加载时获取数据
onBeforeMount(fetchData) onMounted(initData)
</script> </script>
<template> <template>
<VCard class="bg-transparent mb-3 pt-2 shadow-none"> <VCard class="bg-transparent mb-3 pt-2 shadow-none">
<VRow> <VRow>
<VCol <VCol v-if="siteFilterOptions.length > 0" cols="6" md="">
v-if="getSiteFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.site" v-model="filterForm.site"
:items="getSiteFilterOptions" :items="siteFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -323,14 +234,10 @@ onBeforeMount(fetchData)
multiple multiple
/> />
</VCol> </VCol>
<VCol <VCol v-if="seasonFilterOptions.length > 0" cols="6" md="">
v-if="getSeasonFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.season" v-model="filterForm.season"
:items="getSeasonFilterOptions" :items="seasonFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -338,14 +245,10 @@ onBeforeMount(fetchData)
multiple multiple
/> />
</VCol> </VCol>
<VCol <VCol v-if="releaseGroupFilterOptions.length > 0" cols="6" md="">
v-if="getReleaseGroupFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.releaseGroup" v-model="filterForm.releaseGroup"
:items="getReleaseGroupFilterOptions" :items="releaseGroupFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -353,14 +256,10 @@ onBeforeMount(fetchData)
multiple multiple
/> />
</VCol> </VCol>
<VCol <VCol v-if="editionFilterOptions.length > 0" cols="6" md="">
v-if="getEditionFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.edition" v-model="filterForm.edition"
:items="getEditionFilterOptions" :items="editionFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -368,14 +267,10 @@ onBeforeMount(fetchData)
multiple multiple
/> />
</VCol> </VCol>
<VCol <VCol v-if="resolutionFilterOptions.length > 0" cols="6" md="">
v-if="getResolutionFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.resolution" v-model="filterForm.resolution"
:items="getResolutionFilterOptions" :items="resolutionFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -383,14 +278,10 @@ onBeforeMount(fetchData)
multiple multiple
/> />
</VCol> </VCol>
<VCol <VCol v-if="videoCodeFilterOptions.length > 0" cols="6" md="">
v-if="getVideoCodeFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.videoCode" v-model="filterForm.videoCode"
:items="getVideoCodeFilterOptions" :items="videoCodeFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -398,14 +289,10 @@ onBeforeMount(fetchData)
multiple multiple
/> />
</VCol> </VCol>
<VCol <VCol v-if="freeStateFilterOptions.length > 0" cols="6" md="">
v-if="getFreeStateFilterOptions.length > 0"
cols="6"
md=""
>
<VSelect <VSelect
v-model="filterForm.freeState" v-model="filterForm.freeState"
:items="getFreeStateFilterOptions" :items="freeStateFilterOptions"
size="small" size="small"
density="compact" density="compact"
chips chips
@@ -415,40 +302,13 @@ onBeforeMount(fetchData)
</VCol> </VCol>
</VRow> </VRow>
</VCard> </VCard>
<div <div v-if="!isRefreshed" class="mt-12 w-full text-center text-gray-500 text-sm flex flex-col items-center">
v-if="!isRefreshed" <VProgressCircular v-if="!props.keyword" size="48" indeterminate color="primary" />
class="mt-12 w-full text-center text-gray-500 text-sm flex flex-col items-center" <VProgressCircular v-if="props.keyword" class="mb-3" color="primary" :model-value="progressValue" size="64" />
>
<VProgressCircular
v-if="!props.keyword"
size="48"
indeterminate
color="primary"
/>
<VProgressCircular
v-if="props.keyword"
class="mb-3"
color="primary"
:model-value="progressValue"
size="64"
/>
<span>{{ progressText }}</span> <span>{{ progressText }}</span>
</div> </div>
<div <div v-if="dataList.length > 0" class="grid gap-3 grid-torrent-card items-start">
v-if="dataList.length > 0" <TorrentCard v-for="data in dataList" :key="`${data.torrent_info.title}_${data.torrent_info.site}`" :torrent="data" :more="data.more" />
class="grid gap-3 grid-torrent-card items-start"
>
<TorrentCard
v-for="data in getFirstContexts"
v-show="filterTorrentsCard(data)"
:key="data.torrent_info.title"
:torrent="data"
:more="
groupedDataList
.get(`${data.torrent_info.title}_${data.torrent_info.size}`)
?.slice(1)
"
/>
</div> </div>
<NoDataFound <NoDataFound
v-if="dataList.length === 0 && isRefreshed" v-if="dataList.length === 0 && isRefreshed"
+7 -24
View File
@@ -51,10 +51,7 @@ async function querySelectedSites() {
async function saveSelectedSites() { async function saveSelectedSites() {
try { try {
// 用户名密码 // 用户名密码
const result: { [key: string]: any } = await api.post( const result: { [key: string]: any } = await api.post('system/setting/IndexerSites', selectedSites.value)
'system/setting/IndexerSites',
selectedSites.value,
)
if (result.success) if (result.success)
$toast.success('索引站点保存成功') $toast.success('索引站点保存成功')
@@ -97,17 +94,14 @@ onMounted(() => {
<VRow> <VRow>
<VCol cols="12"> <VCol cols="12">
<VCard title="索引站点"> <VCard title="索引站点">
<VCardSubtitle> 只有选中的站点才会在搜索和订阅中使用 </VCardSubtitle> <VCardSubtitle> 只有选中的站点才会在搜索和订阅中使用</VCardSubtitle>
<VCardItem> <VCardItem>
<VChipGroup <VChipGroup v-model="selectedSites" column multiple>
v-model="selectedSites"
column
multiple
>
<VChip <VChip
v-for="site in allSites" v-for="site in allSites"
:key="site.id" :key="site.id"
:color="selectedSites.includes(site.id) ? 'primary' : ''"
filter filter
variant="outlined" variant="outlined"
:value="site.id" :value="site.id"
@@ -118,10 +112,7 @@ onMounted(() => {
</VCardItem> </VCardItem>
<VCardItem> <VCardItem>
<VBtn <VBtn type="submit" @click="saveSelectedSites">
type="submit"
@click="saveSelectedSites"
>
保存 保存
</VBtn> </VBtn>
</VCardItem> </VCardItem>
@@ -131,18 +122,10 @@ onMounted(() => {
<VCard title="站点重置"> <VCard title="站点重置">
<VCardText> <VCardText>
<div> <div>
<VCheckbox <VCheckbox v-model="isConfirmResetSites" label="确认删除所有站点数据并重新同步" />
v-model="isConfirmResetSites"
label="确认删除所有站点数据并重新同步"
/>
</div> </div>
<VBtn <VBtn :disabled="!isConfirmResetSites || resetSitesDisabled" color="error" class="mt-3" @click="resetSites">
:disabled="!isConfirmResetSites || resetSitesDisabled"
color="error"
class="mt-3"
@click="resetSites"
>
{{ resetSitesText }} {{ resetSitesText }}
</VBtn> </VBtn>
</VCardText> </VCardText>