mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 12:23:43 +08:00
ee
This commit is contained in:
parent
6494c7971e
commit
7c833fe3ac
@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
||||||
|
import 'package:hexcolor/hexcolor.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:starcitizen_doctor/api/analytics.dart';
|
import 'package:starcitizen_doctor/api/analytics.dart';
|
||||||
@ -43,6 +44,10 @@ class AppConf {
|
|||||||
|
|
||||||
static late final WindowsDeviceInfo windowsDeviceInfo;
|
static late final WindowsDeviceInfo windowsDeviceInfo;
|
||||||
|
|
||||||
|
static Color? colorBackground;
|
||||||
|
static Color? colorMenu;
|
||||||
|
static Color? colorMica;
|
||||||
|
|
||||||
static const isMSE =
|
static const isMSE =
|
||||||
String.fromEnvironment("MSE", defaultValue: "false") == "true";
|
String.fromEnvironment("MSE", defaultValue: "false") == "true";
|
||||||
|
|
||||||
@ -80,6 +85,11 @@ class AppConf {
|
|||||||
await SystemHelper.initPowershellPath();
|
await SystemHelper.initPowershellPath();
|
||||||
isRunningAdmin = await globalUIModel.checkAdmin();
|
isRunningAdmin = await globalUIModel.checkAdmin();
|
||||||
|
|
||||||
|
/// init defaultColor
|
||||||
|
colorBackground = HexColor("#132431").withOpacity(.75);
|
||||||
|
colorMenu = HexColor("#132431").withOpacity(.95);
|
||||||
|
colorMica = HexColor("#0A3142");
|
||||||
|
|
||||||
/// init windows
|
/// init windows
|
||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
windowManager.waitUntilReadyToShow().then((_) async {
|
windowManager.waitUntilReadyToShow().then((_) async {
|
||||||
@ -100,7 +110,7 @@ class AppConf {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await _checkUpdate();
|
await checkUpdate();
|
||||||
AnalyticsApi.touch("launch");
|
AnalyticsApi.touch("launch");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +118,7 @@ class AppConf {
|
|||||||
return "${AppConf.applicationSupportDir}/._upgrade";
|
return "${AppConf.applicationSupportDir}/._upgrade";
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> _checkUpdate() async {
|
static Future<void> checkUpdate() async {
|
||||||
// clean path
|
// clean path
|
||||||
if (!isMSE) {
|
if (!isMSE) {
|
||||||
final dir = Directory(getUpgradePath());
|
final dir = Directory(getUpgradePath());
|
||||||
@ -118,6 +128,7 @@ class AppConf {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
networkVersionData = await Api.getAppVersion();
|
networkVersionData = await Api.getAppVersion();
|
||||||
|
globalUIModel.checkActivityThemeColor();
|
||||||
dPrint(
|
dPrint(
|
||||||
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData?.lastVersionCode}");
|
"lastVersion=${networkVersionData?.lastVersion} ${networkVersionData?.lastVersionCode}");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/// MSE_lastVersionCode : 27
|
/// MSE_lastVersionCode : 27
|
||||||
/// MSE_minVersionCode : 27
|
/// MSE_minVersionCode : 27
|
||||||
/// p4kDownloadUrl : "https://p4k.42kit.com/Data.p4k"
|
/// p4kDownloadUrl : "https://p4k.42kit.com/Data.p4k"
|
||||||
/// activityColors : {"enable":true,"startTime":1700236800000,"endTime":1701360000000,"background":"","menu":"","mica":""}
|
/// activityColors : {"enable":true,"startTime":1700236800000,"endTime":1701360000000,"background":"#290859","menu":"#310666","mica":"#270452"}
|
||||||
|
|
||||||
class AppVersionData {
|
class AppVersionData {
|
||||||
AppVersionData({
|
AppVersionData({
|
||||||
@ -57,9 +57,9 @@ class AppVersionData {
|
|||||||
/// enable : true
|
/// enable : true
|
||||||
/// startTime : 1700236800000
|
/// startTime : 1700236800000
|
||||||
/// endTime : 1701360000000
|
/// endTime : 1701360000000
|
||||||
/// background : ""
|
/// background : "#290859"
|
||||||
/// menu : ""
|
/// menu : "#310666"
|
||||||
/// mica : ""
|
/// mica : "#270452"
|
||||||
|
|
||||||
class ActivityColors {
|
class ActivityColors {
|
||||||
ActivityColors({
|
ActivityColors({
|
||||||
@ -79,8 +79,8 @@ class ActivityColors {
|
|||||||
mica = json['mica'];
|
mica = json['mica'];
|
||||||
}
|
}
|
||||||
bool? enable;
|
bool? enable;
|
||||||
num? startTime;
|
int? startTime;
|
||||||
num? endTime;
|
int? endTime;
|
||||||
String? background;
|
String? background;
|
||||||
String? menu;
|
String? menu;
|
||||||
String? mica;
|
String? mica;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:hexcolor/hexcolor.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
|
||||||
import 'api/api.dart';
|
|
||||||
import 'base/ui_model.dart';
|
import 'base/ui_model.dart';
|
||||||
import 'common/conf.dart';
|
import 'common/conf.dart';
|
||||||
import 'common/helper/system_helper.dart';
|
import 'common/helper/system_helper.dart';
|
||||||
@ -16,16 +17,13 @@ final globalUIModel = AppGlobalUIModel();
|
|||||||
final globalUIModelProvider = ChangeNotifierProvider((ref) => globalUIModel);
|
final globalUIModelProvider = ChangeNotifierProvider((ref) => globalUIModel);
|
||||||
|
|
||||||
class AppGlobalUIModel extends BaseUIModel {
|
class AppGlobalUIModel extends BaseUIModel {
|
||||||
|
Timer? activityThemeColorTimer;
|
||||||
|
|
||||||
String colorBackground = "#132431";
|
Future<bool> doCheckUpdate(BuildContext context, {bool init = true}) async {
|
||||||
String colorMenu = "#122D42";
|
|
||||||
String colorMica = "#0A3142";
|
|
||||||
|
|
||||||
Future<bool> checkUpdate(BuildContext context, {bool init = true}) async {
|
|
||||||
if (AppConf.isMSE) return true;
|
if (AppConf.isMSE) return true;
|
||||||
if (!init) {
|
if (!init) {
|
||||||
try {
|
try {
|
||||||
AppConf.networkVersionData = await Api.getAppVersion();
|
await AppConf.checkUpdate();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
@ -75,4 +73,45 @@ class AppGlobalUIModel extends BaseUIModel {
|
|||||||
await Future.delayed(const Duration(seconds: 2));
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkActivityThemeColor() {
|
||||||
|
if (activityThemeColorTimer != null) {
|
||||||
|
activityThemeColorTimer?.cancel();
|
||||||
|
activityThemeColorTimer = null;
|
||||||
|
}
|
||||||
|
if (AppConf.networkVersionData == null ||
|
||||||
|
AppConf.networkVersionData?.activityColors?.enable != true) return;
|
||||||
|
|
||||||
|
final startTime = AppConf.networkVersionData!.activityColors?.startTime;
|
||||||
|
final endTime = AppConf.networkVersionData!.activityColors?.endTime;
|
||||||
|
if (startTime == null || endTime == null) return;
|
||||||
|
final now = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
|
dPrint("now == $now start == $startTime end == $endTime");
|
||||||
|
if (now < startTime) {
|
||||||
|
activityThemeColorTimer = Timer(
|
||||||
|
Duration(milliseconds: startTime - now), checkActivityThemeColor);
|
||||||
|
dPrint("start Timer ....");
|
||||||
|
} else if (now >= startTime && now <= endTime) {
|
||||||
|
dPrint("update Color ....");
|
||||||
|
// update Color
|
||||||
|
final colorCfg = AppConf.networkVersionData!.activityColors;
|
||||||
|
AppConf.colorBackground =
|
||||||
|
HexColor(colorCfg?.background ?? "#132431").withOpacity(.75);
|
||||||
|
AppConf.colorMenu =
|
||||||
|
HexColor(colorCfg?.menu ?? "#132431").withOpacity(.95);
|
||||||
|
AppConf.colorMica = HexColor(colorCfg?.mica ?? "#0A3142");
|
||||||
|
notifyListeners();
|
||||||
|
// wait for end
|
||||||
|
activityThemeColorTimer =
|
||||||
|
Timer(Duration(milliseconds: endTime - now), checkActivityThemeColor);
|
||||||
|
} else {
|
||||||
|
dPrint("reset Color ....");
|
||||||
|
AppConf.colorBackground = HexColor("#132431").withOpacity(.75);
|
||||||
|
AppConf.colorMenu = HexColor("#132431").withOpacity(.95);
|
||||||
|
AppConf.colorMica = HexColor("#0A3142");
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:hexcolor/hexcolor.dart';
|
|
||||||
import 'package:starcitizen_doctor/base/ui_model.dart';
|
import 'package:starcitizen_doctor/base/ui_model.dart';
|
||||||
import 'package:starcitizen_doctor/common/conf.dart';
|
import 'package:starcitizen_doctor/common/conf.dart';
|
||||||
import 'package:starcitizen_doctor/ui/index_ui_model.dart';
|
import 'package:starcitizen_doctor/ui/index_ui_model.dart';
|
||||||
@ -31,16 +30,14 @@ class AppUI extends BaseUI {
|
|||||||
title: "StarCitizen Doctor",
|
title: "StarCitizen Doctor",
|
||||||
restorationScopeId: "Doctor",
|
restorationScopeId: "Doctor",
|
||||||
themeMode: ThemeMode.dark,
|
themeMode: ThemeMode.dark,
|
||||||
// theme: FluentThemeData(brightness: Brightness.light),
|
theme: FluentThemeData(
|
||||||
darkTheme: FluentThemeData(
|
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
fontFamily: "SourceHanSansCN-Regular",
|
fontFamily: "SourceHanSansCN-Regular",
|
||||||
navigationPaneTheme: NavigationPaneThemeData(
|
navigationPaneTheme: NavigationPaneThemeData(
|
||||||
backgroundColor:
|
backgroundColor: AppConf.colorBackground,
|
||||||
HexColor(globalUIModel.colorBackground).withOpacity(.75),
|
|
||||||
),
|
),
|
||||||
menuColor: HexColor(globalUIModel.colorMenu).withOpacity(.95),
|
menuColor: AppConf.colorMenu,
|
||||||
micaBackgroundColor: HexColor(globalUIModel.colorMica),
|
micaBackgroundColor: AppConf.colorMica,
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: BaseUIContainer(
|
home: BaseUIContainer(
|
||||||
@ -58,7 +55,6 @@ class WindowButtons extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final FluentThemeData theme = FluentTheme.of(context);
|
final FluentThemeData theme = FluentTheme.of(context);
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 138,
|
width: 138,
|
||||||
height: 50,
|
height: 50,
|
||||||
|
@ -9,7 +9,7 @@ class AboutUIModel extends BaseUIModel {
|
|||||||
launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1");
|
launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final hasUpdate = await globalUIModel.checkUpdate(context!);
|
final hasUpdate = await globalUIModel.doCheckUpdate(context!);
|
||||||
if (!hasUpdate) {
|
if (!hasUpdate) {
|
||||||
if (mounted) showToast(context!, "已是最新版本");
|
if (mounted) showToast(context!, "已是最新版本");
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class IndexUIModel extends BaseUIModel {
|
|||||||
void initModel() {
|
void initModel() {
|
||||||
_checkRunTime();
|
_checkRunTime();
|
||||||
Future.delayed(const Duration(milliseconds: 300))
|
Future.delayed(const Duration(milliseconds: 300))
|
||||||
.then((value) => globalUIModel.checkUpdate(context!));
|
.then((value) => globalUIModel.doCheckUpdate(context!));
|
||||||
super.initModel();
|
super.initModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user