Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
99335593
U
uni-app
项目概览
anyefeiyu
/
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,发现更多精彩内容 >>
提交
99335593
编写于
4月 08, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(runtime): triggerEvent
上级
21ed9546
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
212 addition
and
15 deletion
+212
-15
package.json
package.json
+2
-1
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+67
-4
packages/uni-app-plus/package.json
packages/uni-app-plus/package.json
+1
-1
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+67
-4
packages/uni-mp-weixin/package.json
packages/uni-mp-weixin/package.json
+1
-1
src/core/runtime/wrapper/create-app.js
src/core/runtime/wrapper/create-app.js
+5
-2
src/core/runtime/wrapper/util.js
src/core/runtime/wrapper/util.js
+1
-1
src/platforms/app-plus/runtime/index.js
src/platforms/app-plus/runtime/index.js
+1
-0
src/platforms/mp-alipay/runtime/index.js
src/platforms/mp-alipay/runtime/index.js
+0
-0
src/platforms/mp-baidu/runtime/index.js
src/platforms/mp-baidu/runtime/index.js
+0
-0
src/platforms/mp-toutiao/runtime/index.js
src/platforms/mp-toutiao/runtime/index.js
+0
-0
src/platforms/mp-weixin/runtime/index.js
src/platforms/mp-weixin/runtime/index.js
+47
-0
src/shared/util.js
src/shared/util.js
+20
-1
未找到文件。
package.json
浏览文件 @
99335593
...
@@ -59,7 +59,8 @@
...
@@ -59,7 +59,8 @@
"globals"
:
{
"globals"
:
{
"App"
:
true
,
"App"
:
true
,
"Page"
:
true
,
"Page"
:
true
,
"Component"
:
true
,
"Component"
:
true
,
"Behavior"
:
true
,
"getApp"
:
true
,
"getApp"
:
true
,
"getCurrentPages"
:
true
,
"getCurrentPages"
:
true
,
"plus"
:
true
,
"plus"
:
true
,
...
...
packages/uni-app-plus/dist/index.js
浏览文件 @
99335593
...
@@ -19,7 +19,26 @@ function hasOwn (obj, key) {
...
@@ -19,7 +19,26 @@ function hasOwn (obj, key) {
return
hasOwnProperty
.
call
(
obj
,
key
)
return
hasOwnProperty
.
call
(
obj
,
key
)
}
}
function
noop
()
{}
function
noop
()
{}
/**
* Create a cached version of a pure function.
*/
function
cached
(
fn
)
{
const
cache
=
Object
.
create
(
null
);
return
function
cachedFn
(
str
)
{
const
hit
=
cache
[
str
];
return
hit
||
(
cache
[
str
]
=
fn
(
str
))
}
}
/**
* Camelize a hyphen-delimited string.
*/
const
camelizeRE
=
/-
(\w)
/g
;
const
camelize
=
cached
((
str
)
=>
{
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/
;
const
SYNC_API_RE
=
/requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/
;
...
@@ -241,6 +260,49 @@ var api = /*#__PURE__*/Object.freeze({
...
@@ -241,6 +260,49 @@ var api = /*#__PURE__*/Object.freeze({
requireNativePlugin
:
requireNativePlugin
requireNativePlugin
:
requireNativePlugin
});
});
const
WXPage
=
Page
;
const
WXComponent
=
Component
;
const
customizeRE
=
/:/g
;
const
customize
=
cached
((
str
)
=>
{
return
camelize
(
str
.
replace
(
customizeRE
,
'
-
'
))
});
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
triggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
}
Page
=
function
(
options
=
{})
{
const
name
=
'
onLoad
'
;
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
initTriggerEvent
(
this
);
};
}
else
{
options
[
name
]
=
function
(...
args
)
{
initTriggerEvent
(
this
);
return
oldHook
.
apply
(
this
,
args
)
};
}
return
WXPage
(
options
)
};
const
behavior
=
Behavior
({
created
()
{
initTriggerEvent
(
this
);
}
});
Component
=
function
(
options
=
{})
{
(
options
.
behaviors
||
(
options
.
behaviors
=
[])).
unshift
(
behavior
);
return
WXComponent
(
options
)
};
const
MOCKS
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
const
MOCKS
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
function
initMocks
(
vm
)
{
function
initMocks
(
vm
)
{
...
@@ -280,7 +342,7 @@ function getData (vueOptions, context) {
...
@@ -280,7 +342,7 @@ function getData (vueOptions, context) {
}
}
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
if
(
!
hasOwn
(
data
,
methodName
))
{
if
(
context
.
__lifecycle_hooks__
.
indexOf
(
methodName
)
===
-
1
&&
!
hasOwn
(
data
,
methodName
))
{
data
[
methodName
]
=
methods
[
methodName
];
data
[
methodName
]
=
methods
[
methodName
];
}
}
});
});
...
@@ -534,7 +596,8 @@ const hooks = [
...
@@ -534,7 +596,8 @@ const hooks = [
'
onShow
'
,
'
onShow
'
,
'
onHide
'
,
'
onHide
'
,
'
onError
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onUniNViewMessage
'
];
];
function
createApp
(
vm
)
{
function
createApp
(
vm
)
{
...
@@ -564,7 +627,7 @@ function createApp (vm) {
...
@@ -564,7 +627,7 @@ function createApp (vm) {
});
});
const
appOptions
=
{
const
appOptions
=
{
onLaunch
(
args
)
{
onLaunch
(
args
)
{
this
.
$vm
=
vm
;
this
.
$vm
=
vm
;
...
...
packages/uni-app-plus/package.json
浏览文件 @
99335593
{
{
"name"
:
"@dcloudio/uni-app-plus"
,
"name"
:
"@dcloudio/uni-app-plus"
,
"version"
:
"0.0.20
7
"
,
"version"
:
"0.0.20
9
"
,
"description"
:
"uni-app app-plus"
,
"description"
:
"uni-app app-plus"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
99335593
...
@@ -19,7 +19,26 @@ function hasOwn (obj, key) {
...
@@ -19,7 +19,26 @@ function hasOwn (obj, key) {
return
hasOwnProperty
.
call
(
obj
,
key
)
return
hasOwnProperty
.
call
(
obj
,
key
)
}
}
function
noop
()
{}
function
noop
()
{}
/**
* Create a cached version of a pure function.
*/
function
cached
(
fn
)
{
const
cache
=
Object
.
create
(
null
);
return
function
cachedFn
(
str
)
{
const
hit
=
cache
[
str
];
return
hit
||
(
cache
[
str
]
=
fn
(
str
))
}
}
/**
* Camelize a hyphen-delimited string.
*/
const
camelizeRE
=
/-
(\w)
/g
;
const
camelize
=
cached
((
str
)
=>
{
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
const
SYNC_API_RE
=
/requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/
;
const
SYNC_API_RE
=
/requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/
;
...
@@ -268,6 +287,49 @@ var api = /*#__PURE__*/Object.freeze({
...
@@ -268,6 +287,49 @@ var api = /*#__PURE__*/Object.freeze({
});
});
const
WXPage
=
Page
;
const
WXComponent
=
Component
;
const
customizeRE
=
/:/g
;
const
customize
=
cached
((
str
)
=>
{
return
camelize
(
str
.
replace
(
customizeRE
,
'
-
'
))
});
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
;
mpInstance
.
triggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
};
}
Page
=
function
(
options
=
{})
{
const
name
=
'
onLoad
'
;
const
oldHook
=
options
[
name
];
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
initTriggerEvent
(
this
);
};
}
else
{
options
[
name
]
=
function
(...
args
)
{
initTriggerEvent
(
this
);
return
oldHook
.
apply
(
this
,
args
)
};
}
return
WXPage
(
options
)
};
const
behavior
=
Behavior
({
created
()
{
initTriggerEvent
(
this
);
}
});
Component
=
function
(
options
=
{})
{
(
options
.
behaviors
||
(
options
.
behaviors
=
[])).
unshift
(
behavior
);
return
WXComponent
(
options
)
};
const
MOCKS
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
const
MOCKS
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
function
initMocks
(
vm
)
{
function
initMocks
(
vm
)
{
...
@@ -307,7 +369,7 @@ function getData (vueOptions, context) {
...
@@ -307,7 +369,7 @@ function getData (vueOptions, context) {
}
}
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
if
(
!
hasOwn
(
data
,
methodName
))
{
if
(
context
.
__lifecycle_hooks__
.
indexOf
(
methodName
)
===
-
1
&&
!
hasOwn
(
data
,
methodName
))
{
data
[
methodName
]
=
methods
[
methodName
];
data
[
methodName
]
=
methods
[
methodName
];
}
}
});
});
...
@@ -561,7 +623,8 @@ const hooks = [
...
@@ -561,7 +623,8 @@ const hooks = [
'
onShow
'
,
'
onShow
'
,
'
onHide
'
,
'
onHide
'
,
'
onError
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onUniNViewMessage
'
];
];
function
createApp
(
vm
)
{
function
createApp
(
vm
)
{
...
@@ -591,7 +654,7 @@ function createApp (vm) {
...
@@ -591,7 +654,7 @@ function createApp (vm) {
});
});
const
appOptions
=
{
const
appOptions
=
{
onLaunch
(
args
)
{
onLaunch
(
args
)
{
{
{
if
(
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
if
(
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
...
...
packages/uni-mp-weixin/package.json
浏览文件 @
99335593
{
{
"name"
:
"@dcloudio/uni-mp-weixin"
,
"name"
:
"@dcloudio/uni-mp-weixin"
,
"version"
:
"0.0.92
7
"
,
"version"
:
"0.0.92
8
"
,
"description"
:
"uni-app mp-weixin"
,
"description"
:
"uni-app mp-weixin"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
src/core/runtime/wrapper/create-app.js
浏览文件 @
99335593
import
'
uni-platform/runtime/index
'
import
Vue
from
'
vue
'
import
Vue
from
'
vue
'
import
{
import
{
...
@@ -10,7 +12,8 @@ const hooks = [
...
@@ -10,7 +12,8 @@ const hooks = [
'
onShow
'
,
'
onShow
'
,
'
onHide
'
,
'
onHide
'
,
'
onError
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onUniNViewMessage
'
]
]
export
function
createApp
(
vm
)
{
export
function
createApp
(
vm
)
{
...
@@ -40,7 +43,7 @@ export function createApp (vm) {
...
@@ -40,7 +43,7 @@ export function createApp (vm) {
})
})
const
appOptions
=
{
const
appOptions
=
{
onLaunch
(
args
)
{
onLaunch
(
args
)
{
if
(
__PLATFORM__
===
'
mp-weixin
'
)
{
if
(
__PLATFORM__
===
'
mp-weixin
'
)
{
if
(
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
if
(
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
)
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
)
...
...
src/core/runtime/wrapper/util.js
浏览文件 @
99335593
...
@@ -44,7 +44,7 @@ export function getData (vueOptions, context) {
...
@@ -44,7 +44,7 @@ export function getData (vueOptions, context) {
}
}
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
if
(
!
hasOwn
(
data
,
methodName
))
{
if
(
context
.
__lifecycle_hooks__
.
indexOf
(
methodName
)
===
-
1
&&
!
hasOwn
(
data
,
methodName
))
{
data
[
methodName
]
=
methods
[
methodName
]
data
[
methodName
]
=
methods
[
methodName
]
}
}
})
})
...
...
src/platforms/app-plus/runtime/index.js
0 → 100644
浏览文件 @
99335593
import
'
../../mp-weixin/runtime/index
'
src/platforms/mp-alipay/runtime/index.js
0 → 100644
浏览文件 @
99335593
src/platforms/mp-baidu/runtime/index.js
0 → 100644
浏览文件 @
99335593
src/platforms/mp-toutiao/runtime/index.js
0 → 100644
浏览文件 @
99335593
src/platforms/mp-weixin/runtime/index.js
0 → 100644
浏览文件 @
99335593
import
{
cached
,
camelize
}
from
'
uni-shared
'
const
WXPage
=
Page
const
WXComponent
=
Component
const
customizeRE
=
/:/g
const
customize
=
cached
((
str
)
=>
{
return
camelize
(
str
.
replace
(
customizeRE
,
'
-
'
))
})
function
initTriggerEvent
(
mpInstance
)
{
const
oldTriggerEvent
=
mpInstance
.
triggerEvent
mpInstance
.
triggerEvent
=
function
(
event
,
...
args
)
{
return
oldTriggerEvent
.
apply
(
mpInstance
,
[
customize
(
event
),
...
args
])
}
}
Page
=
function
(
options
=
{})
{
const
name
=
'
onLoad
'
const
oldHook
=
options
[
name
]
if
(
!
oldHook
)
{
options
[
name
]
=
function
()
{
initTriggerEvent
(
this
)
}
}
else
{
options
[
name
]
=
function
(...
args
)
{
initTriggerEvent
(
this
)
return
oldHook
.
apply
(
this
,
args
)
}
}
return
WXPage
(
options
)
}
const
behavior
=
Behavior
({
created
()
{
initTriggerEvent
(
this
)
}
})
Component
=
function
(
options
=
{})
{
(
options
.
behaviors
||
(
options
.
behaviors
=
[])).
unshift
(
behavior
)
return
WXComponent
(
options
)
}
src/shared/util.js
浏览文件 @
99335593
...
@@ -27,6 +27,25 @@ export function toRawType (val) {
...
@@ -27,6 +27,25 @@ export function toRawType (val) {
return
_toString
.
call
(
val
).
slice
(
8
,
-
1
)
return
_toString
.
call
(
val
).
slice
(
8
,
-
1
)
}
}
/**
* Create a cached version of a pure function.
*/
export
function
cached
(
fn
)
{
const
cache
=
Object
.
create
(
null
)
return
function
cachedFn
(
str
)
{
const
hit
=
cache
[
str
]
return
hit
||
(
cache
[
str
]
=
fn
(
str
))
}
}
/**
* Camelize a hyphen-delimited string.
*/
const
camelizeRE
=
/-
(\w)
/g
export
const
camelize
=
cached
((
str
)
=>
{
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
})
export
function
setProperties
(
item
,
props
,
propsData
)
{
export
function
setProperties
(
item
,
props
,
propsData
)
{
props
.
forEach
(
function
(
name
)
{
props
.
forEach
(
function
(
name
)
{
if
(
hasOwn
(
propsData
,
name
))
{
if
(
hasOwn
(
propsData
,
name
))
{
...
@@ -49,7 +68,7 @@ export function formatDateTime ({
...
@@ -49,7 +68,7 @@ export function formatDateTime ({
}
else
{
}
else
{
return
date
.
getFullYear
()
+
'
-
'
+
_completeValue
(
date
.
getMonth
()
+
1
)
+
'
-
'
+
_completeValue
(
date
.
getDate
())
return
date
.
getFullYear
()
+
'
-
'
+
_completeValue
(
date
.
getMonth
()
+
1
)
+
'
-
'
+
_completeValue
(
date
.
getDate
())
}
}
}
}
export
function
updateElementStyle
(
element
,
styles
)
{
export
function
updateElementStyle
(
element
,
styles
)
{
for
(
let
attrName
in
styles
)
{
for
(
let
attrName
in
styles
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录