From 0a64e71cf82e40e40a5a6f7179d044c469a3e444 Mon Sep 17 00:00:00 2001 From: silentrald Date: Sat, 5 Oct 2024 09:53:03 +0800 Subject: [PATCH] [feat] defaultly open to the last version launched on startup --- .../services/bs-launcher/bs-launcher.service.ts | 5 +++++ src/main/services/static-configuration.service.ts | 1 + src/renderer/windows/App.tsx | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/services/bs-launcher/bs-launcher.service.ts b/src/main/services/bs-launcher/bs-launcher.service.ts index 96011b9b..94692ccd 100644 --- a/src/main/services/bs-launcher/bs-launcher.service.ts +++ b/src/main/services/bs-launcher/bs-launcher.service.ts @@ -21,6 +21,7 @@ import { OculusLauncherService } from "./oculus-launcher.service"; import { BSVersion } from "shared/bs-version.interface"; import { BsStore } from "../../../shared/models/bs-store.enum"; import { LaunchMod, LaunchMods } from "shared/models/bs-launch/launch-option.interface"; +import { StaticConfigurationService } from "../static-configuration.service"; export class BSLauncherService { private static instance: BSLauncherService; @@ -32,6 +33,7 @@ export class BSLauncherService { private readonly remoteVersion: BSVersionLibService; private readonly steamLauncher: SteamLauncherService; private readonly oculusLauncher: OculusLauncherService; + private readonly staticConfig: StaticConfigurationService; public static getInstance(): BSLauncherService { if (!BSLauncherService.instance) { @@ -48,6 +50,7 @@ export class BSLauncherService { this.remoteVersion = BSVersionLibService.getInstance(); this.steamLauncher = SteamLauncherService.getInstance(); this.oculusLauncher = OculusLauncherService.getInstance(); + this.staticConfig = StaticConfigurationService.getInstance(); this.bsmProtocolService.on("launch", link => { log.info("Launch from bsm protocol", link.toString()); @@ -73,6 +76,8 @@ export class BSLauncherService { return throwError(() => new Error("Unable to get launcher for the provided version")); } + this.staticConfig.set("last-version-launched", launchOptions.version); + return launcher.launch(launchOptions); } diff --git a/src/main/services/static-configuration.service.ts b/src/main/services/static-configuration.service.ts index 0a90c607..47e99245 100644 --- a/src/main/services/static-configuration.service.ts +++ b/src/main/services/static-configuration.service.ts @@ -89,6 +89,7 @@ export interface StaticConfigKeyValues { "disable-hadware-acceleration": boolean; "use-symlinks": boolean; "use-system-proxy": boolean; + "last-version-launched": BSVersion; // Linux Specific static configs "proton-folder": string; diff --git a/src/renderer/windows/App.tsx b/src/renderer/windows/App.tsx index 4982b93e..83f70588 100644 --- a/src/renderer/windows/App.tsx +++ b/src/renderer/windows/App.tsx @@ -23,6 +23,7 @@ import { ConfigurationService } from "renderer/services/configuration.service"; import { OsDiagnosticService } from "renderer/services/os-diagnostic.service"; import { useService } from "renderer/hooks/use-service.hook"; import { SetupService } from "renderer/services/setup.service"; +import { StaticConfigurationService } from "renderer/services/static-configuration.service"; export default function App() { @@ -34,6 +35,7 @@ export default function App() { const notification = useService(NotificationService); const config = useService(ConfigurationService); const setup = useService(SetupService); + const staticConfig = useService(StaticConfigurationService); const location = useLocation(); const navigate = useNavigate(); @@ -41,10 +43,20 @@ export default function App() { useEffect(() => { setup.check() .then(() => { + navigateToDefaultPage(); checkOneClicks(); - }) + }); }, []); + const navigateToDefaultPage = async () => { + const version = await staticConfig.get("last-version-launched"); + if (!version) { + return; + } + + navigate(`/bs-version/${version.BSVersion}`, { state: version }); + }; + const checkOneClicks = async () => { if (config.get("not-remind-oneclick") === true) {