From d870b788bcf542dbcd7803119c90e9b29699e61a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 25 May 2026 18:16:35 +0800 Subject: [PATCH] feat: add usage version statistics dialog --- src/components/dialog/AboutDialog.vue | 144 +++++++++++++++++++++ src/locales/en-US.ts | 15 +++ src/locales/zh-CN.ts | 14 ++ src/locales/zh-TW.ts | 14 ++ src/views/setting/AccountSettingSystem.vue | 9 ++ 5 files changed, 196 insertions(+) diff --git a/src/components/dialog/AboutDialog.vue b/src/components/dialog/AboutDialog.vue index 2df3a26d..0ab5de2a 100644 --- a/src/components/dialog/AboutDialog.vue +++ b/src/components/dialog/AboutDialog.vue @@ -84,6 +84,24 @@ const releaseDialogTitle = ref('') // 变更日志对话框内容 const releaseDialogBody = ref('') +// 版本统计对话框 +const versionStatisticDialog = ref(false) + +// 版本统计加载状态 +const versionStatisticLoading = ref(false) + +// 版本统计数据 +const versionStatistic = ref({}) + +// 后端版本统计 +const backendVersionStatistics = computed(() => versionStatistic.value?.backend_versions ?? []) + +// 前端版本统计 +const frontendVersionStatistics = computed(() => versionStatistic.value?.frontend_versions ?? []) + +// 活跃用户统计 +const activeUsers = computed(() => versionStatistic.value?.active_users ?? {}) + // 打开日志对话框 function showReleaseDialog(title: string, body: string) { releaseDialogTitle.value = title @@ -91,6 +109,28 @@ function showReleaseDialog(title: string, body: string) { releaseDialog.value = true } +// 查询版本统计 +async function queryVersionStatistic() { + if (!systemEnv.value.USAGE_STATISTIC_SHARE) return + versionStatisticLoading.value = true + try { + const result: { [key: string]: any } = await api.get('system/usage/statistic') + + versionStatistic.value = result.data ?? {} + } catch (error) { + console.log(error) + versionStatistic.value = {} + } finally { + versionStatisticLoading.value = false + } +} + +// 打开版本统计对话框 +async function showVersionStatisticDialog() { + versionStatisticDialog.value = true + await queryVersionStatistic() +} + // 查询系统环境变量 async function querySystemEnv() { try { @@ -182,6 +222,18 @@ onMounted(() => { {{ t('setting.about.latest') }} + + + @@ -406,6 +458,86 @@ onMounted(() => { + + + + + + + {{ t('setting.about.versionStatisticTitle') }} + + + + + +
+
+
{{ t('setting.about.totalInstallUsers') }}
+
{{ versionStatistic.total_users ?? 0 }}
+
+
+
{{ t('setting.about.activeToday') }}
+
{{ activeUsers.today ?? 0 }}
+
+
+
{{ t('setting.about.active7Days') }}
+
{{ activeUsers.last_7_days ?? 0 }}
+
+
+
{{ t('setting.about.active30Days') }}
+
{{ activeUsers.last_30_days ?? 0 }}
+
+
+
+
{{ t('setting.about.backendVersionStatistic') }}
+ + + + {{ t('setting.about.version') }} + {{ t('setting.about.users') }} + + + + + + {{ item.version }} + + {{ item.count }} + + + {{ t('setting.about.noVersionStatisticData') }} + + + +
+
+
{{ t('setting.about.frontendVersionStatistic') }}
+ + + + {{ t('setting.about.version') }} + {{ t('setting.about.users') }} + + + + + + {{ item.version }} + + {{ item.count }} + + + {{ t('setting.about.noVersionStatisticData') }} + + + +
+
+ {{ t('setting.about.lastUpdated') }}: {{ versionStatistic.updated_at }} +
+
+
+
@@ -422,6 +554,18 @@ onMounted(() => { margin-block: 0.5rem 2.5rem; } +.version-stat-summary { + display: grid; + gap: 1rem; + grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); +} + +.version-stat-number { + font-size: 1.5rem; + font-weight: 700; + line-height: 2rem; +} + .markdown-body :deep(h1), .markdown-body :deep(h2), .markdown-body :deep(h3) { diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 72cb7c3d..bbd6843c 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -1378,6 +1378,18 @@ export default { expand: 'Expand', collapse: 'Collapse', clearCache: 'Clear Cache', + versionStatistic: 'Version Statistics', + versionStatisticTitle: 'Installation Version Statistics', + totalInstallUsers: 'Install Users', + activeToday: 'Active Today', + active7Days: 'Active 7 Days', + active30Days: 'Active 30 Days', + backendVersionStatistic: 'Backend Versions', + frontendVersionStatistic: 'Frontend Versions', + version: 'Version', + users: 'Users', + lastUpdated: 'Updated At', + noVersionStatisticData: 'No statistics data', }, system: { custom: 'Custom', @@ -1561,6 +1573,9 @@ export default { 'Share subscription statistics to popular subscriptions for other MP users to reference', pluginStatisticShare: 'Report Plugin Installation Data', pluginStatisticShareHint: 'Report plugin installation data to the server for statistics and display purposes', + usageStatisticShare: 'Report Installation Version Statistics', + usageStatisticShareHint: + 'Report anonymous installation ID and current backend/frontend versions to count users by version', workflowStatisticShare: 'Share Workflow Data', workflowStatisticShareHint: 'Share workflow statistics to popular workflows for other MP users to reference', bigMemoryMode: 'Large Memory Mode', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index a87ed5f4..dae22b0f 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -1373,6 +1373,18 @@ export default { expand: '展开', collapse: '收起', clearCache: '清除缓存', + versionStatistic: '版本统计', + versionStatisticTitle: '安装版本统计', + totalInstallUsers: '安装用户', + activeToday: '今日活跃', + active7Days: '7日活跃', + active30Days: '30日活跃', + backendVersionStatistic: '后端版本', + frontendVersionStatistic: '前端版本', + version: '版本', + users: '用户数', + lastUpdated: '更新时间', + noVersionStatisticData: '暂无统计数据', }, system: { custom: '自定义', @@ -1545,6 +1557,8 @@ export default { subscribeStatisticShareHint: '分享订阅统计数据到热门订阅,供其他MPer参考', pluginStatisticShare: '上报插件安装数据', pluginStatisticShareHint: '上报插件安装数据给服务器,用于统计展示插件安装情况', + usageStatisticShare: '上报安装版本统计', + usageStatisticShareHint: '上报匿名安装ID和当前前后端版本,用于统计各版本安装用户数', workflowStatisticShare: '分享工作流数据', workflowStatisticShareHint: '分享工作流统计数据到热门工作流,供其他MPer参考', bigMemoryMode: '大内存模式', diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index 0a06539c..0e6f45ea 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -1374,6 +1374,18 @@ export default { expand: '展開', collapse: '收起', clearCache: '清除快取', + versionStatistic: '版本統計', + versionStatisticTitle: '安裝版本統計', + totalInstallUsers: '安裝用戶', + activeToday: '今日活躍', + active7Days: '7日活躍', + active30Days: '30日活躍', + backendVersionStatistic: '後端版本', + frontendVersionStatistic: '前端版本', + version: '版本', + users: '用戶數', + lastUpdated: '更新時間', + noVersionStatisticData: '暫無統計數據', }, system: { custom: '自定義', @@ -1546,6 +1558,8 @@ export default { subscribeStatisticShareHint: '分享訂閱統計數據到熱門訂閱,供其他MPer參考', pluginStatisticShare: '上報插件安裝數據', pluginStatisticShareHint: '上報插件安裝數據給服務器,用於統計展示插件安裝情況', + usageStatisticShare: '上報安裝版本統計', + usageStatisticShareHint: '上報匿名安裝ID和當前前後端版本,用於統計各版本安裝用戶數', workflowStatisticShare: '分享工作流數據', workflowStatisticShareHint: '分享工作流統計數據到熱門工作流,供其他MPer參考', bigMemoryMode: '大內存模式', diff --git a/src/views/setting/AccountSettingSystem.vue b/src/views/setting/AccountSettingSystem.vue index 66c77ed3..04958cc9 100644 --- a/src/views/setting/AccountSettingSystem.vue +++ b/src/views/setting/AccountSettingSystem.vue @@ -82,6 +82,7 @@ const SystemSettings = ref({ GLOBAL_IMAGE_CACHE: false, SUBSCRIBE_STATISTIC_SHARE: true, PLUGIN_STATISTIC_SHARE: true, + USAGE_STATISTIC_SHARE: true, WORKFLOW_STATISTIC_SHARE: true, BIG_MEMORY_MODE: false, DB_WAL_ENABLE: false, @@ -1767,6 +1768,14 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => { persistent-hint /> + + +