|
1 | 1 | <template> |
2 | | - <div class="common-layout" data-title="Welcome!" data-intro="Welcome to use api-testing! 👋"> |
3 | | - <el-container style="height: 100%"> |
4 | | - <el-main style="padding-top: 5px; padding-bottom: 5px;"> |
5 | | - <el-container style="height: 100%"> |
6 | | - <el-aside> |
7 | | - <el-button type="primary" @click="openTestSuiteCreateDialog" |
8 | | - data-intro="Click here to create a new test suite" test-id="open-new-suite-dialog" :icon="Edit">{{ |
9 | | - t('button.new') }}</el-button> |
10 | | - <el-button type="primary" @click="openTestSuiteImportDialog" data-intro="Click here to import from Postman" |
11 | | - test-id="open-import-suite-dialog">{{ t('button.import') }}</el-button> |
12 | | - <el-button type="primary" @click="loadStores" :icon="Refresh">{{ t('button.refresh') }}</el-button> |
13 | | - <el-input v-model="filterText" :placeholder="t('tip.filter')" test-id="search" style="padding: 5px;" /> |
14 | | - |
15 | | - <el-tree v-loading="storesLoading" :data=data highlight-current :check-on-click-node="true" |
16 | | - :expand-on-click-node="false" :current-node-key="currentNodekey" ref="treeRef" node-key="id" |
17 | | - :filter-node-method="filterTestCases" @node-click="handleNodeClick" |
18 | | - data-intro="This is the test suite tree. You can click the test suite to edit it." /> |
19 | | - <TemplateFunctions /> |
20 | | - </el-aside> |
21 | | - |
22 | | - <el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px;"> |
23 | | - <TestCase v-if="viewName === 'testcase'" :suite="testSuite" :kindName="testSuiteKind" :name="testCaseName" |
24 | | - @updated="loadStores" style="height: 100%;" |
25 | | - data-intro="This is the test case editor. You can edit the test case here." /> |
26 | | - <TestSuite v-else-if="viewName === 'testsuite'" :name="testSuite" @updated="loadStores" |
27 | | - data-intro="This is the test suite editor. You can edit the test suite here." /> |
28 | | - </el-main> |
29 | | - </el-container> |
30 | | - </el-main> |
31 | | - </el-container> |
| 2 | + <div class="index" data-title="Welcome!" data-intro="Welcome to use api-testing! 👋"> |
| 3 | + <el-card class="card" shawon="hover"> |
| 4 | + <el-button type="primary" @click="openTestSuiteCreateDialog" data-intro="Click here to create a new test suite" |
| 5 | + test-id="open-new-suite-dialog" :icon="Edit">{{ |
| 6 | + t('button.new') }}</el-button> |
| 7 | + <el-button type="primary" @click="openTestSuiteImportDialog" data-intro="Click here to import from Postman" |
| 8 | + test-id="open-import-suite-dialog">{{ t('button.import') }}</el-button> |
| 9 | + <el-button type="primary" @click="loadStores" :icon="Refresh">{{ t('button.refresh') }}</el-button> |
| 10 | + <TemplateFunctions /> |
| 11 | + <br> |
| 12 | + <br> |
| 13 | + <el-input v-model="filterText" :placeholder="t('tip.filter')" test-id="search" style="padding: 5px;" /> |
| 14 | + |
| 15 | + <el-tree v-loading="storesLoading" :data=data highlight-current :check-on-click-node="true" |
| 16 | + :expand-on-click-node="false" :current-node-key="currentNodekey" ref="treeRef" node-key="id" |
| 17 | + :filter-node-method="filterTestCases" @node-click="handleNodeClick" |
| 18 | + data-intro="This is the test suite tree. You can click the test suite to edit it." /> |
| 19 | + </el-card> |
32 | 20 | </div> |
33 | 21 |
|
34 | 22 | <el-dialog v-model="dialogVisible" :title="t('title.createTestSuite')" width="30%" draggable> |
@@ -127,13 +115,14 @@ import { Cache } from '../../utils/cache' |
127 | 115 | import { useI18n } from 'vue-i18n' |
128 | 116 | import { ErrorTips } from '@/utils/tips' |
129 | 117 | import { DefaultResponseProcess } from '@/api/common' |
| 118 | +import { GetStores } from '@/api/store/store' |
130 | 119 | import type { TestStore, Tree, Suite } from '../../types/types' |
131 | 120 | import type { FormInstance, FormRules } from 'element-plus' |
132 | | -import { |
133 | | - ListTestCase, |
134 | | - LoadTestSuite, |
135 | | - CreateTestSuite, |
136 | | - ImportTestSuite |
| 121 | +import { |
| 122 | + ListTestCase, |
| 123 | + LoadTestSuite, |
| 124 | + CreateTestSuite, |
| 125 | + ImportTestSuite |
137 | 126 | } from '@/api/test/test' |
138 | 127 |
|
139 | 128 | const { t } = useI18n() |
@@ -220,7 +209,7 @@ const storesLoading = ref(false) |
220 | 209 |
|
221 | 210 | const loadStores = async () => { |
222 | 211 | storesLoading.value = true |
223 | | - await loadStores() |
| 212 | + await GetStores() |
224 | 213 | .then(DefaultResponseProcess) |
225 | 214 | .then(async (d) => { |
226 | 215 | stores.value = d.data |
@@ -303,39 +292,39 @@ const importSuiteForm = reactive({ |
303 | 292 | store: '' |
304 | 293 | }) |
305 | 294 |
|
306 | | -function openTestSuiteCreateDialog() { |
| 295 | +const openTestSuiteCreateDialog = () => { |
307 | 296 | dialogVisible.value = true |
308 | 297 | } |
309 | 298 |
|
310 | | -function openTestSuiteImportDialog() { |
| 299 | +const openTestSuiteImportDialog = () => { |
311 | 300 | importDialogVisible.value = true |
312 | 301 | } |
313 | 302 |
|
314 | 303 | const rules = reactive<FormRules<Suite>>({ |
315 | 304 | name: [{ required: true, message: 'Name is required', trigger: 'blur' }], |
316 | 305 | store: [{ required: true, message: 'Location is required', trigger: 'blur' }] |
317 | 306 | }) |
318 | | -const submitForm = async (formEl: FormInstance | undefined) => { |
319 | | - if (!formEl) return |
320 | | - await formEl.validate((valid: boolean) => { |
321 | | - if (valid) { |
322 | | - suiteCreatingLoading.value = true |
323 | | - CreateTestSuite(testSuiteForm).then((res: any) => { |
324 | | - suiteCreatingLoading.value = false |
325 | | - if (res.error !== "") { |
326 | | - ElMessage.error('Oops, ' + res.error) |
327 | | - } else { |
328 | | - loadStores() |
329 | | - dialogVisible.value = false |
330 | | - formEl.resetFields() |
331 | | - } |
332 | | - }).catch((err) => { |
333 | | - suiteCreatingLoading.value = false |
334 | | - ElMessage.error('Oops, ' + err) |
335 | | - }) |
336 | | - } |
337 | | - }) |
338 | | -} |
| 307 | +// const submitForm = async (formEl: FormInstance | undefined) => { |
| 308 | +// if (!formEl) return |
| 309 | +// await formEl.validate((valid: boolean) => { |
| 310 | +// if (valid) { |
| 311 | +// suiteCreatingLoading.value = true |
| 312 | +// CreateTestSuite(testSuiteForm).then((res: any) => { |
| 313 | +// suiteCreatingLoading.value = false |
| 314 | +// if (res.error !== "") { |
| 315 | +// ElMessage.error('Oops, ' + res.error) |
| 316 | +// } else { |
| 317 | +// loadStores() |
| 318 | +// dialogVisible.value = false |
| 319 | +// formEl.resetFields() |
| 320 | +// } |
| 321 | +// }).catch((err) => { |
| 322 | +// suiteCreatingLoading.value = false |
| 323 | +// ElMessage.error('Oops, ' + err) |
| 324 | +// }) |
| 325 | +// } |
| 326 | +// }) |
| 327 | +// } |
339 | 328 |
|
340 | 329 | const importSuiteFormRules = reactive<FormRules<Suite>>({ |
341 | 330 | url: [ |
@@ -407,6 +396,17 @@ const suiteKinds = [{ |
407 | 396 | </script> |
408 | 397 |
|
409 | 398 | <style scoped> |
| 399 | +.index { |
| 400 | + display: flex |
| 401 | +} |
| 402 | +
|
| 403 | +.card { |
| 404 | + margin-top: 1%; |
| 405 | + width: 100%; /* 使用百分比单位 */ |
| 406 | + max-width: 1750px; /* 设置最大宽度 */ |
| 407 | + height: auto; |
| 408 | +} |
| 409 | +
|
410 | 410 | header { |
411 | 411 | line-height: 1.5; |
412 | 412 | max-height: 100vh; |
|
0 commit comments