From 8204261013e6d81eaba37a005cea447f85f11c7e Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 19 Mar 2020 16:04:30 +0800 Subject: [PATCH] feat(v3): add uniPageUrl --- .../service/framework/webview/index.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/platforms/app-plus/service/framework/webview/index.js b/src/platforms/app-plus/service/framework/webview/index.js index 241270f489..b2674acde0 100644 --- a/src/platforms/app-plus/service/framework/webview/index.js +++ b/src/platforms/app-plus/service/framework/webview/index.js @@ -49,6 +49,14 @@ function noop (str) { return str } +function getUniPageUrl (path, query) { + const queryString = query ? stringifyQuery(query, noop) : '' + return { + path: path.substr(1), + query: queryString ? queryString.substr(1) : queryString + } +} + function getDebugRefresh (path, query, routeOptions) { const queryString = query ? stringifyQuery(query, noop) : '' return { @@ -60,7 +68,7 @@ function getDebugRefresh (path, query, routeOptions) { } } -export function createWebview (path, routeOptions) { +export function createWebview (path, routeOptions, query) { if (routeOptions.meta.isNVue) { const webviewId = id++ const webviewStyle = parseWebviewStyle( @@ -68,6 +76,7 @@ export function createWebview (path, routeOptions) { path, routeOptions ) + webviewStyle.uniPageUrl = getUniPageUrl(path, query) if (process.env.NODE_ENV !== 'production') { console.log(`[uni-app] createWebview`, webviewId, path, webviewStyle) } @@ -89,9 +98,12 @@ export function initWebview (webview, routeOptions, path, query) { parseInt(webview.id), '', routeOptions - ) - if (!routeOptions.meta.isNVue) { - webviewStyle.debugRefresh = getDebugRefresh(path, query, routeOptions) + ) + + webviewStyle.uniPageUrl = getUniPageUrl(path, query) + + if (!routeOptions.meta.isNVue) { + webviewStyle.debugRefresh = getDebugRefresh(path, query, routeOptions) } if (process.env.NODE_ENV !== 'production') { console.log(`[uni-app] updateWebview`, webviewStyle) -- GitLab