提交 4b4d5e1f 编写于 作者: Q qiang

Merge branch 'dev' of github.com:dcloudio/uni-app into dev

...@@ -7681,7 +7681,7 @@ var serviceContext = (function () { ...@@ -7681,7 +7681,7 @@ var serviceContext = (function () {
return webview return webview
} }
function initWebview (webview, routeOptions) { function initWebview (webview, routeOptions, url = '') {
// 首页或非 nvue 页面 // 首页或非 nvue 页面
if (webview.id === '1' || !routeOptions.meta.isNVue) { if (webview.id === '1' || !routeOptions.meta.isNVue) {
const webviewStyle = parseWebviewStyle( const webviewStyle = parseWebviewStyle(
...@@ -7689,6 +7689,17 @@ var serviceContext = (function () { ...@@ -7689,6 +7689,17 @@ var serviceContext = (function () {
'', '',
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') { if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] updateWebview`, webviewStyle); console.log(`[uni-app] updateWebview`, webviewStyle);
} }
...@@ -7881,7 +7892,8 @@ var serviceContext = (function () { ...@@ -7881,7 +7892,8 @@ var serviceContext = (function () {
/** /**
* 首页需要主动registerPage,二级页面路由跳转时registerPage * 首页需要主动registerPage,二级页面路由跳转时registerPage
*/ */
function registerPage ({ function registerPage ({
url,
path, path,
query, query,
openType, openType,
...@@ -7920,7 +7932,7 @@ var serviceContext = (function () { ...@@ -7920,7 +7932,7 @@ var serviceContext = (function () {
console.log(`[uni-app] registerPage`, path, webview.id); console.log(`[uni-app] registerPage`, path, webview.id);
} }
initWebview(webview, routeOptions); initWebview(webview, routeOptions, url);
const route = path.slice(1); const route = path.slice(1);
...@@ -7986,6 +7998,7 @@ var serviceContext = (function () { ...@@ -7986,6 +7998,7 @@ var serviceContext = (function () {
} }
function _navigateTo ({ function _navigateTo ({
url,
path, path,
query, query,
animationType, animationType,
...@@ -7998,6 +8011,7 @@ var serviceContext = (function () { ...@@ -7998,6 +8011,7 @@ var serviceContext = (function () {
showWebview( showWebview(
registerPage({ registerPage({
url,
path, path,
query, query,
openType: 'navigate' openType: 'navigate'
...@@ -8020,18 +8034,19 @@ var serviceContext = (function () { ...@@ -8020,18 +8034,19 @@ var serviceContext = (function () {
animationDuration animationDuration
}, callbackId) { }, callbackId) {
const urls = url.split('?'); const urls = url.split('?');
const path = urls[0]; const path = urls[0];
const routeStyles = __uniRoutes.find(route => route.path === path).window; const routeStyles = __uniRoutes.find(route => route.path === path).window;
const globalStyle = __uniConfig.window; const globalStyle = __uniConfig.window;
if (!animationType) { if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW; animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW;
} }
if (!animationDuration) { if (!animationDuration) {
animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION; animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION;
} }
const query = parseQuery(urls[1] || ''); const query = parseQuery(urls[1] || '');
navigate(path, function () { navigate(path, function () {
_navigateTo({ _navigateTo({
url,
path, path,
query, query,
animationType, animationType,
...@@ -8041,6 +8056,7 @@ var serviceContext = (function () { ...@@ -8041,6 +8056,7 @@ var serviceContext = (function () {
} }
function _reLaunch ({ function _reLaunch ({
url,
path, path,
query query
}, callbackId) { }, callbackId) {
...@@ -8054,6 +8070,7 @@ var serviceContext = (function () { ...@@ -8054,6 +8070,7 @@ var serviceContext = (function () {
showWebview( showWebview(
registerPage({ registerPage({
url,
path, path,
query, query,
openType: 'reLaunch' openType: 'reLaunch'
...@@ -8082,6 +8099,7 @@ var serviceContext = (function () { ...@@ -8082,6 +8099,7 @@ var serviceContext = (function () {
const query = parseQuery(urls[1] || ''); const query = parseQuery(urls[1] || '');
navigate(path, function () { navigate(path, function () {
_reLaunch({ _reLaunch({
url,
path, path,
query query
}, callbackId); }, callbackId);
...@@ -8089,6 +8107,7 @@ var serviceContext = (function () { ...@@ -8089,6 +8107,7 @@ var serviceContext = (function () {
} }
function _redirectTo ({ function _redirectTo ({
url,
path, path,
query query
}, callbackId) { }, callbackId) {
...@@ -8099,6 +8118,7 @@ var serviceContext = (function () { ...@@ -8099,6 +8118,7 @@ var serviceContext = (function () {
showWebview( showWebview(
registerPage({ registerPage({
url,
path, path,
query, query,
openType: 'redirect' openType: 'redirect'
...@@ -8123,6 +8143,7 @@ var serviceContext = (function () { ...@@ -8123,6 +8143,7 @@ var serviceContext = (function () {
const query = parseQuery(urls[1] || ''); const query = parseQuery(urls[1] || '');
navigate(path, function () { navigate(path, function () {
_redirectTo({ _redirectTo({
url,
path, path,
query query
}, callbackId); }, callbackId);
...@@ -8130,6 +8151,7 @@ var serviceContext = (function () { ...@@ -8130,6 +8151,7 @@ var serviceContext = (function () {
} }
function _switchTab ({ function _switchTab ({
url,
path, path,
from from
}, callbackId) { }, callbackId) {
...@@ -8180,6 +8202,7 @@ var serviceContext = (function () { ...@@ -8180,6 +8202,7 @@ var serviceContext = (function () {
tabBarPage.$getAppWebview().show('none'); tabBarPage.$getAppWebview().show('none');
} else { } else {
return showWebview(registerPage({ return showWebview(registerPage({
url,
path, path,
query: {}, query: {},
openType: 'switchTab' openType: 'switchTab'
...@@ -8205,6 +8228,7 @@ var serviceContext = (function () { ...@@ -8205,6 +8228,7 @@ var serviceContext = (function () {
const path = url.split('?')[0]; const path = url.split('?')[0];
navigate(path, function () { navigate(path, function () {
_switchTab({ _switchTab({
url,
path, path,
from from
}, callbackId); }, callbackId);
......
const { const {
getPlatformFilterTag, getPlatformFilterTag,
normalizeNodeModules normalizeNodeModules,
jsPreprocessOptions
} = require('@dcloudio/uni-cli-shared/lib/platform') } = require('@dcloudio/uni-cli-shared/lib/platform')
const preprocessor = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/preprocess')
const FILTER_TAG = getPlatformFilterTag() 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) { module.exports = function parseCustomBlocks(descriptor, options) {
if (!descriptor.template || !FILTER_TAG || options.isAppNVue) { if (!descriptor.template || !FILTER_TAG || options.isAppNVue) {
...@@ -23,7 +35,7 @@ module.exports = function parseCustomBlocks(descriptor, options) { ...@@ -23,7 +35,7 @@ module.exports = function parseCustomBlocks(descriptor, options) {
block.attrs.lang === FILTER_TAG block.attrs.lang === FILTER_TAG
) )
) { ) {
modules[block.attrs.module] = block modules[block.attrs.module] = preprocessBlock(block)
return true return true
} }
if ( // renderjs if ( // renderjs
...@@ -33,7 +45,7 @@ module.exports = function parseCustomBlocks(descriptor, options) { ...@@ -33,7 +45,7 @@ module.exports = function parseCustomBlocks(descriptor, options) {
block.attrs.lang === 'renderjs' block.attrs.lang === 'renderjs'
) )
) { ) {
descriptor.renderjs = block descriptor.renderjs = preprocessBlock(block)
modules[block.attrs.module] = Object.assign({}, block, { modules[block.attrs.module] = Object.assign({}, block, {
content: '' content: ''
}) })
......
import { import {
parseQuery parseQuery
} from 'uni-shared' } from 'uni-shared'
import { import {
ANI_SHOW, ANI_SHOW,
ANI_DURATION ANI_DURATION
...@@ -25,6 +25,7 @@ import { ...@@ -25,6 +25,7 @@ import {
} from '../../framework/navigator' } from '../../framework/navigator'
function _navigateTo ({ function _navigateTo ({
url,
path, path,
query, query,
animationType, animationType,
...@@ -37,6 +38,7 @@ function _navigateTo ({ ...@@ -37,6 +38,7 @@ function _navigateTo ({
showWebview( showWebview(
registerPage({ registerPage({
url,
path, path,
query, query,
openType: 'navigate' openType: 'navigate'
...@@ -59,22 +61,23 @@ export function navigateTo ({ ...@@ -59,22 +61,23 @@ export function navigateTo ({
animationDuration animationDuration
}, callbackId) { }, callbackId) {
const urls = url.split('?') const urls = url.split('?')
const path = urls[0] const path = urls[0]
const routeStyles = __uniRoutes.find(route => route.path === path).window const routeStyles = __uniRoutes.find(route => route.path === path).window
const globalStyle = __uniConfig.window const globalStyle = __uniConfig.window
if (!animationType) { if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW
} }
if (!animationDuration) { if (!animationDuration) {
animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION
} }
const query = parseQuery(urls[1] || '') const query = parseQuery(urls[1] || '')
navigate(path, function () { navigate(path, function () {
_navigateTo({ _navigateTo({
url,
path, path,
query, query,
animationType, animationType,
animationDuration animationDuration
}, callbackId) }, callbackId)
}, openType === 'appLaunch') }, openType === 'appLaunch')
} }
...@@ -22,6 +22,7 @@ import { ...@@ -22,6 +22,7 @@ import {
} from '../../framework/navigator' } from '../../framework/navigator'
function _reLaunch ({ function _reLaunch ({
url,
path, path,
query query
}, callbackId) { }, callbackId) {
...@@ -35,6 +36,7 @@ function _reLaunch ({ ...@@ -35,6 +36,7 @@ function _reLaunch ({
showWebview( showWebview(
registerPage({ registerPage({
url,
path, path,
query, query,
openType: 'reLaunch' openType: 'reLaunch'
...@@ -63,6 +65,7 @@ export function reLaunch ({ ...@@ -63,6 +65,7 @@ export function reLaunch ({
const query = parseQuery(urls[1] || '') const query = parseQuery(urls[1] || '')
navigate(path, function () { navigate(path, function () {
_reLaunch({ _reLaunch({
url,
path, path,
query query
}, callbackId) }, callbackId)
......
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
} from '../../framework/navigator' } from '../../framework/navigator'
function _redirectTo ({ function _redirectTo ({
url,
path, path,
query query
}, callbackId) { }, callbackId) {
...@@ -30,6 +31,7 @@ function _redirectTo ({ ...@@ -30,6 +31,7 @@ function _redirectTo ({
showWebview( showWebview(
registerPage({ registerPage({
url,
path, path,
query, query,
openType: 'redirect' openType: 'redirect'
...@@ -54,6 +56,7 @@ export function redirectTo ({ ...@@ -54,6 +56,7 @@ export function redirectTo ({
const query = parseQuery(urls[1] || '') const query = parseQuery(urls[1] || '')
navigate(path, function () { navigate(path, function () {
_redirectTo({ _redirectTo({
url,
path, path,
query query
}, callbackId) }, callbackId)
......
...@@ -23,6 +23,7 @@ import { ...@@ -23,6 +23,7 @@ import {
import tabBar from '../../framework/tab-bar' import tabBar from '../../framework/tab-bar'
function _switchTab ({ function _switchTab ({
url,
path, path,
from from
}, callbackId) { }, callbackId) {
...@@ -73,6 +74,7 @@ function _switchTab ({ ...@@ -73,6 +74,7 @@ function _switchTab ({
tabBarPage.$getAppWebview().show('none') tabBarPage.$getAppWebview().show('none')
} else { } else {
return showWebview(registerPage({ return showWebview(registerPage({
url,
path, path,
query: {}, query: {},
openType: 'switchTab' openType: 'switchTab'
...@@ -98,8 +100,9 @@ export function switchTab ({ ...@@ -98,8 +100,9 @@ export function switchTab ({
const path = url.split('?')[0] const path = url.split('?')[0]
navigate(path, function () { navigate(path, function () {
_switchTab({ _switchTab({
url,
path, path,
from from
}, callbackId) }, callbackId)
}, openType === 'appLaunch') }, openType === 'appLaunch')
} }
...@@ -24,7 +24,8 @@ export function getCurrentPages (returnAll) { ...@@ -24,7 +24,8 @@ export function getCurrentPages (returnAll) {
/** /**
* 首页需要主动registerPage,二级页面路由跳转时registerPage * 首页需要主动registerPage,二级页面路由跳转时registerPage
*/ */
export function registerPage ({ export function registerPage ({
url,
path, path,
query, query,
openType, openType,
...@@ -63,7 +64,7 @@ export function registerPage ({ ...@@ -63,7 +64,7 @@ export function registerPage ({
console.log(`[uni-app] registerPage`, path, webview.id) console.log(`[uni-app] registerPage`, path, webview.id)
} }
initWebview(webview, routeOptions) initWebview(webview, routeOptions, url)
const route = path.slice(1) const route = path.slice(1)
......
...@@ -63,7 +63,7 @@ export function createWebview (path, routeOptions) { ...@@ -63,7 +63,7 @@ export function createWebview (path, routeOptions) {
return webview return webview
} }
export function initWebview (webview, routeOptions) { export function initWebview (webview, routeOptions, url = '') {
// 首页或非 nvue 页面 // 首页或非 nvue 页面
if (webview.id === '1' || !routeOptions.meta.isNVue) { if (webview.id === '1' || !routeOptions.meta.isNVue) {
const webviewStyle = parseWebviewStyle( const webviewStyle = parseWebviewStyle(
...@@ -71,6 +71,17 @@ export function initWebview (webview, routeOptions) { ...@@ -71,6 +71,17 @@ export function initWebview (webview, routeOptions) {
'', '',
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') { if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] updateWebview`, webviewStyle) console.log(`[uni-app] updateWebview`, webviewStyle)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册