feat:添加beforeDestroy生命周期,解绑bus.$on 以及。on事件

This commit is contained in:
zhangyu
2020-11-20 11:19:25 +08:00
parent 8fb4540ab5
commit c3ac72e483
30 changed files with 99 additions and 173 deletions

View File

@@ -1396,6 +1396,7 @@
this.clearChart(); this.clearChart();
//const addChartBox = document.querySelector('.right-box-add-chart'); //const addChartBox = document.querySelector('.right-box-add-chart');
//addChartBox.style.cssText = this.oldChartBoxCss; //addChartBox.style.cssText = this.oldChartBoxCss;
this.echartModalStore.off('magictypechanged')
}, },
}; };

View File

@@ -96,6 +96,10 @@
}, },
mounted() { mounted() {
this.initEditor(); this.initEditor();
},
beforeDestroy(){
this.quill.off('selection-change');
this.quill.off('text-change');
} }
} }
</script> </script>

View File

@@ -351,6 +351,9 @@ export default {
}, },
beforeDestroy () { beforeDestroy () {
this.closeSocket(); this.closeSocket();
this.term.off("selection");
this.term.off("data")
} }
} }
</script> </script>

View File

@@ -270,6 +270,9 @@
}) })
} }
}, },
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -920,6 +920,9 @@
} }
*/ */
}, },
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -117,6 +117,9 @@
} }
}); });
}, },
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -105,6 +105,9 @@
} }
}, 500); }, 500);
} }
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -686,6 +686,9 @@
this.dropCol = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-/alertList") this.dropCol = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-/alertList")
? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-/alertList")) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-/alertList"))
: this.tableTitle; : this.tableTitle;
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -278,6 +278,9 @@
}); });
} }
}); });
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -685,6 +685,9 @@
}, 300); }, 300);
//}); //});
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -498,6 +498,9 @@
}, 500); }, 500);
} }
} }
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -212,6 +212,9 @@ export default {
this.popBox.isEdit=n; this.popBox.isEdit=n;
} }
} }
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -70,6 +70,9 @@
} }
} }
}, },
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -120,6 +120,9 @@
return true; return true;
} }
}, },
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -399,6 +399,9 @@
}) })
}, },
}, },
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -693,167 +693,6 @@
setTimeout(()=>{ setTimeout(()=>{
let this_=this; let this_=this;
this.init('modal'); this.init('modal');
this.network.on("click", function (params) {
this_.activeIndex='';
this_.networkPopClose();
this_.network.selectNodes([]);
if(!params.edges.length&&!params.nodes.length){
this_.popDataShowUpdate('');
}
let selId=params.nodes[0];
// if(this_.selNodeId&& this_.selNodeId===selId){return;}
if(selId){
this_.selNodeId=selId;
}else{
this_.selNodeId='';
}
});
this.network.on("selectNode", function (params) { //选择节点
let selId=params.nodes[0];
if(this_.selNodeId&& this_.selNodeId===selId){
if(selId){
this_.cursorMove=true;
if(this_.NodeArr.indexOf(selId)!==-1){
let index = this_.NodeArr.indexOf(selId);
this_.NodeArr=this_.NodeArr.filter((item,i)=> i !== index);
return
}
if(this_.selectNodeTitle&&this_.NodeArrShow){
this_.NodeArr.push(selId);
this_.network.selectNodes(this_.NodeArr,true);
return
}
if(this_.NodeArr.length===0&&this_.editVisNetwork){
this_.nodeEdit();
}
this_.setPopPosition(selId,params);
}
}else{
if(selId){
this_.selNodeId=selId;
this_.cursorMove=true;
this_.nodeData=this_.nodesArray.find((item)=>item.id===selId);
if(this_.NodeArr.indexOf(selId)!==-1){
let index = this_.NodeArr.indexOf(selId);
this_.NodeArr=this_.NodeArr.filter((item,i)=> i !== index);
return
}
if(this_.selectNodeTitle&&this_.NodeArrShow){
this_.NodeArr.push(selId);
this_.network.selectNodes(this_.NodeArr,true);
return
}
if(this_.NodeArr.length===0&&this_.editVisNetwork){
this_.nodeEdit();
}
this_.setPopPosition(selId,params);
this_.popDataShowUpdate('main');
}
}
});
this.network.on("selectEdge", function (params) { // 选择边
this_.selNodeId='';
this_.lineData=this_.edgesArray.find((item)=>item.id===params.edges[0]);
if(this_.editVisNetwork){
this_.lineData.color=this_.lineData.color.color?this_.lineData.color.color:this_.lineData.color;
this_.addLineShow=true;
this_.isLineAdd=false;
}
if(!this_.editVisNetwork){
if(this_.lineData.expressions&&this_.lineData.expressions.length){
this_.expressionsInfoShow=false;
this_.popDataShowUpdate('total')
}else{
this_.popDataShowUpdate()
}
}
// this_.lineData.color=this_.lineData.color.color;
// this_.addLineShow=true;
});
this.network.on("dragStart", function (params) {//节点移动开始
this_.NodeArrShow=false;
this_.networkPopShow=false;
this_.index='';
this_.activeIndex='';
let selId=params.nodes[0];
if(selId){
this_.selNodeId=selId
}
// if(!selId){
// this_.modelTop.forEach(item=>{
// item.show=false;
// })
// }
});
this.network.on("dragging", function () {//节点移动中
this_.viewsCenter=this_.network.getViewPosition();
// let selId=params.nodes[0];
if(this_.selNodeId){
this_.setNodePosition(this_.selNodeId)
}
if(this_.selNodeId&&this_.networkPopShow){
this_.setPopPosition(this_.selNodeId);
}
if(this_.NodeArr.length>0){
this_.NodeArrShow=true;
}
this_.modelTopUpdate();
this_.selNodeArrUpdate();
});
this.network.on("dragEnd", function () {//节点移动结束
this_.viewsCenter=this_.network.getViewPosition();
if(this_.selNodeId){
this_.setNodePosition(this_.selNodeId)
}
if(this_.selNodeId&&this_.networkPopShow){
this_.setPopPosition(this_.selNodeId);
}
if(this_.NodeArr.length>0){
this_.NodeArrShow=true;
}
if(!this_.networkPopShow){
this_.selNodeId=''
}
this_.modelTopUpdate();
this_.selNodeArrUpdate();
});
this.network.on("hoverNode", function () {//hoverNode
this_.cursorMove=true;
// console.log(123123123);
});
this.network.on("blurNode", function () {//blurNode
this_.cursorMove=false;
});
this.network.on("zoom", function (params) {//检测缩放
this_.zoom=params.scale;
this_.modelTopUpdate();
this_.selNodeArrUpdate();
if(this_.networkPopShow){
this_.setPopPosition(this_.selNodeId);
}
this_.topologyZoom(params.scale);
return false
});
this.network.on("resize", function (params) {//检测resize
setTimeout(()=>{
this_.zoom=this_.network.canvasToDOM({x:0,y:1}).y-this_.network.canvasToDOM({x:0,y:0}).y;
this_.modelTopUpdate();
this_.selNodeArrUpdate();
if(this_.networkPopShow){
this_.setPopPosition(this_.selNodeId);
}
});
return false
});
}) })
}, },
beforeDestroy(){ beforeDestroy(){

View File

@@ -70,6 +70,9 @@
}) })
}, },
methods:{}, methods:{},
beforeDestroy(){
}
} }
</script> </script>

