diff --git a/packages/uni-mp-weixin/lib/uni.config.js b/packages/uni-mp-weixin/lib/uni.config.js
index bf79e12547059843aaede1727157aba2ac29d12e..562d4ccf4febe843cf3453b115b04a57a8e64b04 100644
--- a/packages/uni-mp-weixin/lib/uni.config.js
+++ b/packages/uni-mp-weixin/lib/uni.config.js
@@ -29,7 +29,8 @@ module.exports = {
'sitemap.json',
'ext.json',
'custom-tab-bar',
- 'functional-pages'
+ 'functional-pages',
+ 'project.private.config.json'
]
if (process.env.UNI_MP_PLUGIN) {
diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
index 8d201bc4ccf2df2d4b78706a3a31eac5341a4cc6..4dcb81d258f4e7bd46794c2f57a59f7669151013 100644
--- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
@@ -274,6 +274,29 @@ describe('mp:compiler-extra', () => {
)
})
+ it('generate v-slot with v-if', () => {
+ assertCodegen(
+ 'hello',
+ 'hello'
+ )
+ assertCodegen(
+ 'hello',
+ 'hello'
+ )
+ assertCodegen(
+ 'hello',
+ 'hello'
+ )
+ assertCodegen(
+ 'hello',
+ 'hello'
+ )
+ assertCodegen(
+ 'hello',
+ 'hello'
+ )
+ })
+
it('generate events inside v-for', () => {
assertCodegen(
'',
diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
index 8e6ff3c3e21418b28b166e03d6bae00b49316d0f..14c71afe5709b0240c209b9bdfdc88bc0c2e2102 100644
--- a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
@@ -116,7 +116,7 @@ describe('mp:compiler-mp-alipay', () => {
)
assertCodegen(
'{{getValue(item)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'auto'
@@ -124,7 +124,7 @@ describe('mp:compiler-mp-alipay', () => {
)
assertCodegen(
'{{getValue(item.text)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default").text):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'auto'
diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
index 8bb05ec7d8bb6fe07022dfd71bd3fba1b8630d3e..3ea32f7f8d27567c9f4c99be1a59b1ecebf67d25 100644
--- a/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
@@ -87,14 +87,14 @@ describe('mp:compiler-mp-baidu', () => {
)
assertCodegen(
'{{getValue(item)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}', {
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'{{getValue(item.text)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default").text):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}', {
scopedSlotsCompiler: 'auto'
}
diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
index bb2785cecbf5b10d9de593c0738e493d4e86bc94..8887702f8e8baa130746fee3446d4d891a027618 100644
--- a/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
@@ -144,7 +144,7 @@ describe('mp:compiler-mp-weixin', () => {
)
assertCodegen(
'{{getValue(item)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'auto'
@@ -152,7 +152,7 @@ describe('mp:compiler-mp-weixin', () => {
)
assertCodegen(
'{{getValue(item.text)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default").text):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'auto'
@@ -219,7 +219,7 @@ describe('mp:compiler-mp-weixin', () => {
it('generate scoped slot with scopedSlotsCompiler: augmented', () => {
assertCodegen(
'{{getValue(item)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'augmented'
@@ -227,7 +227,7 @@ describe('mp:compiler-mp-weixin', () => {
)
assertCodegen(
'{{item}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?$getScopedSlotsParams("551070e6-1","default","item"):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'augmented'
@@ -235,7 +235,7 @@ describe('mp:compiler-mp-weixin', () => {
)
assertCodegen(
'{{getValue(item.text)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?getValue($getScopedSlotsParams("551070e6-1","default").text):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'augmented'
@@ -243,7 +243,7 @@ describe('mp:compiler-mp-weixin', () => {
)
assertCodegen(
'{{getValue(item)}}',
- '{{$root.m1}}',
+ '{{$root.m1}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-2");var m1=m0?getValue($getScopedSlotsParams("551070e6-2","default","item")):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1}})}',
{
scopedSlotsCompiler: 'augmented'
@@ -274,8 +274,8 @@ describe('mp:compiler-mp-weixin', () => {
}
)
assertCodegen(
- '{{item}}{{item}}',
- '{{$root.m1}}{{$root.m3}}',
+ '{{item}}{{item}}',
+ '{{$root.m1}}{{$root.m3}}',
'with(this){var m0=$hasScopedSlotsParams("551070e6-1");var m1=m0?$getScopedSlotsParams("551070e6-1","default","item"):null;var m2=$hasScopedSlotsParams("551070e6-2");var m3=m2?$getScopedSlotsParams("551070e6-2","default","item"):null;$mp.data=Object.assign({},{$root:{m0:m0,m1:m1,m2:m2,m3:m3}})}',
{
scopedSlotsCompiler: 'augmented'
diff --git a/packages/uni-template-compiler/__tests__/compiler.spec.js b/packages/uni-template-compiler/__tests__/compiler.spec.js
index d9a5ab343b42dffaeba797283b9817531adbbd96..adcb1981fc186aa299eb2786f257c78d090ad4d4 100644
--- a/packages/uni-template-compiler/__tests__/compiler.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler.spec.js
@@ -182,6 +182,30 @@ describe('mp:compiler', () => {
'',
''
)
+ assertCodegen(
+ '',
+ ''
+ )
+ assertCodegen(
+ '',
+ ''
+ )
+ assertCodegen(
+ '',
+ '',
+ 'with(this){{$setScopedSlotsParams(one,{"test":test})}}',
+ {
+ scopedSlotsCompiler: 'augmented'
+ }
+ )
+ assertCodegen(
+ 'text',
+ 'text'
+ )
+ assertCodegen(
+ 'text',
+ 'text'
+ )
})
// it('generate slot fallback content', () => {
diff --git a/packages/uni-template-compiler/lib/module.js b/packages/uni-template-compiler/lib/module.js
index 9a572f58f77f90ecdac29f9fff98daa8b1a9a995..e26cdce67eeafb478afe1ee6b0a967a73d862b01 100644
--- a/packages/uni-template-compiler/lib/module.js
+++ b/packages/uni-template-compiler/lib/module.js
@@ -15,12 +15,13 @@ module.exports = {
preTransformNode (el, {
warn
}) {
- if (el.tag === 'slot' && !el.attrsMap.name) {
+ const attrsMap = el.attrsMap
+ if (el.tag === 'slot' && !(attrsMap.name || attrsMap[':name'])) {
el.attrsList.push({
name: 'SLOT_DEFAULT',
value: true
})
- el.attrsMap.SLOT_DEFAULT = true
+ attrsMap.SLOT_DEFAULT = true
}
// 处理 attr
el.attrsList.forEach(attr => {
@@ -31,11 +32,11 @@ module.exports = {
const origName = attr.name
const newName = origName.replace('.lazy', '')
attr.name = newName
- el.attrsMap[newName] = attr.value
- delete el.attrsMap[origName]
+ attrsMap[newName] = attr.value
+ delete attrsMap[origName]
} else if (onRE.test(attr.name) && !attr.value.trim()) { // 事件为空
attr.value = '__HOLDER__'
- el.attrsMap[attr.name] = attr.value
+ attrsMap[attr.name] = attr.value
}
})
// 暂不支持的指令
diff --git a/packages/uni-template-compiler/lib/script/traverse/render-slot.js b/packages/uni-template-compiler/lib/script/traverse/render-slot.js
index e7df06c7bbd3dcc3c507c912c4ab6d6e1ec64da6..b0d66e1e2bb7d5028b872323f6d1c5fd0a2a1fa4 100644
--- a/packages/uni-template-compiler/lib/script/traverse/render-slot.js
+++ b/packages/uni-template-compiler/lib/script/traverse/render-slot.js
@@ -32,7 +32,7 @@ module.exports = function getRenderSlot (path, state) {
const scoped = state.scoped
// TODO 判断是否包含作用域内变量
const renderSlotStatementArray = scoped && scoped.length ? scoped[scoped.length - 1].renderSlotStatementArray : state.renderSlotStatementArray
- renderSlotStatementArray.push(t.expressionStatement(t.callExpression(t.identifier('$setScopedSlotsParams'), [t.stringLiteral(name.node.value), valueNode])))
+ renderSlotStatementArray.push(t.expressionStatement(t.callExpression(t.identifier('$setScopedSlotsParams'), [name.node, valueNode])))
}
// TODO 组件嵌套
}
diff --git a/packages/uni-template-compiler/lib/script/traverse/resolve-scoped-slots.js b/packages/uni-template-compiler/lib/script/traverse/resolve-scoped-slots.js
index 77284f67ebb234c3e0bb609279f8b2c2c6e66ab3..8b12d66d058a218a2579e304f336f54528d20618 100644
--- a/packages/uni-template-compiler/lib/script/traverse/resolve-scoped-slots.js
+++ b/packages/uni-template-compiler/lib/script/traverse/resolve-scoped-slots.js
@@ -51,7 +51,12 @@ function replaceId (path, ids) {
}
module.exports = function getResolveScopedSlots (parent, state) {
- const properties = parent.get('arguments.0.elements.0.properties')
+ let objectPath = parent.get('arguments.0.elements.0')
+ // TODO v-else
+ if (objectPath.isConditionalExpression()) {
+ objectPath = objectPath.get('consequent')
+ }
+ const properties = objectPath.get('properties')
const fn = properties.find(path => path.get('key').isIdentifier({ name: 'fn' }))
const params = fn.get('value.params.0')
if (!params) {
@@ -83,7 +88,7 @@ module.exports = function getResolveScopedSlots (parent, state) {
const test = t.callExpression(t.identifier('$hasScopedSlotsParams'), [vueId])
orgin.replaceWith(t.arrayExpression([t.conditionalExpression(test, node, t.callExpression(t.identifier(METHOD_CREATE_EMPTY_VNODE), []))]))
// scopedSlotsCompiler auto
- parent.get('arguments.0.elements.0').node.scopedSlotsCompiler = 'augmented'
+ objectPath.node.scopedSlotsCompiler = 'augmented'
}
}
}
diff --git a/packages/uni-template-compiler/lib/template/traverse.js b/packages/uni-template-compiler/lib/template/traverse.js
index aea5f142a53016e5d64e1ddc0122e72a64d59ba4..25acfbc3559bbb7ea7307f12c1960d263c6c9691 100644
--- a/packages/uni-template-compiler/lib/template/traverse.js
+++ b/packages/uni-template-compiler/lib/template/traverse.js
@@ -270,7 +270,7 @@ function traverseArrayExpression (arrayExprNodes, state) {
}, [])
}
-function genSlotNode (slotName, slotNode, fallbackNodes, state) {
+function genSlotNode (slotName, slotNode, fallbackNodes, state, isStaticSlotName = true) {
if (!fallbackNodes || t.isNullLiteral(fallbackNodes)) {
return slotNode
}
@@ -282,7 +282,7 @@ function genSlotNode (slotName, slotNode, fallbackNodes, state) {
return [{
type: 'block',
attr: {
- [prefix + 'if']: '{{$slots.' + slotName + '}}'
+ [prefix + 'if']: isStaticSlotName ? '{{$slots.' + slotName + '}}' : '{{$slots[' + slotName.replace(/^{{/, '').replace(/}}$/, '') + ']}}'
},
children: [].concat(slotNode)
}, {
@@ -297,12 +297,9 @@ function genSlotNode (slotName, slotNode, fallbackNodes, state) {
}
function traverseRenderSlot (callExprNode, state) {
- if (!t.isStringLiteral(callExprNode.arguments[0])) {
- state.errors.add(uniI18n.__('templateCompiler.notSupportDynamicSlotName', { 0: 'v-slot' }))
- return
- }
-
- const slotName = callExprNode.arguments[0].value
+ const slotNameNode = callExprNode.arguments[0]
+ const isStaticSlotName = t.isStringLiteral(slotNameNode)
+ const slotName = isStaticSlotName ? slotNameNode.value : genCode(slotNameNode)
let deleteSlotName = false // 标记是否组件 slot 手动指定了 name="default"
if (state.options.scopedSlotsCompiler !== 'augmented' && callExprNode.arguments.length > 2) { // 作用域插槽
@@ -312,6 +309,10 @@ function traverseRenderSlot (callExprNode, state) {
})
deleteSlotName = props.SLOT_DEFAULT && Object.keys(props).length === 1
if (!deleteSlotName) {
+ if (!isStaticSlotName) {
+ state.errors.add(uniI18n.__('templateCompiler.notSupportDynamicSlotName', { 0: 'v-slot' }))
+ return
+ }
delete props.SLOT_DEFAULT
return genSlotNode(
slotName,
@@ -334,28 +335,50 @@ function traverseRenderSlot (callExprNode, state) {
delete node.attr.name
}
- return genSlotNode(slotName, node, callExprNode.arguments[1], state)
+ return genSlotNode(slotName, node, callExprNode.arguments[1], state, isStaticSlotName)
}
function traverseResolveScopedSlots (callExprNode, state) {
- function single (children, slotName, ignore) {
- if (Array.isArray(children) && children.length === 1) {
- const child = children[0]
- if (!child.type) {
- return
- }
- if (ignore.includes(child.type)) {
- return single(child.children, slotName, ignore)
+ const options = state.options
+ const vIfAttrName = options.platform.directive + 'if'
+ function single (node, slotName, vIfCode, ignore) {
+ let last = node
+ const vIfs = vIfCode ? [vIfCode] : []
+ function find (children) {
+ if (Array.isArray(children) && children.length === 1) {
+ const child = children[0]
+ if (!child.type) {
+ return
+ }
+ last = child
+ if (child.attr && child.attr[vIfAttrName]) {
+ vIfs.push(child.attr[vIfAttrName])
+ delete child.attr[vIfAttrName]
+ }
+ if (ignore.includes(child.type) && !(child.attr && Object.keys(child.attr).length)) {
+ find(child.children, ignore)
+ }
}
- child.attr = child.attr || {}
- child.attr.slot = slotName
- return true
}
+ find(node.children)
+ last.attr = last.attr || {}
+ last.attr.slot = slotName
+ if (vIfs.length) {
+ // 简易合并
+ last.attr[vIfAttrName] = vIfs.length > 1 ? `{{${vIfs.map(str => str.replace(/^\{\{(.+)\}\}$/, '($1)')).join('&&')}}}` : vIfs[0]
+ }
+ return last
}
return callExprNode.arguments[0].elements.map(slotNode => {
let keyProperty = false
let fnProperty = false
let proxyProperty = false
+ let vIfCode
+ // TODO v-else
+ if (t.isConditionalExpression(slotNode)) {
+ vIfCode = genCode(slotNode.test)
+ slotNode = slotNode.consequent
+ }
slotNode.properties.forEach(property => {
switch (property.key.name) {
case 'key':
@@ -371,14 +394,14 @@ function traverseResolveScopedSlots (callExprNode, state) {
const slotName = keyProperty.value.value
const returnExprNodes = fnProperty.value.body.body[0].argument
const parentNode = callExprNode.$node
- if (slotNode.scopedSlotsCompiler !== 'augmented' && !proxyProperty) {
- const resourcePath = state.options.resourcePath
+ if (options.scopedSlotsCompiler !== 'augmented' && slotNode.scopedSlotsCompiler !== 'augmented' && !proxyProperty) {
+ const resourcePath = options.resourcePath
const ownerName = path.basename(resourcePath, path.extname(resourcePath))
const parentName = parentNode.type
const paramExprNode = fnProperty.value.params[0]
- return state.options.platform.resolveScopedSlots(
+ return options.platform.resolveScopedSlots(
slotName, {
genCode,
generate,
@@ -398,21 +421,14 @@ function traverseResolveScopedSlots (callExprNode, state) {
state
)
}
- if (state.options.scopedSlotsCompiler === 'auto' && slotNode.scopedSlotsCompiler === 'augmented') {
+ if (options.scopedSlotsCompiler === 'auto' && slotNode.scopedSlotsCompiler === 'augmented') {
parentNode.attr['scoped-slots-compiler'] = 'augmented'
}
- const children = normalizeChildren(traverseExpr(returnExprNodes, state))
// 除百度、字节外其他小程序仅默认插槽可以支持多个节点
- if (single(children, slotName, ['template', 'block'])) {
- return children[0]
- }
- return {
+ return single({
type: 'block',
- attr: {
- slot: slotName
- },
- children
- }
+ children: normalizeChildren(traverseExpr(returnExprNodes, state))
+ }, slotName, vIfCode, ['template', 'block'])
})
}
diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js
index 4f6376ffb5606170787d6072888a105237a6713e..7cc5e52ad1129d3821cb2c9afe45fd06be037979 100644
--- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js
+++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js
@@ -285,7 +285,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
process.env.UNI_PLATFORM !== 'mp-alipay' &&
process.env.UNI_PLATFORM !== 'quickapp-webview' // 目前 ov 的开发工具支持 eval 模式
) {
- plugins.push(sourceMap.createSourceMapDevToolPlugin(process.env.UNI_PLATFORM === 'mp-weixin'))
+ plugins.push(sourceMap.createSourceMapDevToolPlugin(process.env.UNI_PLATFORM === 'mp-weixin' || process.env.UNI_PLATFORM === 'mp-toutiao'))
}
}
diff --git a/packages/webpack-uni-mp-loader/lib/plugin/mp-weixin-uniad-app.json.js b/packages/webpack-uni-mp-loader/lib/plugin/mp-weixin-uniad-app.json.js
index 2575951db6ba89c5a01eec002518e939c5196c59..4417a5d1eca1a9f17a58eb467271dfdbcf05da9d 100644
--- a/packages/webpack-uni-mp-loader/lib/plugin/mp-weixin-uniad-app.json.js
+++ b/packages/webpack-uni-mp-loader/lib/plugin/mp-weixin-uniad-app.json.js
@@ -4,13 +4,13 @@ module.exports = function (appJson) {
}
if (!appJson.plugins['uni-ad']) {
appJson.plugins['uni-ad'] = {
- version: '1.0.3',
+ version: '1.1.0',
provider: 'wx999bf02c8e05dfc9'
}
}
if (!appJson.plugins['coral-adv']) {
appJson.plugins['coral-adv'] = {
- version: '1.0.7',
+ version: '1.0.9',
provider: 'wx0e203209e27b1e66'
}
}
diff --git a/src/core/helpers/promise.js b/src/core/helpers/promise.js
index 5b19b839bb5b4ba3d45c4867b56459125f10174b..009204d612fec2240546010e7defe6347f7a455f 100644
--- a/src/core/helpers/promise.js
+++ b/src/core/helpers/promise.js
@@ -8,7 +8,7 @@ import {
} from './interceptor'
const SYNC_API_RE =
- /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo/
+ /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting/
const CONTEXT_API_RE = /^create|Manager$/
diff --git a/src/core/service/plugins/app/index.js b/src/core/service/plugins/app/index.js
index c34ef0502fe7137b5278284756a93f6e27d34a67..c5c3e6e4a2a6069cc51e9a4049a9ff71fccf40cb 100644
--- a/src/core/service/plugins/app/index.js
+++ b/src/core/service/plugins/app/index.js
@@ -10,6 +10,29 @@ export {
}
from './create-app'
+export let createLaunchOptions = function () {
+ const scene = 1001
+ const referrerInfo = {
+ appId: '',
+ extraData: {},
+ }
+ try {
+ return {
+ path: this.$route.meta && this.$route.meta.pagePath,
+ query: this.$route.query,
+ scene,
+ referrerInfo
+ }
+ } catch (error) {
+ return {
+ path: '',
+ query: {},
+ scene,
+ referrerInfo
+ }
+ }
+}
+
export function createAppMixin (Vue, routes, entryRoute) {
return {
created: function AppCreated () {
@@ -31,13 +54,10 @@ export function createAppMixin (Vue, routes, entryRoute) {
},
mounted: function appMounted () {
// 稍微靠后点,让 App 有机会在 mounted 事件前注册一些全局事件监听,如 UI 显示(showModal)
- const args = {
- path: this.$route.meta && this.$route.meta.pagePath,
- query: this.$route.query,
- scene: 1001
- }
+ createLaunchOptions = createLaunchOptions.bind(this)
+ const args = createLaunchOptions()
callAppHook(this, 'onLaunch', args)
callAppHook(this, 'onShow', args)
}
}
-}
+}
diff --git a/src/core/view/components/button/index.vue b/src/core/view/components/button/index.vue
index c94b0c40ce00c9968655165169ec1e2b63847ffd..d1bfbfcc635aeb72c1395e160ebb77f89b5f5675 100644
--- a/src/core/view/components/button/index.vue
+++ b/src/core/view/components/button/index.vue
@@ -130,6 +130,8 @@ export default {
touchstart: this._hoverTouchStart,
touchend: this._hoverTouchEnd,
touchcancel: this._hoverTouchCancel,
+ mousedown: this._hoverMousedown,
+ mouseup: this._hoverMouseup,
click: this._onClick
}
},
@@ -429,4 +431,4 @@ export default {
border-color: rgba(230, 67, 64, 0.6);
background-color: transparent;
}
-
+
diff --git a/src/core/view/components/movable-view/index.vue b/src/core/view/components/movable-view/index.vue
index 71f2d6f39325c410ed5d51540e541e05e710abcf..9ee245adcd67b960246c00878ca93e13ed6f69a1 100644
--- a/src/core/view/components/movable-view/index.vue
+++ b/src/core/view/components/movable-view/index.vue
@@ -185,6 +185,9 @@ export default {
ySync (val) {
this._setY(val)
},
+ disabled () {
+ this.__handleTouchStart()
+ },
scaleValue (val) {
this.scaleValueSync = Number(val) || 0
},
diff --git a/src/core/view/components/navigator/index.vue b/src/core/view/components/navigator/index.vue
index 024e4ab6282bcac345d140b484c3df8267ecaac8..6333c4a8d236ef4569f9b835853f6f4a5e66b6ab 100644
--- a/src/core/view/components/navigator/index.vue
+++ b/src/core/view/components/navigator/index.vue
@@ -5,6 +5,8 @@
@touchstart="_hoverTouchStart"
@touchend="_hoverTouchEnd"
@touchcancel="_hoverTouchCancel"
+ @mousedown="_hoverMousedown"
+ @mouseup="_hoverMouseup"
@click="_onClick"
v-on="$listeners"
>
diff --git a/src/core/view/mixins/hover.js b/src/core/view/mixins/hover.js
index 294c9ea633ad9aa1dcc611c4a8cdf200ad65fa7d..4700fcbb61f53fdda7397bf44782f303f2fe0ac3 100644
--- a/src/core/view/mixins/hover.js
+++ b/src/core/view/mixins/hover.js
@@ -4,6 +4,7 @@ export default {
hovering: false
}
},
+
props: {
hoverClass: {
type: String,
@@ -22,8 +23,25 @@ export default {
default: 400
}
},
+
methods: {
_hoverTouchStart (evt) {
+ if (evt.touches.length > 1) {
+ return
+ }
+ this._handleHoverStart(evt)
+ },
+
+ _hoverMousedown (evt) {
+ if (this._hoverTouch) {
+ return
+ }
+
+ this._handleHoverStart(evt)
+ window.addEventListener('mouseup', this._hoverMouseup)
+ },
+
+ _handleHoverStart (evt) {
// TODO detect scrolling
if (evt._hoverPropagationStopped) {
return
@@ -31,9 +49,6 @@ export default {
if (!this.hoverClass || this.hoverClass === 'none' || this.disabled) {
return
}
- if (evt.touches.length > 1) {
- return
- }
if (this.hoverStopPropagation) {
evt._hoverPropagationStopped = true
}
@@ -45,12 +60,27 @@ export default {
}
}, this.hoverStartTime)
},
- _hoverTouchEnd (evt) {
+
+ _hoverMouseup () {
+ if (!this._hoverTouch) {
+ return
+ }
+
+ this._handleHoverEnd()
+ window.removeEventListener('mouseup', this._hoverMouseup)
+ },
+
+ _hoverTouchEnd () {
+ this._handleHoverEnd()
+ },
+
+ _handleHoverEnd () {
this._hoverTouch = false
if (this.hovering) {
this._hoverReset()
}
},
+
_hoverReset () {
requestAnimationFrame(() => {
clearTimeout(this._hoverStayTimer)
@@ -59,10 +89,11 @@ export default {
}, this.hoverStayTime)
})
},
- _hoverTouchCancel (evt) {
+
+ _hoverTouchCancel () {
this._hoverTouch = false
this.hovering = false
clearTimeout(this._hoverStartTimer)
}
}
-}
+}
diff --git a/src/platforms/app-plus/service/api/plugin/get-provider.js b/src/platforms/app-plus/service/api/plugin/get-provider.js
index 4d15959ebf906450d2548f8911a9bae6325057d9..8c09b7dd1331624882b7fbe391040dd60b6c9ae7 100644
--- a/src/platforms/app-plus/service/api/plugin/get-provider.js
+++ b/src/platforms/app-plus/service/api/plugin/get-provider.js
@@ -1,6 +1,7 @@
import {
invoke
} from '../../bridge'
+import { isFn, isPlainObject } from 'uni-shared'
const providers = {
oauth (callback) {
@@ -11,7 +12,7 @@ const providers = {
}) => {
provider.push(id)
})
- callback(null, provider)
+ callback(null, provider, services)
}, err => {
callback(err)
})
@@ -24,7 +25,7 @@ const providers = {
}) => {
provider.push(id)
})
- callback(null, provider)
+ callback(null, provider, services)
}, err => {
callback(err)
})
@@ -37,14 +38,15 @@ const providers = {
}) => {
provider.push(id)
})
- callback(null, provider)
+ callback(null, provider, services)
}, err => {
callback(err)
})
},
push (callback) {
if (typeof weex !== 'undefined' || typeof plus !== 'undefined') {
- callback(null, [plus.push.getClientInfo().id])
+ const clientInfo = plus.push.getClientInfo()
+ callback(null, [clientInfo.id], [clientInfo])
} else {
callback(null, [])
}
@@ -55,7 +57,7 @@ export function getProvider ({
service
}, callbackId) {
if (providers[service]) {
- providers[service]((err, provider) => {
+ providers[service]((err, provider, providers) => {
if (err) {
invoke(callbackId, {
errMsg: 'getProvider:fail ' + err.message
@@ -64,7 +66,25 @@ export function getProvider ({
invoke(callbackId, {
errMsg: 'getProvider:ok',
service,
- provider
+ provider,
+ providers: providers.map((provider) => {
+ const returnProvider = {}
+ if (isPlainObject(provider)) {
+ for (const key in provider) {
+ if (Object.hasOwnProperty.call(provider, key)) {
+ const item = provider[key]
+ if (!isFn(item) && typeof item !== 'undefined') {
+ const _key =
+ key === 'nativeClient' || key === 'serviceReady'
+ ? 'isAppExist'
+ : key
+ returnProvider[_key] = item
+ }
+ }
+ }
+ }
+ return returnProvider
+ })
})
}
})
diff --git a/src/platforms/app-plus/view/components/map/index.vue b/src/platforms/app-plus/view/components/map/index.vue
index 5985544ba14fb1d5aa9874d29041db46a855a0c1..441b9827a5b3abfa754334ef8a57fbbb3091aaee 100644
--- a/src/platforms/app-plus/view/components/map/index.vue
+++ b/src/platforms/app-plus/view/components/map/index.vue
@@ -320,7 +320,9 @@ export default {
if (id || id === 0) {
nativeMarker.onclick = (e) => {
this.$trigger('markertap', {}, {
- markerId: id
+ markerId: id,
+ latitude,
+ longitude
})
}
if (nativeBubble) {
diff --git a/src/platforms/h5/service/api/plugin/get-launch-options-sync.js b/src/platforms/h5/service/api/plugin/get-launch-options-sync.js
new file mode 100644
index 0000000000000000000000000000000000000000..dba99a1447b3c4aaf1915a7f51d56a1016fc625c
--- /dev/null
+++ b/src/platforms/h5/service/api/plugin/get-launch-options-sync.js
@@ -0,0 +1,10 @@
+import {
+ createLaunchOptions
+} from 'uni-core/service/plugins/app'
+
+export function getLaunchOptionsSync () {
+ return createLaunchOptions()
+}
+export function getEnterOptionsSync () {
+ return createLaunchOptions()
+}
diff --git a/src/platforms/h5/view/components/map/index.vue b/src/platforms/h5/view/components/map/index.vue
index aa34ffebebe42159627fa88862fef74584a66b1b..6cb7368c64850d318cc3d293e64901d28cc2d67a 100644
--- a/src/platforms/h5/view/components/map/index.vue
+++ b/src/platforms/h5/view/components/map/index.vue
@@ -374,10 +374,6 @@ export default {
this.isBoundsReady = true
this.$emit('boundsready')
})
- maps.event.addListener(map, 'click', () => {
- // TODO 编译器将 tap 转换为click
- this.$trigger('click', {}, {})
- })
maps.event.addListener(map, 'dragstart', () => {
this.$trigger('regionchange', {}, {
type: 'begin',
diff --git a/src/platforms/h5/view/components/map/map-marker.js b/src/platforms/h5/view/components/map/map-marker.js
index fa0b5f7a39bacfcf6973c057e2845921b5041391..34eb6e348fc88d9f567cb515d516ecb45a53e111 100644
--- a/src/platforms/h5/view/components/map/map-marker.js
+++ b/src/platforms/h5/view/components/map/map-marker.js
@@ -95,7 +95,7 @@ export default {
})
this.$parent._markers[this.idString] = marker
this.updateMarker(props)
- maps.event.addListener(marker, 'click', () => {
+ maps.event.addListener(marker, 'click', (e) => {
const callout = marker.callout
if (callout) {
const div = callout.div
@@ -110,9 +110,14 @@ export default {
}
if (this.idString) {
this.$parent.$trigger('markertap', {}, {
- markerId: Number(this.idString)
+ markerId: Number(this.idString),
+ latitude: typeof e.latLng.lat === 'function' ? e.latLng.lat() : e.latLng.lat,
+ longitude: typeof e.latLng.lat === 'function' ? e.latLng.lng() : e.latLng.lng
})
}
+
+ const event = e.event || e.domEvent
+ event.stopPropagation()
})
},
updateMarker (option) {
diff --git a/src/platforms/h5/view/components/view/index.vue b/src/platforms/h5/view/components/view/index.vue
index 7302e8e92b2a6c26ba758acf7f9e9124c3d6723e..49b129b3e4faa8a227212763ac545e91412284f1 100755
--- a/src/platforms/h5/view/components/view/index.vue
+++ b/src/platforms/h5/view/components/view/index.vue
@@ -5,13 +5,15 @@
@touchstart="_hoverTouchStart"
@touchend="_hoverTouchEnd"
@touchcancel="_hoverTouchCancel"
+ @mousedown="_hoverMousedown"
+ @mouseup="_hoverMouseup"
v-on="$listeners"
>