Kicker.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. </template>
  3. <script>
  4. export default {
  5. name: 'Kicker',
  6. data: function () {
  7. return {
  8. events: ['click', 'mousedown', 'scroll', 'keypress', 'load'],
  9. logoutTimer: null
  10. }
  11. },
  12. mounted() {
  13. this.events.forEach(function (event) {
  14. window.addEventListener(event, this.resetTimer)
  15. }, this);
  16. this.setTimer()
  17. },
  18. destroyed() {
  19. this.events.forEach(function (event) {
  20. window.removeEventListener(event, this.resetTimer)
  21. }, this);
  22. clearTimeout(this.logoutTimer)
  23. },
  24. methods: {
  25. setTimer: function() {
  26. this.logoutTimer = setTimeout(this.logoutUser, this.$root.appSettings.kickUserAfter * 60 * 1000)
  27. },
  28. logoutUser: function() {
  29. clearTimeout(this.logoutTimer)
  30. this.$router.push({ name: 'autolock' })
  31. },
  32. resetTimer: function() {
  33. clearTimeout(this.logoutTimer)
  34. this.setTimer()
  35. }
  36. }
  37. }
  38. </script>