提交 5395dfdb 编写于 作者: fxy060608's avatar fxy060608

fix(app-plus): launch nvue page

上级 8d72f46d
......@@ -10,6 +10,10 @@ import {
TEMP_PATH_BASE
} from '../api/constants'
import {
initEntryPage
} from './config'
import {
getCurrentPages
} from './page'
......@@ -95,17 +99,17 @@ function initGlobalListeners () {
})
})
globalEvent.addEventListener('uistylechange', function (event) {
const args = {
theme: event.uistyle
}
callAppHook(appCtx, 'onThemeChange', args)
publish('onThemeChange', args)
// 兼容旧版本 API
publish('onUIStyleChange', {
style: event.uistyle
globalEvent.addEventListener('uistylechange', function (event) {
const args = {
theme: event.uistyle
}
callAppHook(appCtx, 'onThemeChange', args)
publish('onThemeChange', args)
// 兼容旧版本 API
publish('onUIStyleChange', {
style: event.uistyle
})
})
......@@ -171,50 +175,6 @@ function initTabBar () {
}
}
function initEntryPage () {
let entryPagePath
let entryPageQuery
const weexPlus = weex.requireModule('plus')
if (weexPlus.getRedirectInfo) {
const info = weexPlus.getRedirectInfo() || {}
entryPagePath = info.path
entryPageQuery = info.query ? ('?' + info.query) : ''
} else {
const argsJsonStr = plus.runtime.arguments
if (!argsJsonStr) {
return
}
try {
const args = JSON.parse(argsJsonStr)
entryPagePath = args.path || args.pathName
entryPageQuery = args.query ? ('?' + args.query) : ''
} catch (e) {}
}
if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) {
return
}
const entryRoute = '/' + entryPagePath
const routeOptions = __uniRoutes.find(route => route.path === entryRoute)
if (!routeOptions) {
return
}
if (!routeOptions.meta.isTabBar) {
__uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath
}
__uniConfig.entryPagePath = entryPagePath
__uniConfig.entryPageQuery = entryPageQuery
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`)
}
}
export function clearTempFile () {
// 统一处理路径
function getPath (path) {
......@@ -277,4 +237,4 @@ export function registerApp (appVm) {
__uniConfig.ready = true
process.env.NODE_ENV !== 'production' && perf('registerApp')
}
}
......@@ -19,7 +19,7 @@ function parseRoutes (config) {
})
}
export function registerConfig (config, Vue) {
export function registerConfig (config, Vue) {
Object.assign(__uniConfig, config)
__uniConfig.viewport = ''
......@@ -35,4 +35,55 @@ export function registerConfig (config, Vue) {
if (process.env.NODE_ENV !== 'production') {
console.log('[uni-app] registerConfig', __uniConfig)
}
}
let isInitEntryPage = false
export function initEntryPage () {
if (isInitEntryPage) {
return
}
isInitEntryPage = true
let entryPagePath
let entryPageQuery
const weexPlus = weex.requireModule('plus')
if (weexPlus.getRedirectInfo) {
const info = weexPlus.getRedirectInfo() || {}
entryPagePath = info.path
entryPageQuery = info.query ? ('?' + info.query) : ''
} else {
const argsJsonStr = plus.runtime.arguments
if (!argsJsonStr) {
return
}
try {
const args = JSON.parse(argsJsonStr)
entryPagePath = args.path || args.pathName
entryPageQuery = args.query ? ('?' + args.query) : ''
} catch (e) {}
}
if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) {
return
}
const entryRoute = '/' + entryPagePath
const routeOptions = __uniRoutes.find(route => route.path === entryRoute)
if (!routeOptions) {
return
}
if (!routeOptions.meta.isTabBar) {
__uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath
}
__uniConfig.entryPagePath = entryPagePath
__uniConfig.entryPageQuery = entryPageQuery
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`)
}
}
......@@ -17,6 +17,10 @@ import {
loadPage
} from './load-sub-package'
import {
initEntryPage
} from './config'
const pages = []
export function getCurrentPages (returnAll) {
......@@ -83,6 +87,9 @@ export function registerPage ({
webview,
eventChannel
}) {
// fast 模式,nvue 首页时,初始化下 entry page
webview && initEntryPage()
if (preloadWebviews[url]) {
webview = preloadWebviews[url]
if (webview.__page__) {
......@@ -137,6 +144,8 @@ export function registerPage ({
console.log(`[uni-app] registerPage(${path},${webview.id})`)
}
const isLaunchNVuePage = webview.id === '1' && webview.nvue
initWebview(webview, routeOptions, path, query)
const route = path.slice(1)
......@@ -188,7 +197,7 @@ export function registerPage ({
}
// 首页是 nvue 时,在 registerPage 时,执行路由堆栈
if (webview.id === '1' && webview.nvue) {
if (isLaunchNVuePage) {
if (
__uniConfig.splashscreen &&
__uniConfig.splashscreen.autoclose &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册