feat(privacy): add markSkipped method and H5 skip logic for privacy popup
add markSkipped method to synchronously skip privacy popup, and call it in App.vue created hook for H5 environment when current URL matches skip condition
This commit is contained in:
10
App.vue
10
App.vue
@@ -51,6 +51,16 @@
|
|||||||
$langReady: Promise.resolve({ ok: true, source: 'local' })
|
$langReady: Promise.resolve({ ok: true, source: 'local' })
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
// 同步钩子:在 page mounted 之前同步设置隐私弹窗的 skip 状态
|
||||||
|
// 必须在 onLaunch (async) 之前跑,否则 onLaunch 第一个 await 让出事件循环时
|
||||||
|
// privacy-popup.vue 已经挂载,会走 consumePendingShow 兜底分支把弹窗弹出来
|
||||||
|
created() {
|
||||||
|
// #ifdef H5
|
||||||
|
if (_shouldSkipPrivacyForCurrentUrl()) {
|
||||||
|
PrivacyManager.markSkipped()
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
onLaunch: async function(options) {
|
onLaunch: async function(options) {
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 主题提前加载(关键):让首屏渲染前 CSS 变量已挂上,避免闪一下
|
// 主题提前加载(关键):让首屏渲染前 CSS 变量已挂上,避免闪一下
|
||||||
|
|||||||
@@ -164,6 +164,18 @@ const PrivacyManager = {
|
|||||||
return _needShow;
|
return _needShow;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步标记本次跳过弹窗(不查 storage、不写 storage、不弹窗)
|
||||||
|
* 必须在 page mounted 之前调用,避免 onLaunch await 让出事件循环后
|
||||||
|
* privacy-popup.vue 的 consumePendingShow 走兜底分支把弹窗弹出来
|
||||||
|
* 用于 H5 浏览器直访特定 URL(子串匹配)时不让隐私弹窗挡住
|
||||||
|
*/
|
||||||
|
markSkipped() {
|
||||||
|
_needShow = false;
|
||||||
|
_hasChecked = true;
|
||||||
|
_pendingShow = false;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 触发弹窗(如果需要)
|
* 触发弹窗(如果需要)
|
||||||
* 由 App.vue onLaunch 在 boot 完成后调用
|
* 由 App.vue onLaunch 在 boot 完成后调用
|
||||||
|
|||||||
Reference in New Issue
Block a user