feat: 修改城市auto模式下节点显示问题

This commit is contained in:
speakeloudest 2025-11-28 17:27:01 -08:00
parent 9302764802
commit a17fa079bc
3 changed files with 33 additions and 24 deletions

View File

@ -98,7 +98,6 @@ class HINodeListController extends GetxController with WidgetsBindingObserver {
void onInit() {
super.onInit();
WidgetsBinding.instance.addObserver(this);
_loadSelectedCountry();
}
@override
@ -125,14 +124,4 @@ class HINodeListController extends GetxController with WidgetsBindingObserver {
WidgetsBinding.instance.removeObserver(this);
super.onClose();
}
Future<void> _loadSelectedCountry() async {
try {
final v =
await KRSecureStorage().kr_readData(key: 'SELECTED_COUNTRY_TAG');
if (v != null && v.isNotEmpty) {
homeController.kr_coutryText.value = v;
}
} catch (_) {}
}
}

View File

@ -91,9 +91,8 @@ class HINodeListView extends GetView<HINodeListController> {
// 🔧 async
onTap: () async {
try {
await KRSecureStorage().kr_saveData(
key: 'SELECTED_COUNTRY_TAG', value: 'auto');
controller.homeController.kr_coutryText.value = 'auto';
controller.homeController
.kr_setSelectedCountryTag('auto');
final success = await controller.homeController
.kr_performNodeSwitch('auto');
if (success) {
@ -182,11 +181,8 @@ class HINodeListView extends GetView<HINodeListController> {
return InkWell(
onTap: () async {
try {
await KRSecureStorage().kr_saveData(
key: 'SELECTED_COUNTRY_TAG',
value: country.country);
controller.homeController.kr_coutryText.value =
country.country;
controller.homeController
.kr_setSelectedCountryTag(country.country);
final fastest = findFastestNode(country.outboundList);
final success = await controller.homeController
.kr_performNodeSwitch(fastest.tag);

View File

@ -95,6 +95,13 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
var kr_cutSeletedTag = 'auto'.obs;
var kr_coutryText = 'auto'.obs;
var kr_selectedCountryTag = 'auto'.obs;
void kr_setSelectedCountryTag(String country) {
kr_selectedCountryTag.value = country;
kr_coutryText.value = country;
KRSecureStorage().kr_saveData(key: 'SELECTED_COUNTRY_TAG', value: country);
}
///
final RxString kr_currentIp = AppTranslations.kr_home.disconnected.obs;
final RxString kr_currentProtocol = AppTranslations.kr_home.disconnected.obs;
@ -273,6 +280,8 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
// _kr_initBottomPanelHeight();
//
_loadQuickConnectStatus();
//
await _loadSelectedCountryTag();
//
_bindSubscribeStatus();
@ -334,6 +343,20 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
}
}
Future<void> _loadSelectedCountryTag() async {
try {
final v =
await KRSecureStorage().kr_readData(key: 'SELECTED_COUNTRY_TAG');
if (v != null && v.isNotEmpty) {
kr_selectedCountryTag.value = v;
kr_coutryText.value = v;
} else {
kr_selectedCountryTag.value = 'auto';
kr_coutryText.value = 'auto';
}
} catch (_) {}
}
///
void _kr_initBottomPanelHeight() {
ever(kr_currentListStatus, (status) {
@ -921,10 +944,8 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
Future<void> _kr_prepareCountrySelectionBeforeStart() async {
try {
KRLogUtil.kr_i('开始准备国家选择', tag: 'CountrySelect');
final storedCountry =
await KRSecureStorage().kr_readData(key: 'SELECTED_COUNTRY_TAG') ??
'auto';
KRLogUtil.kr_i('读取 SELECTED_COUNTRY_TAG: $storedCountry',
final storedCountry = kr_selectedCountryTag.value;
KRLogUtil.kr_i('使用响应式 SELECTED_COUNTRY_TAG: $storedCountry',
tag: 'CountrySelect');
if (storedCountry == 'auto') {
KRLogUtil.kr_w('当前为 auto按全局最优节点进行选择', tag: 'CountrySelect');
@ -1483,9 +1504,12 @@ class KRHomeController extends GetxController with WidgetsBindingObserver {
String actualTag;
if (kr_selectedCountryTag.value == 'auto') {
actualTag = kr_cutSeletedTag.value;
}
// 🔧
// 1. kr_cutTag auto使
if (kr_cutTag.value != 'auto' &&
else if (kr_cutTag.value != 'auto' &&
kr_cutTag.value != 'select' &&
kr_cutTag.value.isNotEmpty) {
//