<script>
  import config from './config'
  import { getToken } from '@/utils/auth'
  import updateManager from '@/utils/upgrade.js'
  export default {
    onLaunch() {
      this.initApp()
      updateManager.checkUpdate()
    },
    methods: {
      initApp() {
        // #ifdef APP-PLUS
        plus.navigator.closeSplashscreen()
        // #endif
        this.initConfig()
        this.ensureAuthState()
      },
      initConfig() {
        this.globalData.config = config
      },
      ensureAuthState() {
        const token = getToken()
        const pages = getCurrentPages()
        const currentRoute = pages && pages.length ? `/${pages[0].route}` : ''
        if (!token && currentRoute !== '/pages/login') {
          uni.reLaunch({ url: '/pages/login' })
        }
      }
    }
  }
</script>
<style lang="scss">
  @import '@/static/scss/index.scss';
</style>