Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tomleePHP
uni-app
提交
e5285d29
U
uni-app
项目概览
tomleePHP
/
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,发现更多精彩内容 >>
提交
e5285d29
编写于
5月 23, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(runtime): add uni.$on,uni.$once,uni.$off,uni.$emit
上级
f482d453
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
181 addition
and
36 deletion
+181
-36
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+34
-5
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+28
-5
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+28
-5
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+28
-5
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+28
-5
src/core/helpers/promise.js
src/core/helpers/promise.js
+1
-1
src/core/runtime/event.js
src/core/runtime/event.js
+1
-0
src/core/runtime/index.js
src/core/runtime/index.js
+25
-10
src/core/service/api/event.js
src/core/service/api/event.js
+8
-0
未找到文件。
packages/uni-app-plus/dist/index.js
浏览文件 @
e5285d29
...
...
@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/
^
\$
|
getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -256,6 +256,22 @@ TODOS.forEach(function (name) {
todoApis
[
name
]
=
createTodoApi
(
name
);
});
const
Emitter
=
new
Vue
();
const
$on
=
Emitter
.
$on
.
bind
(
Emitter
);
const
$off
=
Emitter
.
$off
.
bind
(
Emitter
);
const
$once
=
Emitter
.
$once
.
bind
(
Emitter
);
const
$emit
=
Emitter
.
$emit
.
bind
(
Emitter
);
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
function
wrapper$1
(
webview
)
{
webview
.
$processed
=
true
;
...
...
@@ -1142,6 +1158,9 @@ if (typeof Proxy !== 'undefined') {
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
}
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
wx
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
...
...
@@ -1151,6 +1170,10 @@ if (typeof Proxy !== 'undefined') {
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
];
});
Object
.
keys
(
api
).
forEach
(
name
=>
{
uni
[
name
]
=
promisify
(
name
,
api
[
name
]);
});
...
...
@@ -1161,10 +1184,16 @@ if (typeof Proxy !== 'undefined') {
}
});
}
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
{
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
UniEmitter
=
eventApi
;
}
}
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
var
uni$1
=
uni
;
...
...
packages/uni-mp-alipay/dist/index.js
浏览文件 @
e5285d29
...
...
@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/
^
\$
|
getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -656,6 +656,22 @@ var extraApi = /*#__PURE__*/Object.freeze({
getProvider
:
getProvider
});
const
Emitter
=
new
Vue
();
const
$on
=
Emitter
.
$on
.
bind
(
Emitter
);
const
$off
=
Emitter
.
$off
.
bind
(
Emitter
);
const
$once
=
Emitter
.
$once
.
bind
(
Emitter
);
const
$emit
=
Emitter
.
$emit
.
bind
(
Emitter
);
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
function
setStorageSync
(
key
,
data
)
{
return
my
.
setStorageSync
({
key
,
...
...
@@ -1667,6 +1683,9 @@ if (typeof Proxy !== 'undefined') {
return
promisify
(
name
,
todoApis
[
name
])
}
}
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
my
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
...
...
@@ -1685,6 +1704,10 @@ if (typeof Proxy !== 'undefined') {
});
}
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
];
});
Object
.
keys
(
api
).
forEach
(
name
=>
{
uni
[
name
]
=
promisify
(
name
,
api
[
name
]);
});
...
...
@@ -1695,10 +1718,10 @@ if (typeof Proxy !== 'undefined') {
}
});
}
my
.
createApp
=
createApp
;
my
.
createPage
=
createPage
;
my
.
createComponent
=
createComponent
;
my
.
createApp
=
createApp
;
my
.
createPage
=
createPage
;
my
.
createComponent
=
createComponent
;
var
uni$1
=
uni
;
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
e5285d29
...
...
@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/
^
\$
|
getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -413,6 +413,22 @@ var extraApi = /*#__PURE__*/Object.freeze({
getProvider
:
getProvider
});
const
Emitter
=
new
Vue
();
const
$on
=
Emitter
.
$on
.
bind
(
Emitter
);
const
$off
=
Emitter
.
$off
.
bind
(
Emitter
);
const
$once
=
Emitter
.
$once
.
bind
(
Emitter
);
const
$emit
=
Emitter
.
$emit
.
bind
(
Emitter
);
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
function
requestPayment
(
params
)
{
let
parseError
=
false
;
if
(
typeof
params
.
orderInfo
===
'
string
'
)
{
...
...
@@ -1286,6 +1302,9 @@ if (typeof Proxy !== 'undefined') {
return
promisify
(
name
,
todoApis
[
name
])
}
}
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
swan
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
...
...
@@ -1304,6 +1323,10 @@ if (typeof Proxy !== 'undefined') {
});
}
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
];
});
Object
.
keys
(
api
).
forEach
(
name
=>
{
uni
[
name
]
=
promisify
(
name
,
api
[
name
]);
});
...
...
@@ -1314,10 +1337,10 @@ if (typeof Proxy !== 'undefined') {
}
});
}
swan
.
createApp
=
createApp
;
swan
.
createPage
=
createPage
;
swan
.
createComponent
=
createComponent
;
swan
.
createApp
=
createApp
;
swan
.
createPage
=
createPage
;
swan
.
createComponent
=
createComponent
;
var
uni$1
=
uni
;
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
e5285d29
...
...
@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/
^
\$
|
getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -474,6 +474,22 @@ var extraApi = /*#__PURE__*/Object.freeze({
getProvider
:
getProvider
});
const
Emitter
=
new
Vue
();
const
$on
=
Emitter
.
$on
.
bind
(
Emitter
);
const
$off
=
Emitter
.
$off
.
bind
(
Emitter
);
const
$once
=
Emitter
.
$once
.
bind
(
Emitter
);
const
$emit
=
Emitter
.
$emit
.
bind
(
Emitter
);
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
var
api
=
/*#__PURE__*/
Object
.
freeze
({
...
...
@@ -1361,6 +1377,9 @@ if (typeof Proxy !== 'undefined') {
return
promisify
(
name
,
todoApis
[
name
])
}
}
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
tt
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
...
...
@@ -1379,6 +1398,10 @@ if (typeof Proxy !== 'undefined') {
});
}
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
];
});
Object
.
keys
(
api
).
forEach
(
name
=>
{
uni
[
name
]
=
promisify
(
name
,
api
[
name
]);
});
...
...
@@ -1389,10 +1412,10 @@ if (typeof Proxy !== 'undefined') {
}
});
}
tt
.
createApp
=
createApp
;
tt
.
createPage
=
createPage
;
tt
.
createComponent
=
createComponent
;
tt
.
createApp
=
createApp
;
tt
.
createPage
=
createPage
;
tt
.
createComponent
=
createComponent
;
var
uni$1
=
uni
;
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
e5285d29
...
...
@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
SYNC_API_RE
=
/
^
\$
|
getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -326,6 +326,22 @@ var extraApi = /*#__PURE__*/Object.freeze({
getProvider
:
getProvider
});
const
Emitter
=
new
Vue
();
const
$on
=
Emitter
.
$on
.
bind
(
Emitter
);
const
$off
=
Emitter
.
$off
.
bind
(
Emitter
);
const
$once
=
Emitter
.
$once
.
bind
(
Emitter
);
const
$emit
=
Emitter
.
$emit
.
bind
(
Emitter
);
var
eventApi
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on
,
$off
:
$off
,
$once
:
$once
,
$emit
:
$emit
});
var
api
=
/*#__PURE__*/
Object
.
freeze
({
...
...
@@ -1121,6 +1137,9 @@ if (typeof Proxy !== 'undefined') {
return
promisify
(
name
,
todoApis
[
name
])
}
}
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
wx
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
...
...
@@ -1139,6 +1158,10 @@ if (typeof Proxy !== 'undefined') {
});
}
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
];
});
Object
.
keys
(
api
).
forEach
(
name
=>
{
uni
[
name
]
=
promisify
(
name
,
api
[
name
]);
});
...
...
@@ -1149,10 +1172,10 @@ if (typeof Proxy !== 'undefined') {
}
});
}
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
var
uni$1
=
uni
;
...
...
src/core/helpers/promise.js
浏览文件 @
e5285d29
...
...
@@ -2,7 +2,7 @@ import {
isFn
}
from
'
uni-shared
'
const
SYNC_API_RE
=
/getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
const
SYNC_API_RE
=
/
^
\$
|
getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
const
CONTEXT_API_RE
=
/^create|Manager$/
...
...
src/core/runtime/event.js
0 → 100644
浏览文件 @
e5285d29
export
*
from
'
../service/api/event
'
src/core/runtime/index.js
浏览文件 @
e5285d29
...
...
@@ -16,6 +16,8 @@ import todoApi from './todo'
import
*
as
extraApi
from
'
./extra
'
import
*
as
eventApi
from
'
./event
'
import
*
as
api
from
'
uni-platform/service/api/index.js
'
import
{
...
...
@@ -59,6 +61,9 @@ if (typeof Proxy !== 'undefined') {
return
promisify
(
name
,
todoApi
[
name
])
}
}
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
__GLOBAL__
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
...
...
@@ -77,6 +82,10 @@ if (typeof Proxy !== 'undefined') {
})
}
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
]
})
Object
.
keys
(
api
).
forEach
(
name
=>
{
uni
[
name
]
=
promisify
(
name
,
api
[
name
])
})
...
...
@@ -87,15 +96,21 @@ if (typeof Proxy !== 'undefined') {
}
})
}
__GLOBAL__
.
createApp
=
createApp
__GLOBAL__
.
createPage
=
createPage
__GLOBAL__
.
createComponent
=
createComponent
export
{
createApp
,
createPage
,
createComponent
}
if
(
__PLATFORM__
===
'
app-plus
'
)
{
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
UniEmitter
=
eventApi
}
}
__GLOBAL__
.
createApp
=
createApp
__GLOBAL__
.
createPage
=
createPage
__GLOBAL__
.
createComponent
=
createComponent
export
{
createApp
,
createPage
,
createComponent
}
export
default
uni
src/core/service/api/event.js
0 → 100644
浏览文件 @
e5285d29
import
Vue
from
'
vue
'
const
Emitter
=
new
Vue
()
export
const
$on
=
Emitter
.
$on
.
bind
(
Emitter
)
export
const
$off
=
Emitter
.
$off
.
bind
(
Emitter
)
export
const
$once
=
Emitter
.
$once
.
bind
(
Emitter
)
export
const
$emit
=
Emitter
.
$emit
.
bind
(
Emitter
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录