优化第三方平台默认选项

This commit is contained in:
sky_min 2025-11-29 10:35:38 +08:00
parent cd9e5da6a0
commit 18f059663a
2 changed files with 20 additions and 0 deletions

View File

@ -28,6 +28,11 @@ class ThirdPartyPlatformLogic extends BaseGetXController {
void onReady() async {
super.onReady();
await getActivateInfo();
//
final savedIndex = await state.getSavedSelectedPlatformIndex();
if (savedIndex != null && savedIndex < state.platFormSet.length) {
state.selectPlatFormIndex.value = savedIndex;
}
_initReplySubscription();
await getServerDatetime();
showEasyLoading();
@ -209,6 +214,8 @@ class ThirdPartyPlatformLogic extends BaseGetXController {
void savePlatFormSetting() {
if (state.selectPlatFormIndex.value == 1 || state.selectPlatFormIndex.value == 0) {
if (state.registerKey.isNotEmpty) {
//
state.saveSelectedPlatformIndex(state.selectPlatFormIndex.value);
_requestAuthorizationCode();
}
} else {

View File

@ -2,6 +2,7 @@ import 'dart:ui';
import 'package:get/get.dart';
import 'package:get/get_rx/get_rx.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:star_lock/main/lockDetail/lockDetail/ActivateInfoResponse.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
import 'package:star_lock/translations/app_dept.dart';
@ -32,4 +33,16 @@ class ThirdPartyPlatformState {
Map lockInfo = {};
int serverTime = 0; // UTC+0
//
static const String _SELECTED_PLATFORM_INDEX_KEY = 'selected_platform_index';
Future<void> saveSelectedPlatformIndex(int index) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setInt(_SELECTED_PLATFORM_INDEX_KEY, index);
}
//
Future<int?> getSavedSelectedPlatformIndex() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getInt(_SELECTED_PLATFORM_INDEX_KEY);
}
}