View File

@@ -483,8 +483,10 @@
this.importBox.show = true; this.importBox.show = true;
}, },
}, },
beforeDestroy(){
} }
}
</script> </script>
<style scoped> <style scoped>

View File

@@ -341,8 +341,10 @@
this.getAssetList(); this.getAssetList();
}, },
}, },
beforeDestroy(){
} }
}
</script> </script>
<style scoped> <style scoped>

View File

@@ -331,8 +331,10 @@
this.getEndpointList(); this.getEndpointList();
}, },
}, },
beforeDestroy(){
} }
}
</script> </script>
<style scoped> <style scoped>

View File

@@ -114,6 +114,9 @@
} }
}, },
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -173,6 +173,9 @@
this.filter.panelId = this.showPanel.id; this.filter.panelId = this.showPanel.id;
// this.getData(this.filter); // this.getData(this.filter);
}, },
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -1042,6 +1042,17 @@
}) })
}, },
beforeDestroy() { beforeDestroy() {
this.network.off('click');
this.network.off('selectNode');
this.network.off('selectEdge');
this.network.off('hoverEdge');
this.network.off('blurEdge');
this.network.off('dragStart');
this.network.off('dragging');
this.network.off('dragEnd');
this.network.off('blurNode');
this.network.off('zoom');
this.network.off('resize');
this.network=null; this.network=null;
}, },
} }

