diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 1a12968052d2d1ead23ae7f2a7106a3a4476b9a7..8f1dac7826e18371d1c2f84b42e573659fa7ccfc 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -670,7 +670,6 @@ var serviceContext = (function () { }]; var require_context_module_0_0 = /*#__PURE__*/Object.freeze({ - __proto__: null, base64ToArrayBuffer: base64ToArrayBuffer, arrayBufferToBase64: arrayBufferToBase64 }); @@ -682,7 +681,6 @@ var serviceContext = (function () { }]; var require_context_module_0_1 = /*#__PURE__*/Object.freeze({ - __proto__: null, canIUse: canIUse }); @@ -713,7 +711,6 @@ var serviceContext = (function () { }]; var require_context_module_0_2 = /*#__PURE__*/Object.freeze({ - __proto__: null, $on: $on, $once: $once, $off: $off, @@ -728,7 +725,6 @@ var serviceContext = (function () { const removeInterceptor$1 = addInterceptor$1; var require_context_module_0_3 = /*#__PURE__*/Object.freeze({ - __proto__: null, addInterceptor: addInterceptor$1, removeInterceptor: removeInterceptor$1 }); @@ -740,7 +736,6 @@ var serviceContext = (function () { }]; var require_context_module_0_4 = /*#__PURE__*/Object.freeze({ - __proto__: null, upx2px: upx2px }); @@ -877,7 +872,6 @@ var serviceContext = (function () { }; var require_context_module_0_5 = /*#__PURE__*/Object.freeze({ - __proto__: null, canvasGetImageData: canvasGetImageData, canvasPutImageData: canvasPutImageData, canvasToTempFilePath: canvasToTempFilePath, @@ -903,7 +897,6 @@ var serviceContext = (function () { }]; var require_context_module_0_6 = /*#__PURE__*/Object.freeze({ - __proto__: null, createAudioContext: createAudioContext, createVideoContext: createVideoContext, createMapContext: createMapContext, @@ -923,7 +916,6 @@ var serviceContext = (function () { }; var require_context_module_0_7 = /*#__PURE__*/Object.freeze({ - __proto__: null, makePhoneCall: makePhoneCall }); @@ -938,7 +930,6 @@ var serviceContext = (function () { }; var require_context_module_0_8 = /*#__PURE__*/Object.freeze({ - __proto__: null, setClipboardData: setClipboardData }); @@ -953,7 +944,6 @@ var serviceContext = (function () { }; var require_context_module_0_9 = /*#__PURE__*/Object.freeze({ - __proto__: null, openDocument: openDocument }); @@ -964,7 +954,6 @@ var serviceContext = (function () { }; var require_context_module_0_10 = /*#__PURE__*/Object.freeze({ - __proto__: null, chooseLocation: chooseLocation }); @@ -988,7 +977,6 @@ var serviceContext = (function () { }; var require_context_module_0_11 = /*#__PURE__*/Object.freeze({ - __proto__: null, getLocation: getLocation }); @@ -1018,7 +1006,6 @@ var serviceContext = (function () { }; var require_context_module_0_12 = /*#__PURE__*/Object.freeze({ - __proto__: null, openLocation: openLocation }); @@ -1080,7 +1067,6 @@ var serviceContext = (function () { }; var require_context_module_0_13 = /*#__PURE__*/Object.freeze({ - __proto__: null, chooseImage: chooseImage }); @@ -1108,7 +1094,6 @@ var serviceContext = (function () { }; var require_context_module_0_14 = /*#__PURE__*/Object.freeze({ - __proto__: null, chooseVideo: chooseVideo }); @@ -1201,7 +1186,6 @@ var serviceContext = (function () { }; var require_context_module_0_15 = /*#__PURE__*/Object.freeze({ - __proto__: null, getImageInfo: getImageInfo }); @@ -1237,7 +1221,6 @@ var serviceContext = (function () { }; var require_context_module_0_16 = /*#__PURE__*/Object.freeze({ - __proto__: null, previewImage: previewImage }); @@ -1255,7 +1238,6 @@ var serviceContext = (function () { }; var require_context_module_0_17 = /*#__PURE__*/Object.freeze({ - __proto__: null, downloadFile: downloadFile }); @@ -1358,7 +1340,6 @@ var serviceContext = (function () { }; var require_context_module_0_18 = /*#__PURE__*/Object.freeze({ - __proto__: null, request: request }); @@ -1412,7 +1393,6 @@ var serviceContext = (function () { }; var require_context_module_0_19 = /*#__PURE__*/Object.freeze({ - __proto__: null, connectSocket: connectSocket, sendSocketMessage: sendSocketMessage, closeSocket: closeSocket @@ -1449,7 +1429,6 @@ var serviceContext = (function () { }; var require_context_module_0_20 = /*#__PURE__*/Object.freeze({ - __proto__: null, uploadFile: uploadFile }); @@ -1474,7 +1453,6 @@ var serviceContext = (function () { }; var require_context_module_0_21 = /*#__PURE__*/Object.freeze({ - __proto__: null, getProvider: getProvider }); @@ -1623,7 +1601,6 @@ var serviceContext = (function () { )); var require_context_module_0_22 = /*#__PURE__*/Object.freeze({ - __proto__: null, redirectTo: redirectTo, reLaunch: reLaunch, navigateTo: navigateTo, @@ -1667,7 +1644,6 @@ var serviceContext = (function () { const removeStorageSync = getStorageSync; var require_context_module_0_23 = /*#__PURE__*/Object.freeze({ - __proto__: null, getStorage: getStorage, getStorageSync: getStorageSync, setStorage: setStorage, @@ -1704,7 +1680,6 @@ var serviceContext = (function () { }; var require_context_module_0_24 = /*#__PURE__*/Object.freeze({ - __proto__: null, loadFontFace: loadFontFace }); @@ -1747,7 +1722,6 @@ var serviceContext = (function () { }; var require_context_module_0_25 = /*#__PURE__*/Object.freeze({ - __proto__: null, setNavigationBarColor: setNavigationBarColor, setNavigationBarTitle: setNavigationBarTitle }); @@ -1767,7 +1741,6 @@ var serviceContext = (function () { }; var require_context_module_0_26 = /*#__PURE__*/Object.freeze({ - __proto__: null, pageScrollTo: pageScrollTo }); @@ -1885,7 +1858,6 @@ var serviceContext = (function () { }; var require_context_module_0_27 = /*#__PURE__*/Object.freeze({ - __proto__: null, showModal: showModal, showToast: showToast, showLoading: showLoading, @@ -1970,7 +1942,6 @@ var serviceContext = (function () { }; var require_context_module_0_28 = /*#__PURE__*/Object.freeze({ - __proto__: null, setTabBarItem: setTabBarItem, setTabBarStyle: setTabBarStyle, hideTabBar: hideTabBar, @@ -2539,7 +2510,6 @@ var serviceContext = (function () { } var require_context_module_1_0 = /*#__PURE__*/Object.freeze({ - __proto__: null, base64ToArrayBuffer: base64ToArrayBuffer$1, arrayBufferToBase64: arrayBufferToBase64$1 }); @@ -2556,7 +2526,6 @@ var serviceContext = (function () { } var require_context_module_1_1 = /*#__PURE__*/Object.freeze({ - __proto__: null, canIUse: canIUse$1 }); @@ -2565,7 +2534,6 @@ var serviceContext = (function () { }; var require_context_module_1_2 = /*#__PURE__*/Object.freeze({ - __proto__: null, interceptors: interceptors, addInterceptor: addInterceptor, removeInterceptor: removeInterceptor @@ -2614,7 +2582,6 @@ var serviceContext = (function () { } var require_context_module_1_3 = /*#__PURE__*/Object.freeze({ - __proto__: null, upx2px: upx2px$1 }); @@ -2641,7 +2608,6 @@ var serviceContext = (function () { } var eventApis = /*#__PURE__*/Object.freeze({ - __proto__: null, $on: $on$1, $off: $off$1, $once: $once$1, @@ -4310,7 +4276,6 @@ var serviceContext = (function () { } var webview = /*#__PURE__*/Object.freeze({ - __proto__: null, SCAN_ID: SCAN_ID, SCAN_PATH: SCAN_PATH, scanCode: scanCode @@ -4522,7 +4487,6 @@ var serviceContext = (function () { } var weex$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, scanCode: scanCode$1 }); @@ -5288,7 +5252,6 @@ var serviceContext = (function () { } var webview$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, chooseLocation: chooseLocation$1 }); @@ -5352,7 +5315,6 @@ var serviceContext = (function () { } var weex$2 = /*#__PURE__*/Object.freeze({ - __proto__: null, chooseLocation: chooseLocation$2 }); @@ -5473,7 +5435,6 @@ var serviceContext = (function () { } var webview$2 = /*#__PURE__*/Object.freeze({ - __proto__: null, openLocation: openLocation$1 }); @@ -5493,7 +5454,6 @@ var serviceContext = (function () { } var weex$3 = /*#__PURE__*/Object.freeze({ - __proto__: null, openLocation: openLocation$2 }); @@ -6592,14 +6552,14 @@ var serviceContext = (function () { code: err.code, errMsg: 'login:fail:' + err.message }); - }, { scope: 'email' }); + }, provider === 'apple' ? { scope: 'email' } : {}); } // 先注销再登录 - // apple登录logout之后无法重新触发获取email,fullname - if (provider === 'apple') { - login(); - } else { - loginServices[provider].logout(login, login); + // apple登录logout之后无法重新触发获取email,fullname + if (provider === 'apple') { + login(); + } else { + loginServices[provider].logout(login, login); } }; /** @@ -6639,7 +6599,7 @@ var serviceContext = (function () { errMsg: 'operateWXData:fail:请先调用 uni.login' }) } - loginService.getUserInfo(res => { + loginService.getUserInfo(res => { let userInfo; if (provider === 'weixin') { const wechatUserInfo = loginService.userInfo; @@ -6653,38 +6613,38 @@ var serviceContext = (function () { avatarUrl: wechatUserInfo.headimgurl, unionId: wechatUserInfo.unionid }; - } else if (provider === 'apple') { - const appleInfo = loginService.appleInfo; - userInfo = { - openId: appleInfo.user, - fullName: appleInfo.fullName, - email: appleInfo.email, - authorizationCode: appleInfo.authorizationCode, - identityToken: appleInfo.identityToken, - realUserStatus: appleInfo.realUserStatus - }; + } else if (provider === 'apple') { + const appleInfo = loginService.appleInfo; + userInfo = { + openId: appleInfo.user, + fullName: appleInfo.fullName, + email: appleInfo.email, + authorizationCode: appleInfo.authorizationCode, + identityToken: appleInfo.identityToken, + realUserStatus: appleInfo.realUserStatus + }; } else { loginService.userInfo.openId = loginService.userInfo.openId || loginService.userInfo.openid || loginService.authResult.openid; loginService.userInfo.nickName = loginService.userInfo.nickName || loginService.userInfo.nickname; loginService.userInfo.avatarUrl = loginService.userInfo.avatarUrl || loginService.userInfo.avatarUrl || - loginService.userInfo.headimgurl; + loginService.userInfo.headimgurl; userInfo = loginService.userInfo; - } - const result = { - errMsg: 'operateWXData:ok' - }; - if (params.data && params.data.api_name === 'webapi_getuserinfo') { + } + const result = { + errMsg: 'operateWXData:ok' + }; + if (params.data && params.data.api_name === 'webapi_getuserinfo') { result.data = { data: JSON.stringify(userInfo), rawData: '', signature: '', encryptedData: '', iv: '' - }; - } else { - result.userInfo = userInfo; - } + }; + } else { + result.userInfo = userInfo; + } invoke$1(callbackId, result); }, err => { invoke$1(callbackId, { @@ -7178,15 +7138,15 @@ var serviceContext = (function () { uni.hideToast(); // 后退时,关闭 toast,loading - // 当前页面是 condition 进入 - if (currentPage.$page.id === 1 && __uniConfig.realEntryPagePath) { + if (currentPage.$page.meta.isQuit) { + quit(); + } else if (currentPage.$page.id === 1 && __uniConfig.realEntryPagePath) { + // condition uni.reLaunch({ url: '/' + __uniConfig.realEntryPagePath }); } else { - currentPage.$page.meta.isQuit - ? quit() - : back(delta, animationType, animationDuration); + back(delta, animationType, animationDuration); } return { errMsg: 'navigateBack:ok' @@ -7365,7 +7325,11 @@ var serviceContext = (function () { const titleNView = parseTitleNView(routeOptions); if (titleNView) { - if (id === 1 && __uniConfig.realEntryPagePath) { + if ( + id === 1 && + __uniConfig.realEntryPagePath && + !routeOptions.meta.isQuit // 可能是tabBar + ) { titleNView.autoBackButton = true; } webviewStyle.titleNView = titleNView; @@ -7882,8 +7846,13 @@ var serviceContext = (function () { }) { const routeOptions = JSON.parse(JSON.stringify(__uniRoutes.find(route => route.path === path))); - if (openType === 'reLaunch' || pages.length === 0) { - // pages.length===0 表示首页触发 redirectTo + if ( + openType === 'reLaunch' || + ( + openType === 'redirect' && + pages.length === 0 + ) // 首页 redirect + ) { routeOptions.meta.isQuit = true; } else if (!routeOptions.meta.isTabBar) { routeOptions.meta.isQuit = false; @@ -8709,7 +8678,6 @@ var serviceContext = (function () { var api = /*#__PURE__*/Object.freeze({ - __proto__: null, startPullDownRefresh: startPullDownRefresh, stopPullDownRefresh: stopPullDownRefresh, $on: $on$1, @@ -9032,7 +9000,6 @@ var serviceContext = (function () { } var require_context_module_1_4 = /*#__PURE__*/Object.freeze({ - __proto__: null, createInnerAudioContext: createInnerAudioContext }); @@ -9177,7 +9144,6 @@ var serviceContext = (function () { } var require_context_module_1_5 = /*#__PURE__*/Object.freeze({ - __proto__: null, getBackgroundAudioManager: getBackgroundAudioManager }); @@ -10036,7 +10002,6 @@ var serviceContext = (function () { } var require_context_module_1_6 = /*#__PURE__*/Object.freeze({ - __proto__: null, CanvasContext: CanvasContext, createCanvasContext: createCanvasContext$1, canvasGetImageData: canvasGetImageData$1, @@ -10087,7 +10052,6 @@ var serviceContext = (function () { } var require_context_module_1_7 = /*#__PURE__*/Object.freeze({ - __proto__: null, MapContext: MapContext, createMapContext: createMapContext$1 }); @@ -10151,7 +10115,6 @@ var serviceContext = (function () { } var require_context_module_1_8 = /*#__PURE__*/Object.freeze({ - __proto__: null, VideoContext: VideoContext, createVideoContext: createVideoContext$1 }); @@ -10198,7 +10161,6 @@ var serviceContext = (function () { }); var require_context_module_1_9 = /*#__PURE__*/Object.freeze({ - __proto__: null, EditorContext: EditorContext }); @@ -10243,7 +10205,6 @@ var serviceContext = (function () { } var require_context_module_1_10 = /*#__PURE__*/Object.freeze({ - __proto__: null, onAccelerometerChange: onAccelerometerChange, startAccelerometer: startAccelerometer, stopAccelerometer: stopAccelerometer @@ -10267,7 +10228,6 @@ var serviceContext = (function () { const onBLECharacteristicValueChange$1 = on('onBLECharacteristicValueChange'); var require_context_module_1_11 = /*#__PURE__*/Object.freeze({ - __proto__: null, onBluetoothDeviceFound: onBluetoothDeviceFound$1, onBluetoothAdapterStateChange: onBluetoothAdapterStateChange$1, onBLEConnectionStateChange: onBLEConnectionStateChange$1, @@ -10315,7 +10275,6 @@ var serviceContext = (function () { } var require_context_module_1_12 = /*#__PURE__*/Object.freeze({ - __proto__: null, onCompassChange: onCompassChange, startCompass: startCompass, stopCompass: stopCompass @@ -10334,7 +10293,6 @@ var serviceContext = (function () { } var require_context_module_1_13 = /*#__PURE__*/Object.freeze({ - __proto__: null, onNetworkStatusChange: onNetworkStatusChange }); @@ -10412,7 +10370,6 @@ var serviceContext = (function () { } var require_context_module_1_14 = /*#__PURE__*/Object.freeze({ - __proto__: null, getRecorderManager: getRecorderManager }); @@ -10501,7 +10458,6 @@ var serviceContext = (function () { } var require_context_module_1_15 = /*#__PURE__*/Object.freeze({ - __proto__: null, downloadFile: downloadFile$1 }); @@ -10607,7 +10563,6 @@ var serviceContext = (function () { } var require_context_module_1_16 = /*#__PURE__*/Object.freeze({ - __proto__: null, request: request$1 }); @@ -10782,7 +10737,6 @@ var serviceContext = (function () { } var require_context_module_1_17 = /*#__PURE__*/Object.freeze({ - __proto__: null, connectSocket: connectSocket$1, sendSocketMessage: sendSocketMessage$1, closeSocket: closeSocket$1, @@ -10877,7 +10831,6 @@ var serviceContext = (function () { } var require_context_module_1_18 = /*#__PURE__*/Object.freeze({ - __proto__: null, uploadFile: uploadFile$1 }); @@ -10987,7 +10940,6 @@ var serviceContext = (function () { } var require_context_module_1_19 = /*#__PURE__*/Object.freeze({ - __proto__: null, setStorage: setStorage$1, setStorageSync: setStorageSync$1, getStorage: getStorage$1, @@ -11079,7 +11031,6 @@ var serviceContext = (function () { } var require_context_module_1_20 = /*#__PURE__*/Object.freeze({ - __proto__: null, createAnimation: createAnimation }); @@ -11144,7 +11095,6 @@ var serviceContext = (function () { } var require_context_module_1_21 = /*#__PURE__*/Object.freeze({ - __proto__: null, createIntersectionObserver: createIntersectionObserver }); @@ -11285,7 +11235,6 @@ var serviceContext = (function () { } var require_context_module_1_22 = /*#__PURE__*/Object.freeze({ - __proto__: null, createSelectorQuery: createSelectorQuery }); @@ -11302,7 +11251,6 @@ var serviceContext = (function () { } var require_context_module_1_23 = /*#__PURE__*/Object.freeze({ - __proto__: null, onKeyboardHeightChange: onKeyboardHeightChange }); @@ -11327,7 +11275,6 @@ var serviceContext = (function () { } var require_context_module_1_24 = /*#__PURE__*/Object.freeze({ - __proto__: null, loadFontFace: loadFontFace$1 }); @@ -11340,7 +11287,6 @@ var serviceContext = (function () { } var require_context_module_1_25 = /*#__PURE__*/Object.freeze({ - __proto__: null, pageScrollTo: pageScrollTo$1 }); @@ -11377,7 +11323,6 @@ var serviceContext = (function () { } var require_context_module_1_26 = /*#__PURE__*/Object.freeze({ - __proto__: null, removeTabBarBadge: removeTabBarBadge$1, showTabBarRedDot: showTabBarRedDot$1, hideTabBarRedDot: hideTabBarRedDot$1, @@ -11403,7 +11348,6 @@ var serviceContext = (function () { } var require_context_module_1_27 = /*#__PURE__*/Object.freeze({ - __proto__: null, onWindowResize: onWindowResize, offWindowResize: offWindowResize }); @@ -11856,6 +11800,9 @@ var serviceContext = (function () { if (allowDefault) { // 返回默认实现 return defaultApp } + console.error( + '[warn]: getApp() 操作失败,v3模式加速了首页 nvue 的启动速度,当在首页 nvue 中使用 getApp() 不一定可以获取真正的 App 对象。详情请参考:https://uniapp.dcloud.io/collocation/frame/window?id=getapp' + ); } function initGlobalListeners () { @@ -11944,6 +11891,31 @@ var serviceContext = (function () { }); } + function initHotReload () { + const reloadUrl = weex.config.reloadUrl; + if (!reloadUrl) { + return + } + if (reloadUrl === __uniConfig.entryPagePath) { + return + } + const reloadPath = '/' + reloadUrl; + const routeOptions = __uniRoutes.find(route => route.path === reloadPath); + if (!routeOptions) { + return + } + if (routeOptions.meta.isNVue) { // 暂不处理 nvue + return + } + if (!routeOptions.meta.isTabBar) { + __uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath; + } + __uniConfig.entryPagePath = reloadUrl; + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] reloadUrl(${reloadUrl})`); + } + } + function registerApp (appVm) { if (process.env.NODE_ENV !== 'production') { console.log(`[uni-app] registerApp`); @@ -11962,6 +11934,8 @@ var serviceContext = (function () { getCurrentPages: getCurrentPages$1 }); + initHotReload(); + initTabBar(); initGlobalListeners(); @@ -12175,8 +12149,8 @@ var serviceContext = (function () { hideKeyboardTimeout = null; } } else { - // 仅安卓收起键盘时通知view层失去焦点 - if (isAndroid) { + // 安卓/iOS13收起键盘时通知view层失去焦点 + if (isAndroid || parseInt(plus.os.version) >= 13) { hideKeyboardTimeout = setTimeout(function () { hideKeyboardTimeout = null; var pageId = getCurrentPageId(); diff --git a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js index cb9666b130bc1abee881c48190eb789510877806..65b554e84628fe6dfcd4812fe97d63d8b322f972 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js @@ -16,15 +16,28 @@ const { const definePages = require('./define-pages') const appConfigService = require('./app-config-service') +function getTabBarPages (appJson) { + return appJson.tabBar && + appJson.tabBar.list && + appJson.tabBar.list.length && + appJson.tabBar.list +} + +function isTabBarPage (pathName, tabBarPages) { + return tabBarPages.find(item => item.pagePath === pathName) +} + function parseEntryPagePath (appJson, manifestJson) { const argsJsonStr = manifestJson.plus.arguments if (argsJsonStr) { try { const args = JSON.parse(argsJsonStr) const pathName = args.path || args.pathName - if (pathName && pathName !== appJson.pages[0]) { + if (pathName && appJson.pages[0] !== pathName) { appJson.entryPagePath = pathName - appJson.realEntryPagePath = appJson.pages[0] + if (!isTabBarPage(pathName, getTabBarPages(appJson))) { + appJson.realEntryPagePath = appJson.pages[0] + } } } catch (e) {} } @@ -32,12 +45,13 @@ function parseEntryPagePath (appJson, manifestJson) { appJson.entryPagePath = appJson.pages[0] } } + module.exports = function (appJson, manifestJson, { pagesJson, manifest, normalizeNetworkTimeout -}) { - parseEntryPagePath(appJson, manifestJson) +}) { + parseEntryPagePath(appJson, manifestJson) // timeout normalizeNetworkTimeout(appJson) @@ -61,7 +75,7 @@ module.exports = function (appJson, manifestJson, { manifestJson.permissions.UniNView = { 'description': 'UniNView原生渲染' } - // TODO 需要考虑 condition + manifestJson.plus.launchwebview.id = '1' // 首页 id 固定 为 1 // 删除首页 style 中的 uni-app 配置(不注入 app-view.js) delete manifestJson.plus.launchwebview['uni-app'] diff --git a/src/platforms/app-plus/service/api/route/navigate-back.js b/src/platforms/app-plus/service/api/route/navigate-back.js index 1026480121046f4bfe3f64c6639b888f03ad58ad..b4904272341b853c67261a706af31eaccd0fc331 100644 --- a/src/platforms/app-plus/service/api/route/navigate-back.js +++ b/src/platforms/app-plus/service/api/route/navigate-back.js @@ -100,15 +100,15 @@ export function navigateBack ({ uni.hideToast() // 后退时,关闭 toast,loading - // 当前页面是 condition 进入 - if (currentPage.$page.id === 1 && __uniConfig.realEntryPagePath) { + if (currentPage.$page.meta.isQuit) { + quit() + } else if (currentPage.$page.id === 1 && __uniConfig.realEntryPagePath) { + // condition uni.reLaunch({ url: '/' + __uniConfig.realEntryPagePath }) } else { - currentPage.$page.meta.isQuit - ? quit() - : back(delta, animationType, animationDuration) + back(delta, animationType, animationDuration) } return { errMsg: 'navigateBack:ok' diff --git a/src/platforms/app-plus/service/framework/app.js b/src/platforms/app-plus/service/framework/app.js index 81d99f4bdb62de5f47806e865635bf91649375ea..bc960e1aa77d205990e2af6cde8c5d802387b713 100644 --- a/src/platforms/app-plus/service/framework/app.js +++ b/src/platforms/app-plus/service/framework/app.js @@ -49,7 +49,9 @@ export function getApp ({ if (allowDefault) { // 返回默认实现 return defaultApp } - console.error('[warn]: getApp() 操作失败,v3模式加速了首页 nvue 的启动速度,当在首页 nvue 中使用 getApp() 不一定可以获取真正的 App 对象。详情请参考:https://uniapp.dcloud.io/collocation/frame/window?id=getapp') + console.error( + '[warn]: getApp() 操作失败,v3模式加速了首页 nvue 的启动速度,当在首页 nvue 中使用 getApp() 不一定可以获取真正的 App 对象。详情请参考:https://uniapp.dcloud.io/collocation/frame/window?id=getapp' + ) } function initGlobalListeners () { @@ -138,6 +140,31 @@ function initTabBar () { }) } +function initHotReload () { + const reloadUrl = weex.config.reloadUrl + if (!reloadUrl) { + return + } + if (reloadUrl === __uniConfig.entryPagePath) { + return + } + const reloadPath = '/' + reloadUrl + const routeOptions = __uniRoutes.find(route => route.path === reloadPath) + if (!routeOptions) { + return + } + if (routeOptions.meta.isNVue) { // 暂不处理 nvue + return + } + if (!routeOptions.meta.isTabBar) { + __uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath + } + __uniConfig.entryPagePath = reloadUrl + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] reloadUrl(${reloadUrl})`) + } +} + export function registerApp (appVm) { if (process.env.NODE_ENV !== 'production') { console.log(`[uni-app] registerApp`) @@ -156,6 +183,8 @@ export function registerApp (appVm) { getCurrentPages }) + initHotReload() + initTabBar() initGlobalListeners() @@ -167,4 +196,4 @@ export function registerApp (appVm) { __uniConfig.ready = true process.env.NODE_ENV !== 'production' && perf('registerApp') -} +} diff --git a/src/platforms/app-plus/service/framework/page.js b/src/platforms/app-plus/service/framework/page.js index 92d6690fd5e5d00b1062292ee220da51dc40fff4..9e571e82a483e462cda1141a0ceb23be5fdf5836 100644 --- a/src/platforms/app-plus/service/framework/page.js +++ b/src/platforms/app-plus/service/framework/page.js @@ -32,8 +32,13 @@ export function registerPage ({ }) { const routeOptions = JSON.parse(JSON.stringify(__uniRoutes.find(route => route.path === path))) - if (openType === 'reLaunch' || pages.length === 0) { - // pages.length===0 表示首页触发 redirectTo + if ( + openType === 'reLaunch' || + ( + openType === 'redirect' && + pages.length === 0 + ) // 首页 redirect + ) { routeOptions.meta.isQuit = true } else if (!routeOptions.meta.isTabBar) { routeOptions.meta.isQuit = false diff --git a/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js b/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js index a0f940e9e124fa04c3d00deaa0665eec4c7b0dd6..b4c117842792c7d709f6878a83487280626bbf79 100644 --- a/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +++ b/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js @@ -4,8 +4,8 @@ import { import { parsePullToRefresh -} from './pull-to-refresh-parser' - +} from './pull-to-refresh-parser' + import { parseStyleUnit } from './style-unit-parser' @@ -44,7 +44,11 @@ export function parseWebviewStyle (id, path, routeOptions = {}) { const titleNView = parseTitleNView(routeOptions) if (titleNView) { - if (id === 1 && __uniConfig.realEntryPagePath) { + if ( + id === 1 && + __uniConfig.realEntryPagePath && + !routeOptions.meta.isQuit // 可能是tabBar + ) { titleNView.autoBackButton = true } webviewStyle.titleNView = titleNView @@ -74,4 +78,4 @@ export function parseWebviewStyle (id, path, routeOptions = {}) { } return webviewStyle -} +} diff --git a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js index 6b4a0d1fa3dc2e7418cf09e9571781e5d0b1b2c5..48348ec978877f049a5baacc95df1858a55fe64c 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js @@ -67,8 +67,8 @@ export default function parsePage (vuePageOptions) { }, events: { // 支付宝小程序有些页面事件只能放在events下 - onBack(){ - this.$vm.__call_hook('onBackPress'); + onBack () { + this.$vm.__call_hook('onBackPress') } }, __r: handleRef,