es lint fix

This commit is contained in:
thofx
2023-07-22 16:09:07 +08:00
parent 48749b29fe
commit 018778488a
80 changed files with 3994 additions and 2981 deletions
+122 -93
View File
@@ -1,10 +1,11 @@
<script lang="ts" setup>
import { formatFileSize } from "@/@core/utils/formatters";
import api from "@/api";
import { doneNProgress, startNProgress } from "@/api/nprogress";
import { Context } from "@/api/types";
import { useToast } from "vue-toast-notification";
import { useConfirm } from "vuetify-use-dialog";
import type { PropType } from 'vue'
import { useToast } from 'vue-toast-notification'
import { useConfirm } from 'vuetify-use-dialog'
import { formatFileSize } from '@/@core/utils/formatters'
import api from '@/api'
import { doneNProgress, startNProgress } from '@/api/nprogress'
import type { Context } from '@/api/types'
// 输入参数
const props = defineProps({
@@ -12,135 +13,152 @@ const props = defineProps({
more: Array as PropType<Context[]>,
width: String,
height: String,
});
})
// 提示框
const $toast = useToast();
const $toast = useToast()
// 确认框
const createConfirm = useConfirm();
const createConfirm = useConfirm()
// 更多来源界面
const showMoreTorrents = ref(false);
const showMoreTorrents = ref(false)
// 种子信息
const torrent = ref(props.torrent?.torrent_info);
const torrent = ref(props.torrent?.torrent_info)
// 媒体信息
const media = ref(props.torrent?.media_info);
const media = ref(props.torrent?.media_info)
// 识别元数据
const meta = ref(props.torrent?.meta_info);
const meta = ref(props.torrent?.meta_info)
// 站点图标
const siteIcon = ref("");
const siteIcon = ref('')
// 查询站点图标
const getSiteIcon = async () => {
async function getSiteIcon() {
try {
siteIcon.value = (await api.get("site/icon/" + torrent?.value?.site)).data.icon;
} catch (error) {
console.error(error);
siteIcon.value = (await api.get(`site/icon/${torrent?.value?.site}`)).data.icon
}
};
catch (error) {
console.error(error)
}
}
// 询问并添加下载
const handleAddDownload = async (
_site: any = undefined,
async function handleAddDownload(_site: any = undefined,
_media: any = undefined,
_torrent: any = undefined
) => {
_torrent: any = undefined) {
if (!_media || !_torrent || !_site) {
_site = torrent.value?.site_name;
_media = media.value;
_torrent = torrent.value;
_site = torrent.value?.site_name
_media = media.value
_torrent = torrent.value
}
const isConfirmed = await createConfirm({
title: "确认",
title: '确认',
content: `是否确认下载【${_site}${_torrent?.title} ?`,
confirmationText: "确认",
cancellationText: "取消",
confirmationText: '确认',
cancellationText: '取消',
dialogProps: {
maxWidth: 600,
},
});
})
if (!isConfirmed) return;
if (!isConfirmed)
return
addDownload(_media, _torrent);
};
addDownload(_media, _torrent)
}
// 添加下载
const addDownload = async (_media: any, _torrent: any) => {
startNProgress();
async function addDownload(_media: any, _torrent: any) {
startNProgress()
try {
const result: { [key: string]: any } = await api.post("download", {
const result: { [key: string]: any } = await api.post('download', {
media_in: _media,
torrent_in: _torrent,
});
})
if (result.success) {
// 添加下载成功
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`);
} else {
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
}
else {
// 添加下载失败
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`);
$toast.error(`${_torrent?.site_name} ${_torrent?.title} 添加下载失败!`)
}
} catch (error) {
console.error(error);
}
doneNProgress();
};
catch (error) {
console.error(error)
}
doneNProgress()
}
// 打开种子详情页面
const openTorrentDetail = () => {
window.open(torrent.value?.page_url, "_blank");
};
function openTorrentDetail() {
window.open(torrent.value?.page_url, '_blank')
}
// 下载种子文件
const downloadTorrentFile = async () => {
window.open(torrent.value?.enclosure, "_blank");
};
async function downloadTorrentFile() {
window.open(torrent.value?.enclosure, '_blank')
}
// 促销Chip类
const getVolumeFactorClass = (downloadVolume: number, uploadVolume: number) => {
if (downloadVolume === 0) {
return "text-white bg-lime-500";
} else if (downloadVolume < 1) {
return "text-white bg-green-500";
} else if (uploadVolume != 1) {
return "text-white bg-sky-500";
} else {
return "text-white bg-gray-500";
}
};
function getVolumeFactorClass(downloadVolume: number, uploadVolume: number) {
if (downloadVolume === 0)
return 'text-white bg-lime-500'
else if (downloadVolume < 1)
return 'text-white bg-green-500'
else if (uploadVolume !== 1)
return 'text-white bg-sky-500'
else
return 'text-white bg-gray-500'
}
// 装载时查询站点图标
onMounted(() => {
getSiteIcon();
});
getSiteIcon()
})
// 弹出菜单
const dropdownItems = ref([
{
title: "查看详情",
title: '查看详情',
value: 1,
props: {
prependIcon: "mdi-information",
prependIcon: 'mdi-information',
click: openTorrentDetail,
},
},
{
title: "下载种子",
title: '下载种子',
value: 2,
props: {
prependIcon: "mdi-download",
prependIcon: 'mdi-download',
click: downloadTorrentFile,
},
},
]);
])
</script>
<template>
<VCard :width="props.width" :height="props.height" @click="handleAddDownload">
<template #image v-if="!showMoreTorrents">
<VAvatar class="absolute right-2 bottom-2 rounded" variant="flat" rounded="0">
<VCard
:width="props.width"
:height="props.height"
@click="handleAddDownload"
>
<template
v-if="!showMoreTorrents"
#image
>
<VAvatar
class="absolute right-2 bottom-2 rounded"
variant="flat"
rounded="0"
>
<VImg :src="siteIcon" />
</VAvatar>
</template>
@@ -153,19 +171,25 @@ const dropdownItems = ref([
<template #append>
<div class="me-n3">
<IconBtn>
<VIcon icon="mdi-dots-vertical" color="white" />
<VMenu activator="parent" close-on-content-click>
<VIcon
icon="mdi-dots-vertical"
color="white"
/>
<VMenu
activator="parent"
close-on-content-click
>
<VList>
<VListItem
v-for="(item, i) in dropdownItems"
variant="plain"
:key="i"
variant="plain"
@click="item.props.click"
>
<template #prepend>
<VIcon :icon="item.props.prependIcon"></VIcon>
<VIcon :icon="item.props.prependIcon" />
</template>
<VListItemTitle v-text="item.title"></VListItemTitle>
<VListItemTitle v-text="item.title" />
</VListItem>
</VList>
</VMenu>
@@ -177,23 +201,28 @@ const dropdownItems = ref([
{{ torrent?.title }}
</VCardText>
<VCardText>{{ torrent?.description }}</VCardText>
<VCardItem class="pb-3 pt-0 pe-12" v-if="torrent?.labels">
<VCardItem
v-if="torrent?.labels"
class="pb-3 pt-0 pe-12"
>
<VChip
v-for="(label, index) in torrent?.labels"
:key="index"
variant="elevated"
size="small"
v-for="label in torrent?.labels"
color="primary"
class="me-1 mb-1"
>{{ label }}</VChip
>
{{ label }}
</VChip>
<VChip
v-if="meta?.edition"
variant="elevated"
size="small"
class="me-1 mb-1 text-white bg-red-500"
>
{{ meta?.edition }}</VChip
>
{{ meta?.edition }}
</VChip>
<VChip
v-if="meta?.resource_pix"
variant="elevated"
@@ -240,26 +269,27 @@ const dropdownItems = ref([
</VCardItem>
<VCardActions>
<VBtn
@click.stop="showMoreTorrents = !showMoreTorrents"
v-if="props.more && props.more.length > 0"
@click.stop="showMoreTorrents = !showMoreTorrents"
>
<template #append>
<VIcon :icon="showMoreTorrents ? 'mdi-chevron-up' : 'mdi-chevron-down'"></VIcon>
<VIcon :icon="showMoreTorrents ? 'mdi-chevron-up' : 'mdi-chevron-down'" />
</template>
更多来源
</VBtn>
</VCardActions>
<VExpandTransition>
<div v-show="showMoreTorrents">
<VDivider></VDivider>
<VDivider />
<VChipGroup class="p-3">
<VChip
v-for="item in props.more"
v-for="(item, index) in props.more"
:key="index"
@click.stop="
handleAddDownload(
item.torrent_info?.site_name,
item.media_info,
item.torrent_info
item.torrent_info,
)
"
>
@@ -269,17 +299,16 @@ const dropdownItems = ref([
:content="`↑${item.torrent_info?.seeders}`"
inline
size="small"
></VBadge>
/>
<VBadge
v-if="
item.torrent_info?.downloadvolumefactor !== 1
|| item.torrent_info?.uploadvolumefactor !== 1
"
:content="item.torrent_info?.volume_factor"
inline
size="small"
v-if="
item.torrent_info?.downloadvolumefactor !== 1 ||
item.torrent_info?.uploadvolumefactor !== 1
"
>
</VBadge>
/>
</template>
{{ item.torrent_info.site_name }}
</VChip>