mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-08-21 17:36:58 +08:00
fix: game login
This commit is contained in:
@@ -219,7 +219,15 @@ InitWebLocalization();
|
|||||||
async function getRSILauncherToken(channelId) {
|
async function getRSILauncherToken(channelId) {
|
||||||
if (!window.location.href.includes("robertsspaceindustries.com")) return;
|
if (!window.location.href.includes("robertsspaceindustries.com")) return;
|
||||||
|
|
||||||
let loginBodyElement = $(".c-form.c-signIn");
|
// check if logged in and fix redirect
|
||||||
|
if (window.location.href.endsWith('/connect?jumpto=/account/dashboard')) {
|
||||||
|
if (document.body.textContent.trim() === "/account/dashboard") {
|
||||||
|
window.location.href = "https://robertsspaceindustries.com/account/dashboard";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let loginBodyElement = $(".c-form authenticationForm sign_in");
|
||||||
loginBodyElement.show();
|
loginBodyElement.show();
|
||||||
// wait login
|
// wait login
|
||||||
window.chrome.webview.postMessage({ action: 'webview_rsi_login_show_window' });
|
window.chrome.webview.postMessage({ action: 'webview_rsi_login_show_window' });
|
||||||
|
@@ -83,8 +83,11 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
state = state.copyWith(scInstalledPath: "not_install");
|
state = state.copyWith(scInstalledPath: "not_install");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final scInstallPaths =
|
final scInstallPaths = await SCLoggerHelper.getGameInstallPath(
|
||||||
await SCLoggerHelper.getGameInstallPath(listData, withVersion: AppConf.gameChannels, checkExists: true);
|
listData,
|
||||||
|
withVersion: AppConf.gameChannels,
|
||||||
|
checkExists: true,
|
||||||
|
);
|
||||||
|
|
||||||
String scInstalledPath = "not_install";
|
String scInstalledPath = "not_install";
|
||||||
|
|
||||||
@@ -93,13 +96,19 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
scInstalledPath = scInstallPaths.first;
|
scInstalledPath = scInstallPaths.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final lastScreenInfo =
|
final lastScreenInfo = S.current.home_action_info_scan_complete_valid_directories_found(
|
||||||
S.current.home_action_info_scan_complete_valid_directories_found(scInstallPaths.length.toString());
|
scInstallPaths.length.toString(),
|
||||||
|
);
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
scInstalledPath: scInstalledPath, scInstallPaths: scInstallPaths, lastScreenInfo: lastScreenInfo);
|
scInstalledPath: scInstalledPath,
|
||||||
|
scInstallPaths: scInstallPaths,
|
||||||
|
lastScreenInfo: lastScreenInfo,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
scInstalledPath: "not_install", lastScreenInfo: S.current.home_action_info_log_file_parse_fail);
|
scInstalledPath: "not_install",
|
||||||
|
lastScreenInfo: S.current.home_action_info_log_file_parse_fail,
|
||||||
|
);
|
||||||
AnalyticsApi.touch("error_launchLogs");
|
AnalyticsApi.touch("error_launchLogs");
|
||||||
// showToast(context!,
|
// showToast(context!,
|
||||||
// "${S.current.home_action_info_log_file_parse_fail} \n请关闭游戏,退出RSI启动器后重试,若仍有问题,请使用工具箱中的 RSI Launcher log 修复。");
|
// "${S.current.home_action_info_log_file_parse_fail} \n请关闭游戏,退出RSI启动器后重试,若仍有问题,请使用工具箱中的 RSI Launcher log 修复。");
|
||||||
@@ -127,8 +136,14 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ignore: avoid_build_context_in_providers
|
// ignore: avoid_build_context_in_providers
|
||||||
Future<void> goWebView(BuildContext context, String title, String url,
|
Future<void> goWebView(
|
||||||
{bool useLocalization = false, bool loginMode = false, RsiLoginCallback? rsiLoginCallback}) async {
|
BuildContext context,
|
||||||
|
String title,
|
||||||
|
String url, {
|
||||||
|
bool useLocalization = false,
|
||||||
|
bool loginMode = false,
|
||||||
|
RsiLoginCallback? rsiLoginCallback,
|
||||||
|
}) 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");
|
||||||
@@ -138,11 +153,9 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
final ok = await showConfirmDialogs(
|
final ok = await showConfirmDialogs(
|
||||||
context,
|
context,
|
||||||
S.current.home_action_title_star_citizen_website_localization,
|
S.current.home_action_title_star_citizen_website_localization,
|
||||||
Text(
|
Text(S.current.home_action_info_web_localization_plugin_disclaimer, style: const TextStyle(fontSize: 16)),
|
||||||
S.current.home_action_info_web_localization_plugin_disclaimer,
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .6),
|
||||||
style: const TextStyle(fontSize: 16),
|
);
|
||||||
),
|
|
||||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .6));
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (loginMode) {
|
if (loginMode) {
|
||||||
rsiLoginCallback?.call(null, false);
|
rsiLoginCallback?.call(null, false);
|
||||||
@@ -189,12 +202,9 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
|
|
||||||
void _init() {
|
void _init() {
|
||||||
reScanPath();
|
reScanPath();
|
||||||
_serverUpdateTimer = Timer.periodic(
|
_serverUpdateTimer = Timer.periodic(const Duration(minutes: 10), (timer) {
|
||||||
const Duration(minutes: 10),
|
|
||||||
(timer) {
|
|
||||||
_updateSCServerStatus();
|
_updateSCServerStatus();
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
_appUpdateTimer = Timer.periodic(const Duration(minutes: 30), (timer) {
|
_appUpdateTimer = Timer.periodic(const Duration(minutes: 30), (timer) {
|
||||||
checkLocalizationUpdate();
|
checkLocalizationUpdate();
|
||||||
@@ -222,11 +232,13 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final appWebLocalizationVersionsData = AppWebLocalizationVersionsData.fromJson(
|
final appWebLocalizationVersionsData = AppWebLocalizationVersionsData.fromJson(
|
||||||
json.decode((await RSHttp.getText("${URLConf.webTranslateHomeUrl}/versions.json"))));
|
json.decode((await RSHttp.getText("${URLConf.webTranslateHomeUrl}/versions.json"))),
|
||||||
|
);
|
||||||
final countdownFestivalListData = await Api.getFestivalCountdownList();
|
final countdownFestivalListData = await Api.getFestivalCountdownList();
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
webLocalizationVersionsData: appWebLocalizationVersionsData,
|
webLocalizationVersionsData: appWebLocalizationVersionsData,
|
||||||
countdownFestivalListData: countdownFestivalListData);
|
countdownFestivalListData: countdownFestivalListData,
|
||||||
|
);
|
||||||
_updateSCServerStatus();
|
_updateSCServerStatus();
|
||||||
_loadRRS();
|
_loadRRS();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -255,14 +267,21 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
dPrint("RSS update Success !");
|
dPrint("RSS update Success !");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dPrint("_loadRRS Error:$e");
|
dPrint("_loadRRS Error:$e");
|
||||||
|
// 避免持续显示 loading
|
||||||
|
if (state.rssTextItems == null) {
|
||||||
|
state = state.copyWith(rssTextItems: []);
|
||||||
|
}
|
||||||
|
if (state.rssVideoItems == null) {
|
||||||
|
state = state.copyWith(rssVideoItems: []);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkLocalizationUpdate({bool skipReload = false}) async {
|
Future<void> checkLocalizationUpdate({bool skipReload = false}) async {
|
||||||
dPrint("_checkLocalizationUpdate");
|
dPrint("_checkLocalizationUpdate");
|
||||||
final updates = await (ref.read(localizationUIModelProvider.notifier))
|
final updates = await (ref.read(
|
||||||
.checkLangUpdate(skipReload: skipReload)
|
localizationUIModelProvider.notifier,
|
||||||
.unwrap<List<String>>();
|
)).checkLangUpdate(skipReload: skipReload).unwrap<List<String>>();
|
||||||
if (updates == null || updates.isEmpty) {
|
if (updates == null || updates.isEmpty) {
|
||||||
state = state.copyWith(localizationUpdateInfo: null);
|
state = state.copyWith(localizationUpdateInfo: null);
|
||||||
return;
|
return;
|
||||||
@@ -276,7 +295,8 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
summary: S.current.home_localization_new_version_available,
|
summary: S.current.home_localization_new_version_available,
|
||||||
body: S.current.home_localization_new_version_installed(updates.first),
|
body: S.current.home_localization_new_version_installed(updates.first),
|
||||||
appName: S.current.home_title_app_name,
|
appName: S.current.home_title_app_name,
|
||||||
appId: ConstConf.win32AppId);
|
appId: ConstConf.win32AppId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,8 +316,12 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
showDialog(context: context, dismissWithEsc: false, builder: (context) => HomeGameLoginDialogUI(context));
|
showDialog(context: context, dismissWithEsc: false, builder: (context) => HomeGameLoginDialogUI(context));
|
||||||
} else {
|
} else {
|
||||||
final ok = await showConfirmDialogs(
|
final ok = await showConfirmDialogs(
|
||||||
context, S.current.home_info_one_click_launch_warning, Text(S.current.home_info_account_security_warning),
|
context,
|
||||||
confirm: S.current.home_action_install_microsoft_store_version, cancel: S.current.home_action_cancel);
|
S.current.home_info_one_click_launch_warning,
|
||||||
|
Text(S.current.home_info_account_security_warning),
|
||||||
|
confirm: S.current.home_action_install_microsoft_store_version,
|
||||||
|
cancel: S.current.home_action_cancel,
|
||||||
|
);
|
||||||
if (ok == true) {
|
if (ok == true) {
|
||||||
await launchUrlString("https://apps.microsoft.com/detail/9NF3SWFWNKL1?launch=true");
|
await launchUrlString("https://apps.microsoft.com/detail/9NF3SWFWNKL1?launch=true");
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
@@ -318,7 +342,8 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
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);
|
||||||
@@ -328,8 +353,16 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
result = await Process.run(launchExe, args);
|
result = await Process.run(launchExe, args);
|
||||||
} else {
|
} else {
|
||||||
dPrint("set Affinity === $processorAffinity launchExe === $launchExe");
|
dPrint("set Affinity === $processorAffinity launchExe === $launchExe");
|
||||||
result = await Process.run(
|
result = await Process.run("cmd.exe", [
|
||||||
"cmd.exe", ['/C', 'Start', '"StarCitizen"', '/High', '/Affinity', processorAffinity, launchExe, ...args]);
|
'/C',
|
||||||
|
'Start',
|
||||||
|
'"StarCitizen"',
|
||||||
|
'/High',
|
||||||
|
'/Affinity',
|
||||||
|
processorAffinity,
|
||||||
|
launchExe,
|
||||||
|
...args,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
dPrint('Exit code: ${result.exitCode}');
|
dPrint('Exit code: ${result.exitCode}');
|
||||||
dPrint('stdout: ${result.stdout}');
|
dPrint('stdout: ${result.stdout}');
|
||||||
@@ -356,7 +389,9 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
result.stdout ?? "",
|
result.stdout ?? "",
|
||||||
result.stderr ?? "",
|
result.stderr ?? "",
|
||||||
exitInfo == null ? S.current.home_action_info_unknown_error : exitInfo.key,
|
exitInfo == null ? S.current.home_action_info_unknown_error : exitInfo.key,
|
||||||
hasUrl ? S.current.home_action_info_check_web_link : exitInfo?.value ?? ""));
|
hasUrl ? S.current.home_action_info_check_web_link : exitInfo?.value ?? "",
|
||||||
|
),
|
||||||
|
);
|
||||||
if (hasUrl) {
|
if (hasUrl) {
|
||||||
await Future.delayed(const Duration(seconds: 3));
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
launchUrlString(exitInfo!.value);
|
launchUrlString(exitInfo!.value);
|
||||||
|
Reference in New Issue
Block a user