@@ -10,8 +10,8 @@ import { ElTree, ElMessage } from 'element-plus'
10
10
import type { FormInstance , FormRules } from ' element-plus'
11
11
import { Edit , Share } from ' @element-plus/icons-vue'
12
12
import type { Suite } from ' ./types'
13
+ import { API } from ' ./views/net'
13
14
import { Cache } from ' ./views/cache'
14
- import { DefaultResponseProcess } from ' ./views/net'
15
15
import { useI18n } from ' vue-i18n'
16
16
import ClientMonitor from ' skywalking-client-js'
17
17
import { name , version } from ' ../package'
@@ -48,18 +48,7 @@ const handleNodeClick = (data: Tree) => {
48
48
testSuiteKind .value = data .kind
49
49
Cache .SetCurrentStore (data .store )
50
50
51
- const requestOptions = {
52
- method: ' POST' ,
53
- headers: {
54
- ' X-Store-Name' : data .store
55
- },
56
- body: JSON .stringify ({
57
- name: data .label
58
- })
59
- }
60
- fetch (' /server.Runner/ListTestCase' , requestOptions )
61
- .then ((response ) => response .json ())
62
- .then ((d ) => {
51
+ API .ListTestCase (data .label , data .store , (d ) => {
63
52
if (d .items && d .items .length > 0 ) {
64
53
data .children = []
65
54
d .items .forEach ((item : any ) => {
@@ -73,7 +62,7 @@ const handleNodeClick = (data: Tree) => {
73
62
} as Tree )
74
63
})
75
64
}
76
- })
65
+ })
77
66
} else {
78
67
Cache .SetCurrentStore (data .store )
79
68
Cache .SetLastTestCaseLocation (data .parentID , data .id )
@@ -133,13 +122,16 @@ interface Store {
133
122
}
134
123
135
124
const stores = ref ([] as Store [])
125
+ const storesLoading = ref (false )
136
126
function loadStores() {
127
+ storesLoading .value = true
137
128
const requestOptions = {
138
129
method: ' POST' ,
139
130
}
140
131
fetch (' /server.Runner/GetStores' , requestOptions )
141
132
.then ((response ) => response .json ())
142
133
.then (async (d ) => {
134
+ storesLoading .value = false
143
135
stores .value = d .data
144
136
data .value = [] as Tree []
145
137
Cache .SetStores (d .data )
@@ -227,21 +219,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
227
219
if (valid ) {
228
220
suiteCreatingLoading .value = true
229
221
230
- const requestOptions = {
231
- method: ' POST' ,
232
- headers: {
233
- ' X-Store-Name' : testSuiteForm .store
234
- },
235
- body: JSON .stringify ({
236
- name: testSuiteForm .name ,
237
- api: testSuiteForm .api ,
238
- kind: testSuiteForm .kind
239
- })
240
- }
241
-
242
- fetch (' /server.Runner/CreateTestSuite' , requestOptions )
243
- .then (DefaultResponseProcess ())
244
- .then ((e ) => {
222
+ API .CreateTestSuite (testSuiteForm , (e ) => {
245
223
suiteCreatingLoading .value = false
246
224
if (e .error !== " " ) {
247
225
ElMessage .error (' Oops, ' + e .error )
@@ -272,23 +250,11 @@ const importSuiteFormSubmit = async (formEl: FormInstance | undefined) => {
272
250
if (valid ) {
273
251
suiteCreatingLoading .value = true
274
252
275
- const requestOptions = {
276
- method: ' POST' ,
277
- headers: {
278
- ' X-Store-Name' : importSuiteForm .store
279
- },
280
- body: JSON .stringify ({
281
- url: importSuiteForm .url
282
- })
283
- }
284
-
285
- fetch (' /server.Runner/ImportTestSuite' , requestOptions )
286
- .then ((response ) => response .json ())
287
- .then (() => {
288
- loadStores ()
289
- importDialogVisible .value = false
290
- formEl .resetFields ()
291
- })
253
+ API .ImportTestSuite (importSuiteForm , () => {
254
+ loadStores ()
255
+ importDialogVisible .value = false
256
+ formEl .resetFields ()
257
+ })
292
258
}
293
259
})
294
260
}
@@ -325,6 +291,11 @@ const suiteKinds = [{
325
291
}, {
326
292
" name" : " tRPC" ,
327
293
}]
294
+
295
+ const appVersion = ref (' ' )
296
+ API .GetVersion ((d ) => {
297
+ appVersion .value = d .message
298
+ })
328
299
</script >
329
300
330
301
<template >
@@ -340,7 +311,7 @@ const suiteKinds = [{
340
311
341
312
<el-main >
342
313
<el-container style =" height : 100% " >
343
- <el-aside width = " 200px " >
314
+ <el-aside >
344
315
<el-button type =" primary" @click =" openTestSuiteCreateDialog"
345
316
data-intro =" Click here to create a new test suite"
346
317
test-id =" open-new-suite-dialog" :icon =" Edit" >{{ t('button.new') }}</el-button >
@@ -350,6 +321,7 @@ const suiteKinds = [{
350
321
<el-input v-model =" filterText" placeholder =" Filter keyword" test-id =" search" />
351
322
352
323
<el-tree
324
+ v-loading =" storesLoading"
353
325
:data =data
354
326
highlight-current
355
327
:check-on-click-node =" true"
@@ -361,8 +333,6 @@ const suiteKinds = [{
361
333
@node-click =" handleNodeClick"
362
334
data-intro =" This is the test suite tree. You can click the test suite to edit it."
363
335
/>
364
-
365
- <TemplateFunctions />
366
336
</el-aside >
367
337
368
338
<el-main >
@@ -392,6 +362,10 @@ const suiteKinds = [{
392
362
</el-main >
393
363
</el-container >
394
364
</el-main >
365
+ <div style =" position : absolute ; bottom : 0px ; right : 10px ;" >
366
+ <a href =" https://github.com/LinuxSuRen/api-testing" target =" _blank" rel =" noopener" >{{appVersion}}</a >
367
+ </div >
368
+ <TemplateFunctions />
395
369
</el-container >
396
370
</div >
397
371
0 commit comments