diff --git a/frontend/src/components/business/ms-common-script/insertCommonScript.vue b/frontend/src/components/business/ms-common-script/insertCommonScript.vue index e4296a1825..060bc1a04f 100644 --- a/frontend/src/components/business/ms-common-script/insertCommonScript.vue +++ b/frontend/src/components/business/ms-common-script/insertCommonScript.vue @@ -76,8 +76,6 @@ import { useI18n } from '@/hooks/useI18n'; import useAppStore from '@/store/modules/app'; - import { RequestConditionScriptLanguage } from '@/enums/apiEnum'; - import debounce from 'lodash-es/debounce'; const appStore = useAppStore(); @@ -86,7 +84,7 @@ const props = withDefaults( defineProps<{ visible: boolean; - scriptLanguage?: Language | RequestConditionScriptLanguage; + scriptLanguage?: Language; enableRadioSelected?: boolean; // 是否单选开启 okText?: string; checkedId?: string; // 单选时默认选中的id diff --git a/frontend/src/components/business/ms-common-script/ms-script-menu.vue b/frontend/src/components/business/ms-common-script/ms-script-menu.vue index f7d204b931..23c17281b3 100644 --- a/frontend/src/components/business/ms-common-script/ms-script-menu.vue +++ b/frontend/src/components/business/ms-common-script/ms-script-menu.vue @@ -43,12 +43,10 @@ import { useVModel } from '@vueuse/core'; import { Message } from '@arco-design/web-vue'; - import { Language } from '@/components/pure/ms-code-editor/types'; + import { Language, LanguageEnum } from '@/components/pure/ms-code-editor/types'; import { useI18n } from '@/hooks/useI18n'; - import { RequestConditionScriptLanguage } from '@/enums/apiEnum'; - import type { CommonScriptMenu } from './types'; import { getCodeTemplate, SCRIPT_MENU } from './utils'; @@ -56,7 +54,7 @@ const props = defineProps<{ expand: boolean; - languagesType: Language | RequestConditionScriptLanguage; + languagesType: Language; }>(); const emit = defineEmits<{ @@ -73,11 +71,11 @@ const innerLanguageType = useVModel(props, 'languagesType', emit); const languages = [ - { text: 'beanshellJSR223', value: RequestConditionScriptLanguage.BEANSHELL_JSR233 }, - { text: 'beanshell', value: RequestConditionScriptLanguage.BEANSHELL }, - { text: 'python', value: RequestConditionScriptLanguage.PYTHON }, - { text: 'groovy', value: RequestConditionScriptLanguage.GROOVY }, - { text: 'javascript', value: RequestConditionScriptLanguage.JAVASCRIPT }, + { text: 'beanshellJSR223', value: LanguageEnum.BEANSHELL_JSR233 }, + { text: 'beanshell', value: LanguageEnum.BEANSHELL }, + { text: 'python', value: LanguageEnum.PYTHON }, + { text: 'groovy', value: LanguageEnum.GROOVY }, + { text: 'javascript', value: LanguageEnum.JAVASCRIPT }, ]; function expandedHandler() { @@ -127,7 +125,7 @@ return; } } else { - if (innerLanguageType.value !== 'beanshell' && innerLanguageType.value !== 'groovy') { + if (innerLanguageType.value !== LanguageEnum.BEANSHELL && innerLanguageType.value !== LanguageEnum.GROOVY) { if ( obj.title === t('api_test.request.processor.code_add_report_length') || obj.title === t('api_test.request.processor.code_hide_report_length') diff --git a/frontend/src/components/business/ms-common-script/scriptDefined.vue b/frontend/src/components/business/ms-common-script/scriptDefined.vue index 7191f84c66..613aa8e776 100644 --- a/frontend/src/components/business/ms-common-script/scriptDefined.vue +++ b/frontend/src/components/business/ms-common-script/scriptDefined.vue @@ -28,7 +28,7 @@ :width="expandMenu ? '100%' : '68%'" height="460px" theme="vs" - :language="(innerLanguagesType as Language)" + :language="innerLanguagesType" :read-only="false" :show-full-screen="false" :show-theme-change="false" @@ -86,14 +86,13 @@ import useAppStore from '@/store/modules/app'; import type { CommonScriptItem } from '@/models/projectManagement/commonScript'; - import { RequestConditionScriptLanguage } from '@/enums/apiEnum'; const appStore = useAppStore(); const props = withDefaults( defineProps<{ showType: 'commonScript' | 'executionResult'; // 执行类型 - language: Language | RequestConditionScriptLanguage; + language: Language; code: string; enableRadioSelected?: boolean; executionResult?: string; // 执行结果 @@ -104,7 +103,7 @@ } ); const emit = defineEmits<{ - (e: 'update:language', value: Language | RequestConditionScriptLanguage): void; + (e: 'update:language', value: Language): void; (e: 'update:code', value: string): void; }>(); diff --git a/frontend/src/components/business/ms-common-script/utils.ts b/frontend/src/components/business/ms-common-script/utils.ts index a322300c68..47715d22f4 100644 --- a/frontend/src/components/business/ms-common-script/utils.ts +++ b/frontend/src/components/business/ms-common-script/utils.ts @@ -1,4 +1,4 @@ -import { Language } from '@/components/pure/ms-code-editor/types'; +import { Language, LanguageEnum } from '@/components/pure/ms-code-editor/types'; import { useI18n } from '@/hooks/useI18n'; @@ -500,19 +500,19 @@ function jsCode(requestObj) { export function getCodeTemplate(language: Language | RequestConditionScriptLanguage, requestObj: any) { switch (language) { - case 'groovy': + case LanguageEnum.GROOVY: return groovyCode(requestObj); - case 'python': + case LanguageEnum.PYTHON: return pythonCode(requestObj); - case 'beanshell': + case LanguageEnum.BEANSHELL: return javaCode(requestObj); - case 'nashornScript': + case LanguageEnum.NASHORNSCRIPT: return jsCode(requestObj); - case 'rhinoScript': + case LanguageEnum.RHINOSCRIPT: return jsCode(requestObj); - case 'javascript': + case LanguageEnum.JAVASCRIPT: return jsCode(requestObj); - case 'beanshell-jsr233': + case LanguageEnum.BEANSHELL_JSR233: return javaCode(requestObj); default: return ''; diff --git a/frontend/src/components/business/ms-params-input/config.ts b/frontend/src/components/business/ms-params-input/config.ts index d41e626c19..0d5f13996d 100644 --- a/frontend/src/components/business/ms-params-input/config.ts +++ b/frontend/src/components/business/ms-params-input/config.ts @@ -459,14 +459,14 @@ export const mockFunctions: MockParamItem[] = [ ], }, { - label: 'concatconcat', - value: 'concatconcat', - desc: 'ms.paramsInput.concatconcatDesc', + label: 'concat', + value: 'concat', + desc: 'ms.paramsInput.concatDesc', inputGroup: [ { type: 'input', value: '', - label: 'ms.paramsInput.concatconcat', + label: 'ms.paramsInput.concat', placeholder: 'ms.paramsInput.commonPlaceholder', }, ], diff --git a/frontend/src/components/business/ms-params-input/index.vue b/frontend/src/components/business/ms-params-input/index.vue index 1c9018b043..90a104fec9 100644 --- a/frontend/src/components/business/ms-params-input/index.vue +++ b/frontend/src/components/business/ms-params-input/index.vue @@ -166,7 +166,7 @@
{{ t('ms.paramsInput.preview') }}
diff --git a/frontend/src/components/business/ms-params-input/locale/en-US.ts b/frontend/src/components/business/ms-params-input/locale/en-US.ts index e207d0d50d..15e1032423 100644 --- a/frontend/src/components/business/ms-params-input/locale/en-US.ts +++ b/frontend/src/components/business/ms-params-input/locale/en-US.ts @@ -137,8 +137,8 @@ export default { 'ms.paramsInput.substrDesc': 'Starting and ending', 'ms.paramsInput.substrStartPlaceholder': 'Starting value', 'ms.paramsInput.substrEndPlaceholder': 'Ending value', - 'ms.paramsInput.concatconcat': 'String to end with', - 'ms.paramsInput.concatconcatDesc': 'Ending string', + 'ms.paramsInput.concat': 'String to end with', + 'ms.paramsInput.concatDesc': 'Ending string', 'ms.paramsInput.lconcatDesc': 'Starting string', 'ms.paramsInput.lconcat': 'The string to start with', 'ms.paramsInput.sha1Desc': 'SHA1 encryption', diff --git a/frontend/src/components/business/ms-params-input/locale/zh-CN.ts b/frontend/src/components/business/ms-params-input/locale/zh-CN.ts index b4f964427c..10ae7d338a 100644 --- a/frontend/src/components/business/ms-params-input/locale/zh-CN.ts +++ b/frontend/src/components/business/ms-params-input/locale/zh-CN.ts @@ -129,8 +129,8 @@ export default { 'ms.paramsInput.substrDesc': '起止', 'ms.paramsInput.substrStartPlaceholder': '起始值', 'ms.paramsInput.substrEndPlaceholder': '结束值', - 'ms.paramsInput.concatconcat': '要作为结尾的字符串', - 'ms.paramsInput.concatconcatDesc': '结尾字符串', + 'ms.paramsInput.concat': '要作为结尾的字符串', + 'ms.paramsInput.concatDesc': '结尾字符串', 'ms.paramsInput.lconcatDesc': '开头字符串', 'ms.paramsInput.lconcat': '要作为开头的字符串', 'ms.paramsInput.sha1Desc': 'sha1 加密', diff --git a/frontend/src/components/pure/ms-code-editor/index.vue b/frontend/src/components/pure/ms-code-editor/index.vue index 0bab01de57..1e1e97c509 100644 --- a/frontend/src/components/pure/ms-code-editor/index.vue +++ b/frontend/src/components/pure/ms-code-editor/index.vue @@ -75,7 +75,7 @@ name: 'MonacoEditor', props: editorProps, emits: ['update:modelValue', 'change'], - setup(props, { emit }) { + setup(props, { emit, slots }) { const { t } = useI18n(); // 编辑器实例,每次调用组件都会创建独立的实例 let editor: monaco.editor.IStandaloneCodeEditor; @@ -138,14 +138,14 @@ // 如果传入了语言种类数组,则过滤选项 if (props.languages.includes(e)) { return { - label: e, + label: e.toLowerCase(), value: e, }; } return false; } return { - label: e, + label: e.toLowerCase(), value: e, }; }) @@ -172,7 +172,9 @@ props.showThemeChange || props.showLanguageChange || props.showCharsetChange || - props.showFullScreen + props.showFullScreen || + slots.leftTitle || + slots.rightTitle ); watch( @@ -259,7 +261,7 @@ watch( () => props.language, (newValue) => { - monaco.editor.setModelLanguage(editor.getModel()!, newValue); + monaco.editor.setModelLanguage(editor.getModel()!, newValue.toLowerCase()); // 设置语言,语言 ENUM 是大写的,但是 monaco 需要小写 } ); diff --git a/frontend/src/components/pure/ms-code-editor/types.ts b/frontend/src/components/pure/ms-code-editor/types.ts index 3a6bb358ec..8ae9df5657 100644 --- a/frontend/src/components/pure/ms-code-editor/types.ts +++ b/frontend/src/components/pure/ms-code-editor/types.ts @@ -5,25 +5,25 @@ export type Theme = 'vs' | 'hc-black' | 'vs-dark' | CustomTheme; export type FoldingStrategy = 'auto' | 'indentation'; export type RenderLineHighlight = 'all' | 'line' | 'none' | 'gutter'; export const LanguageEnum = { - PLAINTEXT: 'plaintext' as const, - JAVASCRIPT: 'javascript' as const, - TYPESCRIPT: 'typescript' as const, - CSS: 'css' as const, - LESS: 'less' as const, - SASS: 'sass' as const, - HTML: 'html' as const, - SQL: 'sql' as const, - JSON: 'json' as const, - JAVA: 'java' as const, - PYTHON: 'python' as const, - XML: 'xml' as const, - YAML: 'yaml' as const, - SHELL: 'shell' as const, - BEANSHELL: 'beanshell' as const, - BEANSHELL_JSR233: 'beanshell-jsr233' as const, - GROOVY: 'groovy' as const, - NASHORNSCRIPT: 'nashornScript' as const, - RHINOSCRIPT: 'rhinoScript' as const, + PLAINTEXT: 'PLAINTEXT' as const, + JAVASCRIPT: 'JAVASCRIPT' as const, + TYPESCRIPT: 'TYPESCRIPT' as const, + CSS: 'CSS' as const, + LESS: 'LESS' as const, + SASS: 'SASS' as const, + HTML: 'HTML' as const, + SQL: 'SQL' as const, + JSON: 'JSON' as const, + JAVA: 'JAVA' as const, + PYTHON: 'PYTHON' as const, + XML: 'XML' as const, + YAML: 'YAML' as const, + SHELL: 'SHELL' as const, + BEANSHELL: 'BEANSHELL' as const, + BEANSHELL_JSR233: 'BEANSHELL_JSR233' as const, + GROOVY: 'GROOVY' as const, + NASHORNSCRIPT: 'NASHORNSCRIPT' as const, + RHINOSCRIPT: 'RHINOSCRIPT' as const, } as const; export type Language = (typeof LanguageEnum)[keyof typeof LanguageEnum]; export interface Options { diff --git a/frontend/src/models/apiTest/debug.ts b/frontend/src/models/apiTest/debug.ts index 39beae2385..a6b1467464 100644 --- a/frontend/src/models/apiTest/debug.ts +++ b/frontend/src/models/apiTest/debug.ts @@ -1,9 +1,10 @@ +import { Language } from '@/components/pure/ms-code-editor/types'; + import { RequestAssertionCondition, RequestAuthType, RequestBodyFormat, RequestConditionProcessor, - RequestConditionScriptLanguage, RequestContentTypeEnum, RequestExtractEnvType, RequestExtractExpressionEnum, @@ -23,8 +24,6 @@ import { export type ConditionType = RequestConditionProcessor; // 断言-匹配条件规则 export type RequestAssertionConditionType = RequestAssertionCondition; -// 前后置条件-脚本语言类型 -export type RequestConditionScriptLanguageType = RequestConditionScriptLanguage; // 响应时间信息 export interface ResponseTiming { dnsLookupTime: number; @@ -157,7 +156,7 @@ export interface ScriptCommonConfig { script: string; // 脚本内容 scriptId: string; // 脚本id scriptName: string; // 脚本名称 - scriptLanguage: RequestConditionScriptLanguageType; // 脚本语言 + scriptLanguage: Language; // 脚本语言 params: KeyValueParam[]; // 公共脚本参数 } // 断言-响应体断言 diff --git a/frontend/src/views/api-test/components/batchAddKeyVal.vue b/frontend/src/views/api-test/components/batchAddKeyVal.vue index 92072ca1dd..082e2ef01b 100644 --- a/frontend/src/views/api-test/components/batchAddKeyVal.vue +++ b/frontend/src/views/api-test/components/batchAddKeyVal.vue @@ -10,32 +10,31 @@ @confirm="applyBatchParams" >
-
@@ -85,7 +84,7 @@ const tempObj: Record = {}; // 同名参数去重,保留最新的 for (let i = 0; i < arr.length; i++) { const [key, value] = arr[i].split(':'); - if (key) { + if (key || value) { tempObj[key.trim()] = { id: new Date().getTime() + i, ...props.defaultParamItem, diff --git a/frontend/src/views/api-test/components/condition/content.vue b/frontend/src/views/api-test/components/condition/content.vue index 482ba911ca..b4d4765d21 100644 --- a/frontend/src/views/api-test/components/condition/content.vue +++ b/frontend/src/views/api-test/components/condition/content.vue @@ -51,7 +51,8 @@ import { useVModel } from '@vueuse/core'; + import { LanguageEnum } from '@/components/pure/ms-code-editor/types'; import conditionContent from './content.vue'; import conditionList from './list.vue'; @@ -47,7 +48,7 @@ import { useI18n } from '@/hooks/useI18n'; import { ConditionType, ExecuteConditionProcessor } from '@/models/apiTest/debug'; - import { RequestConditionProcessor, RequestConditionScriptLanguage } from '@/enums/apiEnum'; + import { RequestConditionProcessor } from '@/enums/apiEnum'; const props = defineProps<{ list: ExecuteConditionProcessor[]; @@ -94,19 +95,6 @@ emit('change'); } - const scriptEx = ref(`2023-12-04 11:19:28 INFO 9026fd6a 1-1 Thread started: 9026fd6a 1-1 -2023-12-04 11:19:28 ERROR 9026fd6a 1-1 Problem in JSR223 script JSR223Sampler, message: {} -In file: inline evaluation of: prev.getResponseCode() import java.net.URI; import org.apache.http.client.method . . . '' Encountered "import" at line 2, column 1. -in inline evaluation of: prev.getResponseCode() import java.net.URI; import org.apache.http.client.method . . . '' at line number 2 -javax.script.ScriptException '' at line number 2 -javax.script.ScriptException '' at line number 2 -javax.script.ScriptException '' at line number 2 -javax.script.ScriptException '' at line number 2 -javax.script.ScriptException '' at line number 2 -javax.script.ScriptException -org.apache.http.client.method . . . '' at line number 2 -`); - /** * 添加条件 */ @@ -120,9 +108,9 @@ org.apache.http.client.method . . . '' at line number 2 scriptName: t('apiTestDebug.preconditionScriptName'), enableCommonScript: false, enable: true, - script: scriptEx.value, + script: '', scriptId: '', - scriptLanguage: RequestConditionScriptLanguage.BEANSHELL, + scriptLanguage: LanguageEnum.BEANSHELL, params: [], }); break; @@ -134,7 +122,7 @@ org.apache.http.client.method . . . '' at line number 2 // enable: true, // sqlSource: { // scriptName: '', - // script: scriptEx, + // script: '', // storageType: 'column', // params: [], // }, diff --git a/frontend/src/views/api-test/components/paramTable.vue b/frontend/src/views/api-test/components/paramTable.vue index f9c188e6a4..a2c54f344d 100644 --- a/frontend/src/views/api-test/components/paramTable.vue +++ b/frontend/src/views/api-test/components/paramTable.vue @@ -312,7 +312,7 @@ height="300px" :show-full-screen="false" > -