import { Storage } from '../utils/Storage'

/**
 * 闪屏页面
 */
@Entry
@Component
struct PageSplash {
  build() {
    RelativeContainer() {
      Image($r("app.media.start_icon"))
        .alignRules({
          center: { anchor: '__container__', align: VerticalAlign.Center },
          middle: { anchor: '__container__', align: HorizontalAlign.Center }
        })
        .width(300)
    }
    .height('100%')
    .width('100%')
  }

  aboutToAppear(): void {
    // 跳转到登录页面
    const router = this.getUIContext().getRouter()
    setTimeout(() => {
      const url = Storage.isLogin() ? "pages/PageHome" : "pages/PageLogin"
      router.replaceUrl({ url: url }).catch(() => {
      })
    }, 3000)
  }
}