feat: 修改城市auto模式下节点显示问题
This commit is contained in:
parent
9302764802
commit
a17fa079bc
@ -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 (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) {
|
||||
// 用户手动选择了具体节点
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user