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

fix(wxs): detect nested value changes inside props

上级 b7153612
......@@ -2721,8 +2721,11 @@ var serviceContext = (function () {
return false
}
return page.$page.meta.isTabBar
}
if (!/^\//.test(path)) {
path = '/' + path;
}
const route = __uniRoutes.find(route => route.path.replace(/^\//, '') === path.replace(/^\//, ''));
const route = __uniRoutes.find(route => route.path === path);
return route && route.meta.isTabBar
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
......@@ -2886,7 +2889,25 @@ var serviceContext = (function () {
const outOfChina = function (lng, lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false)
};
};
function getStatusbarHeight () {
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0
}
function getScreenInfo () {
const orientation = plus.navigator.getOrientation();
const landscape = Math.abs(orientation) === 90;
// 安卓 plus 接口获取的屏幕大小值不为整数
const width = plus.screen.resolutionWidth;
const height = plus.screen.resolutionHeight;
// 根据方向纠正宽高
return {
screenWidth: Math[landscape ? 'max' : 'min'](width, height),
screenHeight: Math[landscape ? 'min' : 'max'](width, height)
}
}
let audios = {};
......@@ -4941,48 +4962,55 @@ var serviceContext = (function () {
function getSystemInfo () {
const platform = plus.os.name.toLowerCase();
const ios = platform === 'ios';
// 安卓 plus 接口获取的屏幕大小值不为整数,iOS js 获取的屏幕大小横屏时颠倒
const screenWidth = plus.screen.resolutionWidth;
const screenHeight = plus.screen.resolutionHeight;
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
var landscape = Math.abs(plus.navigator.getOrientation()) === 90;
var statusBarHeight = Math.round(plus.navigator.getStatusbarHeight());
if (ios && landscape) {
statusBarHeight = Math.min(20, statusBarHeight);
}
var safeAreaInsets;
function getSafeAreaInsets () {
return {
left: 0,
right: 0,
top: titleNView ? 0 : statusBarHeight,
bottom: 0
}
}
// 判断是否存在 titleNView
var titleNView;
var webview = getLastWebview();
const {
screenWidth,
screenHeight
} = getScreenInfo();
const statusBarHeight = getStatusbarHeight();
let safeAreaInsets;
const titleNView = {
height: 0,
cover: false
};
const webview = getLastWebview();
if (webview) {
let style = webview.getStyle();
if (style) {
titleNView = style && style.titleNView;
titleNView = titleNView && titleNView.type === 'default';
style = style && style.titleNView;
if (style && style.type && style.type !== 'none') {
titleNView.height = style.type === 'transparent' ? 0 : (statusBarHeight + TITLEBAR_HEIGHT);
titleNView.cover = style.type === 'transparent' || style.type === 'float';
}
safeAreaInsets = ios ? webview.getSafeAreaInsets() : getSafeAreaInsets();
safeAreaInsets = webview.getSafeAreaInsets();
} else {
safeAreaInsets = ios ? plus.navigator.getSafeAreaInsets() : getSafeAreaInsets();
safeAreaInsets = plus.navigator.getSafeAreaInsets();
}
var windowBottom = isTabBarPage() && tabBar$1.visible && tabBar$1.cover ? tabBar$1.height : 0;
var windowHeight = Math.min(screenHeight - (titleNView ? (statusBarHeight + TITLEBAR_HEIGHT)
: 0) - windowBottom, screenHeight);
var windowWidth = screenWidth;
var safeArea = {
const tabBarView = {
height: 0,
cover: false
};
if (isTabBarPage()) {
tabBarView.height = tabBar$1.visible ? tabBar$1.height : 0;
tabBarView.cover = tabBar$1.cover;
}
const windowTop = titleNView.cover ? titleNView.height : 0;
const windowBottom = tabBarView.cover ? tabBarView.height : 0;
const windowHeight = screenHeight - titleNView.height - tabBarView.height;
const windowHeightReal = screenHeight - (titleNView.cover ? 0 : titleNView.height) - (tabBarView.cover ? 0 : tabBarView.height);
const windowWidth = screenWidth;
safeAreaInsets = ios ? safeAreaInsets : {
left: 0,
right: 0,
top: titleNView.height && !titleNView.cover ? 0 : statusBarHeight,
bottom: 0
};
const safeArea = {
left: safeAreaInsets.left,
right: windowWidth - safeAreaInsets.right,
top: safeAreaInsets.top,
bottom: windowHeight - safeAreaInsets.bottom,
bottom: windowHeightReal - safeAreaInsets.bottom,
width: windowWidth - safeAreaInsets.left - safeAreaInsets.right,
height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom
height: windowHeightReal - safeAreaInsets.top - safeAreaInsets.bottom
};
return {
......@@ -5001,9 +5029,15 @@ var serviceContext = (function () {
fontSizeSetting: '',
platform,
SDKVersion: '',
windowTop: 0,
windowTop,
windowBottom,
safeArea
safeArea,
safeAreaInsets: {
top: safeAreaInsets.top,
right: safeAreaInsets.right,
bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left
}
}
}
......@@ -7276,7 +7310,7 @@ var serviceContext = (function () {
function parsePullToRefresh (routeOptions) {
const windowOptions = routeOptions.window;
if (windowOptions.enablePullDownRefresh) {
if (windowOptions.enablePullDownRefresh || (windowOptions.pullToRefresh && windowOptions.pullToRefresh.support)) {
const pullToRefreshStyles = Object.create(null);
// 初始化默认值
if (plus.os.name === 'Android') {
......@@ -7498,7 +7532,7 @@ var serviceContext = (function () {
style.dock = 'top';
style.top = 0;
style.width = '100%';
style.height = TITLEBAR_HEIGHT + plus.navigator.getStatusbarHeight();
style.height = TITLEBAR_HEIGHT + getStatusbarHeight();
delete style.left;
delete style.right;
delete style.bottom;
......@@ -7768,7 +7802,10 @@ var serviceContext = (function () {
let todoNavigator = false;
function navigate (path, callback, isAppLaunch) {
{
{
if (isAppLaunch && __uniConfig.splashscreen && __uniConfig.splashscreen.autoclose && (!__uniConfig.splashscreen.alwaysShowBeforeRender)) {
plus.navigator.closeSplashscreen();
}
if (!isAppLaunch && todoNavigator) {
return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面${path}`)
}
......@@ -12073,8 +12110,9 @@ var serviceContext = (function () {
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] registerApp`);
}
appCtx = appVm;
appCtx = appVm;
appCtx.$vm = appVm;
Object.assign(appCtx, defaultApp); // 拷贝默认实现
......@@ -12278,7 +12316,7 @@ var serviceContext = (function () {
const isAndroid = plus.os.name.toLowerCase() === 'android';
const FOCUS_TIMEOUT = isAndroid ? 300 : 700;
const HIDE_TIMEOUT = 300;
const HIDE_TIMEOUT = 800;
let keyboardHeight = 0;
let onKeyboardShow;
let focusTimer;
......@@ -12915,13 +12953,15 @@ var serviceContext = (function () {
const onPageScroll = hasLifecycleHook(vm.$options, 'onPageScroll') ? 1 : 0;
const onPageReachBottom = hasLifecycleHook(vm.$options, 'onReachBottom') ? 1 : 0;
const statusbarHeight = getStatusbarHeight();
return {
disableScroll,
onPageScroll,
onPageReachBottom,
onReachBottomDistance,
windowTop: 0, // TODO
statusbarHeight,
windowTop: windowOptions.titleNView && windowOptions.titleNView.type === 'float' ? (statusbarHeight + TITLEBAR_HEIGHT) : 0,
windowBottom: (tabBar$1.indexOf(route) >= 0 && tabBar$1.cover) ? tabBar$1.height : 0
}
}
......
const path = require('path')
const hash = require('hash-sum')
const qs = require('querystring')
const plugin = require('vue-loader/lib/plugin')
const selectBlock = require('vue-loader/lib/select')
const loaderUtils = require('loader-utils')
const { attrsToQuery } = require('vue-loader/lib/codegen/utils')
const { parse } = require('@vue/component-compiler-utils')
const genStylesCode = require('vue-loader/lib/codegen/styleInjection')
const { genHotReloadCode } = require('vue-loader/lib/codegen/hotReload')
const genCustomBlocksCode = require('vue-loader/lib/codegen/customBlocks')
const componentNormalizerPath = require.resolve('vue-loader/lib/runtime/componentNormalizer')
const { NS } = require('vue-loader/lib/plugin')
const { src } = require('@dcloudio/uni-h5/path')
let errorEmitted = false
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
function loadTemplateCompiler (loaderContext) {
try {
return require('vue-template-compiler')
} catch (e) {
if (/version mismatch/.test(e.toString())) {
loaderContext.emitError(e)
} else {
loaderContext.emitError(new Error(
`[vue-loader] vue-template-compiler must be installed as a peer dependency, ` +
`or a compatible compiler implementation must be passed via options.`
))
}
}
}
let modules
module.exports = function (source) {
const loaderContext = this
if (!errorEmitted && !loaderContext['thread-loader'] && !loaderContext[NS]) {
loaderContext.emitError(new Error(
`vue-loader was used without the corresponding plugin. ` +
`Make sure to include VueLoaderPlugin in your webpack config.`
))
errorEmitted = true
}
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
const {
target,
request,
minimize,
sourceMap,
rootContext,
resourcePath,
resourceQuery
} = loaderContext
const rawQuery = resourceQuery.slice(1)
const inheritQuery = `&${rawQuery}`
const incomingQuery = qs.parse(rawQuery)
const options = loaderUtils.getOptions(loaderContext) || {}
const isServer = target === 'node'
const isShadow = !!options.shadowMode
const isProduction = options.productionMode || minimize || process.env.NODE_ENV === 'production'
const filename = path.basename(resourcePath)
const context = rootContext || process.cwd()
const sourceRoot = path.dirname(path.relative(context, resourcePath))
const descriptor = parse({
source,
compiler: options.compiler || loadTemplateCompiler(loaderContext),
filename,
sourceRoot,
needMap: sourceMap
})
// fixed by xxxxxx
if(!modules && options.compilerOptions && options.compilerOptions.modules){
modules = options.compilerOptions.modules
}
const sourcePath = normalizePath(src)
if (normalizePath(this.resourcePath).indexOf(sourcePath) === 0) {
descriptor.styles.length = 0
options.compilerOptions && (delete options.compilerOptions.modules)
} else if(options.compilerOptions){
options.compilerOptions.modules = modules
}
// if the query has a type field, this is a language block request
// e.g. foo.vue?type=template&id=xxxxx
// and we will return early
if (incomingQuery.type) {
return selectBlock(
descriptor,
loaderContext,
incomingQuery,
!!options.appendExtension
)
}
// module id for scoped CSS & hot-reload
const rawShortFilePath = path
.relative(context, resourcePath)
.replace(/^(\.\.[\/\\])+/, '')
const shortFilePath = rawShortFilePath.replace(/\\/g, '/') + resourceQuery
const id = hash(
isProduction
? (shortFilePath + '\n' + source)
: shortFilePath
)
// feature information
const hasScoped = descriptor.styles.some(s => s.scoped)
const hasFunctional = descriptor.template && descriptor.template.attrs.functional
const needsHotReload = (
!isServer &&
!isProduction &&
(descriptor.script || descriptor.template) &&
options.hotReload !== false
)
// template
let templateImport = `var render, staticRenderFns`
let templateRequest
if (descriptor.template) {
const src = descriptor.template.src || resourcePath
const idQuery = `&id=${id}`
const scopedQuery = hasScoped ? `&scoped=true` : ``
const attrsQuery = attrsToQuery(descriptor.template.attrs)
const query = `?vue&type=template${idQuery}${scopedQuery}${attrsQuery}${inheritQuery}`
const request = templateRequest = stringifyRequest(src + query)
templateImport = `import { render, staticRenderFns } from ${request}`
}
// script
let scriptImport = `var script = {}`
if (descriptor.script) {
const src = descriptor.script.src || resourcePath
const attrsQuery = attrsToQuery(descriptor.script.attrs, 'js')
const query = `?vue&type=script${attrsQuery}${inheritQuery}`
const request = stringifyRequest(src + query)
scriptImport = (
`import script from ${request}\n` +
`export * from ${request}` // support named exports
)
}
// styles
let stylesCode = ``
if (descriptor.styles.length) {
stylesCode = genStylesCode(
loaderContext,
descriptor.styles,
id,
resourcePath,
stringifyRequest,
needsHotReload,
isServer || isShadow // needs explicit injection?
)
}
let code = `
${templateImport}
${scriptImport}
${stylesCode}
/* normalize component */
import normalizer from ${stringifyRequest(`!${componentNormalizerPath}`)}
var component = normalizer(
script,
render,
staticRenderFns,
${hasFunctional ? `true` : `false`},
${/injectStyles/.test(stylesCode) ? `injectStyles` : `null`},
${hasScoped ? JSON.stringify(id) : `null`},
${isServer ? JSON.stringify(hash(request)) : `null`}
${isShadow ? `,true` : ``}
)
`.trim() + `\n`
if (descriptor.customBlocks && descriptor.customBlocks.length) {
code += genCustomBlocksCode(
descriptor.customBlocks,
resourcePath,
resourceQuery,
stringifyRequest
)
}
if (needsHotReload) {
code += `\n` + genHotReloadCode(id, hasFunctional, templateRequest)
}
// Expose filename. This is used by the devtools and Vue runtime warnings.
if (!isProduction) {
// Expose the file's full path in development, so that it can be opened
// from the devtools.
code += `\ncomponent.options.__file = ${JSON.stringify(rawShortFilePath.replace(/\\/g, '/'))}`
} else if (options.exposeFilename) {
// Libraies can opt-in to expose their components' filenames in production builds.
// For security reasons, only expose the file's basename in production.
code += `\ncomponent.options.__file = ${JSON.stringify(filename)}`
}
code += `\nexport default component.exports`
// console.log(code)
return code
}
module.exports.VueLoaderPlugin = plugin
......@@ -6785,6 +6785,8 @@ function updateWxsProps(oldVnode, vnode) {
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
......@@ -6815,6 +6815,8 @@ function updateWxsProps(oldVnode, vnode) {
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
......@@ -6807,6 +6807,8 @@ function updateWxsProps(oldVnode, vnode) {
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
......@@ -6789,6 +6789,8 @@
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
......@@ -6774,6 +6774,8 @@ function updateWxsProps(oldVnode, vnode) {
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
......@@ -6796,6 +6796,8 @@ function updateWxsProps(oldVnode, vnode) {
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
......@@ -6778,6 +6778,8 @@
context.$getComponentDescriptor(context, true),
vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
);
}, {
deep: true
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册