From 74dd549ffb0318ca5784c08761c58c3e51c78079 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 25 Mar 2024 18:31:55 +0800 Subject: [PATCH] plugin statistic --- src/components/cards/PluginAppCard.vue | 23 +++++++++++++++-------- src/views/plugin/PluginCardListView.vue | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/components/cards/PluginAppCard.vue b/src/components/cards/PluginAppCard.vue index b63e35e7..dfc1a632 100644 --- a/src/components/cards/PluginAppCard.vue +++ b/src/components/cards/PluginAppCard.vue @@ -10,6 +10,7 @@ const props = defineProps({ plugin: Object as PropType, width: String, height: String, + count: Number, }) // 定义触发的自定义事件 @@ -185,14 +186,20 @@ const dropdownItems = ref([ {{ props.plugin?.plugin_desc }} - - - {{ props.plugin?.plugin_author }} - + + + + {{ props.plugin?.plugin_author }} + + + + + {{ props.count?.toLocaleString() }} + diff --git a/src/views/plugin/PluginCardListView.vue b/src/views/plugin/PluginCardListView.vue index 7a94ed4d..c842d4f6 100644 --- a/src/views/plugin/PluginCardListView.vue +++ b/src/views/plugin/PluginCardListView.vue @@ -21,6 +21,9 @@ const isAppMarketLoaded = ref(false) // APP市场窗口 const PluginAppDialog = ref(false) +// 插件安装统计 +const PluginStatistics = ref<{ [key: string]: number }>({}) + // 延迟加载 let defer = (_: number) => true @@ -76,6 +79,16 @@ async function fetchUninstalledPlugins() { } } +// 加载插件统计数据 +async function getPluginStatistics() { + try { + PluginStatistics.value = await api.get('plugin/statistic') + } + catch (error) { + console.error(error) + } +} + // 加载所有数据 function refreshData() { fetchInstalledPlugins() @@ -92,6 +105,7 @@ const getUnupdatedPlugins = computed(() => { // 加载时获取数据 onBeforeMount(() => { refreshData() + getPluginStatistics() }) @@ -187,6 +201,7 @@ onBeforeMount(() => { v-if="defer(index)" :key="data.id" :plugin="data" + :count="PluginStatistics[data.id || '0']" @install="pluginInstalled" />