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
+48
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,10 +458,12 @@ 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 }">
<a href="javascript:void(0)" @click.stop="addDownload(item.raw)">
<div class="text-high-emphasis pt-1"> <div class="text-high-emphasis pt-1">
{{ item.raw.title }} {{ item.raw.title }}
</div> </div>
@@ -461,6 +508,7 @@ onMounted(() => {
> >
{{ item.raw?.volume_factor }} {{ item.raw?.volume_factor }}
</VChip> </VChip>
</a>
</template> </template>
<template #item.pubdate="{ item }"> <template #item.pubdate="{ item }">
<div>{{ item.raw.date_elapsed }}</div> <div>{{ item.raw.date_elapsed }}</div>
+3 -2
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="新增用户">