Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
fad6292a
U
uni-app
项目概览
wzj-java
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fad6292a
编写于
11月 18, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): support multiple arguments
上级
c54d85e1
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
79 addition
and
27 deletion
+79
-27
packages/uni-api/src/helpers/api/promise.ts
packages/uni-api/src/helpers/api/promise.ts
+8
-3
packages/uni-api/src/helpers/interceptor.ts
packages/uni-api/src/helpers/interceptor.ts
+1
-1
packages/uni-cli-shared/src/mp/template.ts
packages/uni-cli-shared/src/mp/template.ts
+1
-1
packages/uni-mp-compiler/src/template/codegen.ts
packages/uni-mp-compiler/src/template/codegen.ts
+14
-10
packages/uni-mp-core/src/api/promise.ts
packages/uni-mp-core/src/api/promise.ts
+7
-3
packages/uni-mp-kuaishou/dist/uni.compiler.js
packages/uni-mp-kuaishou/dist/uni.compiler.js
+1
-1
packages/uni-mp-kuaishou/src/compiler/options.ts
packages/uni-mp-kuaishou/src/compiler/options.ts
+1
-1
packages/uni-mp-weixin/__tests__/component.spec.ts
packages/uni-mp-weixin/__tests__/component.spec.ts
+38
-1
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+4
-4
packages/uni-mp-weixin/dist/uni.compiler.js
packages/uni-mp-weixin/dist/uni.compiler.js
+2
-1
packages/uni-mp-weixin/src/compiler/options.ts
packages/uni-mp-weixin/src/compiler/options.ts
+2
-1
未找到文件。
packages/uni-api/src/helpers/api/promise.ts
浏览文件 @
fad6292a
...
...
@@ -27,15 +27,20 @@ export function handlePromise(promise: Promise<unknown>) {
}
export
function
promisify
(
name
:
string
,
fn
:
Function
)
{
return
(
args
=
{})
=>
{
return
(
args
=
{}
,
...
rest
:
unknown
[]
)
=>
{
if
(
hasCallback
(
args
))
{
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
fn
,
args
))
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
fn
,
args
,
rest
))
}
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
invokeApi
(
name
,
fn
,
extend
(
args
,
{
success
:
resolve
,
fail
:
reject
}))
invokeApi
(
name
,
fn
,
extend
(
args
,
{
success
:
resolve
,
fail
:
reject
}),
rest
)
})
)
)
...
...
packages/uni-api/src/helpers/interceptor.ts
浏览文件 @
fad6292a
...
...
@@ -115,7 +115,7 @@ export function invokeApi(
method
:
string
,
api
:
Function
,
options
:
object
,
...
params
:
[]
params
:
unknown
[]
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
)
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
...
...
packages/uni-cli-shared/src/mp/template.ts
浏览文件 @
fad6292a
...
...
@@ -8,7 +8,7 @@ export interface MiniProgramCompilerOptions {
* 需要延迟渲染的组件,通常是某个组件的某个事件会立刻触发,需要延迟到首次 render 之后,比如微信 editor 的 ready 事件,快手 switch 的 change
*/
lazyElement
?:
{
[
name
:
string
]:
string
[]
[
name
:
string
]:
{
name
:
'
on
'
|
'
bind
'
;
arg
:
string
[]
}
[]
}
event
?:
{
format
(
...
...
packages/uni-mp-compiler/src/template/codegen.ts
浏览文件 @
fad6292a
...
...
@@ -213,16 +213,20 @@ function isLazyElement(node: ElementNode, context: TemplateCodegenContext) {
if
(
!
context
.
lazyElement
)
{
return
false
}
const
events
=
context
.
lazyElement
[
node
.
tag
]
return
(
events
&&
node
.
props
.
some
(
const
lazyProps
=
context
.
lazyElement
[
node
.
tag
]
if
(
!
lazyProps
)
{
return
}
return
node
.
props
.
some
(
(
prop
)
=>
prop
.
type
===
NodeTypes
.
DIRECTIVE
&&
prop
.
name
===
'
on
'
&&
lazyProps
.
find
((
lazyProp
)
=>
{
return
(
prop
.
name
===
lazyProp
.
name
&&
prop
.
arg
?.
type
===
NodeTypes
.
SIMPLE_EXPRESSION
&&
events
.
includes
(
prop
.
arg
.
content
)
lazyProp
.
arg
.
includes
(
prop
.
arg
.
content
)
)
})
)
}
/**
...
...
packages/uni-mp-core/src/api/promise.ts
浏览文件 @
fad6292a
...
...
@@ -66,13 +66,16 @@ export function promisify(name: string, api: unknown) {
if
(
!
isFunction
(
api
))
{
return
api
}
return
function
promiseApi
(
options
:
Record
<
string
,
any
>
=
{})
{
return
function
promiseApi
(
options
:
Record
<
string
,
any
>
=
{},
...
rest
:
unknown
[]
)
{
if
(
isFunction
(
options
.
success
)
||
isFunction
(
options
.
fail
)
||
isFunction
(
options
.
complete
)
)
{
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
))
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
rest
))
}
return
wrapperReturnValue
(
name
,
...
...
@@ -84,7 +87,8 @@ export function promisify(name: string, api: unknown) {
extend
({},
options
,
{
success
:
resolve
,
fail
:
reject
,
})
}),
rest
)
})
)
...
...
packages/uni-mp-kuaishou/dist/uni.compiler.js
浏览文件 @
fad6292a
...
...
@@ -147,7 +147,7 @@ const miniProgram = {
},
directive
:
'
ks:
'
,
lazyElement
:
{
switch
:
[
'
change
'
],
switch
:
[
{
name
:
'
on
'
,
arg
:
[
'
change
'
]
}
],
},
};
const
projectConfigFilename
=
'
project.config.json
'
;
...
...
packages/uni-mp-kuaishou/src/compiler/options.ts
浏览文件 @
fad6292a
...
...
@@ -32,7 +32,7 @@ export const miniProgram: MiniProgramCompilerOptions = {
},
directive
:
'
ks:
'
,
lazyElement
:
{
switch
:
[
'
change
'
],
switch
:
[
{
name
:
'
on
'
,
arg
:
[
'
change
'
]
}
],
},
}
const
projectConfigFilename
=
'
project.config.json
'
...
...
packages/uni-mp-weixin/__tests__/component.spec.ts
浏览文件 @
fad6292a
...
...
@@ -11,7 +11,7 @@ describe('mp-weixin: transform component', () => {
}`
)
})
test
(
'
lazy element
'
,
()
=>
{
test
(
'
lazy element
: editor
'
,
()
=>
{
assert
(
`<editor/>`
,
`<editor/>`
,
...
...
@@ -24,6 +24,43 @@ describe('mp-weixin: transform component', () => {
`<block wx:if="{{r0}}"><editor bindready="{{a}}"/></block>`
,
`(_ctx, _cache) => {
return { a: _o(_ctx.ready) }
}`
)
})
test
(
'
lazy element: canvas
'
,
()
=>
{
assert
(
`<canvas/>`
,
`<canvas/>`
,
`(_ctx, _cache) => {
return {}
}`
)
assert
(
`<canvas canvas-id="myCanvas" id="myCanvas"/>`
,
`<canvas canvas-id="myCanvas" id="myCanvas"/>`
,
`(_ctx, _cache) => {
return {}
}`
)
assert
(
`<canvas :id="id"/>`
,
`<block wx:if="{{r0}}"><canvas id="{{a}}"/></block>`
,
`(_ctx, _cache) => {
return { a: _ctx.id }
}`
)
assert
(
`<canvas :canvas-id="id"/>`
,
`<block wx:if="{{r0}}"><canvas canvas-id="{{a}}"/></block>`
,
`(_ctx, _cache) => {
return { a: _ctx.id }
}`
)
assert
(
`<canvas :canvas-id="id" :id="id"/>`
,
`<block wx:if="{{r0}}"><canvas canvas-id="{{a}}" id="{{b}}"/></block>`
,
`(_ctx, _cache) => {
return { a: _ctx.id, b: _ctx.id }
}`
)
})
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
fad6292a
...
...
@@ -236,7 +236,7 @@ function getApiInterceptorHooks(method) {
}
return
interceptor
;
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
function
invokeApi
(
method
,
api
,
options
,
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
isArray
(
interceptor
.
invoke
))
{
...
...
@@ -586,17 +586,17 @@ function promisify(name, api) {
if
(
!
isFunction
(
api
))
{
return
api
;
}
return
function
promiseApi
(
options
=
{})
{
return
function
promiseApi
(
options
=
{}
,
...
rest
)
{
if
(
isFunction
(
options
.
success
)
||
isFunction
(
options
.
fail
)
||
isFunction
(
options
.
complete
))
{
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
));
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
rest
));
}
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
invokeApi
(
name
,
api
,
extend
({},
options
,
{
success
:
resolve
,
fail
:
reject
,
}));
})
,
rest
);
})));
};
}
...
...
packages/uni-mp-weixin/dist/uni.compiler.js
浏览文件 @
fad6292a
...
...
@@ -72,7 +72,8 @@ const miniProgram = {
},
directive
:
'
wx:
'
,
lazyElement
:
{
editor
:
[
'
ready
'
],
canvas
:
[{
name
:
'
bind
'
,
arg
:
[
'
canvas-id
'
,
'
id
'
]
}],
editor
:
[{
name
:
'
on
'
,
arg
:
[
'
ready
'
]
}],
},
};
const
projectConfigFilename
=
'
project.config.json
'
;
...
...
packages/uni-mp-weixin/src/compiler/options.ts
浏览文件 @
fad6292a
...
...
@@ -25,7 +25,8 @@ export const miniProgram: MiniProgramCompilerOptions = {
},
directive
:
'
wx:
'
,
lazyElement
:
{
editor
:
[
'
ready
'
],
canvas
:
[{
name
:
'
bind
'
,
arg
:
[
'
canvas-id
'
,
'
id
'
]
}],
editor
:
[{
name
:
'
on
'
,
arg
:
[
'
ready
'
]
}],
},
}
const
projectConfigFilename
=
'
project.config.json
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录