fix(privacy): 兼容鸿蒙元服务场景补全隐私弹窗逻辑
新增鸿蒙兜底逻辑,当PrivacyManager.show()未执行且用户未同意隐私权限时,触发补偿弹窗,避免用户无法看到隐私授权弹窗
This commit is contained in:
@@ -197,13 +197,26 @@ const PrivacyManager = {
|
||||
/**
|
||||
* 页面 mounted 时补偿检查: 若 show() 在页面 mounted 之前 emit 了事件
|
||||
* 此方法返回 true 并清除标志,页面组件据此自动弹窗
|
||||
* @returns {boolean} true=有补偿弹窗,false=无
|
||||
*
|
||||
* 鸿蒙元服务兼容:
|
||||
* Lang.boot() 可能 hang, PrivacyManager.show() 可能从未被调用过;
|
||||
* 此时 _pendingShow 仍是默认 false, 但用户从未同意过隐私, 必须强制弹一次。
|
||||
* 所以增加 storage 检测: 用户未同意也返回 true (补偿弹窗)。
|
||||
* @returns {boolean} true=需要弹窗,false=不需要
|
||||
*/
|
||||
consumePendingShow() {
|
||||
if (_pendingShow && _needShow) {
|
||||
_pendingShow = false;
|
||||
return true;
|
||||
}
|
||||
// 鸿蒙兜底: PrivacyManager.show() 没跑过 + 用户没同意过 storage → 必须弹
|
||||
// 同一次进程内只补一次,避免隐私弹窗被反复触发
|
||||
if (!_hasChecked && !_pendingShow && !getStorageAgreed()) {
|
||||
_pendingShow = false;
|
||||
_needShow = true;
|
||||
_hasChecked = true;
|
||||
return true;
|
||||
}
|
||||
_pendingShow = false;
|
||||
return false;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user