From 5e87a1776521a3ac1036728e44e752af664eb89d Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Wed, 17 Jun 2026 05:00:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(bug-collect):=20=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=96=B0=E5=A2=9E=E5=BA=94=E7=94=A8=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=EF=BC=8CAPI=20=E8=B0=83=E7=94=A8=E8=A1=A5?= =?UTF-8?q?=E5=85=85=20appKey=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tenant-platform/src/api/bugcollect.ts | 29 +++++------ .../src/composables/useBugCollectApp.ts | 48 +++++++++++++++++++ .../src/views/apps/AppDetailView.vue | 4 +- .../views/bug-collect/BugCollectEvents.vue | 24 +++++++++- .../views/bug-collect/BugCollectFunnels.vue | 24 +++++++++- .../views/bug-collect/BugCollectIssues.vue | 24 +++++++++- .../views/bug-collect/BugCollectOverview.vue | 24 +++++++++- .../views/bug-collect/BugCollectRankFreq.vue | 24 +++++++++- .../views/bug-collect/BugCollectRankRisk.vue | 24 +++++++++- .../views/bug-collect/BugCollectWebhooks.vue | 26 +++++++++- 10 files changed, 227 insertions(+), 24 deletions(-) create mode 100644 tenant-platform/src/composables/useBugCollectApp.ts diff --git a/tenant-platform/src/api/bugcollect.ts b/tenant-platform/src/api/bugcollect.ts index 3fd6449..f06a6b5 100644 --- a/tenant-platform/src/api/bugcollect.ts +++ b/tenant-platform/src/api/bugcollect.ts @@ -88,10 +88,11 @@ export interface BugCollectPageResult { export const bugCollectApi = { // Overview - overview: () => client.get<{ data: BugCollectOverview }>('/bugcollect/v1/overview'), + overview: (appKey: string) => + client.get<{ data: BugCollectOverview }>('/bugcollect/v1/overview', { params: { appKey } }), // Issues - issues(params: { + issues(appKey: string, params: { type?: string platform?: string startDate?: string @@ -99,7 +100,7 @@ export const bugCollectApi = { page?: number size?: number }) { - return client.get<{ data: BugCollectPageResult }>('/bugcollect/v1/issues', { params }) + return client.get<{ data: BugCollectPageResult }>('/bugcollect/v1/issues', { params: { appKey, ...params } }) }, issueDetail(id: string) { @@ -107,16 +108,16 @@ export const bugCollectApi = { }, // Rankings - frequencyRanking() { - return client.get<{ data: BugCollectIssueRanking[] }>('/bugcollect/v1/issues/rankings/frequency') + frequencyRanking(appKey: string) { + return client.get<{ data: BugCollectIssueRanking[] }>('/bugcollect/v1/issues/rankings/frequency', { params: { appKey } }) }, - riskRanking() { - return client.get<{ data: BugCollectIssueRanking[] }>('/bugcollect/v1/issues/rankings/risk') + riskRanking(appKey: string) { + return client.get<{ data: BugCollectIssueRanking[] }>('/bugcollect/v1/issues/rankings/risk', { params: { appKey } }) }, // Events - events(params: { + events(appKey: string, params: { eventName?: string userId?: string startDate?: string @@ -124,21 +125,21 @@ export const bugCollectApi = { page?: number size?: number }) { - return client.get<{ data: BugCollectPageResult }>('/bugcollect/v1/events', { params }) + return client.get<{ data: BugCollectPageResult }>('/bugcollect/v1/events', { params: { appKey, ...params } }) }, // Funnel - funnel(steps: string[]) { + funnel(appKey: string, steps: string[]) { return client.get<{ data: BugCollectFunnelStep[] }>('/bugcollect/v1/events/funnel', { - params: { steps: steps.join(',') }, + params: { appKey, steps: steps.join(',') }, }) }, // Webhooks webhooks: { - list: () => client.get<{ data: BugCollectWebhook[] }>('/bugcollect/v1/webhooks'), - create: (data: Omit) => - client.post<{ data: BugCollectWebhook }>('/bugcollect/v1/webhooks', data), + list: (appKey: string) => client.get<{ data: BugCollectWebhook[] }>('/bugcollect/v1/webhooks', { params: { appKey } }), + create: (appKey: string, data: Omit) => + client.post<{ data: BugCollectWebhook }>('/bugcollect/v1/webhooks', data, { params: { appKey } }), update: (id: string, data: Partial>) => client.put<{ data: BugCollectWebhook }>(`/bugcollect/v1/webhooks/${id}`, data), delete: (id: string) => client.delete(`/bugcollect/v1/webhooks/${id}`), diff --git a/tenant-platform/src/composables/useBugCollectApp.ts b/tenant-platform/src/composables/useBugCollectApp.ts new file mode 100644 index 0000000..77218f4 --- /dev/null +++ b/tenant-platform/src/composables/useBugCollectApp.ts @@ -0,0 +1,48 @@ +import { ref, computed, onMounted } from 'vue' +import { useRoute, useRouter } from 'vue-router' +import { appApi, type App } from '@/api/app' + +const STORAGE_KEY = 'bugcollect_selected_app_key' + +export function useBugCollectApp() { + const route = useRoute() + const router = useRouter() + const apps = ref([]) + const loadingApps = ref(false) + const selectedAppKey = ref(localStorage.getItem(STORAGE_KEY) ?? '') + + const appKey = computed(() => { + const q = route.query.appKey + if (typeof q === 'string' && q.trim()) return q.trim() + return selectedAppKey.value + }) + + async function loadApps() { + loadingApps.value = true + try { + const res = await appApi.list() + apps.value = res.data.data ?? [] + } catch { + apps.value = [] + } finally { + loadingApps.value = false + } + } + + function setApp(key: string) { + selectedAppKey.value = key + localStorage.setItem(STORAGE_KEY, key) + router.replace({ query: { ...route.query, appKey: key } }) + } + + onMounted(() => { + const q = route.query.appKey + if (typeof q === 'string' && q.trim()) { + selectedAppKey.value = q.trim() + localStorage.setItem(STORAGE_KEY, q.trim()) + } + loadApps() + }) + + return { apps, loadingApps, appKey, setApp } +} diff --git a/tenant-platform/src/views/apps/AppDetailView.vue b/tenant-platform/src/views/apps/AppDetailView.vue index 47ae931..1348f84 100644 --- a/tenant-platform/src/views/apps/AppDetailView.vue +++ b/tenant-platform/src/views/apps/AppDetailView.vue @@ -196,10 +196,10 @@
diff --git a/tenant-platform/src/views/bug-collect/BugCollectEvents.vue b/tenant-platform/src/views/bug-collect/BugCollectEvents.vue index 3e82480..ee240ab 100644 --- a/tenant-platform/src/views/bug-collect/BugCollectEvents.vue +++ b/tenant-platform/src/views/bug-collect/BugCollectEvents.vue @@ -2,6 +2,22 @@

事件流水

+ +
+ 选择应用 + + + +
+ +