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