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 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

View File

@ -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')

View File

@ -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;
}>();

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';
@ -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 '';

View File

@ -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',
},
],

View File

@ -166,7 +166,7 @@
</template>
</a-form>
<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]"
>
<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.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',

View File

@ -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 加密',

View File

@ -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
}
);

View File

@ -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 {

View File

@ -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[]; // 公共脚本参数
}
// 断言-响应体断言

View File

@ -10,6 +10,7 @@
@confirm="applyBatchParams"
>
<template #title>
<div>
{{ t('common.batchAdd') }}
<a-tooltip position="right">
<icon-exclamation-circle
@ -17,25 +18,23 @@
size="16"
/>
<template #content>
<div>{{ t('apiTestDebug.batchAddParamsTip2') }} </div>
<div>{{ t('apiTestDebug.batchAddParamsTip3') }} </div>
<div>{{ t('apiTestDebug.batchAddParamsTip1') }}</div>
<div>{{ t('apiTestDebug.batchAddParamsTip2') }}</div>
<div>{{ t('apiTestDebug.batchAddParamsTip3') }}</div>
</template>
</a-tooltip>
</div>
</template>
<div class="flex h-full">
<MsCodeEditor
v-if="showBatchAddParamDrawer"
v-model:model-value="batchParamsCode"
class="flex-1"
theme="MS-text"
theme="vs"
height="100%"
: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>
</div>
</MsDrawer>
@ -85,7 +84,7 @@
const tempObj: Record<string, any> = {}; //
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,

View File

@ -51,7 +51,8 @@
<MsCodeEditor
v-model:model-value="scriptEx"
class="flex-1"
theme="MS-text"
theme="vs"
:language="LanguageEnum.BEANSHELL"
width="500px"
height="388px"
:show-full-screen="false"
@ -127,7 +128,7 @@
<div v-show="commonScriptShowType === 'scriptContent'" class="h-[calc(100%-76px)]">
<MsCodeEditor
v-model:model-value="condition.script"
theme="MS-text"
theme="vs"
height="100%"
:show-full-screen="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
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
`);
const scriptEx = ref(`// 这里可以输入脚本注释
value = vars.get("variable_name");
result = "variable_name".equals(value);
if (!result){
msg = "assertion [" + value + " == 'variable_name']: false;";
AssertionResult.setFailureMessage(msg);
AssertionResult.setFailure(true);
}`);
const { copy, isSupported } = useClipboard();
function copyScriptEx() {

View File

@ -40,6 +40,7 @@
<script setup lang="ts">
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: [],
// },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,8 +33,9 @@ export default {
'apiTestDebug.encodeTip1': 'On: Use encoding',
'apiTestDebug.encodeTip2': 'Off: No encoding is used',
'apiTestDebug.apply': 'Apply',
'apiTestDebug.batchAddParamsTip': 'Writing format: parameter name: parameter value; such as nama: natural',
'apiTestDebug.batchAddParamsTip2': 'Multiple records are separated by newlines.',
'apiTestDebug.batchAddParamsTip1':
'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':
'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.',

View File

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

View File

@ -77,6 +77,7 @@
import MsButton from '@/components/pure/ms-button/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 MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import type { MsTableColumn } from '@/components/pure/ms-table/type';
@ -86,7 +87,7 @@
import { getCommonScriptDetail } from '@/api/modules/project-management/commonScript';
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';
const { t } = useI18n();
@ -223,7 +224,7 @@
projectId: '',
params: '',
script: '',
type: 'beanshell',
type: LanguageEnum.BEANSHELL,
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';
@ -507,17 +507,17 @@ function jsCode(requestObj) {
export function getCodeTemplate(language: Language, 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);
default:
return '';

View File

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