This commit is contained in:
jxxghp
2024-03-18 23:31:21 +08:00
parent ec4ab8762c
commit abcc3c6411
2 changed files with 95 additions and 46 deletions

View File

@@ -1,12 +1,14 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from 'vue' import type { PropType } from 'vue'
import { useToast } from 'vue-toast-notification' import { useToast } from 'vue-toast-notification'
import { useConfirm } from 'vuetify-use-dialog'
import SiteAddEditForm from '../form/SiteAddEditForm.vue' import SiteAddEditForm from '../form/SiteAddEditForm.vue'
import { formatFileSize } from '@core/utils/formatters' import { formatFileSize } from '@core/utils/formatters'
import { requiredValidator } from '@/@validators' import { requiredValidator } from '@/@validators'
import api from '@/api' import api from '@/api'
import type { Site, TorrentInfo } from '@/api/types' import type { Site, TorrentInfo } from '@/api/types'
import ExistIcon from '@core/components/ExistIcon.vue' import ExistIcon from '@core/components/ExistIcon.vue'
import { doneNProgress, startNProgress } from '@/api/nprogress'
// 输入参数 // 输入参数
const cardProps = defineProps({ const cardProps = defineProps({
@@ -27,6 +29,9 @@ const siteIcon = ref<string>('')
// 提示框 // 提示框
const $toast = useToast() const $toast = useToast()
// 确认框
const createConfirm = useConfirm()
// 测试按钮文字 // 测试按钮文字
const testButtonText = ref('测试') const testButtonText = ref('测试')
@@ -200,6 +205,45 @@ function openSitePage() {
window.open(cardProps.site?.url, '_blank') window.open(cardProps.site?.url, '_blank')
} }
// 添加下载
async function addDownload(_torrent: any) {
const isConfirmed = await createConfirm({
title: '确认',
content: `是否确认下载【${_torrent.site_name}${_torrent?.title} ?`,
confirmationText: '确认',
cancellationText: '取消',
dialogProps: {
maxWidth: '50rem',
},
confirmationButtonProps: {
variant: 'tonal',
},
})
if (!isConfirmed)
return
startNProgress()
try {
const result: { [key: string]: any } = await api.post('download/add', {
torrent_in: _torrent,
})
if (result.success) {
// 添加下载成功
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
}
else {
// 添加下载失败
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`)
}
}
catch (error) {
console.error(error)
}
doneNProgress()
}
// 装载时查询站点图标 // 装载时查询站点图标
onMounted(() => { onMounted(() => {
getSiteIcon() getSiteIcon()
@@ -397,6 +441,7 @@ onMounted(() => {
v-model="resourceDialog" v-model="resourceDialog"
max-width="80rem" max-width="80rem"
scrollable scrollable
z-index="1010"
> >
<!-- Dialog Content --> <!-- Dialog Content -->
<VCard :title="`浏览站点 - ${cardProps.site?.name}`"> <VCard :title="`浏览站点 - ${cardProps.site?.name}`">
@@ -413,54 +458,57 @@ onMounted(() => {
item-value="title" item-value="title"
return-object return-object
fixed-header fixed-header
hover
items-per-page-text="每页条数" items-per-page-text="每页条数"
page-text="{0}-{1} {2} " page-text="{0}-{1} {2} "
> >
<template #item.title="{ item }"> <template #item.title="{ item }">
<div class="text-high-emphasis pt-1"> <a href="javascript:void(0)" @click.stop="addDownload(item.raw)">
{{ item.raw.title }} <div class="text-high-emphasis pt-1">
</div> {{ item.raw.title }}
<div class="text-sm my-1"> </div>
{{ item.raw.description }} <div class="text-sm my-1">
</div> {{ item.raw.description }}
<VChip </div>
v-if="item.raw?.hit_and_run" <VChip
variant="elevated" v-if="item.raw?.hit_and_run"
size="small" variant="elevated"
class="me-1 mb-1 text-white bg-black" size="small"
> class="me-1 mb-1 text-white bg-black"
H&R >
</VChip> H&R
<VChip </VChip>
v-if="item.raw?.freedate_diff" <VChip
variant="elevated" v-if="item.raw?.freedate_diff"
color="secondary" variant="elevated"
size="small" color="secondary"
class="me-1 mb-1" size="small"
> class="me-1 mb-1"
{{ item.raw?.freedate_diff }} >
</VChip> {{ item.raw?.freedate_diff }}
<VChip </VChip>
v-for="(label, index) in item.raw?.labels" <VChip
:key="index" v-for="(label, index) in item.raw?.labels"
variant="elevated" :key="index"
size="small" variant="elevated"
color="primary" size="small"
class="me-1 mb-1" color="primary"
> class="me-1 mb-1"
{{ label }} >
</VChip> {{ label }}
<VChip </VChip>
v-if="item.raw?.downloadvolumefactor !== 1 || item.raw?.uploadvolumefactor !== 1" <VChip
:class=" v-if="item.raw?.downloadvolumefactor !== 1 || item.raw?.uploadvolumefactor !== 1"
getVolumeFactorClass(item.raw?.downloadvolumefactor, item.raw?.uploadvolumefactor) :class="
" getVolumeFactorClass(item.raw?.downloadvolumefactor, item.raw?.uploadvolumefactor)
variant="elevated" "
size="small" variant="elevated"
class="me-1 mb-1" size="small"
> class="me-1 mb-1"
{{ item.raw?.volume_factor }} >
</VChip> {{ item.raw?.volume_factor }}
</VChip>
</a>
</template> </template>
<template #item.pubdate="{ item }"> <template #item.pubdate="{ item }">
<div>{{ item.raw.date_elapsed }}</div> <div>{{ item.raw.date_elapsed }}</div>

View File

@@ -369,7 +369,7 @@ onMounted(() => {
</td> </td>
<td>{{ user.is_superuser ? "是" : "否" }}</td> <td>{{ user.is_superuser ? "是" : "否" }}</td>
<td> <td>
<IconBtn v-show="accountInfo.is_superuser && accountInfo.name != user.name"> <IconBtn v-show="accountInfo.is_superuser && accountInfo.name !== user.name">
<VIcon icon="mdi-dots-vertical" /> <VIcon icon="mdi-dots-vertical" />
<VMenu <VMenu
activator="parent" activator="parent"
@@ -409,11 +409,12 @@ onMounted(() => {
</VCard> </VCard>
</VCol> </VCol>
</VRow> </VRow>
<!-- 站点编辑弹窗 --> <!-- =弹窗 -->
<VDialog <VDialog
v-model="addUserDialog" v-model="addUserDialog"
max-width="50rem" max-width="50rem"
persistent persistent
z-index="1010"
> >
<!-- Dialog Content --> <!-- Dialog Content -->
<VCard title="新增用户"> <VCard title="新增用户">