提交 c542f3d0 编写于 作者: d-u-a's avatar d-u-a

update: 新增uni.onThemeChange事件,保留旧版本uni.onUIStyleChange,call app onThemeChange

上级 c207b699
...@@ -119,7 +119,8 @@ const device = [ ...@@ -119,7 +119,8 @@ const device = [
'stopBeaconDiscovery', 'stopBeaconDiscovery',
'checkIsSupportSoterAuthentication', 'checkIsSupportSoterAuthentication',
'checkIsSoterEnrolledInDevice', 'checkIsSoterEnrolledInDevice',
'startSoterAuthentication', 'startSoterAuthentication',
'onThemeChange',
'onUIStyleChange' 'onUIStyleChange'
] ]
......
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
"uni.getBeacons": true, "uni.getBeacons": true,
"uni.startBeaconDiscovery": true, "uni.startBeaconDiscovery": true,
"uni.stopBeaconDiscovery": true, "uni.stopBeaconDiscovery": true,
"uni.onThemeChange": true,
"uni.onUIStyleChange": true "uni.onUIStyleChange": true
} }
}, { }, {
......
...@@ -8,6 +8,17 @@ import { ...@@ -8,6 +8,17 @@ import {
const callbacks = [] const callbacks = []
onMethod('onThemeChange', function (res) {
callbacks.forEach(callbackId => {
invoke(callbackId, res)
})
})
export function onThemeChange (callbackId) {
callbacks.push(callbackId)
}
// 旧版本 API,后期文档更新后考虑移除
onMethod('onUIStyleChange', function (res) { onMethod('onUIStyleChange', function (res) {
callbacks.forEach(callbackId => { callbacks.forEach(callbackId => {
invoke(callbackId, res) invoke(callbackId, res)
......
...@@ -95,9 +95,17 @@ function initGlobalListeners () { ...@@ -95,9 +95,17 @@ function initGlobalListeners () {
}) })
}) })
globalEvent.addEventListener('uistylechange', function (event) { globalEvent.addEventListener('uistylechange', function (event) {
publish('onUIStyleChange', { const args = {
style: event.uistyle theme: event.uistyle
}
callAppHook(appCtx, 'onThemeChange', args)
publish('onThemeChange', args)
// 兼容旧版本 API
publish('onUIStyleChange', {
style: event.uistyle
}) })
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册