From d432d0b592105ef312bdc3d15ef1d5119f6ec1b4 Mon Sep 17 00:00:00 2001 From: silentrald Date: Fri, 31 Jan 2025 22:35:13 +0800 Subject: [PATCH 1/2] [feat] added auto update option on advance settings for windows --- assets/jsons/translations/en.json | 7 +++ src/main/main.ts | 10 ++--- .../services/static-configuration.service.ts | 5 ++- .../pages/settings-page.component.tsx | 43 +++++++++++++++++-- 4 files changed, 54 insertions(+), 11 deletions(-) diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 3054223e7..10489b263 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -319,6 +319,13 @@ "error-notification": { "message": "An error occurred, unable to change system proxy settings." } + }, + "auto-update": { + "title": "Auto Update", + "description": "BSManager will automatically update when you launch the application.", + "error-notification": { + "message": "An error occurred, unable to change auto update settings." + } } } } diff --git a/src/main/main.ts b/src/main/main.ts index ab12b37c9..82d04bd26 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -119,8 +119,6 @@ if (!gotTheLock) { app.whenReady().then(() => { - - app.setAppUserModelId(APP_NAME); initServicesMustBeInitialized(); @@ -132,10 +130,12 @@ if (!gotTheLock) { DeepLinkService.getInstance().dispatchLinkOpened(deepLink); } else if (associatedFile) { FileAssociationService.getInstance().handleFileAssociation(associatedFile); + } else if (process.platform === "linux") { + createWindow("index.html"); } else { - createWindow(process.platform === "linux" - ? "index.html" : "launcher.html" - ); + const autoUpdate = StaticConfigurationService.getInstance().get("auto-update"); + createWindow(autoUpdate === undefined || autoUpdate === true + ? "launcher.html" : "index.html"); } SteamLauncherService.getInstance().restoreSteamVR(); diff --git a/src/main/services/static-configuration.service.ts b/src/main/services/static-configuration.service.ts index 47e99245b..cbc1f23c1 100644 --- a/src/main/services/static-configuration.service.ts +++ b/src/main/services/static-configuration.service.ts @@ -30,8 +30,8 @@ export class StaticConfigurationService { return this.store.has(key); } - public get(key: K): StaticConfigKeyValues[K] { - return this.store.get(key) as StaticConfigKeyValues[K]; + public get(key: K, defaultValue?: StaticConfigKeyValues[K]): StaticConfigKeyValues[K] { + return this.store.get(key, defaultValue) as StaticConfigKeyValues[K]; } public take(key: K, cb: (val: StaticConfigKeyValues[K]) => void): void { @@ -90,6 +90,7 @@ export interface StaticConfigKeyValues { "use-symlinks": boolean; "use-system-proxy": boolean; "last-version-launched": BSVersion; + "auto-update": boolean; // Linux Specific static configs "proton-folder": string; diff --git a/src/renderer/pages/settings-page.component.tsx b/src/renderer/pages/settings-page.component.tsx index 1501162d5..decb32f9a 100644 --- a/src/renderer/pages/settings-page.component.tsx +++ b/src/renderer/pages/settings-page.component.tsx @@ -545,11 +545,17 @@ function AdvancedSettings() { const [hardwareAccelerationEnabled, setHardwareAccelerationEnabled] = useState(true); const [useSymlink, setUseSymlink] = useState(false); const [useSystemProxy, setUseSystemProxy] = useState(false); + const [autoUpdate, setAutoUpdate] = useState(true); + useEffect(() => { staticConfig.get("disable-hadware-acceleration").then(disabled =>setHardwareAccelerationEnabled(() => disabled !== true)); - staticConfig.get("use-symlinks").then(useSymlinks => setUseSymlink(() => useSymlinks)); - staticConfig.get("use-system-proxy").then(useSystemProxy => setUseSystemProxy(() => useSystemProxy)); + + if (window.electron.platform === "win32") { + staticConfig.get("use-symlinks").then(useSymlinks => setUseSymlink(() => useSymlinks)); + staticConfig.get("use-system-proxy").then(useSystemProxy => setUseSystemProxy(() => useSystemProxy)); + staticConfig.get("auto-update").then(value => setAutoUpdate(() => value)); + } }, []); const onChangeHardwareAcceleration = async (newHardwareAccelerationEnabled: boolean) => { @@ -630,12 +636,41 @@ function AdvancedSettings() { setUseSystemProxy(() => newUseSystemProxy); } - const advancedItems: Item[] = [{ + const onChangeAutoUpdate = async (newAutoUpdate: boolean) => { + if (window.electron.platform !== "win32") { + return; + } + + const { error } = await tryit(() => staticConfig.set("auto-update", newAutoUpdate)); + if (error) { + notification.notifyError({ + title: "notifications.types.error", + desc: "pages.settings.advanced.auto-update.error-notification.message", + }); + return; + } + + setAutoUpdate(() => newAutoUpdate); + } + + const advancedItems: Item[] = []; + + if (window.electron.platform === "win32") { + advancedItems.push({ + checked: autoUpdate, + text: t.text("pages.settings.advanced.auto-update.title"), + desc: t.text("pages.settings.advanced.auto-update.description"), + onChange: onChangeAutoUpdate + }); + } + + advancedItems.push({ checked: hardwareAccelerationEnabled, text: t.text("pages.settings.advanced.hardware-acceleration.title"), desc: t.text("pages.settings.advanced.hardware-acceleration.description"), onChange: onChangeHardwareAcceleration - }]; + }); + if (window.electron.platform === "win32") { advancedItems.push({ checked: useSymlink, From a7fb2744a7cfc08d74cb5f58984861204b2fbe67 Mon Sep 17 00:00:00 2001 From: Zagrios <40181755+Zagrios@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:12:02 +0100 Subject: [PATCH 2/2] minor fixes + translations --- assets/jsons/translations/de.json | 7 +++++++ assets/jsons/translations/es.json | 7 +++++++ assets/jsons/translations/fr.json | 7 +++++++ assets/jsons/translations/it.json | 7 +++++++ assets/jsons/translations/ja.json | 7 +++++++ assets/jsons/translations/ko.json | 7 +++++++ assets/jsons/translations/pt-br.json | 7 +++++++ assets/jsons/translations/ru.json | 7 +++++++ assets/jsons/translations/zh-tw.json | 7 +++++++ assets/jsons/translations/zh.json | 7 +++++++ src/main/main.ts | 6 +++--- src/renderer/pages/settings-page.component.tsx | 2 +- 12 files changed, 74 insertions(+), 4 deletions(-) diff --git a/assets/jsons/translations/de.json b/assets/jsons/translations/de.json index c7eadb2d0..82620834b 100644 --- a/assets/jsons/translations/de.json +++ b/assets/jsons/translations/de.json @@ -319,6 +319,13 @@ "error-notification": { "message": "Es ist ein Fehler aufgetreten, die Systemproxyeinstellungen können nicht geändert werden." } + }, + "auto-update": { + "title": "Automatische Aktualisierung", + "description": "BSManager wird beim Start der Anwendung automatisch aktualisiert.", + "error-notification": { + "message": "Ein Fehler ist aufgetreten, die Einstellungen für die automatische Aktualisierung können nicht geändert werden." + } } } } diff --git a/assets/jsons/translations/es.json b/assets/jsons/translations/es.json index c7681628a..442460a53 100644 --- a/assets/jsons/translations/es.json +++ b/assets/jsons/translations/es.json @@ -319,6 +319,13 @@ "error-notification": { "message": "Ocurrió un error, no se pueden cambiar los ajustes del proxy del sistema." } + }, + "auto-update": { + "title": "Actualización automática", + "description": "BSManager se actualizará automáticamente al iniciar la aplicación.", + "error-notification": { + "message": "Ocurrió un error, no se pudo cambiar la configuración de actualización automática." + } } } } diff --git a/assets/jsons/translations/fr.json b/assets/jsons/translations/fr.json index d065f6d5d..514f89dfd 100644 --- a/assets/jsons/translations/fr.json +++ b/assets/jsons/translations/fr.json @@ -319,6 +319,13 @@ "error-notification": { "message": "Une erreur est survenue, impossible de modifier les paramètres du proxy système." } + }, + "auto-update": { + "title": "Mise à jour automatique", + "description": "BSManager se mettra automatiquement à jour au lancement de l'application.", + "error-notification": { + "message": "Une erreur est survenue, impossible de modifier les paramètres de mise à jour automatique." + } } } } diff --git a/assets/jsons/translations/it.json b/assets/jsons/translations/it.json index 0bb01e704..51ba5cbe4 100644 --- a/assets/jsons/translations/it.json +++ b/assets/jsons/translations/it.json @@ -319,6 +319,13 @@ "error-notification": { "message": "C'è stato un errore, impossibile cambiare le impostazioni del proxy di sistema." } + }, + "auto-update": { + "title": "Aggiornamento automatico", + "description": "BSManager si aggiornerà automaticamente all'avvio dell'applicazione.", + "error-notification": { + "message": "Si è verificato un errore, impossibile modificare le impostazioni di aggiornamento automatico." + } } } } diff --git a/assets/jsons/translations/ja.json b/assets/jsons/translations/ja.json index 32e8c7edd..02db77d2f 100644 --- a/assets/jsons/translations/ja.json +++ b/assets/jsons/translations/ja.json @@ -319,6 +319,13 @@ "error-notification": { "message": "エラーが発生しました。システムプロキシ設定を変更できません。" } + }, + "auto-update": { + "title": "自動更新", + "description": "アプリケーション起動時にBSManagerが自動的に更新されます。", + "error-notification": { + "message": "エラーが発生し、自動更新の設定を変更できませんでした。" + } } } } diff --git a/assets/jsons/translations/ko.json b/assets/jsons/translations/ko.json index 035fefed7..82417688d 100644 --- a/assets/jsons/translations/ko.json +++ b/assets/jsons/translations/ko.json @@ -320,6 +320,13 @@ "error-notification": { "message": "오류가 발생했습니다. 시스템 프록시 설정을 변경할 수 없습니다." } + }, + "auto-update": { + "title": "자동 업데이트", + "description": "애플리케이션을 실행할 때 BSManager가 자동으로 업데이트됩니다.", + "error-notification": { + "message": "오류가 발생하여 자동 업데이트 설정을 변경할 수 없습니다." + } } } } diff --git a/assets/jsons/translations/pt-br.json b/assets/jsons/translations/pt-br.json index db3447f91..b518412fa 100644 --- a/assets/jsons/translations/pt-br.json +++ b/assets/jsons/translations/pt-br.json @@ -319,6 +319,13 @@ "error-notification": { "message": "Um erro aconteceu, não foi possível alterar a configuração de proxy de sistema." } + }, + "auto-update": { + "title": "Atualização automática", + "description": "O BSManager será atualizado automaticamente ao iniciar o aplicativo.", + "error-notification": { + "message": "Ocorreu um erro, não foi possível alterar as configurações de atualização automática." + } } } } diff --git a/assets/jsons/translations/ru.json b/assets/jsons/translations/ru.json index 4a4500a1e..c1e98cf23 100644 --- a/assets/jsons/translations/ru.json +++ b/assets/jsons/translations/ru.json @@ -319,6 +319,13 @@ "error-notification": { "message": "Произошла ошибка, не удалось изменить настройки системного прокси." } + }, + "auto-update": { + "title": "Автообновление", + "description": "BSManager будет автоматически обновляться при запуске приложения.", + "error-notification": { + "message": "Произошла ошибка, не удалось изменить настройки автообновления." + } } } } diff --git a/assets/jsons/translations/zh-tw.json b/assets/jsons/translations/zh-tw.json index cacac60a4..90f18e110 100644 --- a/assets/jsons/translations/zh-tw.json +++ b/assets/jsons/translations/zh-tw.json @@ -319,6 +319,13 @@ "error-notification": { "message": "發生錯誤,無法更改系統代理設置。" } + }, + "auto-update": { + "title": "自動更新", + "description": "啟動應用程式時,BSManager 將自動更新。", + "error-notification": { + "message": "發生錯誤,無法更改自動更新設定。" + } } } } diff --git a/assets/jsons/translations/zh.json b/assets/jsons/translations/zh.json index da08ac9bd..864f99f4b 100644 --- a/assets/jsons/translations/zh.json +++ b/assets/jsons/translations/zh.json @@ -318,6 +318,13 @@ "error-notification": { "message": "发生错误,无法启用系统代理。" } + }, + "auto-update": { + "title": "自动更新", + "description": "启动应用程序时,BSManager 将自动更新。", + "error-notification": { + "message": "发生错误,无法更改自动更新设置。" + } } } } diff --git a/src/main/main.ts b/src/main/main.ts index 82d04bd26..ef02f470a 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -133,9 +133,9 @@ if (!gotTheLock) { } else if (process.platform === "linux") { createWindow("index.html"); } else { - const autoUpdate = StaticConfigurationService.getInstance().get("auto-update"); - createWindow(autoUpdate === undefined || autoUpdate === true - ? "launcher.html" : "index.html"); + const autoUpdate = StaticConfigurationService.getInstance().get("auto-update", true); + // Skip launcher only if autoUpdate is strictly false + createWindow(autoUpdate !== false ? "launcher.html" : "index.html"); } SteamLauncherService.getInstance().restoreSteamVR(); diff --git a/src/renderer/pages/settings-page.component.tsx b/src/renderer/pages/settings-page.component.tsx index decb32f9a..b685fa834 100644 --- a/src/renderer/pages/settings-page.component.tsx +++ b/src/renderer/pages/settings-page.component.tsx @@ -554,7 +554,7 @@ function AdvancedSettings() { if (window.electron.platform === "win32") { staticConfig.get("use-symlinks").then(useSymlinks => setUseSymlink(() => useSymlinks)); staticConfig.get("use-system-proxy").then(useSystemProxy => setUseSystemProxy(() => useSystemProxy)); - staticConfig.get("auto-update").then(value => setAutoUpdate(() => value)); + staticConfig.get("auto-update").then(value => setAutoUpdate(() => value !== false)); } }, []);