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
@@ -14,56 +14,28 @@ class _KRChatwootViewState extends State<KRChatwootView> {
// 实例化控制器
final KRChatwootController _controller = KRChatwootController();
// 控制加载遮罩状态
bool _isPageLoading = true;
@override
Widget build(BuildContext context) {
return Scaffold(
// 设置背景色为白色,确保顶部 20px 区域不漏出底色
backgroundColor: Colors.white,
body: Padding(
// 在这里设置顶部 20px 的间距
padding: const EdgeInsets.only(top: 20.0),
child: Stack(
children: [
ChatwootWidget(
baseUrl: _controller.baseUrl,
websiteToken: _controller.inboxIdentifier,
user: _controller.chatUser,
locale: "zh_CN",
onAttachFile: _controller.onFilePicker,
onLoadStarted: () {
debugPrint("KRChatwoot: 开始加载 SDK");
},
closeWidget: () {
print('返回');
Get.back();
},
onLoadCompleted: () {
debugPrint("KRChatwoot: SDK 加载完毕");
if (mounted) {
setState(() => _isPageLoading = false);
}
},
),
// 获取系统状态栏高度
final double statusBarHeight = MediaQuery.of(context).padding.top;
// 加载中的占位图
if (_isPageLoading)
Container(
color: Colors.white,
child: const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(strokeWidth: 2),
const SizedBox(height: 16),
Text("正在连接客服...", style: TextStyle(color: Colors.grey)),
],
),
),
),
],
return Scaffold(
backgroundColor: const Color(0xFFF9F9FB),
body: SafeArea(
top: false, // 依然保持禁用自动顶部保护
child: Padding(
// 在状态栏高度的基础上减去 10 像素,实现向上移动
padding: EdgeInsets.only(top: statusBarHeight - 10),
child: ChatwootWidget(
baseUrl: _controller.baseUrl,
websiteToken: _controller.inboxIdentifier,
user: _controller.chatUser,
locale: "zh_CN",
onAttachFile: _controller.onFilePicker,
onLoadStarted: () => debugPrint("KRChatwoot: 开始加载 SDK"),
closeWidget: () => Get.back(),
onLoadCompleted: () => debugPrint("KRChatwoot: SDK 加载完毕"),
),
),
),
);