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 @@

事件流水

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