feat: 修改权限问题

This commit is contained in:
2026-01-25 20:07:19 -08:00
parent 94d0a78e89
commit e00754847d
5 changed files with 46 additions and 107 deletions
@@ -11,37 +11,25 @@ class KRChatwootController {
final String baseUrl = 'https://app.chatwoot.com';
final String inboxIdentifier = 'YXQmh16ymNYW1SVybhnoQQ9w';
KRChatwootController() {
KRSecureStorage().kr_readData(key: 'USER_INFO').then((value) {
print('KRSecureStorage_keyUserInfo: $value');
});
}
/// 获取当前用户信息
/// 建议从你的全局 UserState 或本地存储中动态获取
ChatwootUser get chatUser {
final appRunData = KRAppRunData.getInstance();
final userId = appRunData.kr_userId.value?.toString();
final deviceId = appRunData.deviceId;
final authType = appRunData.kr_authType;
final account = appRunData.kr_account.value;
// 优先使用 userId 作为唯一标识,如果没有则使用 deviceId
final identifier = userId ?? deviceId ?? 'unknown_user';
// 名字使用账号,如果没有则显示 Guest
final name = account ?? 'Guest';
// 邮箱如果是邮箱格式则使用,否则构造一个唯一的虚拟邮箱以满足格式要求
String email = '';
if (account != null && account.contains('@')) {
email = account;
if (authType == 'device') {
email = account.toString();
} else {
email = '$identifier@hifastvpn.com';
email = '待绑定$deviceId';
}
return ChatwootUser(
identifier: identifier, // 必填:用于关联历史聊天记录
name: name,
identifier: account, // 必填:用于关联历史聊天记录
name: deviceId,
email: email,
);
}