feat: 添加隐私授权检查与处理逻辑,优化用户体验
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { _decorator, Node, Button, Label, tween, Vec3, UIOpacity, UITransform, Color, instantiate, ProgressBar } from 'cc';
|
||||
import { BaseView } from 'db://assets/scripts/core/BaseView';
|
||||
import { ViewManager } from 'db://assets/scripts/core/ViewManager';
|
||||
import { WxSDK, checkPrivacySetting, requirePrivacyAuthorize } from 'db://assets/scripts/utils/WxSDK';
|
||||
import { WxSDK } from 'db://assets/scripts/utils/WxSDK';
|
||||
import { StaminaManager } from 'db://assets/scripts/utils/StaminaManager';
|
||||
import { ToastManager } from 'db://assets/scripts/utils/ToastManager';
|
||||
import { StaminaInfo } from 'db://assets/scripts/types/ApiTypes';
|
||||
@@ -71,8 +71,6 @@ export class PageHome extends BaseView {
|
||||
this.updateAchievementTitleInfo();
|
||||
this._initButtons();
|
||||
this._initWxShare();
|
||||
// 检查隐私授权
|
||||
this._checkPrivacyAuthorization();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,28 +84,6 @@ export class PageHome extends BaseView {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查隐私授权状态
|
||||
*/
|
||||
private async _checkPrivacyAuthorization(): Promise<void> {
|
||||
if (!WxSDK.isWechat()) {
|
||||
console.log('[PageHome] 非微信环境,跳过隐私授权检查');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { needAuthorization } = await checkPrivacySetting();
|
||||
if (needAuthorization) {
|
||||
console.log('[PageHome] 用户未授权隐私,引导授权');
|
||||
await requirePrivacyAuthorize();
|
||||
} else {
|
||||
console.log('[PageHome] 用户已授权隐私');
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('[PageHome] 隐私授权检查异常:', err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化按钮事件
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user