This commit is contained in:
shijing 2021-11-01 15:38:11 +08:00
parent 46e1547571
commit fced843b99
2 changed files with 25 additions and 12 deletions

View File

@ -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>

View File

@ -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>