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