实时视频流index页全局刷新改为provide+inject组合局部刷新

merge-requests/1/head
张鑫 5 years ago
parent 7c6666428e
commit 28ff32b80c

@ -1,11 +1,30 @@
<template> <template>
<div id="app"> <div id="app">
<router-view /> <router-view v-if="isRouterAlive"/>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'App',
data () {
return {
isRouterAlive: true
}
},
provide(){ //
return {
reload: this.reload
}
},
methods: {
reload(){
this.isRouterAlive = false
this.$nextTick( function () {
this.isRouterAlive = true
})
}
},
mounted() { mounted() {
window.onmessage = e => { window.onmessage = e => {
if (!e.data.id) return; if (!e.data.id) return;

@ -72,6 +72,7 @@ export default {
num:240 num:240
}; };
}, },
inject: ['reload'],
mounted() { mounted() {
this.getRealTimeList() this.getRealTimeList()
// this.getVideos() // this.getVideos()
@ -84,9 +85,9 @@ export default {
}, },
methods: { methods: {
// //
handleUpDown() { // handleUpDown() {
this.controlLabel = !this.controlLabel; // this.controlLabel = !this.controlLabel;
}, // },
getRealTimeList(){ getRealTimeList(){
var that=this var that=this
this.$api.httpApi.getRealTimeList({ this.$api.httpApi.getRealTimeList({
@ -135,7 +136,7 @@ export default {
that.num = that.num-1; that.num = that.num-1;
console.log(that.num) console.log(that.num)
if(that.num == -1){ if(that.num == -1){
location.reload(); that.reload() //
that.num = 240 that.num = 240
} }
},1000) },1000)

Loading…
Cancel
Save