View File

@@ -233,6 +233,9 @@ export default {
// } // }
// }; // };
}, },
beforeDestroy(){
window.onresize=null
}
} }
</script> </script>

View File

@@ -29,9 +29,9 @@
<el-form-item :label="$t('config.system.basic.storageRetention')" prop="storage_local_retention"> <el-form-item :label="$t('config.system.basic.storageRetention')" prop="storage_local_retention">
<el-input v-model.number="basic.storage_local_retention" ></el-input><span class="nz-input-append">{{$t('config.system.basic.day')}}</span> <el-input v-model.number="basic.storage_local_retention" ></el-input><span class="nz-input-append">{{$t('config.system.basic.day')}}</span>
</el-form-item> </el-form-item>
<!--<el-form-item :label="$t('config.system.basic.maxSeries')" prop="storage_local_retention">--> <el-form-item :label="$t('config.system.basic.maxSeries')" prop="storage_local_retention">
<!--<el-input-number v-model="basic.query_max_series" controls-position="right" :min="-1" :max="1000" :precision="0"></el-input-number>--> <el-input-number v-model="basic.query_max_series" controls-position="right" :min="-1" :max="1000" :precision="0"></el-input-number>
<!--</el-form-item>--> </el-form-item>
<el-form-item :label="$t('config.system.basic.timezone')" prop="timezone"> <el-form-item :label="$t('config.system.basic.timezone')" prop="timezone">
<!-- <el-input v-model.number="basic.timezone" ></el-input>--> <!-- <el-input v-model.number="basic.timezone" ></el-input>-->
<el-select v-model="basic.timezone"> <el-select v-model="basic.timezone">
@@ -327,7 +327,7 @@
current_site_url:'', current_site_url:'',
timezone:'', timezone:'',
default_cabinet_usize:'', default_cabinet_usize:'',
// query_max_series:'' query_max_series:''
}, },
basicCopy:null, basicCopy:null,
basicRules:{ basicRules:{

View File

@@ -225,6 +225,9 @@
handler(n,o){ handler(n,o){
} }
} }
},
beforeDestroy(){
} }
} }
</script> </script>

View File

@@ -872,6 +872,9 @@
this.storeSuggestions(); this.storeSuggestions();
} }
} }
},
beforeDestroy(){
this.quill.off('text-change')
} }
} }
</script> </script>

View File

@@ -480,6 +480,9 @@
destroyed() { destroyed() {
if(this.chart){ if(this.chart){
this.chart.clear(); this.chart.clear();
this.chart.off('mouseover');
this.chart.off('mouseout');
EleResize.off(this.$el, this.resize, this.chartType);
} }
} }
} }

View File

@@ -1581,17 +1581,19 @@
this.setFreshDataTimer(); this.setFreshDataTimer();
}) })
window.onresize = () => { // window.onresize = () => {
let vm = this; // let vm = this;
setTimeout(() => { // setTimeout(() => {
//vm.map. // //vm.map.
}, 500); // }, 500);
}; // };
},
beforeDestroy(){
this.allProject=null;
}, },
destroyed() { destroyed() {
clearInterval(this.freshDataTimer); clearInterval(this.freshDataTimer);
clearInterval(this.freshDateTimer); clearInterval(this.freshDateTimer);
this.allProject=null;
} }
} }
</script> </script>

View File

@@ -741,6 +741,9 @@
temp.search(); temp.search();
},1000) },1000)
}, },
},
beforeDestroy(){
} }
} }
</script> </script>