fix: 修改公共脚本不同语言分号问题&评论组件展开折叠问题

This commit is contained in:
xinxin.wu 2024-04-23 18:11:00 +08:00 committed by 刘瑞斌
parent e8295cd86b
commit 6805e8cf06
5 changed files with 55 additions and 54 deletions

View File

@ -143,13 +143,6 @@ export default defineComponent({
); );
}; };
watch(
() => props.commentList,
() => {
expendedIds.value = [];
}
);
const renderChildrenList = (list?: CommentItem[]) => { const renderChildrenList = (list?: CommentItem[]) => {
if (!list || list.length === 0) { if (!list || list.length === 0) {
return null; return null;
@ -176,6 +169,7 @@ export default defineComponent({
const renderParentList = (list: CommentItem[]) => { const renderParentList = (list: CommentItem[]) => {
return list.map((item) => ( return list.map((item) => (
<> <>
{/* {expendedIds.value}--expendedIds */}
<Item <Item
mode={'parent'} mode={'parent'}
onReply={() => handleReply(item)} onReply={() => handleReply(item)}

View File

@ -136,7 +136,7 @@
result: '', result: '',
}; };
const form = ref({ ...initForm }); const form = ref({ ...cloneDeep(initForm) });
const columns: MsTableColumn = [ const columns: MsTableColumn = [
{ {
@ -243,7 +243,7 @@
() => showScriptDrawer.value, () => showScriptDrawer.value,
(val) => { (val) => {
if (val) { if (val) {
form.value = { ...initForm }; form.value = { ...cloneDeep(initForm) };
innerParams.value = []; innerParams.value = [];
editScriptId.value = props.scriptId; editScriptId.value = props.scriptId;
if (editScriptId.value) { if (editScriptId.value) {

View File

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<div class="p-[12px] pt-0"> <div class="p-[12px] pt-0">
<div v-for="item of SCRIPT_MENU" :key="item.value" class="menuItem px-1" @click="handleClick(item)"> <div v-for="item of scriptMenus" :key="item.value" class="menuItem px-1" @click="handleClick(item)">
{{ item.title }} {{ item.title }}
</div> </div>
</div> </div>
@ -50,7 +50,7 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import type { CommonScriptMenu } from './types'; import type { CommonScriptMenu } from './types';
import { getCodeTemplate, SCRIPT_MENU } from './utils'; import { getCodeTemplate, getScriptMenu } from './utils';
const { t } = useI18n(); const { t } = useI18n();
@ -81,6 +81,10 @@
{ text: 'JavaScript', value: LanguageEnum.JAVASCRIPT }, { text: 'JavaScript', value: LanguageEnum.JAVASCRIPT },
]; ];
const scriptMenus = computed(() => {
return innerLanguageType.value !== LanguageEnum.PYTHON ? getScriptMenu(';') : getScriptMenu('');
});
function expandedHandler() { function expandedHandler() {
innerExpand.value = !innerExpand.value; innerExpand.value = !innerExpand.value;
} }

View File

@ -21,49 +21,51 @@ function getInsertCommonScript() {
return []; return [];
} }
export const SCRIPT_MENU: CommonScriptMenu[] = [ export function getScriptMenu(SemicolonStr: string) {
// TODO 这个版本不上 return [
// { // TODO 这个版本不上
// title: t('project.code_segment.importApiTest'), // {
// value: 'api_definition', // title: t('project.code_segment.importApiTest'),
// command: 'api_definition', // value: 'api_definition',
// }, // command: 'api_definition',
{ // },
title: t('project.code_segment.newApiTest'), {
value: 'new_api_request', title: t('project.code_segment.newApiTest'),
command: 'new_api_request', value: 'new_api_request',
}, command: 'new_api_request',
{ },
title: t('project.processor.codeTemplateGetVariable'), {
value: 'vars.get("variable_name");', title: t('project.processor.codeTemplateGetVariable'),
}, value: `vars.get("variable_name")${SemicolonStr}`,
{ },
title: t('project.processor.codeTemplateSetVariable'), {
value: 'vars.put("variable_name", "variable_value");', title: t('project.processor.codeTemplateSetVariable'),
}, value: `vars.put("variable_name", "variable_value")${SemicolonStr}`,
{ },
title: t('project.processor.codeTemplateGetResponseHeader'), {
value: 'prev.getResponseHeaders();', title: t('project.processor.codeTemplateGetResponseHeader'),
}, value: `prev.getResponseHeaders()${SemicolonStr}`,
{ },
title: t('project.processor.codeTemplateGetResponseCode'), {
value: 'prev.getResponseCode();', title: t('project.processor.codeTemplateGetResponseCode'),
}, value: `prev.getResponseCode()${SemicolonStr}`,
{ },
title: t('project.processor.codeTemplateGetResponseResult'), {
value: 'prev.getResponseDataAsString();', title: t('project.processor.codeTemplateGetResponseResult'),
}, value: `prev.getResponseDataAsString()${SemicolonStr}`,
{ },
title: t('project.processor.paramEnvironmentSetGlobalVariable'), {
value: `vars.put(\${__metersphere_env_id}+"key","value");\nvars.put("key","value");`, title: t('project.processor.paramEnvironmentSetGlobalVariable'),
}, value: `vars.put(\${__metersphere_env_id}+"key","value");\nvars.put("key","value");`,
...getInsertCommonScript(), },
{ ...getInsertCommonScript(),
title: t('project.processor.terminationTest'), {
value: 'api_stop', title: t('project.processor.terminationTest'),
command: 'api_stop', value: 'api_stop',
}, command: 'api_stop',
]; },
];
}
// 处理groovyCode 请求头 // 处理groovyCode 请求头
function getGroovyHeaders(requestHeaders: Record<string, any>) { function getGroovyHeaders(requestHeaders: Record<string, any>) {

View File

@ -92,6 +92,7 @@
value: 'LIST', value: 'LIST',
}, },
], ],
width: 150,
titleSlotName: 'typeTitle', titleSlotName: 'typeTitle',
typeTitleTooltip: t('apiScenario.params.typeTooltip'), typeTitleTooltip: t('apiScenario.params.typeTooltip'),
}, },