import store from '@/store'


const whiteList = [
  '/pages/login/index'
]

export default {
  created() {
    // 登录判断跳转
    this.$u.routeAuth = (...args) => {
      let url = args[0]
      if (typeof url !== 'string' && typeof url.url === 'string') {
        url = url.url
      }

      if (store.getters.isLogin || whiteList.includes(url)) {
        this.$u.route(...args)
      } else {
        this.$u.route('/pages/login/index')
      }
    }

    this.$u.routeLogin = (...args) => {
      uni.$u.throttle(this.$u.route('/pages/login/index'), 1000)
    }
  }
}
