<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
import ast from '@/utils/astrict.js'
import { faceStop } from '@/api/user/user'
export default {
  name: 'App', 
  data() {
    return {
      intval: null
    }
  },
  created() {
    this.intval = ast()
    // window.addEventListener('beforeunload', (event) => {
    //   faceStop().then(res => { console.log(res) })
    // })
    window.onbeforeunload = (e) => {
      e = e || window.event
      if (e) {
        e.returnValue = '关闭提示'
      }

      faceStop().then(res => { console.log(res) })

      // Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
      return '关闭提示'
    }
  },
  destroyed() {
    if (this.intval) {
      clearInterval(this.intval)
    }
  }
}
</script>
