Skip to content

Commit ec894a1

Browse files
committed
refactor(api): Optimize service and application details interface parameter transmission
1 parent 4d17607 commit ec894a1

5 files changed

Lines changed: 18 additions & 16 deletions

File tree

ui-vue3/src/api/mock/mockApp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ Mock.mock(devTool.mockUrl('/mock/application/instance/info'), 'get', () => {
151151
}
152152
})
153153

154-
Mock.mock(devTool.mockUrl('/mock/application/detail'), 'get', () => {
154+
Mock.mock(devTool.mockUrl('/application/detail'), 'get', () => {
155155
return {
156-
code: 200,
156+
code: 'Success',
157157
msg: 'success',
158158
data: {
159159
appName: Mock.mock('@word(10,20)'),

ui-vue3/src/api/service/app.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ export const searchApplications = (params: any): Promise<any> => {
2525
})
2626
}
2727

28-
export const getApplicationDetail = (params: any): Promise<any> => {
28+
export const getApplicationDetail = (appName: string): Promise<any> => {
2929
return request({
3030
url: '/application/detail',
3131
method: 'get',
32-
params
32+
params: {
33+
appName
34+
}
3335
})
3436
}
3537

ui-vue3/src/api/service/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const searchService = (params: any): Promise<any> => {
2626
})
2727
}
2828

29-
export const getServiceDetail = (params: any): Promise<any> => {
29+
export const getServiceDetail = (serviceName: string): Promise<any> => {
3030
return request({
3131
url: '/service/detail',
3232
method: 'get',
33-
params
33+
params: { serviceName }
3434
})
3535
}
3636

ui-vue3/src/views/resources/applications/tabs/topology.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const renderTopology = (graphData: any) => {
243243
244244
detailLoading.value = true
245245
try {
246-
const res = await getApplicationDetail({ appName })
246+
const res = await getApplicationDetail(appName)
247247
if (res?.code !== HTTP_STATUS.SUCCESS) {
248248
detailError.value = String(res?.message ?? '请求失败')
249249
detailData.value = {}

ui-vue3/src/views/resources/services/tabs/topology.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import { PRIMARY_COLOR } from '@/base/constants'
5656
import { HTTP_STATUS } from '@/base/http/constants'
5757
import { getServiceDetail, getServiceGraph } from '@/api/service/service'
58+
import { getApplicationDetail } from '@/api/service/app'
5859
import { computed, defineComponent, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
5960
import type { PropType } from 'vue'
6061
import { VueNode } from 'g6-extension-vue'
@@ -224,7 +225,6 @@ const buildGraphData = (raw: any) => {
224225
225226
return { nodes, edges }
226227
}
227-
228228
const renderTopology = (graphData: any) => {
229229
const root = document.getElementById('topology')
230230
if (!root) return
@@ -270,12 +270,6 @@ const renderTopology = (graphData: any) => {
270270
const handleNodeClick = async (e: any) => {
271271
const serviceName = String(e?.target?.id ?? '')
272272
const nodeData: any = serviceName ? graphRef.value?.getNodeData(serviceName) : undefined
273-
const params = {
274-
serviceName: serviceName,
275-
side: nodeData?.rule ?? 'provider',
276-
version: route.params?.version || '',
277-
group: route.params?.group || ''
278-
}
279273
280274
if (!serviceName) return
281275
@@ -284,7 +278,7 @@ const renderTopology = (graphData: any) => {
284278
currentDetailKey.value = serviceName
285279
detailError.value = ''
286280
287-
const cacheKey = `${serviceName}|${params.side}|${params.version}|${params.group}`
281+
const cacheKey = `${serviceName}`
288282
const cached = detailCache.get(cacheKey)
289283
if (cached) {
290284
detailData.value = cached
@@ -294,7 +288,13 @@ const renderTopology = (graphData: any) => {
294288
295289
detailLoading.value = true
296290
try {
297-
const res = await getServiceDetail(params)
291+
let res
292+
if (nodeData.type === 'application') {
293+
res = await getApplicationDetail(nodeData.id)
294+
} else if (nodeData.type === 'service') {
295+
res = await getServiceDetail(nodeData.id)
296+
}
297+
console.log('res', res)
298298
if (res?.code !== HTTP_STATUS.SUCCESS) {
299299
detailError.value = String(res?.message ?? '请求失败')
300300
detailData.value = {}

0 commit comments

Comments
 (0)