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

<script>
import { ossLogin } from "@/api/system/ossLogin"
import { setToken,getToken } from '@/utils/auth'

export default {
  name: 'App',
  created() {
    window.addEventListener('message',msg => {
      if(msg.data.key === 'login'){
        const { authToken } = msg.data.data
        ossLogin({
          auth_token: authToken
        }).then(res => {
          setToken(res.access_token)
          this.$store.commit('user/SET_TOKEN',res.access_token)
          this.$router.push("/")
        })
      }
    })
  }
}
</script>
