From 1429909d95d93c0396d5da53c420baeff29c080c Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 19 May 2020 09:59:18 +0800 Subject: [PATCH] fix(v3): show.callback --- src/platforms/app-plus/page-factory.js | 4 +-- .../app-plus/service/api/route/util.js | 28 ++++++++++++++++--- .../app-plus/service/framework/page.js | 4 +-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/platforms/app-plus/page-factory.js b/src/platforms/app-plus/page-factory.js index 029776525..753919afe 100644 --- a/src/platforms/app-plus/page-factory.js +++ b/src/platforms/app-plus/page-factory.js @@ -21,11 +21,11 @@ export function createPage (pagePath, pageId, pageQuery, pageInstance) { mpType: 'page', pageId, pagePath, - pageQuery, + pageQuery, pageInstance }) if (process.env.NODE_ENV !== 'production') { - console.log(`new ${pagePath}`, Date.now() - startTime) + console.log(`new ${pagePath}[${pageId}]:time(${Date.now() - startTime})`) } return pageVm } diff --git a/src/platforms/app-plus/service/api/route/util.js b/src/platforms/app-plus/service/api/route/util.js index ec7f38a61..c02644ebc 100644 --- a/src/platforms/app-plus/service/api/route/util.js +++ b/src/platforms/app-plus/service/api/route/util.js @@ -7,7 +7,7 @@ import { navigateFinish } from '../../framework/navigator' -export function showWebview (webview, animationType, animationDuration, showCallback, delay) { +export function showWebview (webview, animationType, animationDuration, showCallback, delay) { if (typeof delay === 'undefined') { delay = webview.nvue ? 0 : 100 } @@ -21,16 +21,36 @@ export function showWebview (webview, animationType, animationDuration, showCall if (process.env.NODE_ENV !== 'production') { console.log(`[show][${Date.now()}]`, delay) } + const duration = animationDuration || ANI_DURATION setTimeout(() => { + const execShowCallback = function () { + if (execShowCallback._called) { + if (process.env.NODE_ENV !== 'production') { + console.log('execShowCallback.prevent') + } + return + } + execShowCallback._called = true + showCallback && showCallback() + navigateFinish(webview) + } + const timer = setTimeout(() => { + if (process.env.NODE_ENV !== 'production') { + console.log(`[show.callback.timer][${Date.now()}]`) + } + execShowCallback() + }, duration + 150) webview.show( animationType || ANI_SHOW, - animationDuration || ANI_DURATION, + duration, () => { if (process.env.NODE_ENV !== 'production') { console.log(`[show.callback][${Date.now()}]`) } - showCallback && showCallback() - navigateFinish(webview) + if (!execShowCallback._called) { + clearTimeout(timer) + } + execShowCallback() } ) }, delay) diff --git a/src/platforms/app-plus/service/framework/page.js b/src/platforms/app-plus/service/framework/page.js index 0bc446f2c..a2f3916ef 100644 --- a/src/platforms/app-plus/service/framework/page.js +++ b/src/platforms/app-plus/service/framework/page.js @@ -93,7 +93,7 @@ export function registerPage ({ } pages.splice(index, 1) if (process.env.NODE_ENV !== 'production') { - console.log('[uni-app] removePage', path, webview.id) + console.log('[uni-app] removePage(' + path + ')[' + webview.id + ']') } } }, @@ -134,4 +134,4 @@ export function registerPage ({ } return webview -} +} -- GitLab