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

feat(v3): plus.runtime.arguments => entryPagePath

上级 152a6858
...@@ -9451,10 +9451,12 @@ var serviceContext = (function () { ...@@ -9451,10 +9451,12 @@ var serviceContext = (function () {
]; ];
var tempCanvas; var tempCanvas;
function getTempCanvas () { function getTempCanvas (width = 0, height = 0) {
if (!tempCanvas) { if (!tempCanvas) {
tempCanvas = document.createElement('canvas'); tempCanvas = document.createElement('canvas');
} }
tempCanvas.width = width;
tempCanvas.height = height;
return tempCanvas return tempCanvas
} }
...@@ -11771,7 +11773,7 @@ var serviceContext = (function () { ...@@ -11771,7 +11773,7 @@ var serviceContext = (function () {
const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo'; const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo';
process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`); process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`);
return uni[navigateType]({ return uni[navigateType]({
url: entryPagePath, url: entryPagePath + (__uniConfig.entryPageQuery || ''),
openType: 'appLaunch' openType: 'appLaunch'
}) })
} }
...@@ -12003,28 +12005,39 @@ var serviceContext = (function () { ...@@ -12003,28 +12005,39 @@ var serviceContext = (function () {
}); });
} }
function initHotReload () { function initEntryPage () {
const reloadUrl = weex.config.reloadUrl; const argsJsonStr = plus.runtime.arguments;
if (!reloadUrl) { if (!argsJsonStr) {
return return
} }
if (reloadUrl === __uniConfig.entryPagePath) {
let entryPagePath;
let entryPageQuery;
try {
const args = JSON.parse(argsJsonStr);
entryPagePath = args.path || args.pathName;
entryPageQuery = (args.query ? ('?' + args.query) : '');
} catch (e) {}
if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) {
return return
} }
const reloadPath = '/' + reloadUrl;
const routeOptions = __uniRoutes.find(route => route.path === reloadPath); const entryRoute = '/' + entryPagePath;
const routeOptions = __uniRoutes.find(route => route.path === entryRoute);
if (!routeOptions) { if (!routeOptions) {
return return
} }
if (routeOptions.meta.isNVue) { // 暂不处理 nvue
return
}
if (!routeOptions.meta.isTabBar) { if (!routeOptions.meta.isTabBar) {
__uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath; __uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath;
} }
__uniConfig.entryPagePath = reloadUrl;
__uniConfig.entryPagePath = entryPagePath;
__uniConfig.entryPageQuery = entryPageQuery;
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] reloadUrl(${reloadUrl})`); console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`);
} }
} }
...@@ -12046,7 +12059,7 @@ var serviceContext = (function () { ...@@ -12046,7 +12059,7 @@ var serviceContext = (function () {
getCurrentPages: getCurrentPages$1 getCurrentPages: getCurrentPages$1
}); });
initHotReload(); initEntryPage();
initTabBar(); initTabBar();
......
...@@ -33,8 +33,10 @@ function parseEntryPagePath (appJson, manifestJson) { ...@@ -33,8 +33,10 @@ function parseEntryPagePath (appJson, manifestJson) {
try { try {
const args = JSON.parse(argsJsonStr) const args = JSON.parse(argsJsonStr)
const pathName = args.path || args.pathName const pathName = args.path || args.pathName
const entryPageQuery = (args.query ? ('?' + args.query) : '')
if (pathName && appJson.pages[0] !== pathName) { if (pathName && appJson.pages[0] !== pathName) {
appJson.entryPagePath = pathName appJson.entryPagePath = pathName
appJson.entryPageQuery = entryPageQuery
if (!isTabBarPage(pathName, getTabBarPages(appJson))) { if (!isTabBarPage(pathName, getTabBarPages(appJson))) {
appJson.realEntryPagePath = appJson.pages[0] appJson.realEntryPagePath = appJson.pages[0]
} }
...@@ -83,7 +85,7 @@ module.exports = function (appJson, manifestJson, { ...@@ -83,7 +85,7 @@ module.exports = function (appJson, manifestJson, {
if (appJson.page[appJson.entryPagePath].nvue) { // 首页是 nvue if (appJson.page[appJson.entryPagePath].nvue) { // 首页是 nvue
manifestJson.launch_path = '' // 首页地址为空 manifestJson.launch_path = '' // 首页地址为空
manifestJson.plus.launchwebview.uniNView = { manifestJson.plus.launchwebview.uniNView = {
path: appJson.entryPagePath path: appJson.entryPagePath + '.js' + (appJson.entryPageQuery || '')
} }
if (manifestJson.plus.tabBar) { if (manifestJson.plus.tabBar) {
manifestJson.plus.tabBar.child = ['lauchwebview'] manifestJson.plus.tabBar.child = ['lauchwebview']
...@@ -100,4 +102,4 @@ module.exports = function (appJson, manifestJson, { ...@@ -100,4 +102,4 @@ module.exports = function (appJson, manifestJson, {
manifest.content = JSON.stringify(manifest.content) manifest.content = JSON.stringify(manifest.content)
delete appJson.nvue delete appJson.nvue
return [manifest, definePages(appJson), appConfigService(appJson)] return [manifest, definePages(appJson), appConfigService(appJson)]
} }
...@@ -140,28 +140,39 @@ function initTabBar () { ...@@ -140,28 +140,39 @@ function initTabBar () {
}) })
} }
function initHotReload () { function initEntryPage () {
const reloadUrl = weex.config.reloadUrl const argsJsonStr = plus.runtime.arguments
if (!reloadUrl) { if (!argsJsonStr) {
return return
} }
if (reloadUrl === __uniConfig.entryPagePath) {
let entryPagePath
let entryPageQuery
try {
const args = JSON.parse(argsJsonStr)
entryPagePath = args.path || args.pathName
entryPageQuery = (args.query ? ('?' + args.query) : '')
} catch (e) {}
if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) {
return return
} }
const reloadPath = '/' + reloadUrl
const routeOptions = __uniRoutes.find(route => route.path === reloadPath) const entryRoute = '/' + entryPagePath
const routeOptions = __uniRoutes.find(route => route.path === entryRoute)
if (!routeOptions) { if (!routeOptions) {
return return
} }
if (routeOptions.meta.isNVue) { // 暂不处理 nvue
return
}
if (!routeOptions.meta.isTabBar) { if (!routeOptions.meta.isTabBar) {
__uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath __uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath
} }
__uniConfig.entryPagePath = reloadUrl
__uniConfig.entryPagePath = entryPagePath
__uniConfig.entryPageQuery = entryPageQuery
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] reloadUrl(${reloadUrl})`) console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`)
} }
} }
...@@ -183,7 +194,7 @@ export function registerApp (appVm) { ...@@ -183,7 +194,7 @@ export function registerApp (appVm) {
getCurrentPages getCurrentPages
}) })
initHotReload() initEntryPage()
initTabBar() initTabBar()
......
...@@ -38,7 +38,7 @@ export default function onWebviewReady (data, pageId) { ...@@ -38,7 +38,7 @@ export default function onWebviewReady (data, pageId) {
const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo' const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo'
process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`) process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`)
return uni[navigateType]({ return uni[navigateType]({
url: entryPagePath, url: entryPagePath + (__uniConfig.entryPageQuery || ''),
openType: 'appLaunch' openType: 'appLaunch'
}) })
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册