mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-02 22:31:07 +08:00
feat(SiteResource): 添加站点资源分类功能并优化资源查询逻辑
This commit is contained in:
@@ -1254,3 +1254,10 @@ export interface RecommendSource {
|
|||||||
// 媒体数据源API地址
|
// 媒体数据源API地址
|
||||||
api_path: string
|
api_path: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 站点资源分类
|
||||||
|
export interface SiteCategory {
|
||||||
|
id: number
|
||||||
|
cat: string
|
||||||
|
desc: string
|
||||||
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ onMounted(() => {
|
|||||||
<VCard
|
<VCard
|
||||||
:variant="cardProps.site?.is_active ? 'elevated' : 'outlined'"
|
:variant="cardProps.site?.is_active ? 'elevated' : 'outlined'"
|
||||||
class="overflow-hidden h-full flex flex-col"
|
class="overflow-hidden h-full flex flex-col"
|
||||||
@click="siteEditDialog = true"
|
@click="handleResourceBrowse"
|
||||||
>
|
>
|
||||||
<template #image>
|
<template #image>
|
||||||
<VAvatar class="absolute right-2 bottom-2 rounded" variant="flat" rounded="0">
|
<VAvatar class="absolute right-2 bottom-2 rounded" variant="flat" rounded="0">
|
||||||
@@ -195,11 +195,11 @@ onMounted(() => {
|
|||||||
<VIcon icon="mdi-chevron-down" color="primary" />
|
<VIcon icon="mdi-chevron-down" color="primary" />
|
||||||
<VMenu activator="parent" close-on-content-click>
|
<VMenu activator="parent" close-on-content-click>
|
||||||
<VList>
|
<VList>
|
||||||
<VListItem variant="plain" @click="handleResourceBrowse">
|
<VListItem variant="plain" @click="siteEditDialog = true" base-color="info">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<VIcon icon="mdi-search-web" />
|
<VIcon icon="mdi-file-edit-outline" />
|
||||||
</template>
|
</template>
|
||||||
<VListItemTitle>浏览站点资源</VListItemTitle>
|
<VListItemTitle>编辑站点</VListItemTitle>
|
||||||
</VListItem>
|
</VListItem>
|
||||||
<VListItem variant="plain" @click="handleSiteUserData">
|
<VListItem variant="plain" @click="handleSiteUserData">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
|
|||||||
@@ -1,19 +1,31 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Site } from '@/api/types'
|
import { Site } from '@/api/types'
|
||||||
import { useDisplay } from 'vuetify'
|
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import type { TorrentInfo } from '@/api/types'
|
import type { TorrentInfo, SiteCategory } from '@/api/types'
|
||||||
import { formatFileSize } from '@core/utils/formatters'
|
import { formatFileSize } from '@core/utils/formatters'
|
||||||
import AddDownloadDialog from '../dialog/AddDownloadDialog.vue'
|
import AddDownloadDialog from '../dialog/AddDownloadDialog.vue'
|
||||||
|
|
||||||
// 显示器宽度
|
|
||||||
const display = useDisplay()
|
|
||||||
|
|
||||||
// 输入参数
|
// 输入参数
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
site: Object as PropType<Site>,
|
site: Object as PropType<Site>,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 关键字
|
||||||
|
const keyword = ref<string>()
|
||||||
|
|
||||||
|
// 选择分类
|
||||||
|
const selectCategory = ref<number[]>([])
|
||||||
|
|
||||||
|
// 全部分类
|
||||||
|
const siteCategoryList = ref<SiteCategory[]>()
|
||||||
|
|
||||||
|
// 分类选项
|
||||||
|
const categoryOptions = computed(() => {
|
||||||
|
return siteCategoryList.value?.map(item => {
|
||||||
|
return { title: item.desc, value: item.id }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// 注册事件
|
// 注册事件
|
||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
|
|
||||||
@@ -55,17 +67,6 @@ async function downloadTorrentFile(enclosure: string) {
|
|||||||
window.open(enclosure, '_blank')
|
window.open(enclosure, '_blank')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用API,查询站点资源
|
|
||||||
async function getResourceList() {
|
|
||||||
resourceLoading.value = true
|
|
||||||
try {
|
|
||||||
resourceDataList.value = await api.get(`site/resource/${props.site?.id}`)
|
|
||||||
resourceLoading.value = false
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 促销Chip类
|
// 促销Chip类
|
||||||
function getVolumeFactorClass(downloadVolume: number, uploadVolume: number) {
|
function getVolumeFactorClass(downloadVolume: number, uploadVolume: number) {
|
||||||
if (downloadVolume === 0) return 'text-white bg-lime-500'
|
if (downloadVolume === 0) return 'text-white bg-lime-500'
|
||||||
@@ -93,8 +94,34 @@ function addDownloadError(error: string) {
|
|||||||
addDownloadDialog.value = false
|
addDownloadDialog.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 调用API,查询站点资源
|
||||||
|
async function getResourceList() {
|
||||||
|
resourceLoading.value = true
|
||||||
|
try {
|
||||||
|
resourceDataList.value = await api.get(`site/resource/${props.site?.id}`, {
|
||||||
|
params: {
|
||||||
|
keyword: keyword.value,
|
||||||
|
cat: selectCategory.value?.join(','),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
resourceLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载站点分类
|
||||||
|
async function getSiteCategoryList() {
|
||||||
|
try {
|
||||||
|
siteCategoryList.value = await api.get(`site/category/${props.site?.id}`)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 装载时查询站点图标
|
// 装载时查询站点图标
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getSiteCategoryList()
|
||||||
getResourceList()
|
getResourceList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -113,6 +140,28 @@ onMounted(() => {
|
|||||||
</VToolbarItems>
|
</VToolbarItems>
|
||||||
</VToolbar>
|
</VToolbar>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="p-3">
|
||||||
|
<VRow>
|
||||||
|
<VCol cols="6" md="5">
|
||||||
|
<VTextField v-model="keyword" size="small" density="compact" label="搜索关键字" clearable />
|
||||||
|
</VCol>
|
||||||
|
<VCol cols="6" md="5">
|
||||||
|
<VSelect
|
||||||
|
v-model="selectCategory"
|
||||||
|
:items="categoryOptions"
|
||||||
|
size="small"
|
||||||
|
density="compact"
|
||||||
|
chips
|
||||||
|
label="资源分类"
|
||||||
|
multiple
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
|
<VCol cols="12" md="2" class="text-center">
|
||||||
|
<VBtn block prepend-icon="mdi-magnify" @click="getResourceList">搜索</VBtn>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
</div>
|
||||||
<VCardText class="px-0 py-0 my-0">
|
<VCardText class="px-0 py-0 my-0">
|
||||||
<VDataTable
|
<VDataTable
|
||||||
v-model:items-per-page="resourceItemsPerPage"
|
v-model:items-per-page="resourceItemsPerPage"
|
||||||
|
|||||||
Reference in New Issue
Block a user