提交 c8095b1f 编写于 作者: D DCloud_LXH

feat: uni.offThemeChange

上级 4ab5b33f
import { ON_THEME_CHANGE } from '@dcloudio/uni-shared'
import { defineOnApi } from '@dcloudio/uni-api'
import { ON_THEME_CHANGE, OFF_THEME_CHANGE } from '@dcloudio/uni-shared'
import { defineOnApi, defineOffApi } from '@dcloudio/uni-api'
const themeChangeCallBack = (res: UniApp.OnThemeChangeCallbackResult) => {
UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res)
}
export const onThemeChange = defineOnApi<typeof uni.onThemeChange>(
ON_THEME_CHANGE,
() => {
UniServiceJSBridge.on(ON_THEME_CHANGE, (res) => {
UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res)
})
UniServiceJSBridge.on(ON_THEME_CHANGE, themeChangeCallBack)
}
)
export const offThemeChange = defineOffApi<typeof uni.offThemeChange>(
OFF_THEME_CHANGE,
() => {
UniServiceJSBridge.off(ON_THEME_CHANGE, themeChangeCallBack)
}
)
......@@ -86,6 +86,7 @@
"offNetworkStatusChange",
"offPageNotFound",
"offPushMessage",
"offThemeChange",
"offUnhandledRejection",
"offWindowResize",
"onAccelerometerChange",
......
import { ON_THEME_CHANGE } from '@dcloudio/uni-shared'
import { defineOnApi } from '@dcloudio/uni-api'
import { ON_THEME_CHANGE, OFF_THEME_CHANGE } from '@dcloudio/uni-shared'
import { defineOnApi, defineOffApi } from '@dcloudio/uni-api'
const themeChangeCallBack = (res: UniApp.OnThemeChangeCallbackResult) => {
UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res)
}
export const onThemeChange = defineOnApi<typeof uni.onThemeChange>(
ON_THEME_CHANGE,
() => {
UniServiceJSBridge.on(ON_THEME_CHANGE, (res) => {
UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res)
})
UniServiceJSBridge.on(ON_THEME_CHANGE, themeChangeCallBack)
}
)
export const offThemeChange = defineOffApi<typeof uni.offThemeChange>(
OFF_THEME_CHANGE,
() => {
UniServiceJSBridge.off(ON_THEME_CHANGE, themeChangeCallBack)
}
)
......@@ -43,6 +43,7 @@ export const ON_HIDE = 'onHide'
export const ON_LAUNCH = 'onLaunch'
export const ON_ERROR = 'onError'
export const ON_THEME_CHANGE = 'onThemeChange'
export const OFF_THEME_CHANGE = 'offThemeChange'
export const ON_KEYBOARD_HEIGHT_CHANGE = 'onKeyboardHeightChange'
export const ON_PAGE_NOT_FOUND = 'onPageNotFound'
export const ON_UNHANDLE_REJECTION = 'onUnhandledRejection'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册