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() { void onInit() {
super.onInit(); super.onInit();
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
_loadSelectedCountry();
} }
@override @override
@ -125,14 +124,4 @@ class HINodeListController extends GetxController with WidgetsBindingObserver {
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
super.onClose(); 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 // 🔧 async
onTap: () async { onTap: () async {
try { try {
await KRSecureStorage().kr_saveData( controller.homeController
key: 'SELECTED_COUNTRY_TAG', value: 'auto'); .kr_setSelectedCountryTag('auto');
controller.homeController.kr_coutryText.value = 'auto';
final success = await controller.homeController final success = await controller.homeController
.kr_performNodeSwitch('auto'); .kr_performNodeSwitch('auto');
if (success) { if (success) {
@ -182,11 +181,8 @@ class HINodeListView extends GetView<HINodeListController> {
return InkWell( return InkWell(
onTap: () async { onTap: () async {
try { try {
await KRSecureStorage().kr_saveData( controller.homeController
key: 'SELECTED_COUNTRY_TAG', .kr_setSelectedCountryTag(country.country);
value: country.country);
controller.homeController.kr_coutryText.value =
country.country;
final fastest = findFastestNode(country.outboundList); final fastest = findFastestNode(country.outboundList);
final success = await controller.homeController final success = await controller.homeController
.kr_performNodeSwitch(fastest.tag); .kr_performNodeSwitch(fastest.tag);

View File

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