fix(接口调试): 插件 path 参数不传&代码编辑器语言大写

This commit is contained in:
baiqi 2024-02-23 14:04:07 +08:00 committed by Craftsman
parent aaf93702e1
commit f50ed1b36a
24 changed files with 138 additions and 138 deletions

View File

@ -76,8 +76,6 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { RequestConditionScriptLanguage } from '@/enums/apiEnum';
import debounce from 'lodash-es/debounce'; import debounce from 'lodash-es/debounce';
const appStore = useAppStore(); const appStore = useAppStore();
@ -86,7 +84,7 @@
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
visible: boolean; visible: boolean;
scriptLanguage?: Language | RequestConditionScriptLanguage; scriptLanguage?: Language;
enableRadioSelected?: boolean; // enableRadioSelected?: boolean; //
okText?: string; okText?: string;
checkedId?: string; // id checkedId?: string; // id

View File

@ -43,12 +43,10 @@
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { Message } from '@arco-design/web-vue'; 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 { useI18n } from '@/hooks/useI18n';
import { RequestConditionScriptLanguage } from '@/enums/apiEnum';
import type { CommonScriptMenu } from './types'; import type { CommonScriptMenu } from './types';
import { getCodeTemplate, SCRIPT_MENU } from './utils'; import { getCodeTemplate, SCRIPT_MENU } from './utils';
@ -56,7 +54,7 @@
const props = defineProps<{ const props = defineProps<{
expand: boolean; expand: boolean;
languagesType: Language | RequestConditionScriptLanguage; languagesType: Language;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -73,11 +71,11 @@
const innerLanguageType = useVModel(props, 'languagesType', emit); const innerLanguageType = useVModel(props, 'languagesType', emit);
const languages = [ const languages = [
{ text: 'beanshellJSR223', value: RequestConditionScriptLanguage.BEANSHELL_JSR233 }, { text: 'beanshellJSR223', value: LanguageEnum.BEANSHELL_JSR233 },
{ text: 'beanshell', value: RequestConditionScriptLanguage.BEANSHELL }, { text: 'beanshell', value: LanguageEnum.BEANSHELL },
{ text: 'python', value: RequestConditionScriptLanguage.PYTHON }, { text: 'python', value: LanguageEnum.PYTHON },
{ text: 'groovy', value: RequestConditionScriptLanguage.GROOVY }, { text: 'groovy', value: LanguageEnum.GROOVY },
{ text: 'javascript', value: RequestConditionScriptLanguage.JAVASCRIPT }, { text: 'javascript', value: LanguageEnum.JAVASCRIPT },
]; ];
function expandedHandler() { function expandedHandler() {
@ -127,7 +125,7 @@
return; return;
} }
} else { } else {
if (innerLanguageType.value !== 'beanshell' && innerLanguageType.value !== 'groovy') { if (innerLanguageType.value !== LanguageEnum.BEANSHELL && innerLanguageType.value !== LanguageEnum.GROOVY) {
if ( if (
obj.title === t('api_test.request.processor.code_add_report_length') || obj.title === t('api_test.request.processor.code_add_report_length') ||
obj.title === t('api_test.request.processor.code_hide_report_length') obj.title === t('api_test.request.processor.code_hide_report_length')

View File

@ -28,7 +28,7 @@
:width="expandMenu ? '100%' : '68%'" :width="expandMenu ? '100%' : '68%'"
height="460px" height="460px"
theme="vs" theme="vs"
:language="(innerLanguagesType as Language)" :language="innerLanguagesType"
:read-only="false" :read-only="false"
:show-full-screen="false" :show-full-screen="false"
:show-theme-change="false" :show-theme-change="false"
@ -86,14 +86,13 @@
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import type { CommonScriptItem } from '@/models/projectManagement/commonScript'; import type { CommonScriptItem } from '@/models/projectManagement/commonScript';
import { RequestConditionScriptLanguage } from '@/enums/apiEnum';
const appStore = useAppStore(); const appStore = useAppStore();
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
showType: 'commonScript' | 'executionResult'; // showType: 'commonScript' | 'executionResult'; //
language: Language | RequestConditionScriptLanguage; language: Language;
code: string; code: string;
enableRadioSelected?: boolean; enableRadioSelected?: boolean;
executionResult?: string; // executionResult?: string; //
@ -104,7 +103,7 @@
} }
); );
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:language', value: Language | RequestConditionScriptLanguage): void; (e: 'update:language', value: Language): void;
(e: 'update:code', value: string): void; (e: 'update:code', value: string): void;
}>(); }>();

