feat: bugfix
This commit is contained in:
parent
83e742a9dc
commit
adcde623c7
@ -1309,6 +1309,9 @@ class AppConfig {
|
|||||||
/// 网站ID
|
/// 网站ID
|
||||||
String kr_website_id = "";
|
String kr_website_id = "";
|
||||||
|
|
||||||
|
/// 设备限制数量
|
||||||
|
String device_limit = '0';
|
||||||
|
|
||||||
/// 是否为白天模式
|
/// 是否为白天模式
|
||||||
bool kr_is_daytime = true;
|
bool kr_is_daytime = true;
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,7 @@ class KRSiteInfo {
|
|||||||
final String customHtml;
|
final String customHtml;
|
||||||
final String customData;
|
final String customData;
|
||||||
final String crispId;
|
final String crispId;
|
||||||
|
final String deviceLimit;
|
||||||
|
|
||||||
KRSiteInfo({
|
KRSiteInfo({
|
||||||
required this.host,
|
required this.host,
|
||||||
@ -73,10 +74,12 @@ class KRSiteInfo {
|
|||||||
required this.customHtml,
|
required this.customHtml,
|
||||||
required this.customData,
|
required this.customData,
|
||||||
required this.crispId,
|
required this.crispId,
|
||||||
|
required this.deviceLimit,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory KRSiteInfo.fromJson(Map<String, dynamic> json) {
|
factory KRSiteInfo.fromJson(Map<String, dynamic> json) {
|
||||||
String crispId = '0';
|
String crispId = '0';
|
||||||
|
String deviceLimit = '0';
|
||||||
|
|
||||||
// 尝试解析 custom_data 中的 kr_website_id
|
// 尝试解析 custom_data 中的 kr_website_id
|
||||||
try {
|
try {
|
||||||
@ -89,6 +92,16 @@ class KRSiteInfo {
|
|||||||
// 解析失败时使用默认值
|
// 解析失败时使用默认值
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 尝试解析 custom_data 中的 deviceLimit
|
||||||
|
try {
|
||||||
|
final customDataStr = json['custom_data'] ?? '';
|
||||||
|
if (customDataStr.isNotEmpty) {
|
||||||
|
final customDataJson = jsonDecode(customDataStr) as Map<String, dynamic>;
|
||||||
|
deviceLimit = (customDataJson['deviceLimit'] ?? 0).toString();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// 解析失败时使用默认值
|
||||||
|
}
|
||||||
return KRSiteInfo(
|
return KRSiteInfo(
|
||||||
host: json['host'] ?? '',
|
host: json['host'] ?? '',
|
||||||
siteName: json['site_name'] ?? '',
|
siteName: json['site_name'] ?? '',
|
||||||
@ -98,6 +111,7 @@ class KRSiteInfo {
|
|||||||
customHtml: json['custom_html'] ?? '',
|
customHtml: json['custom_html'] ?? '',
|
||||||
customData: json['custom_data'] ?? '',
|
customData: json['custom_data'] ?? '',
|
||||||
crispId: crispId,
|
crispId: crispId,
|
||||||
|
deviceLimit: deviceLimit,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,10 +37,12 @@ class HIMenuView extends GetView<HIMenuController> {
|
|||||||
mainAxisSize: MainAxisSize.min, // 让 Column 包裹内容
|
mainAxisSize: MainAxisSize.min, // 让 Column 包裹内容
|
||||||
children: [
|
children: [
|
||||||
Obx(() {
|
Obx(() {
|
||||||
final account = KRAppRunData.getInstance().kr_account.value ?? '未登录';
|
final account = KRAppRunData.getInstance().kr_account.value;
|
||||||
|
final isDeviceLogin = account != null && account.startsWith('9000');
|
||||||
|
final accountText = isDeviceLogin ? '待绑定' : 'ID: ${KRAppRunData.getInstance().kr_account.value.toString()}';
|
||||||
return UserInfoCard(
|
return UserInfoCard(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
userId: account,
|
userId: accountText,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'ID: $userId',
|
userId,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@ -222,22 +222,22 @@ class HIUserInfoController extends GetxController {
|
|||||||
String iconName = 'devices';
|
String iconName = 'devices';
|
||||||
|
|
||||||
if (userAgent.contains('Android') || userAgent.toLowerCase().contains('android')) {
|
if (userAgent.contains('Android') || userAgent.toLowerCase().contains('android')) {
|
||||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeAndroid;
|
deviceType = 'Android' ;// AppTranslations.kr_deviceManagement.deviceTypeAndroid;
|
||||||
iconName = 'phone_android';
|
iconName = 'phone_android';
|
||||||
} else if (userAgent.contains('iOS') || userAgent.contains('iPhone') || userAgent.toLowerCase().contains('ios')) {
|
} else if (userAgent.contains('iOS') || userAgent.contains('iPhone') || userAgent.toLowerCase().contains('ios')) {
|
||||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeIos;
|
deviceType = 'iPhone'; // AppTranslations.kr_deviceManagement.deviceTypeIos;
|
||||||
iconName = 'phone_iphone';
|
iconName = 'phone_iphone';
|
||||||
} else if (userAgent.contains('iPad')) {
|
} else if (userAgent.contains('iPad')) {
|
||||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeIpad;
|
deviceType = 'iPad';// AppTranslations.kr_deviceManagement.deviceTypeIpad;
|
||||||
iconName = 'tablet';
|
iconName = 'tablet';
|
||||||
} else if (userAgent.contains('macOS') || userAgent.contains('Mac') || userAgent.toLowerCase().contains('mac')) {
|
} else if (userAgent.contains('macOS') || userAgent.contains('Mac') || userAgent.toLowerCase().contains('mac')) {
|
||||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeMacos;
|
deviceType = 'Mac';// AppTranslations.kr_deviceManagement.deviceTypeMacos;
|
||||||
iconName = 'desktop_mac';
|
iconName = 'desktop_mac';
|
||||||
} else if (userAgent.contains('Windows') || userAgent.toLowerCase().contains('windows')) {
|
} else if (userAgent.contains('Windows') || userAgent.toLowerCase().contains('windows')) {
|
||||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeWindows;
|
deviceType = 'Windows'; //AppTranslations.kr_deviceManagement.deviceTypeWindows;
|
||||||
iconName = 'computer';
|
iconName = 'computer';
|
||||||
} else if (userAgent.contains('Linux') || userAgent.toLowerCase().contains('linux')) {
|
} else if (userAgent.contains('Linux') || userAgent.toLowerCase().contains('linux')) {
|
||||||
deviceType = AppTranslations.kr_deviceManagement.deviceTypeLinux;
|
deviceType = 'Linux';//AppTranslations.kr_deviceManagement.deviceTypeLinux;
|
||||||
iconName = 'computer';
|
iconName = 'computer';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import 'package:kaer_with_panels/app/widgets/hi_help_entrance.dart';
|
|||||||
import 'package:kaer_with_panels/app/common/app_run_data.dart';
|
import 'package:kaer_with_panels/app/common/app_run_data.dart';
|
||||||
import 'package:kaer_with_panels/app/modules/kr_home/controllers/kr_home_controller.dart';
|
import 'package:kaer_with_panels/app/modules/kr_home/controllers/kr_home_controller.dart';
|
||||||
import 'package:kaer_with_panels/app/widgets/dialogs/hi_dialog.dart';
|
import 'package:kaer_with_panels/app/widgets/dialogs/hi_dialog.dart';
|
||||||
|
import 'package:kaer_with_panels/app/common/app_config.dart';
|
||||||
|
|
||||||
class HIUserInfoView extends GetView<HIUserInfoController> {
|
class HIUserInfoView extends GetView<HIUserInfoController> {
|
||||||
const HIUserInfoView({super.key});
|
const HIUserInfoView({super.key});
|
||||||
@ -70,32 +71,19 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
Obx(() {
|
Obx(() {
|
||||||
final account = KRAppRunData.getInstance().kr_account.value;
|
final account = KRAppRunData.getInstance().kr_account.value;
|
||||||
final isDeviceLogin = account != null && account.startsWith('9000');
|
final isDeviceLogin = account != null && account.startsWith('9000');
|
||||||
|
final accountText = isDeviceLogin ? '待绑定' : 'ID: ${KRAppRunData.getInstance().kr_account.value.toString()}';
|
||||||
if (isDeviceLogin) return const SizedBox();
|
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
account ?? '',
|
accountText,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 20.sp,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
height: 0.9,
|
//height: 0.9,
|
||||||
),
|
),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
Obx(() {
|
|
||||||
final userId = KRAppRunData.getInstance().kr_userId.value;
|
|
||||||
return Text(
|
|
||||||
'ID: ${(userId != null && userId.toString().isNotEmpty) ? userId : '—'}',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white.withOpacity(0.85),
|
|
||||||
fontSize: 14.sp,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
final currentSubscribe =
|
final currentSubscribe =
|
||||||
controller.kr_subscribeService.kr_currentSubscribe.value;
|
controller.kr_subscribeService.kr_currentSubscribe.value;
|
||||||
@ -167,10 +155,10 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 0.w).copyWith(bottom: 10.w), // 在这里增加底部间距
|
margin: EdgeInsets.symmetric(horizontal: 0).copyWith(bottom: 10), // 在这里增加底部间距
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.w),
|
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(22.w),
|
borderRadius: BorderRadius.circular(22),
|
||||||
border: Border.all(color: Colors.white, width: 2),
|
border: Border.all(color: Colors.white, width: 2),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -180,7 +168,7 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
isDeviceLogin ? '绑定邮箱' : '修改密码',
|
isDeviceLogin ? '绑定邮箱' : '修改密码',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 16.sp,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -200,7 +188,7 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
if (controller.isLoading.value) {
|
if (controller.isLoading.value) {
|
||||||
// 使用 Padding 在加载指示器上方添加间距
|
// 使用 Padding 在加载指示器上方添加间距
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(top: 20.w),
|
padding: EdgeInsets.only(top: 20),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
@ -208,7 +196,7 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 0.w),
|
padding: EdgeInsets.symmetric(horizontal: 0),
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
// 1. 禁止 GridView 自身的滚动,因为它已经在 SingleChildScrollView 内部
|
// 1. 禁止 GridView 自身的滚动,因为它已经在 SingleChildScrollView 内部
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
@ -217,9 +205,10 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
// 3. 设置网格的配置
|
// 3. 设置网格的配置
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2, // 强制两列
|
crossAxisCount: 2, // 强制两列
|
||||||
crossAxisSpacing: 10.w, // 水平间距
|
crossAxisSpacing: 10, // 水平间距
|
||||||
mainAxisSpacing: 10.w, // 垂直间距
|
mainAxisSpacing: 10, // 垂直间距
|
||||||
childAspectRatio: 1.5, // 宽高比,需要微调以获得最佳视觉效果
|
mainAxisExtent: 76,
|
||||||
|
// childAspectRatio: 1.5, // 宽高比,需要微调以获得最佳视觉效果
|
||||||
),
|
),
|
||||||
// 4. itemCount 和 itemBuilder 的逻辑保持不变
|
// 4. itemCount 和 itemBuilder 的逻辑保持不变
|
||||||
itemCount: controller.devices.length + 1,
|
itemCount: controller.devices.length + 1,
|
||||||
@ -233,13 +222,13 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
onDelete: (id) {
|
onDelete: (id) {
|
||||||
HIDialog.show(
|
HIDialog.show(
|
||||||
customMessageWidget: Padding(
|
customMessageWidget: Padding(
|
||||||
padding: EdgeInsets.only(top: 16.w),
|
padding: EdgeInsets.only(top: 16),
|
||||||
child: Text(
|
child: Text(
|
||||||
'请确认是否移除此设备?',
|
'请确认是否移除此设备?',
|
||||||
style: KrAppTextStyle(
|
style: KrAppTextStyle(
|
||||||
color:
|
color:
|
||||||
Theme.of(context).textTheme.bodyMedium?.color,
|
Theme.of(context).textTheme.bodyMedium?.color,
|
||||||
fontSize: 14.sp,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -411,9 +400,9 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
children: [
|
children: [
|
||||||
// 主体内容容器
|
// 主体内容容器
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 14.w),
|
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(24.w), // 可以适当调整圆角
|
borderRadius: BorderRadius.circular(24), // 可以适当调整圆角
|
||||||
border: Border.all(color: Colors.white, width: 2),
|
border: Border.all(color: Colors.white, width: 2),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -422,25 +411,25 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(_getIconData(iconName), color: Colors.white, size: 18.w),
|
Icon(_getIconData(iconName), color: Colors.white, size: 18),
|
||||||
SizedBox(width: 6.w),
|
SizedBox(width: 6),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'设备:${_extractDeviceModel(userAgent, deviceType)}',
|
'设备:${deviceType}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 10.sp, //
|
fontSize: 10, //
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
SizedBox(height: 4.h),
|
SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'SN: ${identifier.substring(0, identifier.length > 4 ? 4 : identifier.length)}$id',
|
'SN: ${identifier.substring(0, identifier.length > 4 ? 4 : identifier.length)}$id',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withOpacity(0.9),
|
color: Colors.white.withOpacity(0.9),
|
||||||
fontSize: 10.sp,
|
fontSize: 10,
|
||||||
fontWeight: FontWeight.w500),
|
fontWeight: FontWeight.w500),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@ -494,8 +483,8 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
Widget _buildAddDeviceCard() {
|
Widget _buildAddDeviceCard() {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
print('可用设备 ${controller.kr_subscribeService.kr_currentSubscribe}');
|
|
||||||
// 在这里处理点击“添加设备”的逻辑
|
// 在这里处理点击“添加设备”的逻辑
|
||||||
|
final device_limit = AppConfig.getInstance().device_limit;
|
||||||
HIDialog.show(
|
HIDialog.show(
|
||||||
customMessageWidget: Padding(
|
customMessageWidget: Padding(
|
||||||
padding: EdgeInsets.only(top: 16.w, bottom: 16.w),
|
padding: EdgeInsets.only(top: 16.w, bottom: 16.w),
|
||||||
@ -514,7 +503,7 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 20.w),
|
SizedBox(height: 20.w),
|
||||||
Text(
|
Text(
|
||||||
'每个账号最多允许同时使用2台设备同时在线',
|
"每个账号最多允许同时使用${device_limit}台设备同时在线",
|
||||||
style: KrAppTextStyle(
|
style: KrAppTextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 14.sp,
|
fontSize: 14.sp,
|
||||||
|
|||||||
@ -201,6 +201,7 @@ class KRDeleteAccountView extends GetView<KRDeleteAccountController> {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
controller: controller.kr_codeController,
|
controller: controller.kr_codeController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
style: KrAppTextStyle(
|
style: KrAppTextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|||||||
@ -416,4 +416,4 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
controller.kr_check();
|
controller.kr_check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,13 +170,16 @@ class KRSplashController extends GetxController {
|
|||||||
print('📞 准备调用 KRSiteConfigService().initialize()...');
|
print('📞 准备调用 KRSiteConfigService().initialize()...');
|
||||||
final success = await KRSiteConfigService().initialize();
|
final success = await KRSiteConfigService().initialize();
|
||||||
final crispId = await KRSiteConfigService().getCrispId();
|
final crispId = await KRSiteConfigService().getCrispId();
|
||||||
|
final device_limit = await KRSiteConfigService().getDeviceLimit();
|
||||||
print('📞 KRSiteConfigService().initialize() 返回: $success');
|
print('📞 KRSiteConfigService().initialize() 返回: $success');
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
final config = AppConfig.getInstance();
|
final config = AppConfig.getInstance();
|
||||||
config.kr_website_id = crispId;
|
config.kr_website_id = crispId;
|
||||||
|
config.device_limit = device_limit;
|
||||||
print('📞 KRSiteConfigService().initialize() 返回: $crispId');
|
print('📞 KRSiteConfigService().initialize() 返回: $crispId');
|
||||||
print('AppConfig website_id 已更新为: ${config.kr_website_id}');
|
print('AppConfig website_id 已更新为: ${config.kr_website_id}');
|
||||||
|
print('AppConfig device_limit 已更新为: ${config.device_limit}');
|
||||||
|
|
||||||
// print('[SPLASH_TIMING] ✅ 网站配置初始化成功');
|
// print('[SPLASH_TIMING] ✅ 网站配置初始化成功');
|
||||||
// await _kr_checkAndPerformDeviceLogin();
|
// await _kr_checkAndPerformDeviceLogin();
|
||||||
|
|||||||
@ -341,6 +341,11 @@ class KRSiteConfigService extends ChangeNotifier {
|
|||||||
return _siteConfig?.site.crispId ?? '0';
|
return _siteConfig?.site.crispId ?? '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 获取设备限制
|
||||||
|
String getDeviceLimit() {
|
||||||
|
return _siteConfig?.site.deviceLimit ?? '0';
|
||||||
|
}
|
||||||
|
|
||||||
/// 重置配置
|
/// 重置配置
|
||||||
void reset() {
|
void reset() {
|
||||||
_siteConfig = null;
|
_siteConfig = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user