Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
99335593
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
718
Star
38705
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看板
体验新版 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
...
...
@@ -60,6 +60,7 @@
"App"
:
true
,
"Page"
:
true
,
"Component"
:
true
,
"Behavior"
:
true
,
"getApp"
:
true
,
"getCurrentPages"
:
true
,
"plus"
:
true
,
...
...
packages/uni-app-plus/dist/index.js
浏览文件 @
99335593
...
...
@@ -21,6 +21,25 @@ function hasOwn (obj, key) {
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
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -241,6 +260,49 @@ var api = /*#__PURE__*/Object.freeze({
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__
'
];
function
initMocks
(
vm
)
{
...
...
@@ -280,7 +342,7 @@ function getData (vueOptions, context) {
}
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
if
(
!
hasOwn
(
data
,
methodName
))
{
if
(
context
.
__lifecycle_hooks__
.
indexOf
(
methodName
)
===
-
1
&&
!
hasOwn
(
data
,
methodName
))
{
data
[
methodName
]
=
methods
[
methodName
];
}
});
...
...
@@ -534,7 +596,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onUniNViewMessage
'
];
function
createApp
(
vm
)
{
...
...
packages/uni-app-plus/package.json
浏览文件 @
99335593
{
"name"
:
"@dcloudio/uni-app-plus"
,
"version"
:
"0.0.20
7
"
,
"version"
:
"0.0.20
9
"
,
"description"
:
"uni-app app-plus"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
99335593
...
...
@@ -21,6 +21,25 @@ function hasOwn (obj, key) {
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
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -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__
'
];
function
initMocks
(
vm
)
{
...
...
@@ -307,7 +369,7 @@ function getData (vueOptions, context) {
}
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
if
(
!
hasOwn
(
data
,
methodName
))
{
if
(
context
.
__lifecycle_hooks__
.
indexOf
(
methodName
)
===
-
1
&&
!
hasOwn
(
data
,
methodName
))
{
data
[
methodName
]
=
methods
[
methodName
];
}
});
...
...
@@ -561,7 +623,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onUniNViewMessage
'
];
function
createApp
(
vm
)
{
...
...
packages/uni-mp-weixin/package.json
浏览文件 @
99335593
{
"name"
:
"@dcloudio/uni-mp-weixin"
,
"version"
:
"0.0.92
7
"
,
"version"
:
"0.0.92
8
"
,
"description"
:
"uni-app mp-weixin"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
...
...
src/core/runtime/wrapper/create-app.js
浏览文件 @
99335593
import
'
uni-platform/runtime/index
'
import
Vue
from
'
vue
'
import
{
...
...
@@ -10,7 +12,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onUniNViewMessage
'
]
export
function
createApp
(
vm
)
{
...
...
src/core/runtime/wrapper/util.js
浏览文件 @
99335593
...
...
@@ -44,7 +44,7 @@ export function getData (vueOptions, context) {
}
Object
.
keys
(
methods
).
forEach
(
methodName
=>
{
if
(
!
hasOwn
(
data
,
methodName
))
{
if
(
context
.
__lifecycle_hooks__
.
indexOf
(
methodName
)
===
-
1
&&
!
hasOwn
(
data
,
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) {
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
)
{
props
.
forEach
(
function
(
name
)
{
if
(
hasOwn
(
propsData
,
name
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录