Skip to content

Commit

Permalink
feat:仪表盘不活跃时不刷新 && 网盘整理联动刮削
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Jun 24, 2024
1 parent 8efeb77 commit 6fad85e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moviepilot",
"version": "1.9.8",
"version": "1.9.8-1",
"private": true,
"bin": "dist/service.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialog/ReorganizeDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ onMounted(() => {
</VCol>
</VRow>
<VRow>
<VCol cols="12" md="6" v-if="props.storage == 'local'">
<VCol cols="12" md="6">
<VSwitch
v-model="transferForm.scrape"
label="刮削元数据"
Expand Down
14 changes: 10 additions & 4 deletions src/components/misc/DashboardElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ import MediaServerLibrary from '@/views/dashboard/MediaServerLibrary.vue'
import MediaServerPlaying from '@/views/dashboard/MediaServerPlaying.vue'
import DashboardRender from '@/components/render/DashboardRender.vue'
import { isNullOrEmptyObject } from '@/@core/utils'
// 输入参数
const props = defineProps({
// 仪表板配置
config: Object as PropType<DashboardItem>,
// 刷新状态
refreshStatus: Boolean,
// 是否允许刷新数据
allowRefresh: {
type: Boolean,
default: true,
},
})
const emit = defineEmits(['update:refreshStatus'])
Expand All @@ -32,10 +38,10 @@ onUnmounted(() => {
<AnalyticsStorage v-if="config?.id === 'storage'" />
<AnalyticsMediaStatistic v-else-if="config?.id === 'mediaStatistic'" />
<AnalyticsWeeklyOverview v-else-if="config?.id === 'weeklyOverview'" />
<AnalyticsSpeed v-else-if="config?.id === 'speed'" />
<AnalyticsScheduler v-else-if="config?.id === 'scheduler'" />
<AnalyticsCpu v-else-if="config?.id === 'cpu'" />
<AnalyticsMemory v-else-if="config?.id === 'memory'" />
<AnalyticsSpeed v-else-if="config?.id === 'speed'" :allowRefresh="props.allowRefresh" />
<AnalyticsScheduler v-else-if="config?.id === 'scheduler'" :allowRefresh="props.allowRefresh" />
<AnalyticsCpu v-else-if="config?.id === 'cpu'" :allowRefresh="props.allowRefresh" />
<AnalyticsMemory v-else-if="config?.id === 'memory'" :allowRefresh="props.allowRefresh" />
<MediaServerLibrary v-else-if="config?.id === 'library'" />
<MediaServerPlaying v-else-if="config?.id === 'playing'" />
<MediaServerLatest v-else-if="config?.id === 'latest'" />
Expand Down
15 changes: 14 additions & 1 deletion src/pages/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const superUser = store.state.auth.superUser
// 是否拉升高度
const isElevated = ref(true)
// 是否发送请求的总开关
const isRequest = ref(true)
// 计算属性,控制是否拉升高度
const elevatedConf = controlledComputed(
() => isElevated.value,
Expand Down Expand Up @@ -269,7 +272,8 @@ async function getPluginDashboard(id: string, key: string) {
if (
res.attrs?.refresh &&
pluginDashboardRefreshStatus.value[pluginDashboardId] &&
enableConfig.value[pluginDashboardId]
enableConfig.value[pluginDashboardId] &&
isRequest.value
) {
// 清除之前的定时器
if (refreshTimers.value[pluginDashboardId]) {
Expand Down Expand Up @@ -298,6 +302,14 @@ onBeforeMount(async () => {
await loadDashboardConfig()
getPluginDashboardMeta()
})
onActivated(async () => {
isRequest.value = true
})
onDeactivated(() => {
isRequest.value = false
})
</script>

<template>
Expand All @@ -314,6 +326,7 @@ onBeforeMount(async () => {
<VCol v-if="enableConfig[buildPluginDashboardId(element.id, element.key)] && element.cols" v-bind:="element.cols">
<DashboardElement
:config="element"
:allow-refresh="isRequest"
v-model:refreshStatus="pluginDashboardRefreshStatus[buildPluginDashboardId(element.id, element.key)]"
/>
</VCol>
Expand Down
10 changes: 10 additions & 0 deletions src/views/dashboard/AnalyticsCpu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { useTheme } from 'vuetify'
import { hexToRgb } from '@layouts/utils'
import api from '@/api'
// 输入参数
const props = defineProps({
// 是否允许刷新数据
allowRefresh: {
type: Boolean,
default: true,
},
})
const vuetifyTheme = useTheme()
const currentTheme = controlledComputed(
Expand Down Expand Up @@ -94,6 +103,7 @@ const chartOptions = controlledComputed(
// 调用API接口获取最新CPU使用率
async function getCpuUsage() {
if (!props.allowRefresh) return
try {
// 请求数据
current.value = (await api.get('dashboard/cpu')) ?? 0
Expand Down
10 changes: 10 additions & 0 deletions src/views/dashboard/AnalyticsMemory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import { hexToRgb } from '@layouts/utils'
import api from '@/api'
import { formatBytes } from '@/@core/utils/formatters'
// 输入参数
const props = defineProps({
// 是否允许刷新数据
allowRefresh: {
type: Boolean,
default: true,
},
})
const vuetifyTheme = useTheme()
const currentTheme = controlledComputed(
Expand Down Expand Up @@ -100,6 +109,7 @@ const chartOptions = controlledComputed(
// 调用API接口获取最新内存使用量
async function getMemorgUsage() {
if (!props.allowRefresh) return
try {
// 请求数据
;[usedMemory.value, memoryUsage.value] = await api.get('dashboard/memory')
Expand Down
12 changes: 12 additions & 0 deletions src/views/dashboard/AnalyticsScheduler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
import api from '@/api'
import type { ScheduleInfo } from '@/api/types'
// 输入参数
const props = defineProps({
// 是否允许刷新数据
allowRefresh: {
type: Boolean,
default: true,
},
})
// 定时服务列表
const schedulerList = ref<ScheduleInfo[]>([])
Expand All @@ -10,6 +19,9 @@ let refreshTimer: NodeJS.Timeout | null = null
// 调用API加载定时服务列表
async function loadSchedulerList() {
if (!props.allowRefresh) {
return
}
try {
const res: ScheduleInfo[] = await api.get('dashboard/schedule')
Expand Down
13 changes: 13 additions & 0 deletions src/views/dashboard/AnalyticsSpeed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { formatFileSize } from '@/@core/utils/formatters'
import api from '@/api'
import type { DownloaderInfo } from '@/api/types'
// 输入参数
const props = defineProps({
// 是否允许刷新数据
allowRefresh: {
type: Boolean,
default: true,
},
})
// 定时器
let refreshTimer: NodeJS.Timeout | null = null
Expand Down Expand Up @@ -35,6 +44,10 @@ const infoItems = ref([
// 调用API查询下载器数据
async function loadDownloaderInfo() {
if (!props.allowRefresh) {
return
}
try {
const res: DownloaderInfo = await api.get('dashboard/downloader')
Expand Down

0 comments on commit 6fad85e

Please sign in to comment.