View File

@ -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'; import { useI18n } from '@/hooks/useI18n';
@ -500,19 +500,19 @@ function jsCode(requestObj) {
export function getCodeTemplate(language: Language | RequestConditionScriptLanguage, requestObj: any) { export function getCodeTemplate(language: Language | RequestConditionScriptLanguage, requestObj: any) {
switch (language) { switch (language) {
case 'groovy': case LanguageEnum.GROOVY:
return groovyCode(requestObj); return groovyCode(requestObj);
case 'python': case LanguageEnum.PYTHON:
return pythonCode(requestObj); return pythonCode(requestObj);
case 'beanshell': case LanguageEnum.BEANSHELL:
return javaCode(requestObj); return javaCode(requestObj);
case 'nashornScript': case LanguageEnum.NASHORNSCRIPT:
return jsCode(requestObj); return jsCode(requestObj);
case 'rhinoScript': case LanguageEnum.RHINOSCRIPT:
return jsCode(requestObj); return jsCode(requestObj);
case 'javascript': case LanguageEnum.JAVASCRIPT:
return jsCode(requestObj); return jsCode(requestObj);
case 'beanshell-jsr233': case LanguageEnum.BEANSHELL_JSR233:
return javaCode(requestObj); return javaCode(requestObj);
default: default:
return ''; return '';

View File

@ -459,14 +459,14 @@ export const mockFunctions: MockParamItem[] = [
], ],
}, },
{ {
label: 'concatconcat', label: 'concat',
value: 'concatconcat', value: 'concat',
desc: 'ms.paramsInput.concatconcatDesc', desc: 'ms.paramsInput.concatDesc',
inputGroup: [ inputGroup: [
{ {
type: 'input', type: 'input',
value: '', value: '',
label: 'ms.paramsInput.concatconcat', label: 'ms.paramsInput.concat',
placeholder: 'ms.paramsInput.commonPlaceholder', placeholder: 'ms.paramsInput.commonPlaceholder',
}, },
], ],

View File

@ -166,7 +166,7 @@
</template> </template>
</a-form> </a-form>
<div <div
v-if="paramForm.type === 'mock'" v-if="paramSettingType === 'mock'"
class="mb-[16px] flex items-center gap-[16px] bg-[var(--color-text-n9)] p-[5px_8px]" class="mb-[16px] flex items-center gap-[16px] bg-[var(--color-text-n9)] p-[5px_8px]"
> >
<div class="text-[var(--color-text-3)]">{{ t('ms.paramsInput.preview') }}</div> <div class="text-[var(--color-text-3)]">{{ t('ms.paramsInput.preview') }}</div>

View File

@ -137,8 +137,8 @@ export default {
'ms.paramsInput.substrDesc': 'Starting and ending', 'ms.paramsInput.substrDesc': 'Starting and ending',
'ms.paramsInput.substrStartPlaceholder': 'Starting value', 'ms.paramsInput.substrStartPlaceholder': 'Starting value',
'ms.paramsInput.substrEndPlaceholder': 'Ending value', 'ms.paramsInput.substrEndPlaceholder': 'Ending value',
'ms.paramsInput.concatconcat': 'String to end with', 'ms.paramsInput.concat': 'String to end with',
'ms.paramsInput.concatconcatDesc': 'Ending string', 'ms.paramsInput.concatDesc': 'Ending string',
'ms.paramsInput.lconcatDesc': 'Starting string', 'ms.paramsInput.lconcatDesc': 'Starting string',
'ms.paramsInput.lconcat': 'The string to start with', 'ms.paramsInput.lconcat': 'The string to start with',
'ms.paramsInput.sha1Desc': 'SHA1 encryption', 'ms.paramsInput.sha1Desc': 'SHA1 encryption',

View File

@ -129,8 +129,8 @@ export default {
'ms.paramsInput.substrDesc': '起止', 'ms.paramsInput.substrDesc': '起止',
'ms.paramsInput.substrStartPlaceholder': '起始值', 'ms.paramsInput.substrStartPlaceholder': '起始值',
'ms.paramsInput.substrEndPlaceholder': '结束值', 'ms.paramsInput.substrEndPlaceholder': '结束值',
'ms.paramsInput.concatconcat': '要作为结尾的字符串', 'ms.paramsInput.concat': '要作为结尾的字符串',
'ms.paramsInput.concatconcatDesc': '结尾字符串', 'ms.paramsInput.concatDesc': '结尾字符串',
'ms.paramsInput.lconcatDesc': '开头字符串', 'ms.paramsInput.lconcatDesc': '开头字符串',
'ms.paramsInput.lconcat': '要作为开头的字符串', 'ms.paramsInput.lconcat': '要作为开头的字符串',
'ms.paramsInput.sha1Desc': 'sha1 加密', 'ms.paramsInput.sha1Desc': 'sha1 加密',

View File

@ -75,7 +75,7 @@
name: 'MonacoEditor', name: 'MonacoEditor',
props: editorProps, props: editorProps,
emits: ['update:modelValue', 'change'], emits: ['update:modelValue', 'change'],
setup(props, { emit }) { setup(props, { emit, slots }) {
const { t } = useI18n(); const { t } = useI18n();
// //
let editor: monaco.editor.IStandaloneCodeEditor; let editor: monaco.editor.IStandaloneCodeEditor;
@ -138,14 +138,14 @@
// //
if (props.languages.includes(e)) { if (props.languages.includes(e)) {
return { return {
label: e, label: e.toLowerCase(),
value: e, value: e,
}; };
} }
return false; return false;
} }
return { return {
label: e, label: e.toLowerCase(),
value: e, value: e,
}; };
}) })
@ -172,7 +172,9 @@
props.showThemeChange || props.showThemeChange ||
props.showLanguageChange || props.showLanguageChange ||
props.showCharsetChange || props.showCharsetChange ||
props.showFullScreen props.showFullScreen ||
slots.leftTitle ||
slots.rightTitle
); );
watch( watch(
@ -259,7 +261,7 @@
watch( watch(
() => props.language, () => props.language,
(newValue) => { (newValue) => {
monaco.editor.setModelLanguage(editor.getModel()!, newValue); monaco.editor.setModelLanguage(editor.getModel()!, newValue.toLowerCase()); // ENUM monaco
} }
); );

View File

@ -5,25 +5,25 @@ export type Theme = 'vs' | 'hc-black' | 'vs-dark' | CustomTheme;
export type FoldingStrategy = 'auto' | 'indentation'; export type FoldingStrategy = 'auto' | 'indentation';
export type RenderLineHighlight = 'all' | 'line' | 'none' | 'gutter'; export type RenderLineHighlight = 'all' | 'line' | 'none' | 'gutter';
export const LanguageEnum = { export const LanguageEnum = {
PLAINTEXT: 'plaintext' as const, PLAINTEXT: 'PLAINTEXT' as const,
JAVASCRIPT: 'javascript' as const, JAVASCRIPT: 'JAVASCRIPT' as const,
TYPESCRIPT: 'typescript' as const, TYPESCRIPT: 'TYPESCRIPT' as const,
CSS: 'css' as const, CSS: 'CSS' as const,
LESS: 'less' as const, LESS: 'LESS' as const,
SASS: 'sass' as const, SASS: 'SASS' as const,
HTML: 'html' as const, HTML: 'HTML' as const,
SQL: 'sql' as const, SQL: 'SQL' as const,
JSON: 'json' as const, JSON: 'JSON' as const,
JAVA: 'java' as const, JAVA: 'JAVA' as const,
PYTHON: 'python' as const, PYTHON: 'PYTHON' as const,
XML: 'xml' as const, XML: 'XML' as const,
YAML: 'yaml' as const, YAML: 'YAML' as const,
SHELL: 'shell' as const, SHELL: 'SHELL' as const,
BEANSHELL: 'beanshell' as const, BEANSHELL: 'BEANSHELL' as const,
BEANSHELL_JSR233: 'beanshell-jsr233' as const, BEANSHELL_JSR233: 'BEANSHELL_JSR233' as const,
GROOVY: 'groovy' as const, GROOVY: 'GROOVY' as const,
NASHORNSCRIPT: 'nashornScript' as const, NASHORNSCRIPT: 'NASHORNSCRIPT' as const,
RHINOSCRIPT: 'rhinoScript' as const, RHINOSCRIPT: 'RHINOSCRIPT' as const,
} as const; } as const;
export type Language = (typeof LanguageEnum)[keyof typeof LanguageEnum]; export type Language = (typeof LanguageEnum)[keyof typeof LanguageEnum];
export interface Options { export interface Options {

View File

@ -1,9 +1,10 @@
import { Language } from '@/components/pure/ms-code-editor/types';
import { import {
RequestAssertionCondition, RequestAssertionCondition,
RequestAuthType, RequestAuthType,
RequestBodyFormat, RequestBodyFormat,
RequestConditionProcessor, RequestConditionProcessor,
RequestConditionScriptLanguage,
RequestContentTypeEnum, RequestContentTypeEnum,
RequestExtractEnvType, RequestExtractEnvType,
RequestExtractExpressionEnum, RequestExtractExpressionEnum,
@ -23,8 +24,6 @@ import {
export type ConditionType = RequestConditionProcessor; export type ConditionType = RequestConditionProcessor;
// 断言-匹配条件规则 // 断言-匹配条件规则
export type RequestAssertionConditionType = RequestAssertionCondition; export type RequestAssertionConditionType = RequestAssertionCondition;
// 前后置条件-脚本语言类型
export type RequestConditionScriptLanguageType = RequestConditionScriptLanguage;
// 响应时间信息 // 响应时间信息
export interface ResponseTiming { export interface ResponseTiming {
dnsLookupTime: number; dnsLookupTime: number;
@ -157,7 +156,7 @@ export interface ScriptCommonConfig {
script: string; // 脚本内容 script: string; // 脚本内容
scriptId: string; // 脚本id scriptId: string; // 脚本id
scriptName: string; // 脚本名称 scriptName: string; // 脚本名称
scriptLanguage: RequestConditionScriptLanguageType; // 脚本语言 scriptLanguage: Language; // 脚本语言
params: KeyValueParam[]; // 公共脚本参数 params: KeyValueParam[]; // 公共脚本参数
} }
// 断言-响应体断言 // 断言-响应体断言

View File

@ -10,6 +10,7 @@
@confirm="applyBatchParams" @confirm="applyBatchParams"
> >
<template #title> <template #title>
<div>
{{ t('common.batchAdd') }} {{ t('common.batchAdd') }}
<a-tooltip position="right"> <a-tooltip position="right">
<icon-exclamation-circle <icon-exclamation-circle
@ -17,25 +18,23 @@
size="16" size="16"
/> />
<template #content> <template #content>
<div>{{ t('apiTestDebug.batchAddParamsTip2') }} </div> <div>{{ t('apiTestDebug.batchAddParamsTip1') }}</div>
<div>{{ t('apiTestDebug.batchAddParamsTip3') }} </div> <div>{{ t('apiTestDebug.batchAddParamsTip2') }}</div>
<div>{{ t('apiTestDebug.batchAddParamsTip3') }}</div>
</template> </template>
</a-tooltip> </a-tooltip>
</div>
</template> </template>
<div class="flex h-full"> <div class="flex h-full">
<MsCodeEditor <MsCodeEditor
v-if="showBatchAddParamDrawer" v-if="showBatchAddParamDrawer"
v-model:model-value="batchParamsCode" v-model:model-value="batchParamsCode"
class="flex-1" class="flex-1"
theme="MS-text" theme="vs"
height="100%" height="100%"
:show-full-screen="false" :show-full-screen="false"
:show-theme-change="false"
> >
<template #title>
<div class="text-[12px] leading-[16px] text-[var(--color-text-4)]">
{{ t('apiTestDebug.batchAddParamsTip') }}
</div>
</template>
</MsCodeEditor> </MsCodeEditor>
</div> </div>
</MsDrawer> </MsDrawer>
@ -85,7 +84,7 @@
const tempObj: Record<string, any> = {}; // const tempObj: Record<string, any> = {}; //
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
const [key, value] = arr[i].split(':'); const [key, value] = arr[i].split(':');
if (key) { if (key || value) {
tempObj[key.trim()] = { tempObj[key.trim()] = {
id: new Date().getTime() + i, id: new Date().getTime() + i,
...props.defaultParamItem, ...props.defaultParamItem,

View File

@ -51,7 +51,8 @@
<MsCodeEditor <MsCodeEditor
v-model:model-value="scriptEx" v-model:model-value="scriptEx"
class="flex-1" class="flex-1"
theme="MS-text" theme="vs"
:language="LanguageEnum.BEANSHELL"
width="500px" width="500px"
height="388px" height="388px"
:show-full-screen="false" :show-full-screen="false"
@ -127,7 +128,7 @@
<div v-show="commonScriptShowType === 'scriptContent'" class="h-[calc(100%-76px)]"> <div v-show="commonScriptShowType === 'scriptContent'" class="h-[calc(100%-76px)]">
<MsCodeEditor <MsCodeEditor
v-model:model-value="condition.script" v-model:model-value="condition.script"
theme="MS-text" theme="vs"
height="100%" height="100%"
:show-full-screen="false" :show-full-screen="false"
:show-theme-change="false" :show-theme-change="false"
@ -380,18 +381,14 @@
}); });
} }
const scriptEx = ref(`2023-12-04 11:19:28 INFO 9026fd6a 1-1 Thread started: 9026fd6a 1-1 const scriptEx = ref(`// 这里可以输入脚本注释
2023-12-04 11:19:28 ERROR 9026fd6a 1-1 Problem in JSR223 script JSR223Sampler, message: {} value = vars.get("variable_name");
In file: inline evaluation of: prev.getResponseCode() import java.net.URI; import org.apache.http.client.method . . . '' Encountered "import" at line 2, column 1. result = "variable_name".equals(value);
in inline evaluation of: prev.getResponseCode() import java.net.URI; import org.apache.http.client.method . . . '' at line number 2 if (!result){
javax.script.ScriptException '' at line number 2 msg = "assertion [" + value + " == 'variable_name']: false;";
javax.script.ScriptException '' at line number 2 AssertionResult.setFailureMessage(msg);
javax.script.ScriptException '' at line number 2 AssertionResult.setFailure(true);
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
`);
const { copy, isSupported } = useClipboard(); const { copy, isSupported } = useClipboard();
function copyScriptEx() { function copyScriptEx() {

View File

@ -40,6 +40,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { LanguageEnum } from '@/components/pure/ms-code-editor/types';
import conditionContent from './content.vue'; import conditionContent from './content.vue';
import conditionList from './list.vue'; import conditionList from './list.vue';
@ -47,7 +48,7 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { ConditionType, ExecuteConditionProcessor } from '@/models/apiTest/debug'; import { ConditionType, ExecuteConditionProcessor } from '@/models/apiTest/debug';
import { RequestConditionProcessor, RequestConditionScriptLanguage } from '@/enums/apiEnum'; import { RequestConditionProcessor } from '@/enums/apiEnum';
const props = defineProps<{ const props = defineProps<{
list: ExecuteConditionProcessor[]; list: ExecuteConditionProcessor[];
@ -94,19 +95,6 @@
emit('change'); 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'), scriptName: t('apiTestDebug.preconditionScriptName'),
enableCommonScript: false, enableCommonScript: false,
enable: true, enable: true,
script: scriptEx.value, script: '',
scriptId: '', scriptId: '',
scriptLanguage: RequestConditionScriptLanguage.BEANSHELL, scriptLanguage: LanguageEnum.BEANSHELL,
params: [], params: [],
}); });
break; break;
@ -134,7 +122,7 @@ org.apache.http.client.method . . . '' at line number 2
// enable: true, // enable: true,
// sqlSource: { // sqlSource: {
// scriptName: '', // scriptName: '',
// script: scriptEx, // script: '',
// storageType: 'column', // storageType: 'column',
// params: [], // params: [],
// }, // },

View File

@ -312,7 +312,7 @@
height="300px" height="300px"
:show-full-screen="false" :show-full-screen="false"
> >
<template #title> <template #rightTitle>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="text-[var(--color-text-1)]"> <div class="text-[var(--color-text-1)]">
{{ t('apiTestDebug.quickInputParamsTip') }} {{ t('apiTestDebug.quickInputParamsTip') }}

View File

@ -88,7 +88,7 @@
:show-full-screen="false" :show-full-screen="false"
:language="currentCodeLanguage" :language="currentCodeLanguage"
> >
<template #title> <template #rightTitle>
<div class="flex flex-col"> <div class="flex flex-col">
<div class="text-[12px] leading-[16px] text-[var(--color-text-4)]"> <div class="text-[12px] leading-[16px] text-[var(--color-text-4)]">
{{ t('apiTestDebug.batchAddParamsTip') }} {{ t('apiTestDebug.batchAddParamsTip') }}

View File

@ -42,6 +42,7 @@
v-model:model-value="requestVModel.url" v-model:model-value="requestVModel.url"
:max-length="255" :max-length="255"
:placeholder="t('apiTestDebug.urlPlaceholder')" :placeholder="t('apiTestDebug.urlPlaceholder')"
allow-clear
@change="handleUrlChange" @change="handleUrlChange"
/> />
</a-input-group> </a-input-group>
@ -49,7 +50,7 @@
<div class="ml-[16px]"> <div class="ml-[16px]">
<a-dropdown-button <a-dropdown-button
:button-props="{ loading: requestVModel.executeLoading }" :button-props="{ loading: requestVModel.executeLoading }"
:disabled="requestVModel.executeLoading" :disabled="requestVModel.executeLoading || (isHttpProtocol && !requestVModel.url)"
class="exec-btn" class="exec-btn"
@click="execute" @click="execute"
@select="execute" @select="execute"
@ -64,14 +65,26 @@
</a-doption> </a-doption>
</template> </template>
</a-dropdown-button> </a-dropdown-button>
<a-dropdown v-if="props.isDefinition" @select="handleSelect"> <a-dropdown
<a-button type="secondary">{{ t('common.save') }}</a-button> v-if="props.isDefinition"
:loading="saveLoading || (isHttpProtocol && !requestVModel.url)"
@select="handleSelect"
>
<a-button type="secondary">
{{ t('common.save') }}
</a-button>
<template #content> <template #content>
<a-doption value="save">{{ t('common.save') }}</a-doption> <a-doption value="save">{{ t('common.save') }}</a-doption>
<a-doption value="saveAsCase">{{ t('apiTestManagement.saveAsCase') }}</a-doption> <a-doption value="saveAsCase">{{ t('apiTestManagement.saveAsCase') }}</a-doption>
</template> </template>
</a-dropdown> </a-dropdown>
<a-button v-else type="secondary" :loading="saveLoading" @click="handleSaveShortcut"> <a-button
v-else
type="secondary"
:disabled="isHttpProtocol && !requestVModel.url"
:loading="saveLoading"
@click="handleSaveShortcut"
>
<div class="flex items-center"> <div class="flex items-center">
{{ t('common.save') }} {{ t('common.save') }}
<div class="text-[var(--color-text-4)]">(<icon-command size="14" />+S)</div> <div class="text-[var(--color-text-4)]">(<icon-command size="14" />+S)</div>
@ -84,6 +97,7 @@
v-model:model-value="requestVModel.name" v-model:model-value="requestVModel.name"
:max-length="255" :max-length="255"
:placeholder="t('apiTestManagement.apiNamePlaceholder')" :placeholder="t('apiTestManagement.apiNamePlaceholder')"
allow-clear
@change="handleActiveDebugChange" @change="handleActiveDebugChange"
/> />
</div> </div>
@ -612,7 +626,7 @@
const saveModalVisible = ref(false); const saveModalVisible = ref(false);
const saveModalForm = ref({ const saveModalForm = ref({
name: '', name: '',
path: requestVModel.value.url || '', path: requestVModel.value.url,
moduleId: 'root', moduleId: 'root',
}); });
const saveModalFormRef = ref<FormInstance>(); const saveModalFormRef = ref<FormInstance>();
@ -772,6 +786,7 @@
...saveModalForm.value, ...saveModalForm.value,
protocol: requestVModel.value.protocol, protocol: requestVModel.value.protocol,
method: isHttpProtocol.value ? requestVModel.value.method : requestVModel.value.protocol, method: isHttpProtocol.value ? requestVModel.value.method : requestVModel.value.protocol,
path: requestVModel.value.url || undefined,
}); });
requestVModel.value.id = res.id; requestVModel.value.id = res.id;
requestVModel.value.isNew = false; requestVModel.value.isNew = false;
@ -779,6 +794,7 @@
requestVModel.value.unSaved = false; requestVModel.value.unSaved = false;
requestVModel.value.name = saveModalForm.value.name; requestVModel.value.name = saveModalForm.value.name;
requestVModel.value.label = saveModalForm.value.name; requestVModel.value.label = saveModalForm.value.name;
requestVModel.value.url = saveModalForm.value.path;
saveLoading.value = false; saveLoading.value = false;
saveModalVisible.value = false; saveModalVisible.value = false;
done(true); done(true);

View File

@ -109,7 +109,7 @@
:language="responseLanguage" :language="responseLanguage"
theme="vs" theme="vs"
height="100%" height="100%"
:languages="['json', 'html', 'xml', 'plaintext']" :languages="[LanguageEnum.JSON, LanguageEnum.HTML, LanguageEnum.XML, LanguageEnum.PLAINTEXT]"
:show-full-screen="false" :show-full-screen="false"
:show-theme-change="false" :show-theme-change="false"
show-language-change show-language-change
@ -150,6 +150,7 @@
import MsButton from '@/components/pure/ms-button/index.vue'; import MsButton from '@/components/pure/ms-button/index.vue';
import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue'; import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue';
import { LanguageEnum } from '@/components/pure/ms-code-editor/types';
import MsIcon from '@/components/pure/ms-icon-font/index.vue'; import MsIcon from '@/components/pure/ms-icon-font/index.vue';
import type { Direction } from '@/components/pure/ms-split-box/index.vue'; import type { Direction } from '@/components/pure/ms-split-box/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
@ -246,15 +247,15 @@
const responseLanguage = computed(() => { const responseLanguage = computed(() => {
const { contentType } = props.response.requestResults[0].responseResult; const { contentType } = props.response.requestResults[0].responseResult;
if (contentType.includes('json')) { if (contentType.includes('json')) {
return 'json'; return LanguageEnum.JSON;
} }
if (contentType.includes('html')) { if (contentType.includes('html')) {
return 'html'; return LanguageEnum.HTML;
} }
if (contentType.includes('xml')) { if (contentType.includes('xml')) {
return 'xml'; return LanguageEnum.XML;
} }
return 'plaintext'; return LanguageEnum.PLAINTEXT;
}); });
const responseEditorRef = ref<InstanceType<typeof MsCodeEditor>>(); const responseEditorRef = ref<InstanceType<typeof MsCodeEditor>>();

View File

@ -69,7 +69,7 @@
v-model:model-value="curlCode" v-model:model-value="curlCode"
theme="MS-text" theme="MS-text"
height="100%" height="100%"
language="plaintext" :language="LanguageEnum.PLAINTEXT"
:show-theme-change="false" :show-theme-change="false"
:show-full-screen="false" :show-full-screen="false"
> >
@ -84,6 +84,7 @@
import MsCard from '@/components/pure/ms-card/index.vue'; import MsCard from '@/components/pure/ms-card/index.vue';
import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue'; import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue';
import { LanguageEnum } from '@/components/pure/ms-code-editor/types';
import MsDrawer from '@/components/pure/ms-drawer/index.vue'; import MsDrawer from '@/components/pure/ms-drawer/index.vue';
import MsEditableTab from '@/components/pure/ms-editable-tab/index.vue'; import MsEditableTab from '@/components/pure/ms-editable-tab/index.vue';
import { TabItem } from '@/components/pure/ms-editable-tab/types'; import { TabItem } from '@/components/pure/ms-editable-tab/types';

View File

@ -33,8 +33,9 @@ export default {
'apiTestDebug.encodeTip1': 'On: Use encoding', 'apiTestDebug.encodeTip1': 'On: Use encoding',
'apiTestDebug.encodeTip2': 'Off: No encoding is used', 'apiTestDebug.encodeTip2': 'Off: No encoding is used',
'apiTestDebug.apply': 'Apply', 'apiTestDebug.apply': 'Apply',
'apiTestDebug.batchAddParamsTip': 'Writing format: parameter name: parameter value; such as nama: natural', 'apiTestDebug.batchAddParamsTip1':
'apiTestDebug.batchAddParamsTip2': 'Multiple records are separated by newlines.', 'Writing format: parameter name: parameter value; such as nama:natural, multiple records separated by newline',
'apiTestDebug.batchAddParamsTip2': 'Added as string type by default; file type parameters cannot be edited here',
'apiTestDebug.batchAddParamsTip3': 'apiTestDebug.batchAddParamsTip3':
'Parameter names in batch addition are repeated. By default, the last data is the latest data.', 'Parameter names in batch addition are repeated. By default, the last data is the latest data.',
'apiTestDebug.quickInputParamsTip': 'Support Mock/JMeter/Json/Text/String, etc.', 'apiTestDebug.quickInputParamsTip': 'Support Mock/JMeter/Json/Text/String, etc.',

View File

@ -33,8 +33,8 @@ export default {
'apiTestDebug.encodeTip1': '开启:使用编码', 'apiTestDebug.encodeTip1': '开启:使用编码',
'apiTestDebug.encodeTip2': '关闭:不使用编码', 'apiTestDebug.encodeTip2': '关闭:不使用编码',
'apiTestDebug.apply': '应用', 'apiTestDebug.apply': '应用',
'apiTestDebug.batchAddParamsTip': '书写格式:参数名:参数值;如 nama:natural', 'apiTestDebug.batchAddParamsTip1': '书写格式:参数名:参数值;如 nama:natural,多条记录以换行分隔',
'apiTestDebug.batchAddParamsTip2': '多条记录以换行分隔;', 'apiTestDebug.batchAddParamsTip2': '默认添加为 string 类型file 类型参数无法在此编辑',
'apiTestDebug.batchAddParamsTip3': '批量添加里的参数名重复,默认以最后一条数据为最新数据', 'apiTestDebug.batchAddParamsTip3': '批量添加里的参数名重复,默认以最后一条数据为最新数据',
'apiTestDebug.quickInputParamsTip': '支持Mock/JMeter/Json/Text/String等', 'apiTestDebug.quickInputParamsTip': '支持Mock/JMeter/Json/Text/String等',
'apiTestDebug.descPlaceholder': '请输入内容', 'apiTestDebug.descPlaceholder': '请输入内容',

View File

@ -77,6 +77,7 @@
import MsButton from '@/components/pure/ms-button/index.vue'; import MsButton from '@/components/pure/ms-button/index.vue';
import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue'; import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue';
import { LanguageEnum } from '@/components/pure/ms-code-editor/types';
import MsDrawer from '@/components/pure/ms-drawer/index.vue'; import MsDrawer from '@/components/pure/ms-drawer/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import type { MsTableColumn } from '@/components/pure/ms-table/type'; import type { MsTableColumn } from '@/components/pure/ms-table/type';
@ -86,7 +87,7 @@
import { getCommonScriptDetail } from '@/api/modules/project-management/commonScript'; import { getCommonScriptDetail } from '@/api/modules/project-management/commonScript';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import type { AddOrUpdateCommonScript, ParamsRequestType } from '@/models/projectManagement/commonScript'; import type { AddOrUpdateCommonScript } from '@/models/projectManagement/commonScript';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
const { t } = useI18n(); const { t } = useI18n();
@ -223,7 +224,7 @@
projectId: '', projectId: '',
params: '', params: '',
script: '', script: '',
type: 'beanshell', type: LanguageEnum.BEANSHELL,
result: '', result: '',
}; };

View File

@ -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'; import { useI18n } from '@/hooks/useI18n';
@ -507,17 +507,17 @@ function jsCode(requestObj) {
export function getCodeTemplate(language: Language, requestObj: any) { export function getCodeTemplate(language: Language, requestObj: any) {
switch (language) { switch (language) {
case 'groovy': case LanguageEnum.GROOVY:
return groovyCode(requestObj); return groovyCode(requestObj);
case 'python': case LanguageEnum.PYTHON:
return pythonCode(requestObj); return pythonCode(requestObj);
case 'beanshell': case LanguageEnum.BEANSHELL:
return javaCode(requestObj); return javaCode(requestObj);
case 'nashornScript': case LanguageEnum.NASHORNSCRIPT:
return jsCode(requestObj); return jsCode(requestObj);
case 'rhinoScript': case LanguageEnum.RHINOSCRIPT:
return jsCode(requestObj); return jsCode(requestObj);
case 'javascript': case LanguageEnum.JAVASCRIPT:
return jsCode(requestObj); return jsCode(requestObj);
default: default:
return ''; return '';

View File

@ -195,7 +195,7 @@
<!-- TODO:代码编辑器懒加载 --> <!-- TODO:代码编辑器懒加载 -->
<div v-show="form.addType === 'multiple'"> <div v-show="form.addType === 'multiple'">
<MsCodeEditor v-model:model-value="editorContent" width="100%" height="400px" theme="MS-text"> <MsCodeEditor v-model:model-value="editorContent" width="100%" height="400px" theme="MS-text">
<template #title> <template #rightTitle>
<a-form-item <a-form-item
:label="t('system.resourcePool.batchAddResource')" :label="t('system.resourcePool.batchAddResource')"
asterisk-position="end" asterisk-position="end"