Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
10f51f22
U
uni-app
项目概览
DCloud
/
uni-app
4 个月 前同步成功
通知
731
Star
38707
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
10f51f22
编写于
7月 30, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
13a8971d
d854dc9d
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
475 addition
and
425 deletion
+475
-425
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+8
-6
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+8
-6
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+8
-6
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+8
-6
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+8
-6
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+8
-6
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
...ni-template-compiler/__tests__/compiler-mp-alipay.spec.js
+5
-5
packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
...ni-template-compiler/__tests__/compiler-mp-weixin.spec.js
+12
-0
packages/uni-template-compiler/__tests__/compiler.spec.js
packages/uni-template-compiler/__tests__/compiler.spec.js
+2
-2
packages/uni-template-compiler/lib/script/traverse/data/attrs.js
...s/uni-template-compiler/lib/script/traverse/data/attrs.js
+15
-14
packages/uni-template-compiler/lib/script/traverse/data/event.js
...s/uni-template-compiler/lib/script/traverse/data/event.js
+3
-3
packages/uni-template-compiler/lib/template/generate.js
packages/uni-template-compiler/lib/template/generate.js
+4
-1
packages/uni-template-compiler/lib/template/traverse.js
packages/uni-template-compiler/lib/template/traverse.js
+8
-1
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
...vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
+366
-359
src/platforms/app-plus/service/api/plugin/restore-global.js
src/platforms/app-plus/service/api/plugin/restore-global.js
+4
-2
src/platforms/app-plus/service/bridge.js
src/platforms/app-plus/service/bridge.js
+5
-1
src/platforms/mp-alipay/runtime/wrapper/util.js
src/platforms/mp-alipay/runtime/wrapper/util.js
+3
-1
未找到文件。
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
10f51f22
...
...
@@ -174,12 +174,14 @@ function findHooks(vueOptions, hooks = new Set()) {
hooks
.
add
(
name
);
}
});
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
if
(
__VUE_OPTIONS_API__
)
{
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
}
}
}
return
hooks
;
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
10f51f22
...
...
@@ -165,12 +165,14 @@ function findHooks(vueOptions, hooks = new Set()) {
hooks
.
add
(
name
);
}
});
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
if
(
__VUE_OPTIONS_API__
)
{
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
}
}
}
return
hooks
;
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
10f51f22
...
...
@@ -165,12 +165,14 @@ function findHooks(vueOptions, hooks = new Set()) {
hooks
.
add
(
name
);
}
});
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
if
(
__VUE_OPTIONS_API__
)
{
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
}
}
}
return
hooks
;
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
10f51f22
...
...
@@ -165,12 +165,14 @@ function findHooks(vueOptions, hooks = new Set()) {
hooks
.
add
(
name
);
}
});
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
if
(
__VUE_OPTIONS_API__
)
{
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
}
}
}
return
hooks
;
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
10f51f22
...
...
@@ -165,12 +165,14 @@ function findHooks(vueOptions, hooks = new Set()) {
hooks
.
add
(
name
);
}
});
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
if
(
__VUE_OPTIONS_API__
)
{
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
}
}
}
return
hooks
;
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
10f51f22
...
...
@@ -165,12 +165,14 @@ function findHooks(vueOptions, hooks = new Set()) {
hooks
.
add
(
name
);
}
});
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
if
(
__VUE_OPTIONS_API__
)
{
const
{
extends
:
extendsOptions
,
mixins
}
=
vueOptions
;
if
(
mixins
)
{
mixins
.
forEach
(
mixin
=>
findHooks
(
mixin
,
hooks
));
}
if
(
extendsOptions
)
{
findHooks
(
extendsOptions
,
hooks
);
}
}
}
return
hooks
;
...
...
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
浏览文件 @
10f51f22
...
...
@@ -18,7 +18,7 @@ describe('mp:compiler-mp-alipay', () => {
it
(
'
generate v-for directive
'
,
()
=>
{
assertCodegen
(
'
<view><view v-for="(item,index) in items" :key="index"></view></view>
'
,
'
<view><
block a:for="{{items}}" a:for-item="item" a:for-index="index" a:key="index"><view></view></block
></view>
'
'
<view><
view a:for="{{items}}" a:for-item="item" a:for-index="index" a:key="index"></view
></view>
'
)
})
...
...
@@ -39,11 +39,11 @@ describe('mp:compiler-mp-alipay', () => {
)
assertCodegen
(
'
<component1 v-for="item in items" ref="c3"></component1>
'
,
'
<
block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{
\'
551070e6-1-
\'
+__i0__}}" ref="__r" data-ref-in-for="c3" onVueInit="__l"></component1></block
>
'
'
<
component1 vue-id="{{
\'
551070e6-1-
\'
+__i0__}}" ref="__r" data-ref-in-for="c3" a:for="{{items}}" a:for-item="item" a:for-index="__i0__" onVueInit="__l"></component1
>
'
)
assertCodegen
(
'
<component1 v-for="item in items" :ref="c4"></component1>
'
,
'
<
block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{
\'
551070e6-1-
\'
+__i0__}}" ref="__r" data-ref-in-for="{{c4}}" onVueInit="__l"></component1></block
>
'
'
<
component1 vue-id="{{
\'
551070e6-1-
\'
+__i0__}}" ref="__r" data-ref-in-for="{{c4}}" a:for="{{items}}" a:for-item="item" a:for-index="__i0__" onVueInit="__l"></component1
>
'
)
})
it
(
'
generate default slot
'
,
()
=>
{
...
...
@@ -126,8 +126,8 @@ describe('mp:compiler-mp-alipay', () => {
it
(
'
generate events with v-on directive
'
,
()
=>
{
assertCodegen
(
'
<uni-list-item title="标题文字" note="描述信息" show-extra-icon="true" :extra-icon="{color:
\'
#4cd964
\'
,size:
\'
22
\'
,type:
\'
spinner
\'
}"></uni-list-item>
'
,
'
<uni-list-item vue-id="551070e6-1" title="标题文字" note="描述信息" show-extra-icon="true" extra-icon="{{
$root.a0
}}" onVueInit="__l"></uni-list-item>
'
,
'
with(this){
var a0={color:"#4cd964",size:"22",type:"spinner"};$mp.data=Object.assign({},{$root:{a0:a0}})
}
'
'
<uni-list-item vue-id="551070e6-1" title="标题文字" note="描述信息" show-extra-icon="true" extra-icon="{{
({color:
\'
#4cd964
\'
,size:
\'
22
\'
,type:
\'
spinner
\'
})
}}" onVueInit="__l"></uni-list-item>
'
,
'
with(this){}
'
)
assertCodegen
(
...
...
packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
浏览文件 @
10f51f22
...
...
@@ -120,4 +120,16 @@ describe('mp:compiler-mp-weixin', () => {
'
<view><slot-comp generic:scoped-slots-test="test-slot-comp-test" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[
\'
test
\'
]}}"></slot-comp><slot-comp generic:scoped-slots-test="test-slot-comp-test1" vue-id="551070e6-2" bind:__l="__l" vue-slots="{{[
\'
test
\'
]}}"></slot-comp><slot-comp generic:scoped-slots-test="test-slot-comp-test2" vue-id="551070e6-3" bind:__l="__l" vue-slots="{{[
\'
test
\'
]}}"></slot-comp><slot-comp generic:scoped-slots-test="test-slot-comp-test3" vue-id="551070e6-4" bind:__l="__l" vue-slots="{{[
\'
test
\'
]}}"></slot-comp></view>
'
)
})
it
(
'
generate ObjectExpression
'
,
()
=>
{
assertCodegen
(
'
<view v-for="(item,key) in {x:0}" :key="key">{{item}}</view>
'
,
'
<block wx:for="{{({x:0})}}" wx:for-item="item" wx:for-index="key" wx:key="key"><view>{{item}}</view></block>
'
)
assertCodegen
(
'
<template v-for="(item, key) in { list1, list2 }"></template>
'
,
'
<block wx:for="{{({list1,list2})}}" wx:for-item="item" wx:for-index="key"></block>
'
)
assertCodegen
(
'
<test :obj="{x:0}"></test>
'
,
'
<test vue-id="551070e6-1" obj="{{({x:0})}}" bind:__l="__l"></test>
'
)
})
})
packages/uni-template-compiler/__tests__/compiler.spec.js
浏览文件 @
10f51f22
...
...
@@ -329,8 +329,8 @@ describe('mp:compiler', () => {
// v-for
assertCodegen
(
'
<view v-for="(item,index) in list" :key="index"><view @click="$test.test(item)">test</view></view>
'
,
'
<block wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><view data-event-opts="{{[[
\'
tap
\'
,[[
\'
e0
\'
,[
\'
$event
\'
]]]]]}}" data-event-params="{{
[{item}]
}}" bindtap="__e">test</view></view></block>
'
,
'
with(this){if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=
(_temp.eventParams||_temp["event-params"])[0
],item=_temp2.item;var _temp,_temp2;return $test.test(item)}}}
'
'
<block wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><view data-event-opts="{{[[
\'
tap
\'
,[[
\'
e0
\'
,[
\'
$event
\'
]]]]]}}" data-event-params="{{
({item})
}}" bindtap="__e">test</view></view></block>
'
,
'
with(this){if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=
_temp.eventParams||_temp["event-params"
],item=_temp2.item;var _temp,_temp2;return $test.test(item)}}}
'
)
// tricky symbols in args
// assertCodegen(
...
...
packages/uni-template-compiler/lib/script/traverse/data/attrs.js
浏览文件 @
10f51f22
const
{
IDENTIFIER_ATTR
}
=
require
(
'
../../../constants
'
)
//
const {
//
IDENTIFIER_ATTR
//
} = require('../../../constants')
const
getMemberExpr
=
require
(
'
../member-expr
'
)
//
const getMemberExpr = require('../member-expr')
module
.
exports
=
function
processAttrs
(
paths
,
path
,
state
,
isComponent
,
tagName
)
{
const
attrsPath
=
paths
.
attrs
if
(
attrsPath
)
{
attrsPath
.
get
(
'
value.properties
'
).
forEach
(
propertyPath
=>
{
const
valuePath
=
propertyPath
.
get
(
'
value
'
)
if
(
valuePath
.
isObjectExpression
())
{
valuePath
.
replaceWith
(
getMemberExpr
(
null
,
IDENTIFIER_ATTR
,
valuePath
.
node
,
state
))
}
})
}
// 不再单独处理ObjectExpression,改为在转换temlplte时用()包裹(微信、QQ)
// const attrsPath = paths.attrs
// if (attrsPath) {
// attrsPath.get('value.properties').forEach(propertyPath => {
// const valuePath = propertyPath.get('value')
// if (valuePath.isObjectExpression()) {
// valuePath.replaceWith(getMemberExpr(null, IDENTIFIER_ATTR, valuePath.node, state))
// }
// })
// }
return
[]
}
}
packages/uni-template-compiler/lib/script/traverse/data/event.js
浏览文件 @
10f51f22
...
...
@@ -347,7 +347,7 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false,
const
datasetUid
=
funcPath
.
scope
.
generateDeclaredUidIdentifier
().
name
const
paramsUid
=
funcPath
.
scope
.
generateDeclaredUidIdentifier
().
name
const
dataset
=
ATTR_DATA_EVENT_PARAMS
.
substring
(
5
)
const
code
=
`var
${
datasetUid
}
=arguments[arguments.length-1].currentTarget.dataset,
${
paramsUid
}
=
(
${
datasetUid
}
.
${
dataset
.
replace
(
/-
([
a-z
])
/
,
(
_
,
str
)
=>
str
.
toUpperCase
())}
||
${
datasetUid
}
['
${
dataset
}
'])[0
],
${
params
.
map
(
item
=>
`
${
item
}
=
${
paramsUid
}
.
${
item
}
`
).
join
(
'
,
'
)}
`
const
code
=
`var
${
datasetUid
}
=arguments[arguments.length-1].currentTarget.dataset,
${
paramsUid
}
=
${
datasetUid
}
.
${
dataset
.
replace
(
/-
([
a-z
])
/
,
(
_
,
str
)
=>
str
.
toUpperCase
())}
||
${
datasetUid
}
['
${
dataset
}
'
],
${
params
.
map
(
item
=>
`
${
item
}
=
${
paramsUid
}
.
${
item
}
`
).
join
(
'
,
'
)}
`
funcPath
.
node
.
body
.
body
.
unshift
(
parser
.
parse
(
code
).
program
.
body
[
0
])
}
methods
.
push
(
addEventExpressionStatement
(
funcPath
,
state
,
isComponent
,
isNativeOn
))
...
...
@@ -478,8 +478,8 @@ module.exports = function processEvent (paths, path, state, isComponent, tagName
ret
.
push
(
t
.
objectProperty
(
t
.
stringLiteral
(
ATTR_DATA_EVENT_PARAMS
),
//
使用数组格式,
直接使用对象格式微信小程序编译会报错
t
.
stringLiteral
(
`{{
[{
${
params
.
join
(
'
,
'
)}
}]
}}`
)
// 直接使用对象格式微信小程序编译会报错
t
.
stringLiteral
(
`{{
({
${
params
.
join
(
'
,
'
)}
})
}}`
)
)
)
}
...
...
packages/uni-template-compiler/lib/template/generate.js
浏览文件 @
10f51f22
...
...
@@ -105,7 +105,10 @@ function genElement (ast, state, isRoot = false) {
if
(
ast
.
attr
[
name
]
===
''
&&
name
!==
'
value
'
)
{
// value属性需要保留=''
return
name
}
return
`
${
name
}
="
${
ast
.
attr
[
name
]}
"`
let
value
=
ast
.
attr
[
name
]
// 微信和QQ小程序解析 {{{}}} 报错,需要使用()包裹
value
=
value
.
replace
(
/
(\{\{)(\{
.+
?\})(\}\})
/
,
'
$1($2)$3
'
)
return
`
${
name
}
="
${
value
}
"`
})
.
join
(
'
'
)
:
''
...
...
packages/uni-template-compiler/lib/template/traverse.js
浏览文件 @
10f51f22
...
...
@@ -399,10 +399,17 @@ function traverseRenderList (callExprNode, state) {
}
}
const
children
=
traverseExpr
(
forReturnStatementArgument
,
state
)
// 支付宝小程序在 block 标签上使用 key 时顺序不能保障
if
(
state
.
options
.
platform
.
name
===
'
mp-alipay
'
&&
t
.
isCallExpression
(
forReturnStatementArgument
)
&&
children
&&
children
.
type
)
{
children
.
attr
=
children
.
attr
||
{}
Object
.
assign
(
children
.
attr
,
attr
)
return
children
}
return
{
type
:
'
block
'
,
attr
,
children
:
normalizeChildren
(
traverseExpr
(
forReturnStatementArgument
,
state
)
)
children
:
normalizeChildren
(
children
)
}
}
...
...
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
浏览文件 @
10f51f22
此差异已折叠。
点击以展开。
src/platforms/app-plus/service/api/plugin/restore-global.js
浏览文件 @
10f51f22
import
{
newSetStatusBarStyle
newSetStatusBarStyle
,
restoreOldSetStatusBarStyle
}
from
'
../../bridge
'
export
function
restoreGlobal
(
...
...
@@ -19,7 +20,8 @@ export function restoreGlobal (
console
.
log
(
`[restoreGlobal][
${
Date
.
now
()}
]`
)
}
weex
=
newWeex
plus
=
newPlus
plus
=
newPlus
restoreOldSetStatusBarStyle
(
plus
.
navigator
.
setStatusBarStyle
)
plus
.
navigator
.
setStatusBarStyle
=
newSetStatusBarStyle
/* eslint-disable no-global-assign */
setTimeout
=
newSetTimeout
...
...
src/platforms/app-plus/service/bridge.js
浏览文件 @
10f51f22
...
...
@@ -23,7 +23,11 @@ export function publish (name, ...args) {
export
let
lastStatusBarStyle
const
oldSetStatusBarStyle
=
plus
.
navigator
.
setStatusBarStyle
let
oldSetStatusBarStyle
=
plus
.
navigator
.
setStatusBarStyle
export
function
restoreOldSetStatusBarStyle
(
setStatusBarStyle
)
{
oldSetStatusBarStyle
=
setStatusBarStyle
}
export
function
newSetStatusBarStyle
(
style
)
{
lastStatusBarStyle
=
style
...
...
src/platforms/mp-alipay/runtime/wrapper/util.js
浏览文件 @
10f51f22
...
...
@@ -128,10 +128,12 @@ export function triggerEvent (type, detail, options) {
}
const
eventOpts
=
this
.
props
[
'
data-event-opts
'
]
const
eventParams
=
this
.
props
[
'
data-event-params
'
]
const
target
=
{
dataset
:
{
eventOpts
eventOpts
,
eventParams
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录