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