[feat] defaultly open to the last version launched on startup

This commit is contained in:
silentrald
2024-10-05 09:53:03 +08:00
parent 18adf064f3
commit 0a64e71cf8
3 changed files with 19 additions and 1 deletions
@@ -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);
}
@@ -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;
+13 -1
View File
@@ -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) {