mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 10:14:45 +08:00
feat: log 分析器
This commit is contained in:
@ -7,6 +7,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:starcitizen_doctor/app.dart';
|
||||
import 'package:starcitizen_doctor/common/helper/log_helper.dart';
|
||||
import 'package:starcitizen_doctor/generated/l10n.dart';
|
||||
import 'package:starcitizen_doctor/ui/tools/log_analyze_ui/log_analyze_ui.dart';
|
||||
|
||||
import 'base_utils.dart';
|
||||
@ -21,6 +23,7 @@ class MultiWindowAppState with _$MultiWindowAppState {
|
||||
required String backgroundColor,
|
||||
required String menuColor,
|
||||
required String micaColor,
|
||||
required List<String> gameInstallPaths,
|
||||
String? languageCode,
|
||||
String? countryCode,
|
||||
}) = _MultiWindowAppState;
|
||||
@ -29,12 +32,17 @@ class MultiWindowAppState with _$MultiWindowAppState {
|
||||
}
|
||||
|
||||
class MultiWindowManager {
|
||||
static Future<void> launchSubWindow(String type, AppGlobalState appGlobalState) async {
|
||||
static Future<void> launchSubWindow(String type, String title, AppGlobalState appGlobalState) async {
|
||||
final gameInstallPaths = await SCLoggerHelper.getGameInstallPath(await SCLoggerHelper.getLauncherLogList() ?? []);
|
||||
final window = await DesktopMultiWindow.createWindow(jsonEncode({
|
||||
'window_type': type,
|
||||
'app_state': _appStateToWindowState(appGlobalState).toJson(),
|
||||
'app_state': _appStateToWindowState(
|
||||
appGlobalState,
|
||||
gameInstallPaths: gameInstallPaths,
|
||||
).toJson(),
|
||||
}));
|
||||
window.setTitle("Log 分析器");
|
||||
window.setFrame(const Rect.fromLTWH(0, 0, 900, 1200));
|
||||
window.setTitle(title);
|
||||
await window.center();
|
||||
await window.show();
|
||||
// sendAppStateBroadcast(appGlobalState);
|
||||
@ -48,29 +56,28 @@ class MultiWindowManager {
|
||||
);
|
||||
}
|
||||
|
||||
static MultiWindowAppState _appStateToWindowState(AppGlobalState appGlobalState) {
|
||||
static MultiWindowAppState _appStateToWindowState(AppGlobalState appGlobalState, {List<String>? gameInstallPaths}) {
|
||||
return MultiWindowAppState(
|
||||
backgroundColor: colorToHexCode(appGlobalState.themeConf.backgroundColor),
|
||||
menuColor: colorToHexCode(appGlobalState.themeConf.menuColor),
|
||||
micaColor: colorToHexCode(appGlobalState.themeConf.micaColor),
|
||||
languageCode: appGlobalState.appLocale?.languageCode,
|
||||
countryCode: appGlobalState.appLocale?.countryCode,
|
||||
gameInstallPaths: gameInstallPaths ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
static void runSubWindowApp(List<String> args) {
|
||||
final argument = args[2].isEmpty ? const {} : jsonDecode(args[2]) as Map<String, dynamic>;
|
||||
final windowAppState = MultiWindowAppState.fromJson(argument['app_state'] ?? {});
|
||||
Widget? windowWidget;
|
||||
switch (argument["window_type"]) {
|
||||
case "log_analyze":
|
||||
windowWidget = const ToolsLogAnalyzeDialogUI();
|
||||
windowWidget = ToolsLogAnalyzeDialogUI(appState: windowAppState);
|
||||
break;
|
||||
default:
|
||||
throw Exception('Unknown window type');
|
||||
}
|
||||
|
||||
final windowAppState = MultiWindowAppState.fromJson(argument['app_state'] ?? {});
|
||||
|
||||
return runApp(ProviderScope(
|
||||
child: FluentApp(
|
||||
title: "StarCitizenToolBox",
|
||||
@ -81,8 +88,9 @@ class MultiWindowManager {
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
FluentLocalizations.delegate,
|
||||
S.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('en', 'US')],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
home: windowWidget,
|
||||
theme: FluentThemeData(
|
||||
brightness: Brightness.dark,
|
||||
@ -94,10 +102,10 @@ class MultiWindowManager {
|
||||
micaBackgroundColor: HexColor(windowAppState.micaColor),
|
||||
buttonTheme: ButtonThemeData(
|
||||
defaultButtonStyle: ButtonStyle(
|
||||
shape: WidgetStateProperty.all(RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
side: BorderSide(color: Colors.white.withValues(alpha: .01)))),
|
||||
))),
|
||||
shape: WidgetStateProperty.all(RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
side: BorderSide(color: Colors.white.withValues(alpha: .01)))),
|
||||
))),
|
||||
locale: windowAppState.languageCode != null
|
||||
? Locale(windowAppState.languageCode!, windowAppState.countryCode)
|
||||
: null,
|
||||
|
@ -23,6 +23,7 @@ mixin _$MultiWindowAppState {
|
||||
String get backgroundColor => throw _privateConstructorUsedError;
|
||||
String get menuColor => throw _privateConstructorUsedError;
|
||||
String get micaColor => throw _privateConstructorUsedError;
|
||||
List<String> get gameInstallPaths => throw _privateConstructorUsedError;
|
||||
String? get languageCode => throw _privateConstructorUsedError;
|
||||
String? get countryCode => throw _privateConstructorUsedError;
|
||||
|
||||
@ -46,6 +47,7 @@ abstract class $MultiWindowAppStateCopyWith<$Res> {
|
||||
{String backgroundColor,
|
||||
String menuColor,
|
||||
String micaColor,
|
||||
List<String> gameInstallPaths,
|
||||
String? languageCode,
|
||||
String? countryCode});
|
||||
}
|
||||
@ -68,6 +70,7 @@ class _$MultiWindowAppStateCopyWithImpl<$Res, $Val extends MultiWindowAppState>
|
||||
Object? backgroundColor = null,
|
||||
Object? menuColor = null,
|
||||
Object? micaColor = null,
|
||||
Object? gameInstallPaths = null,
|
||||
Object? languageCode = freezed,
|
||||
Object? countryCode = freezed,
|
||||
}) {
|
||||
@ -84,6 +87,10 @@ class _$MultiWindowAppStateCopyWithImpl<$Res, $Val extends MultiWindowAppState>
|
||||
? _value.micaColor
|
||||
: micaColor // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
gameInstallPaths: null == gameInstallPaths
|
||||
? _value.gameInstallPaths
|
||||
: gameInstallPaths // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
languageCode: freezed == languageCode
|
||||
? _value.languageCode
|
||||
: languageCode // ignore: cast_nullable_to_non_nullable
|
||||
@ -108,6 +115,7 @@ abstract class _$$MultiWindowAppStateImplCopyWith<$Res>
|
||||
{String backgroundColor,
|
||||
String menuColor,
|
||||
String micaColor,
|
||||
List<String> gameInstallPaths,
|
||||
String? languageCode,
|
||||
String? countryCode});
|
||||
}
|
||||
@ -128,6 +136,7 @@ class __$$MultiWindowAppStateImplCopyWithImpl<$Res>
|
||||
Object? backgroundColor = null,
|
||||
Object? menuColor = null,
|
||||
Object? micaColor = null,
|
||||
Object? gameInstallPaths = null,
|
||||
Object? languageCode = freezed,
|
||||
Object? countryCode = freezed,
|
||||
}) {
|
||||
@ -144,6 +153,10 @@ class __$$MultiWindowAppStateImplCopyWithImpl<$Res>
|
||||
? _value.micaColor
|
||||
: micaColor // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
gameInstallPaths: null == gameInstallPaths
|
||||
? _value._gameInstallPaths
|
||||
: gameInstallPaths // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
languageCode: freezed == languageCode
|
||||
? _value.languageCode
|
||||
: languageCode // ignore: cast_nullable_to_non_nullable
|
||||
@ -163,8 +176,10 @@ class _$MultiWindowAppStateImpl implements _MultiWindowAppState {
|
||||
{required this.backgroundColor,
|
||||
required this.menuColor,
|
||||
required this.micaColor,
|
||||
required final List<String> gameInstallPaths,
|
||||
this.languageCode,
|
||||
this.countryCode});
|
||||
this.countryCode})
|
||||
: _gameInstallPaths = gameInstallPaths;
|
||||
|
||||
factory _$MultiWindowAppStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$MultiWindowAppStateImplFromJson(json);
|
||||
@ -175,6 +190,15 @@ class _$MultiWindowAppStateImpl implements _MultiWindowAppState {
|
||||
final String menuColor;
|
||||
@override
|
||||
final String micaColor;
|
||||
final List<String> _gameInstallPaths;
|
||||
@override
|
||||
List<String> get gameInstallPaths {
|
||||
if (_gameInstallPaths is EqualUnmodifiableListView)
|
||||
return _gameInstallPaths;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_gameInstallPaths);
|
||||
}
|
||||
|
||||
@override
|
||||
final String? languageCode;
|
||||
@override
|
||||
@ -182,7 +206,7 @@ class _$MultiWindowAppStateImpl implements _MultiWindowAppState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MultiWindowAppState(backgroundColor: $backgroundColor, menuColor: $menuColor, micaColor: $micaColor, languageCode: $languageCode, countryCode: $countryCode)';
|
||||
return 'MultiWindowAppState(backgroundColor: $backgroundColor, menuColor: $menuColor, micaColor: $micaColor, gameInstallPaths: $gameInstallPaths, languageCode: $languageCode, countryCode: $countryCode)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -196,6 +220,8 @@ class _$MultiWindowAppStateImpl implements _MultiWindowAppState {
|
||||
other.menuColor == menuColor) &&
|
||||
(identical(other.micaColor, micaColor) ||
|
||||
other.micaColor == micaColor) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._gameInstallPaths, _gameInstallPaths) &&
|
||||
(identical(other.languageCode, languageCode) ||
|
||||
other.languageCode == languageCode) &&
|
||||
(identical(other.countryCode, countryCode) ||
|
||||
@ -204,8 +230,14 @@ class _$MultiWindowAppStateImpl implements _MultiWindowAppState {
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, backgroundColor, menuColor,
|
||||
micaColor, languageCode, countryCode);
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
backgroundColor,
|
||||
menuColor,
|
||||
micaColor,
|
||||
const DeepCollectionEquality().hash(_gameInstallPaths),
|
||||
languageCode,
|
||||
countryCode);
|
||||
|
||||
/// Create a copy of MultiWindowAppState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@ -229,6 +261,7 @@ abstract class _MultiWindowAppState implements MultiWindowAppState {
|
||||
{required final String backgroundColor,
|
||||
required final String menuColor,
|
||||
required final String micaColor,
|
||||
required final List<String> gameInstallPaths,
|
||||
final String? languageCode,
|
||||
final String? countryCode}) = _$MultiWindowAppStateImpl;
|
||||
|
||||
@ -242,6 +275,8 @@ abstract class _MultiWindowAppState implements MultiWindowAppState {
|
||||
@override
|
||||
String get micaColor;
|
||||
@override
|
||||
List<String> get gameInstallPaths;
|
||||
@override
|
||||
String? get languageCode;
|
||||
@override
|
||||
String? get countryCode;
|
||||
|
@ -12,6 +12,9 @@ _$MultiWindowAppStateImpl _$$MultiWindowAppStateImplFromJson(
|
||||
backgroundColor: json['backgroundColor'] as String,
|
||||
menuColor: json['menuColor'] as String,
|
||||
micaColor: json['micaColor'] as String,
|
||||
gameInstallPaths: (json['gameInstallPaths'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
languageCode: json['languageCode'] as String?,
|
||||
countryCode: json['countryCode'] as String?,
|
||||
);
|
||||
@ -22,6 +25,7 @@ Map<String, dynamic> _$$MultiWindowAppStateImplToJson(
|
||||
'backgroundColor': instance.backgroundColor,
|
||||
'menuColor': instance.menuColor,
|
||||
'micaColor': instance.micaColor,
|
||||
'gameInstallPaths': instance.gameInstallPaths,
|
||||
'languageCode': instance.languageCode,
|
||||
'countryCode': instance.countryCode,
|
||||
};
|
||||
|
Reference in New Issue
Block a user