refactor: 统一全局事件总线使用方式

This commit is contained in:
shiziyuan9527 2022-02-21 11:08:06 +08:00 committed by shiziyuan9527
parent 5aca315a01
commit 077cc22f33
6 changed files with 7 additions and 15 deletions

View File

@ -83,7 +83,6 @@ import MsApiReportViewHeader from "./ApiReportViewHeader";
import {RequestFactory} from "../../definition/model/ApiTestModel"; import {RequestFactory} from "../../definition/model/ApiTestModel";
import {windowPrint, getCurrentProjectID, getUUID} from "@/common/js/utils"; import {windowPrint, getCurrentProjectID, getUUID} from "@/common/js/utils";
import {STEP} from "../scenario/Setting"; import {STEP} from "../scenario/Setting";
import {scenario} from "@/business/components/track/plan/event-bus";
export default { export default {
name: "SysnApiReportDetail", name: "SysnApiReportDetail",
@ -367,7 +366,7 @@ export default {
if (e.data && e.data.indexOf("MS_TEST_END") !== -1) { if (e.data && e.data.indexOf("MS_TEST_END") !== -1) {
this.getReport(); this.getReport();
this.messageWebSocket.close(); this.messageWebSocket.close();
scenario.$emit('hide', this.scenarioId); this.$EventBus.$emit('hide', this.scenarioId);
this.$emit('refresh', this.debugResult); this.$emit('refresh', this.debugResult);
} }
}, },

View File

@ -310,7 +310,6 @@ import {
getLastTableSortField getLastTableSortField
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import {API_SCENARIO_FILTERS} from "@/common/js/table-constants"; import {API_SCENARIO_FILTERS} from "@/common/js/table-constants";
import {scenario} from "@/business/components/track/plan/event-bus";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn"; import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
@ -568,7 +567,7 @@ export default {
}, },
created() { created() {
this.apiscenariofilters = API_SCENARIO_FILTERS(); this.apiscenariofilters = API_SCENARIO_FILTERS();
scenario.$on('hide', id => { this.$EventBus.$on('hide', id => {
this.hideStopBtn(id); this.hideStopBtn(id);
}); });
this.projectId = getCurrentProjectID(); this.projectId = getCurrentProjectID();
@ -617,7 +616,7 @@ export default {
} }
}, },
beforeDestroy() { beforeDestroy() {
scenario.$off("hide"); this.$EventBus.$off("hide");
}, },
watch: { watch: {
selectNodeIds() { selectNodeIds() {

View File

@ -1,3 +0,0 @@
import Vue from 'vue';
export const hub = new Vue();
export const scenario = new Vue();

View File

@ -287,7 +287,6 @@ import MsTableOperatorButton from "../../../../../common/components/MsTableOpera
import {TEST_PLAN_TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components"; import {TEST_PLAN_TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components";
import BatchEdit from "../../../../case/components/BatchEdit"; import BatchEdit from "../../../../case/components/BatchEdit";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import {hub} from "@/business/components/track/plan/event-bus";
import MsTag from "@/business/components/common/components/MsTag"; import MsTag from "@/business/components/common/components/MsTag";
import { import {
buildBatchParam, buildBatchParam,
@ -451,7 +450,7 @@ export default {
}, },
mounted() { mounted() {
this.$emit('setCondition', this.condition); this.$emit('setCondition', this.condition);
hub.$on("openFailureTestCase", row => { this.$EventBus.$on("openFailureTestCase", row => {
this.isReadOnly = true; this.isReadOnly = true;
this.condition.status = 'Failure'; this.condition.status = 'Failure';
this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row, this.tableData); this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row, this.tableData);
@ -463,7 +462,7 @@ export default {
this.getVersionOptions(); this.getVersionOptions();
}, },
beforeDestroy() { beforeDestroy() {
hub.$off("openFailureTestCase"); this.$EventBus.$off("openFailureTestCase");
}, },
methods: { methods: {
nextPage() { nextPage() {

View File

@ -15,7 +15,6 @@
import TypeTableItem from "../../../../../common/tableItems/planview/TypeTableItem"; import TypeTableItem from "../../../../../common/tableItems/planview/TypeTableItem";
import MethodTableItem from "../../../../../common/tableItems/planview/MethodTableItem"; import MethodTableItem from "../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../common/tableItems/planview/StatusTableItem"; import StatusTableItem from "../../../../../common/tableItems/planview/StatusTableItem";
import {hub} from "@/business/components/track/plan/event-bus";
import FunctionalFailureCasesList from "./component/FunctionalFailureCasesList"; import FunctionalFailureCasesList from "./component/FunctionalFailureCasesList";
import ApiFailureCasesList from "./component/ApiFailureCasesList"; import ApiFailureCasesList from "./component/ApiFailureCasesList";
import ScenarioFailureCasesList from "./component/ScenarioFailureCasesList"; import ScenarioFailureCasesList from "./component/ScenarioFailureCasesList";
@ -66,7 +65,7 @@
}, },
methods: { methods: {
goFailureTestCase(row) { goFailureTestCase(row) {
hub.$emit("openFailureTestCase", row); this.$EventBus.$emit("openFailureTestCase", row);
} }
} }
} }

View File

@ -92,7 +92,6 @@
import TypeTableItem from "../../../../../common/tableItems/planview/TypeTableItem"; import TypeTableItem from "../../../../../common/tableItems/planview/TypeTableItem";
import MethodTableItem from "../../../../../common/tableItems/planview/MethodTableItem"; import MethodTableItem from "../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../common/tableItems/planview/StatusTableItem"; import StatusTableItem from "../../../../../common/tableItems/planview/StatusTableItem";
import {hub} from "@/business/components/track/plan/event-bus";
export default { export default {
name: "FailureResultComponent", name: "FailureResultComponent",
components: {StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem, CommonComponent}, components: {StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem, CommonComponent},
@ -127,7 +126,7 @@
}, },
methods: { methods: {
goFailureTestCase(row) { goFailureTestCase(row) {
hub.$emit("openFailureTestCase", row); this.$EventBus.$emit("openFailureTestCase", row);
} }
} }
} }