feat: 初始化时配置项未完成配置,导致客服有bug,

This commit is contained in:
speakeloudest 2025-12-03 23:24:25 -08:00
parent 4f6be35f61
commit d63b3bfc3c
4 changed files with 27 additions and 19 deletions

View File

@ -36,6 +36,7 @@ import 'package:kaer_with_panels/app/services/singbox_imp/kr_sing_box_imp.dart';
import 'package:flutter/foundation.dart';
import 'package:kaer_with_panels/app/utils/kr_init_log_collector.dart'; // 🔧
import 'package:kaer_with_panels/app/utils/kr_latency_tester.dart'; // 🔧
import 'package:kaer_with_panels/app/utils/account_guard.dart';
class KRHomeController extends GetxController with WidgetsBindingObserver {
// 🔧
@ -1871,21 +1872,9 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
super.onReady();
Future.delayed(const Duration(milliseconds: 200), () async {
final rawAccount = KRAppRunData.getInstance().kr_account.value;
final account = rawAccount?.trim();
if (account == null ||
account.isEmpty ||
account.toLowerCase() == 'null') {
await HIDialog.show(
message: '未检测到账号信息,请重试初始化',
confirmText: '重试',
preventBackDismiss: true,
onConfirm: () {
Get.offAllNamed(Routes.KR_SPLASH);
},
);
}
ensureAccountExists().then((ok) {
print('ok');
});
});
}

View File

@ -97,6 +97,9 @@ class KRSiteConfigService extends ChangeNotifier {
_siteConfig = KRSiteConfig.fromJson(responseData['data']);
_isInitialized = true;
final config = AppConfig.getInstance();
config.kr_website_id = getCrispId();
config.device_limit = getDeviceLimit();
//
_printConfigInfo();

View File

@ -1,12 +1,21 @@
import 'package:get/get.dart';
import 'package:kaer_with_panels/app/common/app_run_data.dart';
import 'package:kaer_with_panels/app/common/app_config.dart';
import 'package:kaer_with_panels/app/widgets/dialogs/hi_dialog.dart';
import 'package:kaer_with_panels/app/routes/app_pages.dart';
import 'package:kaer_with_panels/app/utils/kr_common_util.dart';
import 'package:kaer_with_panels/app/services/kr_site_config_service.dart';
Future<bool> ensureAccountExists() async {
final rawAccount = KRAppRunData.getInstance().kr_account.value;
final account = rawAccount?.trim();
if (account == null || account.isEmpty || account.toLowerCase() == 'null') {
final app = KRAppRunData.getInstance();
final account = app.kr_account.value;
final isLoggedIn = app.kr_isLogin.value;
final config = AppConfig.getInstance();
if (account == null ||
account.isEmpty ||
!isLoggedIn
) {
await HIDialog.show(
message: '未检测到账号信息,请重试初始化',
confirmText: '重试',
@ -17,5 +26,12 @@ Future<bool> ensureAccountExists() async {
);
return false;
}
var crispId = config.kr_website_id;
var deviceLimitText = config.device_limit;
var deviceLimit = int.tryParse(deviceLimitText) ?? 0;
if ((crispId.isEmpty || crispId == '0') || deviceLimit == 0) {
KRSiteConfigService().initialize();
}
return true;
}

View File

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.0.4+103
version: 0.0.4+107
environment:
sdk: '>=3.5.0 <4.0.0'