提交 3c1bbccd 编写于 作者: D DCloud_LXH

fix(app): onThemeChange triggered twice

上级 8c30bd31
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
} from '../../platform' } from '../../platform'
const callbacks = [] const callbacks = []
const oldCallbacks = []
onMethod('onThemeChange', function (res) { onMethod('onThemeChange', function (res) {
callbacks.forEach(callbackId => { callbacks.forEach(callbackId => {
...@@ -20,12 +21,12 @@ export function onThemeChange (callbackId) { ...@@ -20,12 +21,12 @@ export function onThemeChange (callbackId) {
// 旧版本 API,后期文档更新后考虑移除 // 旧版本 API,后期文档更新后考虑移除
onMethod('onUIStyleChange', function (res) { onMethod('onUIStyleChange', function (res) {
callbacks.forEach(callbackId => { oldCallbacks.forEach(callbackId => {
invoke(callbackId, res) invoke(callbackId, res)
}) })
}) })
export function onUIStyleChange (callbackId) { export function onUIStyleChange (callbackId) {
callbacks.push(callbackId) oldCallbacks.push(callbackId)
console.warn('The "uni.onUIStyleChange" API is deprecated, please use "uni.onThemeChange". Learn more: https://uniapp.dcloud.net.cn/api/system/theme.') console.warn('The "uni.onUIStyleChange" API is deprecated, please use "uni.onThemeChange". Learn more: https://uniapp.dcloud.net.cn/api/system/theme.')
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册