plugin statistic

This commit is contained in:
jxxghp
2024-03-25 18:31:58 +08:00
parent 4d8f369ba0
commit 74dd549ffb
2 changed files with 30 additions and 8 deletions
+15 -8
View File
@@ -10,6 +10,7 @@ const props = defineProps({
plugin: Object as PropType<Plugin>, plugin: Object as PropType<Plugin>,
width: String, width: String,
height: String, height: String,
count: Number,
}) })
// 定义触发的自定义事件 // 定义触发的自定义事件
@@ -185,14 +186,20 @@ const dropdownItems = ref([
{{ props.plugin?.plugin_desc }} {{ props.plugin?.plugin_desc }}
</VCardText> </VCardText>
<VCardText class="flex items-center justify-start pb-2"> <VCardText class="flex items-center justify-start pb-2">
<VIcon icon="mdi-account" class="me-1" /> <span>
<a <VIcon icon="mdi-account" class="me-1" />
:href="props.plugin?.author_url" <a
target="_blank" :href="props.plugin?.author_url"
@click.stop target="_blank"
> @click.stop
{{ props.plugin?.plugin_author }} >
</a> {{ props.plugin?.plugin_author }}
</a>
</span>
<span v-if="props.count" class="ms-3">
<VIcon icon="mdi-download" class="me-1" />
{{ props.count?.toLocaleString() }}
</span>
</VCardText> </VCardText>
</VCard> </VCard>
<!-- 安装插件进度框 --> <!-- 安装插件进度框 -->
+15
View File
@@ -21,6 +21,9 @@ const isAppMarketLoaded = ref(false)
// APP市场窗口 // APP市场窗口
const PluginAppDialog = ref(false) const PluginAppDialog = ref(false)
// 插件安装统计
const PluginStatistics = ref<{ [key: string]: number }>({})
// 延迟加载 // 延迟加载
let defer = (_: number) => true 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() { function refreshData() {
fetchInstalledPlugins() fetchInstalledPlugins()
@@ -92,6 +105,7 @@ const getUnupdatedPlugins = computed(() => {
// 加载时获取数据 // 加载时获取数据
onBeforeMount(() => { onBeforeMount(() => {
refreshData() refreshData()
getPluginStatistics()
}) })
</script> </script>
@@ -187,6 +201,7 @@ onBeforeMount(() => {
v-if="defer(index)" v-if="defer(index)"
:key="data.id" :key="data.id"
:plugin="data" :plugin="data"
:count="PluginStatistics[data.id || '0']"
@install="pluginInstalled" @install="pluginInstalled"
/> />
</div> </div>