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

fix(v3): improve navigate logic

上级 dc0c688e
...@@ -1601,6 +1601,37 @@ var serviceContext = (function () { ...@@ -1601,6 +1601,37 @@ var serviceContext = (function () {
removeStorageSync: removeStorageSync removeStorageSync: removeStorageSync
}); });
const loadFontFace = {
family: {
type: String,
required: true
},
source: {
type: String,
required: true
},
desc: {
type: Object,
required: false
},
success: {
type: Function,
required: false
},
fail: {
type: Function,
required: false
},
complete: {
type: Function,
required: false
}
};
var require_context_module_0_24 = /*#__PURE__*/Object.freeze({
loadFontFace: loadFontFace
});
const FRONT_COLORS = ['#ffffff', '#000000']; const FRONT_COLORS = ['#ffffff', '#000000'];
const setNavigationBarColor = { const setNavigationBarColor = {
'frontColor': { 'frontColor': {
...@@ -1639,7 +1670,7 @@ var serviceContext = (function () { ...@@ -1639,7 +1670,7 @@ var serviceContext = (function () {
} }
}; };
var require_context_module_0_24 = /*#__PURE__*/Object.freeze({ var require_context_module_0_25 = /*#__PURE__*/Object.freeze({
setNavigationBarColor: setNavigationBarColor, setNavigationBarColor: setNavigationBarColor,
setNavigationBarTitle: setNavigationBarTitle setNavigationBarTitle: setNavigationBarTitle
}); });
...@@ -1658,7 +1689,7 @@ var serviceContext = (function () { ...@@ -1658,7 +1689,7 @@ var serviceContext = (function () {
} }
}; };
var require_context_module_0_25 = /*#__PURE__*/Object.freeze({ var require_context_module_0_26 = /*#__PURE__*/Object.freeze({
pageScrollTo: pageScrollTo pageScrollTo: pageScrollTo
}); });
...@@ -1775,7 +1806,7 @@ var serviceContext = (function () { ...@@ -1775,7 +1806,7 @@ var serviceContext = (function () {
} }
}; };
var require_context_module_0_26 = /*#__PURE__*/Object.freeze({ var require_context_module_0_27 = /*#__PURE__*/Object.freeze({
showModal: showModal, showModal: showModal,
showToast: showToast, showToast: showToast,
showLoading: showLoading, showLoading: showLoading,
...@@ -1859,7 +1890,7 @@ var serviceContext = (function () { ...@@ -1859,7 +1890,7 @@ var serviceContext = (function () {
} }
}; };
var require_context_module_0_27 = /*#__PURE__*/Object.freeze({ var require_context_module_0_28 = /*#__PURE__*/Object.freeze({
setTabBarItem: setTabBarItem, setTabBarItem: setTabBarItem,
setTabBarStyle: setTabBarStyle, setTabBarStyle: setTabBarStyle,
hideTabBar: hideTabBar, hideTabBar: hideTabBar,
...@@ -1898,10 +1929,11 @@ var serviceContext = (function () { ...@@ -1898,10 +1929,11 @@ var serviceContext = (function () {
'./plugin/get-provider.js': require_context_module_0_21, './plugin/get-provider.js': require_context_module_0_21,
'./route/route.js': require_context_module_0_22, './route/route.js': require_context_module_0_22,
'./storage/storage.js': require_context_module_0_23, './storage/storage.js': require_context_module_0_23,
'./ui/navigation-bar.js': require_context_module_0_24, './ui/load-font-face.js': require_context_module_0_24,
'./ui/page-scroll-to.js': require_context_module_0_25, './ui/navigation-bar.js': require_context_module_0_25,
'./ui/popup.js': require_context_module_0_26, './ui/page-scroll-to.js': require_context_module_0_26,
'./ui/tab-bar.js': require_context_module_0_27, './ui/popup.js': require_context_module_0_27,
'./ui/tab-bar.js': require_context_module_0_28,
}; };
var req = function req(key) { var req = function req(key) {
...@@ -2554,7 +2586,7 @@ var serviceContext = (function () { ...@@ -2554,7 +2586,7 @@ var serviceContext = (function () {
const oldSetStatusBarStyle = plus.navigator.setStatusBarStyle; const oldSetStatusBarStyle = plus.navigator.setStatusBarStyle;
function newSetStatusBarStyle(style) { function newSetStatusBarStyle (style) {
lastStatusBarStyle = style; lastStatusBarStyle = style;
oldSetStatusBarStyle(style); oldSetStatusBarStyle(style);
} }
...@@ -7560,10 +7592,10 @@ var serviceContext = (function () { ...@@ -7560,10 +7592,10 @@ var serviceContext = (function () {
let todoNavigator = false; let todoNavigator = false;
function navigate (path, callback) { function navigate (path, callback, isAppLaunch) {
{ {
if (todoNavigator) { if (!isAppLaunch && todoNavigator) {
return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面`) return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面${path}`)
} }
// 未创建 preloadWebview 或 preloadWebview 已被使用 // 未创建 preloadWebview 或 preloadWebview 已被使用
const waitPreloadWebview = !preloadWebview || (preloadWebview && preloadWebview.__uniapp_route); const waitPreloadWebview = !preloadWebview || (preloadWebview && preloadWebview.__uniapp_route);
...@@ -7811,6 +7843,7 @@ var serviceContext = (function () { ...@@ -7811,6 +7843,7 @@ var serviceContext = (function () {
function navigateTo$1 ({ function navigateTo$1 ({
url, url,
openType,
animationType, animationType,
animationDuration animationDuration
}) { }) {
...@@ -7824,7 +7857,7 @@ var serviceContext = (function () { ...@@ -7824,7 +7857,7 @@ var serviceContext = (function () {
animationType, animationType,
animationDuration animationDuration
}); });
}); }, openType === 'appLaunch');
} }
function _reLaunch ({ function _reLaunch ({
...@@ -7986,7 +8019,8 @@ var serviceContext = (function () { ...@@ -7986,7 +8019,8 @@ var serviceContext = (function () {
function switchTab$1 ({ function switchTab$1 ({
url, url,
from from,
openType
}) { }) {
const path = url.split('?')[0]; const path = url.split('?')[0];
navigate(path, function () { navigate(path, function () {
...@@ -7994,7 +8028,7 @@ var serviceContext = (function () { ...@@ -7994,7 +8028,7 @@ var serviceContext = (function () {
path, path,
from from
}); });
}); }, openType === 'appLaunch');
} }
function showKeyboard () { function showKeyboard () {
...@@ -8517,11 +8551,15 @@ var serviceContext = (function () { ...@@ -8517,11 +8551,15 @@ var serviceContext = (function () {
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
startPullDownRefresh: startPullDownRefresh, startPullDownRefresh: startPullDownRefresh,
stopPullDownRefresh: stopPullDownRefresh, stopPullDownRefresh: stopPullDownRefresh,
compressImage: compressImage,
$on: $on$1, $on: $on$1,
$off: $off$1, $off: $off$1,
$once: $once$1, $once: $once$1,
$emit: $emit$1, $emit: $emit$1,
createAudioInstance: createAudioInstance,
destroyAudioInstance: destroyAudioInstance,
setAudioState: setAudioState,
getAudioState: getAudioState,
operateAudio: operateAudio,
getMusicPlayerState: getMusicPlayerState, getMusicPlayerState: getMusicPlayerState,
operateMusicPlayer: operateMusicPlayer, operateMusicPlayer: operateMusicPlayer,
setBackgroundAudioState: setBackgroundAudioState, setBackgroundAudioState: setBackgroundAudioState,
...@@ -8584,11 +8622,7 @@ var serviceContext = (function () { ...@@ -8584,11 +8622,7 @@ var serviceContext = (function () {
stopVoice: stopVoice, stopVoice: stopVoice,
chooseImage: chooseImage$1, chooseImage: chooseImage$1,
chooseVideo: chooseVideo$1, chooseVideo: chooseVideo$1,
createAudioInstance: createAudioInstance, compressImage: compressImage,
destroyAudioInstance: destroyAudioInstance,
setAudioState: setAudioState,
getAudioState: getAudioState,
operateAudio: operateAudio,
getImageInfo: getImageInfo$1, getImageInfo: getImageInfo$1,
previewImage: previewImage$1, previewImage: previewImage$1,
operateRecorder: operateRecorder, operateRecorder: operateRecorder,
...@@ -10992,6 +11026,30 @@ var serviceContext = (function () { ...@@ -10992,6 +11026,30 @@ var serviceContext = (function () {
onKeyboardHeightChange: onKeyboardHeightChange onKeyboardHeightChange: onKeyboardHeightChange
}); });
UniServiceJSBridge.subscribe('onLoadFontFaceCallback', ({
callbackId,
data
}) => {
invoke(callbackId, data);
});
function loadFontFace$1 (options, callbackId) {
const pageId = getCurrentPageId();
if (!pageId) {
return {
errMsg: 'loadFontFace:fail not font page'
}
}
UniServiceJSBridge.publishHandler('loadFontFace', {
options,
callbackId
}, pageId);
}
var require_context_module_1_23 = /*#__PURE__*/Object.freeze({
loadFontFace: loadFontFace$1
});
function pageScrollTo$1 (args) { function pageScrollTo$1 (args) {
const pages = getCurrentPages(); const pages = getCurrentPages();
if (pages.length) { if (pages.length) {
...@@ -11000,7 +11058,7 @@ var serviceContext = (function () { ...@@ -11000,7 +11058,7 @@ var serviceContext = (function () {
return {} return {}
} }
var require_context_module_1_23 = /*#__PURE__*/Object.freeze({ var require_context_module_1_24 = /*#__PURE__*/Object.freeze({
pageScrollTo: pageScrollTo$1 pageScrollTo: pageScrollTo$1
}); });
...@@ -11036,7 +11094,7 @@ var serviceContext = (function () { ...@@ -11036,7 +11094,7 @@ var serviceContext = (function () {
callbacks$a.push(callbackId); callbacks$a.push(callbackId);
} }
var require_context_module_1_24 = /*#__PURE__*/Object.freeze({ var require_context_module_1_25 = /*#__PURE__*/Object.freeze({
removeTabBarBadge: removeTabBarBadge$1, removeTabBarBadge: removeTabBarBadge$1,
showTabBarRedDot: showTabBarRedDot$1, showTabBarRedDot: showTabBarRedDot$1,
hideTabBarRedDot: hideTabBarRedDot$1, hideTabBarRedDot: hideTabBarRedDot$1,
...@@ -11061,7 +11119,7 @@ var serviceContext = (function () { ...@@ -11061,7 +11119,7 @@ var serviceContext = (function () {
callbacks$b.splice(callbacks$b.indexOf(callbackId), 1); callbacks$b.splice(callbacks$b.indexOf(callbackId), 1);
} }
var require_context_module_1_25 = /*#__PURE__*/Object.freeze({ var require_context_module_1_26 = /*#__PURE__*/Object.freeze({
onWindowResize: onWindowResize, onWindowResize: onWindowResize,
offWindowResize: offWindowResize offWindowResize: offWindowResize
}); });
...@@ -11094,9 +11152,10 @@ var serviceContext = (function () { ...@@ -11094,9 +11152,10 @@ var serviceContext = (function () {
'./ui/create-intersection-observer.js': require_context_module_1_20, './ui/create-intersection-observer.js': require_context_module_1_20,
'./ui/create-selector-query.js': require_context_module_1_21, './ui/create-selector-query.js': require_context_module_1_21,
'./ui/keyboard.js': require_context_module_1_22, './ui/keyboard.js': require_context_module_1_22,
'./ui/page-scroll-to.js': require_context_module_1_23, './ui/load-font-face.js': require_context_module_1_23,
'./ui/tab-bar.js': require_context_module_1_24, './ui/page-scroll-to.js': require_context_module_1_24,
'./ui/window.js': require_context_module_1_25, './ui/tab-bar.js': require_context_module_1_25,
'./ui/window.js': require_context_module_1_26,
}; };
var req = function req(key) { var req = function req(key) {
...@@ -11335,7 +11394,8 @@ var serviceContext = (function () { ...@@ -11335,7 +11394,8 @@ 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,
openType: 'appLaunch'
}) })
} }
} }
......
...@@ -49,6 +49,7 @@ function _navigateTo ({ ...@@ -49,6 +49,7 @@ function _navigateTo ({
export function navigateTo ({ export function navigateTo ({
url, url,
openType,
animationType, animationType,
animationDuration animationDuration
}) { }) {
...@@ -62,5 +63,5 @@ export function navigateTo ({ ...@@ -62,5 +63,5 @@ export function navigateTo ({
animationType, animationType,
animationDuration animationDuration
}) })
}) }, openType === 'appLaunch')
} }
...@@ -91,7 +91,8 @@ function _switchTab ({ ...@@ -91,7 +91,8 @@ function _switchTab ({
export function switchTab ({ export function switchTab ({
url, url,
from from,
openType
}) { }) {
const path = url.split('?')[0] const path = url.split('?')[0]
navigate(path, function () { navigate(path, function () {
...@@ -99,5 +100,5 @@ export function switchTab ({ ...@@ -99,5 +100,5 @@ export function switchTab ({
path, path,
from from
}) })
}) }, openType === 'appLaunch')
} }
...@@ -6,10 +6,10 @@ import { ...@@ -6,10 +6,10 @@ import {
let todoNavigator = false let todoNavigator = false
export function navigate (path, callback) { export function navigate (path, callback, isAppLaunch) {
if (__PLATFORM__ === 'app-plus') { if (__PLATFORM__ === 'app-plus') {
if (todoNavigator) { if (!isAppLaunch && todoNavigator) {
return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面`) return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面${path}`)
} }
// 未创建 preloadWebview 或 preloadWebview 已被使用 // 未创建 preloadWebview 或 preloadWebview 已被使用
const waitPreloadWebview = !preloadWebview || (preloadWebview && preloadWebview.__uniapp_route) const waitPreloadWebview = !preloadWebview || (preloadWebview && preloadWebview.__uniapp_route)
......
...@@ -38,7 +38,8 @@ export default function onWebviewReady (data, pageId) { ...@@ -38,7 +38,8 @@ 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,
openType: 'appLaunch'
}) })
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册