提交 9f42733d 编写于 作者: G Guillaume Chau

feat: auto refresh if no components

上级 a10a424c
......@@ -165,7 +165,7 @@
</template>
<script>
import { mapState } from 'vuex'
import { mapState, mapGetters } from 'vuex'
import { SPECIAL_TOKENS } from '@utils/util'
import Keyboard from '@front/mixins/keyboard'
import GroupDropdown from '@front/components/GroupDropdown.vue'
......@@ -238,6 +238,10 @@ export default {
view: state => state.view
}),
...mapGetters('components', {
totalComponentCount: 'totalCount'
}),
specialTokens () {
return SPECIAL_TOKENS
},
......@@ -274,10 +278,12 @@ export default {
this.mediaQuery = window.matchMedia('(min-width: 685px)')
this.switchView(this.mediaQuery)
this.mediaQuery.addListener(this.switchView)
this.autoRefreshTimer = setInterval(this.shouldAutoRefresh, 1000)
},
destroyed () {
this.mediaQuery.removeListener(this.switchView)
clearInterval(this.autoRefreshTimer)
},
methods: {
......@@ -291,6 +297,12 @@ export default {
})
},
shouldAutoRefresh () {
if (this.totalComponentCount === 0) {
this.refresh()
}
},
switchView (mediaQueryEvent) {
this.$store.commit(
'SWITCH_VIEW',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册