mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 10:03:43 +08:00
feat: LocalizationUIModel keep selectLang
This commit is contained in:
parent
afa77e0c38
commit
ff07b07cc6
@ -7,8 +7,7 @@ import 'package:starcitizen_doctor/common/utils/log.dart';
|
|||||||
|
|
||||||
class AnalyticsApi {
|
class AnalyticsApi {
|
||||||
static touch(String key) async {
|
static touch(String key) async {
|
||||||
// debug 不统计
|
if (kDebugMode || kProfileMode) return;
|
||||||
if (kDebugMode) return;
|
|
||||||
dPrint("AnalyticsApi.touch === $key start");
|
dPrint("AnalyticsApi.touch === $key start");
|
||||||
try {
|
try {
|
||||||
final r = await RSHttp.postData(
|
final r = await RSHttp.postData(
|
||||||
@ -20,7 +19,7 @@ class AnalyticsApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Map<String,dynamic>> getAnalyticsData() async {
|
static Future<Map<String, dynamic>> getAnalyticsData() async {
|
||||||
final r = await RSHttp.get("${URLConf.analyticsApiHome}/analytics");
|
final r = await RSHttp.get("${URLConf.analyticsApiHome}/analytics");
|
||||||
if (r.data == null) return {};
|
if (r.data == null) return {};
|
||||||
final jsonData = json.decode(utf8.decode(r.data!));
|
final jsonData = json.decode(utf8.decode(r.data!));
|
||||||
|
@ -6,6 +6,7 @@ import 'package:archive/archive_io.dart';
|
|||||||
import 'package:fluent_ui/fluent_ui.dart';
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:starcitizen_doctor/api/analytics.dart';
|
import 'package:starcitizen_doctor/api/analytics.dart';
|
||||||
import 'package:starcitizen_doctor/api/api.dart';
|
import 'package:starcitizen_doctor/api/api.dart';
|
||||||
@ -80,6 +81,10 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
_customizeDirListenSub?.cancel();
|
_customizeDirListenSub?.cancel();
|
||||||
_customizeDirListenSub = null;
|
_customizeDirListenSub = null;
|
||||||
});
|
});
|
||||||
|
final appConfBox = await Hive.openBox("app_conf");
|
||||||
|
final lang = await appConfBox.get("localization_selectedLanguage",
|
||||||
|
defaultValue: languageSupport.keys.first);
|
||||||
|
state = state.copyWith(selectedLanguage: lang);
|
||||||
await _loadData();
|
await _loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,9 +330,11 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
return ref.read(homeUIModelProvider).scInstalledPath;
|
return ref.read(homeUIModelProvider).scInstalledPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectLang(String v) {
|
void selectLang(String v) async {
|
||||||
state = state.copyWith(selectedLanguage: v);
|
state = state.copyWith(selectedLanguage: v);
|
||||||
_loadData();
|
_loadData();
|
||||||
|
final appConfBox = await Hive.openBox("app_conf");
|
||||||
|
await appConfBox.put("localization_selectedLanguage", v);
|
||||||
}
|
}
|
||||||
|
|
||||||
VoidCallback? onBack(BuildContext context) {
|
VoidCallback? onBack(BuildContext context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user