mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-09-13 20:54:41 +08:00
feat: _fixFestivalCountdownListDateTime 节日已过7天时,更新为下一年的时间
This commit is contained in:
@@ -136,14 +136,13 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ignore: avoid_build_context_in_providers
|
// ignore: avoid_build_context_in_providers
|
||||||
Future<void> goWebView(
|
Future<void> goWebView(BuildContext context,
|
||||||
BuildContext context,
|
String title,
|
||||||
String title,
|
String url, {
|
||||||
String url, {
|
bool useLocalization = false,
|
||||||
bool useLocalization = false,
|
bool loginMode = false,
|
||||||
bool loginMode = false,
|
RsiLoginCallback? rsiLoginCallback,
|
||||||
RsiLoginCallback? rsiLoginCallback,
|
}) async {
|
||||||
}) async {
|
|
||||||
if (useLocalization) {
|
if (useLocalization) {
|
||||||
const tipVersion = 2;
|
const tipVersion = 2;
|
||||||
final box = await Hive.openBox("app_conf");
|
final box = await Hive.openBox("app_conf");
|
||||||
@@ -154,7 +153,10 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
context,
|
context,
|
||||||
S.current.home_action_title_star_citizen_website_localization,
|
S.current.home_action_title_star_citizen_website_localization,
|
||||||
Text(S.current.home_action_info_web_localization_plugin_disclaimer, style: const TextStyle(fontSize: 16)),
|
Text(S.current.home_action_info_web_localization_plugin_disclaimer, style: const TextStyle(fontSize: 16)),
|
||||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .6),
|
constraints: BoxConstraints(maxWidth: MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.width * .6),
|
||||||
);
|
);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (loginMode) {
|
if (loginMode) {
|
||||||
@@ -225,8 +227,7 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
final box = await Hive.openBox("app_conf");
|
final box = await Hive.openBox("app_conf");
|
||||||
final version = box.get("close_placard", defaultValue: "");
|
final version = box.get("close_placard", defaultValue: "");
|
||||||
if (r.enable == true) {
|
if (r.enable == true) {
|
||||||
if (r.alwaysShow != true && version == r.version) {
|
if (r.alwaysShow != true && version == r.version) {} else {
|
||||||
} else {
|
|
||||||
state = state.copyWith(appPlacardData: r);
|
state = state.copyWith(appPlacardData: r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +238,7 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
final countdownFestivalListData = await Api.getFestivalCountdownList();
|
final countdownFestivalListData = await Api.getFestivalCountdownList();
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
webLocalizationVersionsData: appWebLocalizationVersionsData,
|
webLocalizationVersionsData: appWebLocalizationVersionsData,
|
||||||
countdownFestivalListData: countdownFestivalListData,
|
countdownFestivalListData: _fixFestivalCountdownListDateTime(countdownFestivalListData),
|
||||||
);
|
);
|
||||||
_updateSCServerStatus();
|
_updateSCServerStatus();
|
||||||
_loadRRS();
|
_loadRRS();
|
||||||
@@ -248,6 +249,31 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
checkLocalizationUpdate();
|
checkLocalizationUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 节日已过7天时,更新为下一年的时间
|
||||||
|
List<CountdownFestivalItemData> _fixFestivalCountdownListDateTime(List<CountdownFestivalItemData> list) {
|
||||||
|
final now = DateTime.now();
|
||||||
|
|
||||||
|
return list.map((item) {
|
||||||
|
if (item.time == null) return item;
|
||||||
|
final itemDateTime = DateTime.fromMillisecondsSinceEpoch(item.time! * 1000);
|
||||||
|
final itemDatePlusSeven = itemDateTime.add(const Duration(days: 7));
|
||||||
|
if (itemDatePlusSeven.isBefore(now)) {
|
||||||
|
final nextYearDate = DateTime(
|
||||||
|
now.year + 1,
|
||||||
|
itemDateTime.month,
|
||||||
|
itemDateTime.day,
|
||||||
|
itemDateTime.hour,
|
||||||
|
itemDateTime.minute,
|
||||||
|
itemDateTime.second,
|
||||||
|
);
|
||||||
|
final newTimestamp = (nextYearDate.millisecondsSinceEpoch / 1000).round();
|
||||||
|
return CountdownFestivalItemData(name: item.name, time: newTimestamp, icon: item.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _updateSCServerStatus() async {
|
Future<void> _updateSCServerStatus() async {
|
||||||
try {
|
try {
|
||||||
final s = await Api.getScServerStatus();
|
final s = await Api.getScServerStatus();
|
||||||
@@ -336,14 +362,12 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
ref.read(localizationUIModelProvider.notifier).onChangeGameInstallPath(value);
|
ref.read(localizationUIModelProvider.notifier).onChangeGameInstallPath(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> doLaunchGame(
|
Future<void> doLaunchGame(// ignore: avoid_build_context_in_providers
|
||||||
// ignore: avoid_build_context_in_providers
|
BuildContext context,
|
||||||
BuildContext context,
|
String launchExe,
|
||||||
String launchExe,
|
List<String> args,
|
||||||
List<String> args,
|
String installPath,
|
||||||
String installPath,
|
String? processorAffinity,) async {
|
||||||
String? processorAffinity,
|
|
||||||
) async {
|
|
||||||
var runningMap = Map<String, bool>.from(state.isGameRunning);
|
var runningMap = Map<String, bool>.from(state.isGameRunning);
|
||||||
runningMap[installPath] = true;
|
runningMap[installPath] = true;
|
||||||
state = state.copyWith(isGameRunning: runningMap);
|
state = state.copyWith(isGameRunning: runningMap);
|
||||||
|
Reference in New Issue
Block a user