diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 54355c8320895e96f56a267f95fa55c85246e75a..cbb9bfea2801112b135b27081b220c382eb030da 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -7681,7 +7681,7 @@ var serviceContext = (function () { return webview } - function initWebview (webview, routeOptions) { + function initWebview (webview, routeOptions, url = '') { // 首页或非 nvue 页面 if (webview.id === '1' || !routeOptions.meta.isNVue) { const webviewStyle = parseWebviewStyle( @@ -7689,6 +7689,17 @@ var serviceContext = (function () { '', routeOptions ); + if (url) { + const part = url.split('?'); + webviewStyle.debugRefresh = { + isTab: routeOptions.meta.isTabBar, + arguments: JSON.stringify({ + path: part[0].substr(1), + query: part[1] || '' + }) + }; + } + if (process.env.NODE_ENV !== 'production') { console.log(`[uni-app] updateWebview`, webviewStyle); } @@ -7881,7 +7892,8 @@ var serviceContext = (function () { /** * 首页需要主动registerPage,二级页面路由跳转时registerPage */ - function registerPage ({ + function registerPage ({ + url, path, query, openType, @@ -7920,7 +7932,7 @@ var serviceContext = (function () { console.log(`[uni-app] registerPage`, path, webview.id); } - initWebview(webview, routeOptions); + initWebview(webview, routeOptions, url); const route = path.slice(1); @@ -7986,6 +7998,7 @@ var serviceContext = (function () { } function _navigateTo ({ + url, path, query, animationType, @@ -7998,6 +8011,7 @@ var serviceContext = (function () { showWebview( registerPage({ + url, path, query, openType: 'navigate' @@ -8020,18 +8034,19 @@ var serviceContext = (function () { animationDuration }, callbackId) { const urls = url.split('?'); - const path = urls[0]; - const routeStyles = __uniRoutes.find(route => route.path === path).window; - const globalStyle = __uniConfig.window; - if (!animationType) { - animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW; - } - if (!animationDuration) { - animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION; + const path = urls[0]; + const routeStyles = __uniRoutes.find(route => route.path === path).window; + const globalStyle = __uniConfig.window; + if (!animationType) { + animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW; + } + if (!animationDuration) { + animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION; } const query = parseQuery(urls[1] || ''); navigate(path, function () { _navigateTo({ + url, path, query, animationType, @@ -8041,6 +8056,7 @@ var serviceContext = (function () { } function _reLaunch ({ + url, path, query }, callbackId) { @@ -8054,6 +8070,7 @@ var serviceContext = (function () { showWebview( registerPage({ + url, path, query, openType: 'reLaunch' @@ -8082,6 +8099,7 @@ var serviceContext = (function () { const query = parseQuery(urls[1] || ''); navigate(path, function () { _reLaunch({ + url, path, query }, callbackId); @@ -8089,6 +8107,7 @@ var serviceContext = (function () { } function _redirectTo ({ + url, path, query }, callbackId) { @@ -8099,6 +8118,7 @@ var serviceContext = (function () { showWebview( registerPage({ + url, path, query, openType: 'redirect' @@ -8123,6 +8143,7 @@ var serviceContext = (function () { const query = parseQuery(urls[1] || ''); navigate(path, function () { _redirectTo({ + url, path, query }, callbackId); @@ -8130,6 +8151,7 @@ var serviceContext = (function () { } function _switchTab ({ + url, path, from }, callbackId) { @@ -8180,6 +8202,7 @@ var serviceContext = (function () { tabBarPage.$getAppWebview().show('none'); } else { return showWebview(registerPage({ + url, path, query: {}, openType: 'switchTab' @@ -8205,6 +8228,7 @@ var serviceContext = (function () { const path = url.split('?')[0]; navigate(path, function () { _switchTab({ + url, path, from }, callbackId); diff --git a/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/parseCustomBlocks.js b/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/parseCustomBlocks.js index ffea1534db8472d1c7cdb48a0c1a9d1148f12469..a474d024a4c28f60f250d57b685bf9855e6dea0a 100644 --- a/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/parseCustomBlocks.js +++ b/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/parseCustomBlocks.js @@ -1,10 +1,22 @@ const { getPlatformFilterTag, - normalizeNodeModules + normalizeNodeModules, + jsPreprocessOptions } = require('@dcloudio/uni-cli-shared/lib/platform') +const preprocessor = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/preprocess') + const FILTER_TAG = getPlatformFilterTag() +function preprocessBlock(block) { + if (block.content) { + block.content = preprocessor.preprocess(block.content, jsPreprocessOptions.context, { + type: jsPreprocessOptions.type + }).trim() + } + return block +} + module.exports = function parseCustomBlocks(descriptor, options) { if (!descriptor.template || !FILTER_TAG || options.isAppNVue) { @@ -23,7 +35,7 @@ module.exports = function parseCustomBlocks(descriptor, options) { block.attrs.lang === FILTER_TAG ) ) { - modules[block.attrs.module] = block + modules[block.attrs.module] = preprocessBlock(block) return true } if ( // renderjs @@ -33,7 +45,7 @@ module.exports = function parseCustomBlocks(descriptor, options) { block.attrs.lang === 'renderjs' ) ) { - descriptor.renderjs = block + descriptor.renderjs = preprocessBlock(block) modules[block.attrs.module] = Object.assign({}, block, { content: '' }) diff --git a/src/platforms/app-plus/service/api/route/navigate-to.js b/src/platforms/app-plus/service/api/route/navigate-to.js index d7523f44b41a023dd0fd1d41d8135deef56ef14a..1ff60f4dc77eb2dd792fe9cbf46931ec57c5f102 100644 --- a/src/platforms/app-plus/service/api/route/navigate-to.js +++ b/src/platforms/app-plus/service/api/route/navigate-to.js @@ -1,7 +1,7 @@ import { parseQuery -} from 'uni-shared' - +} from 'uni-shared' + import { ANI_SHOW, ANI_DURATION @@ -25,6 +25,7 @@ import { } from '../../framework/navigator' function _navigateTo ({ + url, path, query, animationType, @@ -37,6 +38,7 @@ function _navigateTo ({ showWebview( registerPage({ + url, path, query, openType: 'navigate' @@ -59,22 +61,23 @@ export function navigateTo ({ animationDuration }, callbackId) { const urls = url.split('?') - const path = urls[0] - const routeStyles = __uniRoutes.find(route => route.path === path).window - const globalStyle = __uniConfig.window - if (!animationType) { - animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW - } - if (!animationDuration) { - animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION + const path = urls[0] + const routeStyles = __uniRoutes.find(route => route.path === path).window + const globalStyle = __uniConfig.window + if (!animationType) { + animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW + } + if (!animationDuration) { + animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION } const query = parseQuery(urls[1] || '') navigate(path, function () { _navigateTo({ + url, path, query, animationType, animationDuration }, callbackId) }, openType === 'appLaunch') -} +} diff --git a/src/platforms/app-plus/service/api/route/re-launch.js b/src/platforms/app-plus/service/api/route/re-launch.js index 272d93408b636ca280221198ed04024e94c00052..7793375fb2402ca5b04c3a00f763126431ac9961 100644 --- a/src/platforms/app-plus/service/api/route/re-launch.js +++ b/src/platforms/app-plus/service/api/route/re-launch.js @@ -22,6 +22,7 @@ import { } from '../../framework/navigator' function _reLaunch ({ + url, path, query }, callbackId) { @@ -35,6 +36,7 @@ function _reLaunch ({ showWebview( registerPage({ + url, path, query, openType: 'reLaunch' @@ -63,6 +65,7 @@ export function reLaunch ({ const query = parseQuery(urls[1] || '') navigate(path, function () { _reLaunch({ + url, path, query }, callbackId) diff --git a/src/platforms/app-plus/service/api/route/redirect-to.js b/src/platforms/app-plus/service/api/route/redirect-to.js index 850c8a55582a142da322c6854935c33150db833a..ade666e2352f96c4f44badd833b13c5ce7b889ea 100644 --- a/src/platforms/app-plus/service/api/route/redirect-to.js +++ b/src/platforms/app-plus/service/api/route/redirect-to.js @@ -20,6 +20,7 @@ import { } from '../../framework/navigator' function _redirectTo ({ + url, path, query }, callbackId) { @@ -30,6 +31,7 @@ function _redirectTo ({ showWebview( registerPage({ + url, path, query, openType: 'redirect' @@ -54,6 +56,7 @@ export function redirectTo ({ const query = parseQuery(urls[1] || '') navigate(path, function () { _redirectTo({ + url, path, query }, callbackId) diff --git a/src/platforms/app-plus/service/api/route/switch-tab.js b/src/platforms/app-plus/service/api/route/switch-tab.js index bc23f900661a36a04ae4f53d2ad255559573a023..9bcea79f5aa7592d4dd1903233a983530f5f8337 100644 --- a/src/platforms/app-plus/service/api/route/switch-tab.js +++ b/src/platforms/app-plus/service/api/route/switch-tab.js @@ -23,6 +23,7 @@ import { import tabBar from '../../framework/tab-bar' function _switchTab ({ + url, path, from }, callbackId) { @@ -73,6 +74,7 @@ function _switchTab ({ tabBarPage.$getAppWebview().show('none') } else { return showWebview(registerPage({ + url, path, query: {}, openType: 'switchTab' @@ -98,8 +100,9 @@ export function switchTab ({ const path = url.split('?')[0] navigate(path, function () { _switchTab({ + url, path, from }, callbackId) }, openType === 'appLaunch') -} +} diff --git a/src/platforms/app-plus/service/framework/page.js b/src/platforms/app-plus/service/framework/page.js index f1fbe5a33433a7cdacb8d1eba3318ea19cfb02e4..843d62432e1686cce704461431fb6c89343f9392 100644 --- a/src/platforms/app-plus/service/framework/page.js +++ b/src/platforms/app-plus/service/framework/page.js @@ -24,7 +24,8 @@ export function getCurrentPages (returnAll) { /** * 首页需要主动registerPage,二级页面路由跳转时registerPage */ -export function registerPage ({ +export function registerPage ({ + url, path, query, openType, @@ -63,7 +64,7 @@ export function registerPage ({ console.log(`[uni-app] registerPage`, path, webview.id) } - initWebview(webview, routeOptions) + initWebview(webview, routeOptions, url) const route = path.slice(1) diff --git a/src/platforms/app-plus/service/framework/webview/index.js b/src/platforms/app-plus/service/framework/webview/index.js index d95356fded00111d0e7819d8ab02bc03056eb613..11cb191688fde2e86a96afcbdb87db86b0339dd5 100644 --- a/src/platforms/app-plus/service/framework/webview/index.js +++ b/src/platforms/app-plus/service/framework/webview/index.js @@ -63,7 +63,7 @@ export function createWebview (path, routeOptions) { return webview } -export function initWebview (webview, routeOptions) { +export function initWebview (webview, routeOptions, url = '') { // 首页或非 nvue 页面 if (webview.id === '1' || !routeOptions.meta.isNVue) { const webviewStyle = parseWebviewStyle( @@ -71,6 +71,17 @@ export function initWebview (webview, routeOptions) { '', routeOptions ) + if (url) { + const part = url.split('?') + webviewStyle.debugRefresh = { + isTab: routeOptions.meta.isTabBar, + arguments: JSON.stringify({ + path: part[0].substr(1), + query: part[1] || '' + }) + } + } + if (process.env.NODE_ENV !== 'production') { console.log(`[uni-app] updateWebview`, webviewStyle) }