diff --git a/console/atest-ui/src/App.vue b/console/atest-ui/src/App.vue index c30f68bc..3dbdebba 100644 --- a/console/atest-ui/src/App.vue +++ b/console/atest-ui/src/App.vue @@ -16,6 +16,7 @@ import MockManager from './views/MockManager.vue' import StoreManager from './views/StoreManager.vue' import SecretManager from './views/SecretManager.vue' import WelcomePage from './views/WelcomePage.vue' +import FileManage from './views/FileManager.vue' import { useI18n } from 'vue-i18n' const { t, locale: i18nLocale } = useI18n() @@ -121,6 +122,10 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => { + + + + @@ -144,6 +149,7 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => { + @@ -157,4 +163,4 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => { .el-menu-vertical:not(.el-menu--collapse) { width: 200px; } - \ No newline at end of file + diff --git a/console/atest-ui/src/locales/en.json b/console/atest-ui/src/locales/en.json index 6a4a60b0..0f01642e 100644 --- a/console/atest-ui/src/locales/en.json +++ b/console/atest-ui/src/locales/en.json @@ -47,6 +47,7 @@ "welcome": "Welcome", "secrets": "Secrets", "stores": "Stores", + "files": "Files", "templateQuery": "Template Functions Query", "output": "Output" }, diff --git a/console/atest-ui/src/locales/zh.json b/console/atest-ui/src/locales/zh.json index 3ab04e62..0af3ab56 100644 --- a/console/atest-ui/src/locales/zh.json +++ b/console/atest-ui/src/locales/zh.json @@ -41,6 +41,7 @@ "welcome": "欢迎", "secrets": "凭据", "stores": "存储", + "files": "文件", "parameter": "参数", "templateQuery": "模板函数查询", "output": "输出" diff --git a/console/atest-ui/src/views/FileManager.vue b/console/atest-ui/src/views/FileManager.vue new file mode 100644 index 00000000..db31e8c7 --- /dev/null +++ b/console/atest-ui/src/views/FileManager.vue @@ -0,0 +1,70 @@ + + + diff --git a/console/atest-ui/src/views/TestCase.vue b/console/atest-ui/src/views/TestCase.vue index 9a81a5a9..682a25cc 100644 --- a/console/atest-ui/src/views/TestCase.vue +++ b/console/atest-ui/src/views/TestCase.vue @@ -242,7 +242,8 @@ const emptyTestCaseWithSuite: TestCaseWithSuite = { cookie: [], form: [], body: '', - filepath: '' + filepath: '', + filename: '' }, response: { statusCode: 0, @@ -337,7 +338,6 @@ function determineBodyType(e: TestCase) { break case 'multipart/form-data': bodyType.value = 6 - e.request.form.forEach(fItem => { if (fItem.key !== '' && fItem.key !== '') { e.request.filepath = fItem.key + "=" + fItem.value @@ -634,6 +634,7 @@ const deleteAllHistory = async (formEl) => { } const options = GetHTTPMethods() +const fileLists = ref([]) const requestActiveTab = ref(Cache.GetPreference().requestActiveTab) watch(requestActiveTab, Cache.WatchRequestActiveTab) Magic.Keys(() => { @@ -721,6 +722,22 @@ function formChange() { } } +function handleSelectChange() { + const items = testCaseWithSuite.value.data.request.filename + if (items) { + testCaseWithSuite.value.data.request.form = [{ + key: "file", + value: items + } as Pair] + + const file = fileLists.value.find((e) => e.value === items) + if (file) { + const content = file.content.split(',')[1] + testCaseWithSuite.value.data.request.body = atob(content) + } + } +} + const filepathChange = () => { const items = testCaseWithSuite.value.data.request.filepath.split("=") if (items && items.length > 1) { @@ -730,6 +747,7 @@ const filepathChange = () => { } as Pair] } } + const bodyType = ref(1) function bodyTypeChange(e: number) { let contentType = "" @@ -744,6 +762,20 @@ function bodyTypeChange(e: number) { contentType = 'multipart/form-data' filepathChange() break; + case 7: + // 获取localStorage中的数据 + const savedFiles = localStorage.getItem('fileLists') + if (savedFiles) { + const fileList = JSON.parse(savedFiles) + console.log(fileList) + fileLists.value = fileList.map(file => ({ + label: file.name, + value: file.name, + content: file.content, + disabled: false + })) + } + break; } if (contentType !== "") { @@ -1020,9 +1052,23 @@ Magic.Keys(() => { x-www-form-urlencoded JSON EmbedFile + UploadFile
+ + +
Filename: diff --git a/console/atest-ui/src/views/types.ts b/console/atest-ui/src/views/types.ts index 2a88bfbc..a036a1f8 100644 --- a/console/atest-ui/src/views/types.ts +++ b/console/atest-ui/src/views/types.ts @@ -68,6 +68,7 @@ export interface TestCaseRequest { form: Pair[] body: string filepath: string + filename: string } export interface TestCaseResponse { @@ -187,4 +188,4 @@ export function FlattenObject(obj: any): any { acc[pair[0]] = pair[1] return acc }, {}) -} \ No newline at end of file +}