<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
import { useAppStore } from '@/store/app'
import { useUserStore } from '@/store/user'

onLaunch(async () => {
  console.log('App =====> onLaunch')
  // 检查是否已登录
  const appStore = useAppStore()

  if (!appStore.isLogined) {
    uni.navigateTo({ url: '/pages-sub/auth/index' })
  } else {
    // 获取用户信息，用于：1.展示   2.判断是否需要完善信息
    const userStore = useUserStore()
    const res = await userStore.getUserInfo()
    userStore.setUserDetail(res.Data)
  }
})

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

<style lang="scss">
/* stylelint-disable selector-type-no-unknown */
button::after {
  border: none;
}

swiper,
scroll-view {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

image {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

// 单行省略，优先使用 unocss: text-ellipsis
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 两行省略
.ellipsis-2 {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

// 三行省略
.ellipsis-3 {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
</style>
