mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
插件仪表板支持自动刷新 & 仅管理员可见
This commit is contained in:
+16
-2
@@ -14,10 +14,14 @@ import api from '@/api'
|
|||||||
import { isNullOrEmptyObject } from '@/@core/utils'
|
import { isNullOrEmptyObject } from '@/@core/utils'
|
||||||
import { useDisplay } from 'vuetify'
|
import { useDisplay } from 'vuetify'
|
||||||
import { PluginDashboard } from '@/api/types'
|
import { PluginDashboard } from '@/api/types'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
// 显示器宽度
|
// 显示器宽度
|
||||||
const display = useDisplay()
|
const display = useDisplay()
|
||||||
|
|
||||||
|
// 从Vuex Store中获取superuser信息
|
||||||
|
const superUser = store.state.auth.superUser
|
||||||
|
|
||||||
// 从localStorage中获取数据
|
// 从localStorage中获取数据
|
||||||
const default_config = {
|
const default_config = {
|
||||||
mediaStatistic: true,
|
mediaStatistic: true,
|
||||||
@@ -76,6 +80,8 @@ function setDashboardConfig() {
|
|||||||
|
|
||||||
// 调用API获取有仪表板的插件
|
// 调用API获取有仪表板的插件
|
||||||
async function getDashboardPlugins() {
|
async function getDashboardPlugins() {
|
||||||
|
// 只有超级用户才能获取插件仪表板
|
||||||
|
if (!superUser) return
|
||||||
try {
|
try {
|
||||||
dashboard_plugins.value = await api.get('/plugin/dashboards')
|
dashboard_plugins.value = await api.get('/plugin/dashboards')
|
||||||
if (!isNullOrEmptyObject(dashboard_plugins.value)) {
|
if (!isNullOrEmptyObject(dashboard_plugins.value)) {
|
||||||
@@ -96,8 +102,16 @@ async function getDashboardPlugins() {
|
|||||||
// 获取一个插件的仪表板配置项
|
// 获取一个插件的仪表板配置项
|
||||||
async function getPluginDashboard(id: string) {
|
async function getPluginDashboard(id: string) {
|
||||||
try {
|
try {
|
||||||
api.get(`/plugin/dashboard/${id}`).then(res => {
|
api.get(`/plugin/dashboard/${id}`).then((res: any) => {
|
||||||
if (res) plugin_dashboards.value.push(res)
|
if (res) {
|
||||||
|
plugin_dashboards.value.push(res)
|
||||||
|
if (res.attrs?.refresh) {
|
||||||
|
// 定时刷新
|
||||||
|
setTimeout(() => {
|
||||||
|
getPluginDashboard(id)
|
||||||
|
}, res.attrs.refresh * 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|||||||
Reference in New Issue
Block a user