feat: 党的献礼需求

This commit is contained in:
chenjianxing 2021-07-01 17:25:38 +08:00 committed by jianxing
parent cc47c18991
commit c05b0d665f
3 changed files with 59 additions and 12 deletions

View File

@ -105,7 +105,7 @@
<el-row> <el-row>
<el-col :span="21"> <el-col :span="21">
<!-- 调试部分 --> <!-- 调试部分 -->
<div class="ms-debug-div" @click="showAll"> <div class="ms-debug-div" @click="showAll" :class="{'is-top' : isTop}" ref="debugHeader">
<el-row style="margin: 5px"> <el-row style="margin: 5px">
<el-col :span="4" class="ms-col-one ms-font"> <el-col :span="4" class="ms-col-one ms-font">
<el-tooltip placement="top" effect="light"> <el-tooltip placement="top" effect="light">
@ -144,9 +144,11 @@
:project-list="projectList" ref="envPopover"/> :project-list="projectList" ref="envPopover"/>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click <el-tooltip content="Ctrl + R">
@click="runDebug">{{ $t('api_test.request.debug') }} <el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click
</el-button> @click="runDebug">{{ $t('api_test.request.debug') }}
</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" :content="$t('commons.refresh')" placement="right-start"> <el-tooltip class="item" effect="dark" :content="$t('commons.refresh')" placement="right-start">
<el-button :disabled="scenarioDefinition.length < 1" size="mini" icon="el-icon-refresh" <el-button :disabled="scenarioDefinition.length < 1" size="mini" icon="el-icon-refresh"
v-prevent-re-click @click="getApiScenario"></el-button> v-prevent-re-click @click="getApiScenario"></el-button>
@ -158,8 +160,9 @@
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<!-- 场景步骤内容 --> <!-- 场景步骤内容 -->
<div> <div ref="stepInfo">
<el-tooltip :content="$t('api_test.automation.open_expansion')" placement="top" effect="light"> <el-tooltip :content="$t('api_test.automation.open_expansion')" placement="top" effect="light">
<i class="el-icon-circle-plus-outline ms-open-btn ms-open-btn-left" v-prevent-re-click @click="openExpansion"/> <i class="el-icon-circle-plus-outline ms-open-btn ms-open-btn-left" v-prevent-re-click @click="openExpansion"/>
</el-tooltip> </el-tooltip>
@ -279,7 +282,14 @@ import {
import {parseEnvironment} from "../../definition/model/EnvironmentModel"; import {parseEnvironment} from "../../definition/model/EnvironmentModel";
import {ELEMENT_TYPE, ELEMENTS} from "./Setting"; import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
import MsApiCustomize from "./ApiCustomize"; import MsApiCustomize from "./ApiCustomize";
import {getUUID, objToStrMap, strMapToObj, handleCtrlSEvent, getCurrentProjectID} from "@/common/js/utils"; import {
getUUID,
objToStrMap,
strMapToObj,
handleCtrlSEvent,
getCurrentProjectID,
handleCtrlREvent
} from "@/common/js/utils";
import ApiEnvironmentConfig from "@/business/components/api/test/components/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "@/business/components/api/test/components/ApiEnvironmentConfig";
import MsInputTag from "./MsInputTag"; import MsInputTag from "./MsInputTag";
import MsRun from "./DebugRun"; import MsRun from "./DebugRun";
@ -392,7 +402,8 @@ export default {
stepEnable: true, stepEnable: true,
envResult: { envResult: {
loading: false loading: false
} },
isTop: false,
} }
}, },
created() { created() {
@ -403,8 +414,11 @@ export default {
this.getWsProjects(); this.getWsProjects();
this.getMaintainerOptions(); this.getMaintainerOptions();
this.getApiScenario(); this.getApiScenario();
this.addListener(); // ctrl s },
mounted() {
this.$nextTick(() => {
this.addListener();
});
}, },
directives: {OutsideClick}, directives: {OutsideClick},
computed: { computed: {
@ -561,14 +575,20 @@ export default {
}, },
addListener() { addListener() {
document.addEventListener("keydown", this.createCtrlSHandle); document.addEventListener("keydown", this.createCtrlSHandle);
// document.addEventListener("keydown", (even => handleCtrlSEvent(even, this.$refs.httpApi.saveApi))); document.addEventListener("keydown", this.createCtrlRHandle);
document.addEventListener("scroll", this.handleScroll, true);
}, },
removeListener() { removeListener() {
document.removeEventListener("keydown", this.createCtrlSHandle); document.removeEventListener("keydown", this.createCtrlSHandle);
document.removeEventListener("keydown", this.createCtrlRHandle);
document.removeEventListener("scroll", this.handleScroll);
}, },
createCtrlSHandle(event) { createCtrlSHandle(event) {
handleCtrlSEvent(event, this.editScenario); handleCtrlSEvent(event, this.editScenario);
}, },
createCtrlRHandle(event) {
handleCtrlREvent(event, this.runDebug);
},
getIdx(index) { getIdx(index) {
return index - 0.33 return index - 0.33
}, },
@ -870,7 +890,7 @@ export default {
}, },
runDebug() { runDebug() {
/*触发执行操作*/ /*触发执行操作*/
this.$refs['currentScenario'].validate((valid) => { this.$refs.currentScenario.validate((valid) => {
if (valid) { if (valid) {
let definition = JSON.parse(JSON.stringify(this.currentScenario)); let definition = JSON.parse(JSON.stringify(this.currentScenario));
definition.hashTree = this.scenarioDefinition; definition.hashTree = this.scenarioDefinition;
@ -1252,6 +1272,17 @@ export default {
disableAll() { disableAll() {
this.stepEnable = false; this.stepEnable = false;
this.stepNode(); this.stepNode();
},
handleScroll() {
let stepInfo = this.$refs.stepInfo;
let debugHeader = this.$refs.debugHeader;
let originWidth = debugHeader.clientWidth;
if (stepInfo.getBoundingClientRect().top <= 178) {
this.isTop = true;
debugHeader.style.width = originWidth + 'px';
} else {
this.isTop = false;
}
} }
} }
} }
@ -1421,4 +1452,11 @@ export default {
.ms-open-btn-left { .ms-open-btn-left {
margin-left: 35px; margin-left: 35px;
} }
.is-top {
position: fixed;
top: 125px;
background: white;
z-index: 999;
}
</style> </style>

View File

@ -73,7 +73,7 @@
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index" type="success" effect="plain" <ms-tag v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index" type="success" effect="plain"
:content="tag" style="margin-left: 0px; margin-right: 2px"/> :content="tag" style="margin-left: 0px; margin-right: 2px"/>
<span></span> <span/>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column

View File

@ -440,6 +440,15 @@ export function handleCtrlSEvent(event, func) {
} }
} }
export function handleCtrlREvent(event, func) {
if (event.keyCode === 82 && event.ctrlKey) {
func();
event.preventDefault();
event.returnValue = false;
return false;
}
}
export function strMapToObj(strMap) { export function strMapToObj(strMap) {
if (strMap) { if (strMap) {
let obj = Object.create(null); let obj = Object.create(null);