re-launch.js 920 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9
import {
  parseQuery
} from 'uni-shared'

import {
  showWebview
} from './util'

import {
10 11
  setStatusBarStyle,
  invoke
fxy060608's avatar
fxy060608 已提交
12 13 14 15 16 17
} from '../../bridge'

import tabBar from '../../../../app-plus/service/framework/tab-bar'

export function reLaunch ({
  url
18
}, callbackId) {
fxy060608's avatar
fxy060608 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  const urls = url.split('?')
  const path = urls[0]

  const query = parseQuery(urls[1] || '')

  const pages = getCurrentPages(true).slice(0)

  const routeOptions = __uniRoutes.find(route => route.path === path)

  if (routeOptions.meta.isTabBar) {
    tabBar.switchTab(url)
  }

  showWebview(
    __registerPage({
      path,
      query,
      openType: 'reLaunch'
    }),
    'none',
39 40 41 42 43 44
    0,
    () => {
      invoke(callbackId, {
        errMsg: 'reLaunch:ok'
      })
    }
fxy060608's avatar
fxy060608 已提交
45 46 47 48 49 50 51 52
  )

  pages.forEach(page => {
    page.$remove()
    page.$getAppWebview().close('none')
  })

  setStatusBarStyle()
53
}