polling
This commit is contained in:
parent
46e1547571
commit
fced843b99
|
@ -5,6 +5,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
provide(){
|
||||
|
@ -15,17 +16,9 @@ export default {
|
|||
data(){
|
||||
return{
|
||||
isRouterAlive:true,
|
||||
timer:null
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
this.$store.dispatch("user/getCount", {});
|
||||
this.timer = window.setInterval(() => {
|
||||
setTimeout(() => {
|
||||
this.$store.dispatch("user/getCount", {})
|
||||
},0)
|
||||
},30000)
|
||||
|
||||
},
|
||||
methods:{
|
||||
reload(){
|
||||
|
@ -34,10 +27,8 @@ export default {
|
|||
this.isRouterAlive=true;
|
||||
})
|
||||
},
|
||||
},
|
||||
destroyed() {
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
import { Navbar, Sidebar, AppMain,TagsView } from './components'
|
||||
import ResizeMixin from './mixin/ResizeHandler'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
import { getToken } from '@/utils/auth' // get token from cookie
|
||||
export default {
|
||||
name: 'Layout',
|
||||
components: {
|
||||
|
@ -57,6 +57,24 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
timer:null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let hasToken = getToken();
|
||||
if (hasToken) {
|
||||
this.$store.dispatch("user/getCount", {});
|
||||
}
|
||||
this.timer = window.setInterval(() => {
|
||||
setTimeout(() => {
|
||||
if (hasToken) {
|
||||
this.$store.dispatch("user/getCount", {});
|
||||
}
|
||||
},0)
|
||||
},5000)
|
||||
},
|
||||
methods: {
|
||||
handleClickOutside() {
|
||||
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
||||
|
@ -70,6 +88,10 @@ export default {
|
|||
this.$router.push({name:'ticket',params:{}})
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue