<script setup>
  import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
  import { useTokenStore } from './stores/token'
  import { reLaunch } from './utils/router'

  /** 静默登录逻辑 */
  const silentLogin = async () => {
    const tokenStore = useTokenStore()
    if (tokenStore.token && !tokenStore.isTokenExpired()) {
      reLaunch('/pages/news-list/news-list')
      return
    }

    // 没有token去登录页
    reLaunch('/pages/login/login?id=1')
  }

  onLaunch(() => {
    console.log('App Launch111')
    silentLogin()
  })

  onShow(() => {
    console.log('App Show222')
  })

  onHide(() => {
    console.log('App Hide333')
  })
</script>

<style lang="scss">
  /*每个页面公共css */
  @import './styles/global.scss';
</style>
