mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
fix downloader
This commit is contained in:
@@ -466,3 +466,18 @@ export interface Process {
|
|||||||
// 进程内存占用
|
// 进程内存占用
|
||||||
memory: number,
|
memory: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 下载器信息
|
||||||
|
export interface DownloaderInfo {
|
||||||
|
// 下载速度
|
||||||
|
download_speed: number
|
||||||
|
// 上传速度
|
||||||
|
upload_speed: number
|
||||||
|
// 下载量
|
||||||
|
download_size: number
|
||||||
|
// 上传量
|
||||||
|
upload_size: number
|
||||||
|
// 剩余空间
|
||||||
|
free_space:number
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import VueApexCharts from 'vue3-apexcharts'
|
|
||||||
import { useTheme } from 'vuetify'
|
|
||||||
|
|
||||||
const vuetifyTheme = useTheme()
|
|
||||||
|
|
||||||
const currentTheme = controlledComputed(() => vuetifyTheme.name.value, () => vuetifyTheme.current.value.colors)
|
|
||||||
|
|
||||||
const series = [
|
|
||||||
{
|
|
||||||
name: '2020',
|
|
||||||
data: [45, 85, 65, 50, 70],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const chartOptions = controlledComputed(() => vuetifyTheme.name.value, () => {
|
|
||||||
const backgroundColor = currentTheme.value.background
|
|
||||||
|
|
||||||
return {
|
|
||||||
chart: {
|
|
||||||
type: 'bar',
|
|
||||||
stacked: false,
|
|
||||||
parentHeightOffset: 0,
|
|
||||||
toolbar: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
show: false,
|
|
||||||
padding: {
|
|
||||||
top: -10,
|
|
||||||
left: -7,
|
|
||||||
right: 0,
|
|
||||||
bottom: 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
colors: [currentTheme.value.error, currentTheme.value.primary, currentTheme.value.error, currentTheme.value.primary, currentTheme.value.primary],
|
|
||||||
plotOptions: {
|
|
||||||
bar: {
|
|
||||||
horizontal: false,
|
|
||||||
columnWidth: '20%',
|
|
||||||
borderRadius: 4,
|
|
||||||
startingShape: 'rounded',
|
|
||||||
endingShape: 'rounded',
|
|
||||||
distributed: true,
|
|
||||||
colors: {
|
|
||||||
backgroundBarColors: [backgroundColor, backgroundColor, backgroundColor, backgroundColor, backgroundColor],
|
|
||||||
backgroundBarRadius: 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
legend: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
dataLabels: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
xaxis: {
|
|
||||||
labels: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
axisBorder: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
axisTicks: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
yaxis: {
|
|
||||||
show: false,
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<VCard>
|
|
||||||
<VCardText>
|
|
||||||
<h6 class="text-h6">
|
|
||||||
2,856
|
|
||||||
</h6>
|
|
||||||
|
|
||||||
<VueApexCharts
|
|
||||||
:options="chartOptions"
|
|
||||||
:series="series"
|
|
||||||
:height="95"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<p class="text-center font-weight-medium mb-0">
|
|
||||||
Sessions
|
|
||||||
</p>
|
|
||||||
</VCardText>
|
|
||||||
</VCard>
|
|
||||||
</template>
|
|
||||||
@@ -1,21 +1,76 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const earnings = [
|
import { formatFileSize } from "@/@core/utils/formatters";
|
||||||
|
import api from "@/api";
|
||||||
|
import { DownloaderInfo } from "@/api/types";
|
||||||
|
|
||||||
|
// 定时器
|
||||||
|
let refreshTimer: NodeJS.Timer | null = null;
|
||||||
|
|
||||||
|
// 下载器信息
|
||||||
|
const downloadInfo = ref<DownloaderInfo>({
|
||||||
|
// 下载速度
|
||||||
|
download_speed: 0,
|
||||||
|
// 上传速度
|
||||||
|
upload_speed: 0,
|
||||||
|
// 下载量
|
||||||
|
download_size: 0,
|
||||||
|
// 上传量
|
||||||
|
upload_size: 0,
|
||||||
|
// 剩余空间
|
||||||
|
free_space: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 显示项
|
||||||
|
const infoItems = ref([
|
||||||
{
|
{
|
||||||
avatar: "mdi-upload",
|
avatar: "",
|
||||||
title: "总上传量",
|
title: "",
|
||||||
amount: "193 GB",
|
amount: "",
|
||||||
},
|
},
|
||||||
{
|
]);
|
||||||
avatar: "mdi-download",
|
|
||||||
title: "总下载量",
|
// 调用API查询下载器数据
|
||||||
amount: "12,235 GB",
|
const loadDownloaderInfo = async () => {
|
||||||
},
|
try {
|
||||||
{
|
const res: DownloaderInfo = await api.get("dashboard/downloader");
|
||||||
avatar: "mdi-content-save",
|
downloadInfo.value = res;
|
||||||
title: "磁盘剩余空间",
|
infoItems.value = [
|
||||||
amount: "1.24 TB",
|
{
|
||||||
},
|
avatar: "mdi-upload",
|
||||||
];
|
title: "总上传量",
|
||||||
|
amount: formatFileSize(res.upload_size),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
avatar: "mdi-download",
|
||||||
|
title: "总下载量",
|
||||||
|
amount: formatFileSize(res.download_size),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
avatar: "mdi-content-save",
|
||||||
|
title: "磁盘剩余空间",
|
||||||
|
amount: formatFileSize(res.free_space),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadDownloaderInfo();
|
||||||
|
// 启动定时器
|
||||||
|
refreshTimer = setInterval(() => {
|
||||||
|
loadDownloaderInfo();
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 组件卸载时停止定时器
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (refreshTimer) {
|
||||||
|
clearInterval(refreshTimer);
|
||||||
|
refreshTimer = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -33,24 +88,24 @@ const earnings = [
|
|||||||
<VCardText class="pt-4">
|
<VCardText class="pt-4">
|
||||||
<div class="d-flex align-center">
|
<div class="d-flex align-center">
|
||||||
<h4 class="text-h4 me-2">
|
<h4 class="text-h4 me-2">
|
||||||
↑21 KB/s <br />
|
↑{{ formatFileSize(downloadInfo.upload_speed) }}/s <br />
|
||||||
↓24,895 KB/s
|
↓{{ formatFileSize(downloadInfo.download_speed) }}/s
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<VList class="card-list mt-9">
|
<VList class="card-list mt-9">
|
||||||
<VListItem v-for="earning in earnings" :key="earning.title">
|
<VListItem v-for="item in infoItems" :key="item.title">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<VIcon rounded :icon="earning.avatar" />
|
<VIcon rounded :icon="item.avatar" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<VListItemTitle class="text-sm font-weight-medium mb-1">
|
<VListItemTitle class="text-sm font-weight-medium mb-1">
|
||||||
{{ earning.title }}
|
{{ item.title }}
|
||||||
</VListItemTitle>
|
</VListItemTitle>
|
||||||
|
|
||||||
<template #append>
|
<template #append>
|
||||||
<div>
|
<div>
|
||||||
<h6 class="text-sm font-weight-medium mb-2">
|
<h6 class="text-sm font-weight-medium mb-2">
|
||||||
{{ earning.amount }}
|
{{ item.amount }}
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user