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

This commit is contained in:
2025-11-28 17:27:01 -08:00
parent 9302764802
commit a17fa079bc
3 changed files with 33 additions and 24 deletions
@@ -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) {
// 用户手动选择了具体节点