From 884abde6e545ef8cc39ec58c9726f2b691e4b0f8 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 14 Jun 2022 16:56:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=90=AFTCP=20Mock=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E7=AB=AF=E5=8F=A3=E5=8F=B7=E4=B8=BA?= =?UTF-8?q?0=E6=9C=AA=E9=9A=8F=E6=9C=BA=E4=B8=80=E4=B8=AA=E5=8F=AF?= =?UTF-8?q?=E7=94=A8=E7=AB=AF=E5=8F=A3=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1014028 --user=宋天阳 【接口测试】开启TCP Mock时,默认端口号为0未随机一个可用端口号 {#_orginal_url#} --- .../metersphere/service/ProjectService.java | 4 +-- .../resources/i18n/messages_en_US.properties | 21 ++++++------ .../resources/i18n/messages_zh_CN.properties | 20 ++++++----- .../resources/i18n/messages_zh_TW.properties | 21 ++++++------ .../project/menu/appmanage/AppManage.vue | 34 ++++++++++++------- 5 files changed, 57 insertions(+), 43 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index ae2b0653ea..59ba63e886 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -569,7 +569,7 @@ public class ProjectService { .andTypeValueEqualTo(String.valueOf(project.getMockTcpPort())) .andProjectIdNotEqualTo(projectId); if (projectApplicationMapper.countByExample(example) > 0) { - MSException.throwException("TCP Port is not unique!"); + MSException.throwException(Translator.get("tcp_mock_not_unique")); } } } @@ -958,7 +958,7 @@ public class ProjectService { } } if (returnPort == 0) { - MSException.throwException("无可用TCP端口"); + MSException.throwException(Translator.get("no_tcp_mock_port")); } return String.valueOf(returnPort); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 6366c1990e..f92b97b8fb 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -313,25 +313,24 @@ count=Count cannot_find_project=Cannot find project project_repeatable_is_false=Url repeatable not open #环境组 -null_environment_group_name = Environment group name is null -environment_group_name = Environment group name -environment_group_exist = already exists +null_environment_group_name=Environment group name is null +environment_group_name=Environment group name +environment_group_exist=already exists environment_group_has_duplicate_project=Environment group has duplicate project #误报库 error_report_library=Error report issue_jira_info_error=Check the service integration information or Jira project ID error_code_is_unique=Error code is not unique - no_version_exists=version not exists jira_auth_error=Account name or password (Token) is wrong jira_auth_url_error=The test connection failed, please check whether the Jira address is correct #ui 指令校驗 param_error=Param Error -is_null= can't be null -url_is_null= URL can't be null -frame_index_is_null= frame index can't be null -element_is_null= element can't be null -locator_is_null= locator can't be null +is_null=can't be null +url_is_null=URL can't be null +frame_index_is_null=frame index can't be null +element_is_null=element can't be null +locator_is_null=locator can't be null coord=coord input_content=input subitem_type=subitem type @@ -374,4 +373,6 @@ cmdElseIf=ElseIf close=close cmdExtraction=extracion cmdExtractWindow=window extraction -cmdExtractElement=element extraction \ No newline at end of file +cmdExtractElement=element extraction +tcp_mock_not_unique=This tcp port is be used +no_tcp_mock_port=No idle tcp port, please contact administrators. \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 0cf404f5ef..2b0dfd63e6 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -312,9 +312,9 @@ count=统计 cannot_find_project=未找到测试项目 project_repeatable_is_false=项目未配置URL可重复 #环境组 -null_environment_group_name = 环境组名称不存在 -environment_group_name = 环境组名称 -environment_group_exist = 已存在 +null_environment_group_name=环境组名称不存在 +environment_group_name=环境组名称 +environment_group_exist=已存在 environment_group_has_duplicate_project=每个项目只能选择一个环境! #误报库 error_report_library=误报库 @@ -325,11 +325,11 @@ jira_auth_error=账号名或密码(Token)错误 jira_auth_url_error=测试连接失败,请检查Jira地址是否正确 #ui 指令校验 param_error=参数校验失败!请检查 -is_null= 不能为空 -url_is_null= URL 参数不能为空 -frame_index_is_null= 网页索引号不能为空 -element_is_null= 元素对象已经被删除 -locator_is_null= 元素定位参数不能有空 +is_null=不能为空 +url_is_null=URL 参数不能为空 +frame_index_is_null=网页索引号不能为空 +element_is_null=元素对象已经被删除 +locator_is_null=元素定位参数不能有空 coord=坐标 input_content=输入内容 subitem_type=子选项类型 @@ -372,4 +372,6 @@ cmdElseIf=ElseIf close=关闭网页 cmdExtraction=数据提取 cmdExtractWindow=提取窗口信息 -cmdExtractElement=提取元素信息 \ No newline at end of file +cmdExtractElement=提取元素信息 +tcp_mock_not_unique=该TCP端口号已被使用 +no_tcp_mock_port=无可用的TCP端口号,请联系管理员 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 7784ac40b8..44cf6e0f02 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -311,25 +311,24 @@ count=統計 cannot_find_project=未找到測試項目 project_repeatable_is_false=項目未配置URL可重複 #环境组 -null_environment_group_name = 環境組名稱不存在 -environment_group_name = 環境組名稱 -environment_group_exist = 已存在 +null_environment_group_name=環境組名稱不存在 +environment_group_name=環境組名稱 +environment_group_exist=已存在 environment_group_has_duplicate_project=每個項目只能選擇一個環境! #误报库 error_report_library=誤報庫 issue_jira_info_error=請檢查服務集成信息或Jira項目ID error_code_is_unique=錯誤代碼不可重複 - no_version_exists=不存在版本!請先創建項目的版本 jira_auth_error=賬號名或密碼(Token)錯誤 jira_auth_url_error=測試連接失敗,請檢查Jira地址是否正確 #ui 指令校驗 param_error=參數校驗失敗!請檢查 -is_null= 不能為空 -url_is_null= URL 參數不能為空 -frame_index_is_null= 網頁索引號不能為空 -element_is_null= 元素對象已經被刪除 -locator_is_null= 元素定位參數不能有空 +is_null=不能為空 +url_is_null=URL 參數不能為空 +frame_index_is_null=網頁索引號不能為空 +element_is_null=元素對象已經被刪除 +locator_is_null=元素定位參數不能有空 coord=坐標 input_content=輸入內容 subitem_type=子選項類型 @@ -372,4 +371,6 @@ cmdElseIf=ElseIf close=關閉網頁 cmdExtraction=數據提取 cmdExtractWindow=提取窗口信息 -cmdExtractElement=提取元素信息 \ No newline at end of file +cmdExtractElement=提取元素信息 +tcp_mock_not_unique=該TCP端口號已被使用 +no_tcp_mock_port=無可用的TCP端口號,請聯繫管理員 \ No newline at end of file diff --git a/frontend/src/business/components/project/menu/appmanage/AppManage.vue b/frontend/src/business/components/project/menu/appmanage/AppManage.vue index 69e0b0b480..b56e0dc9f6 100644 --- a/frontend/src/business/components/project/menu/appmanage/AppManage.vue +++ b/frontend/src/business/components/project/menu/appmanage/AppManage.vue @@ -66,7 +66,7 @@ + :expr.sync="config.apiShareReportTime" :share-link="true" + :unit-options="applyUnitOptions" + @chooseChange="switchChange('API_SHARE_REPORT_TIME', config.apiShareReportTime)" + :title="$t('report.report_sharing_link')"/> @@ -100,9 +102,9 @@ - + - + {{ $t('commons.view_settings') }} @@ -153,12 +155,7 @@ import MsContainer from "@/business/components/common/components/MsContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer"; -import { - getCurrentProjectID, - getCurrentUserId, - getCurrentWorkspaceId, - hasLicense, -} from "@/common/js/utils"; +import {getCurrentProjectID, hasLicense,} from "@/common/js/utils"; import AppManageItem from "@/business/components/project/menu/appmanage/AppManageItem"; import TimingItem from "@/business/components/project/menu/appmanage/TimingItem"; @@ -225,6 +222,19 @@ export default { }, }, methods: { + tcpMockSwitchChange(value, other) { + if (value && this.config.mockTcpPort === 0) { + this.result = this.$get('/project/genTcpMockPort/' + this.projectId, res => { + let port = res.data; + this.config.mockTcpPort = port; + this.$nextTick(() => { + this.switchChange("MOCK_TCP_OPEN", value, ['MOCK_TCP_PORT', this.config.mockTcpPort]); + }) + }); + } else { + this.switchChange("MOCK_TCP_OPEN", value, other); + } + }, switchChange(type, value, other) { let configs = []; if (other && value) { @@ -247,7 +257,7 @@ export default { if (res.data) { this.config = res.data; this.config.shareReport = true; - if(!this.config.uiQuickMenu){ + if (!this.config.uiQuickMenu) { this.config.uiQuickMenu = "server"; } }