From ad0244916975f1451037b6910e1a2120c274b1ce Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Wed, 2 Nov 2022 19:25:23 +0800 Subject: [PATCH] feat: uni.offThemeChange --- lib/apis.js | 1 + src/core/service/api/device/theme.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/apis.js b/lib/apis.js index 34bd0e0a8..32f5d2f41 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -139,6 +139,7 @@ const device = [ 'checkIsSoterEnrolledInDevice', 'startSoterAuthentication', 'onThemeChange', + 'offThemeChange', 'onUIStyleChange', 'getSystemSetting', 'getAppAuthorizeSetting', diff --git a/src/core/service/api/device/theme.js b/src/core/service/api/device/theme.js index a6543ad66..375f7e498 100644 --- a/src/core/service/api/device/theme.js +++ b/src/core/service/api/device/theme.js @@ -23,6 +23,16 @@ export function onThemeChange (callbackId) { callbacks.push(callbackId) } +export function offThemeChange (callbackId) { + // 暂不支持移除所有监听 + if (callbackId) { + const index = callbacks.indexOf(callbackId) + if (index >= 0) { + callbacks.splice(index, 1) + } + } +} + // 旧版本 API,后期文档更新后考虑移除 onMethod('onUIStyleChange', function (res) { oldCallbacks.forEach(callbackId => { -- GitLab