initAppLaunch.ts 845 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1
import { invokeHook } from '@dcloudio/uni-core'
fxy060608's avatar
fxy060608 已提交
2
import { injectAppHooks } from '@dcloudio/uni-api'
Q
qiang 已提交
3
import { ON_LAUNCH, ON_SHOW, ON_HIDE } from '@dcloudio/uni-shared'
fxy060608's avatar
fxy060608 已提交
4
import { ComponentPublicInstance } from 'vue'
5
import { initLaunchOptions } from './utils'
fxy060608's avatar
fxy060608 已提交
6 7

export function initAppLaunch(appVm: ComponentPublicInstance) {
fxy060608's avatar
fxy060608 已提交
8
  injectAppHooks(appVm.$)
9
  const { entryPagePath, entryPageQuery, referrerInfo } = __uniConfig
10 11 12 13 14
  const args = initLaunchOptions({
    path: entryPagePath,
    query: entryPageQuery,
    referrerInfo: referrerInfo,
  })
fxy060608's avatar
fxy060608 已提交
15 16
  invokeHook(appVm, ON_LAUNCH, args)
  invokeHook(appVm, ON_SHOW, args)
Q
qiang 已提交
17 18 19 20 21 22
  // https://tower.im/teams/226535/todos/16905/
  const getAppState = weex.requireModule('plus').getAppState
  const appState = getAppState && Number(getAppState())
  if (appState === 2) {
    invokeHook(appVm, ON_HIDE, args)
  }
fxy060608's avatar
fxy060608 已提交
23
}