mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: adding optional common redist install
This commit is contained in:
@@ -350,7 +350,10 @@
|
||||
"error_importing_theme": "Error importing theme",
|
||||
"theme_imported": "Theme imported successfully",
|
||||
"enable_friend_request_notifications": "When a friend request is received",
|
||||
"enable_auto_install": "Download updates automatically"
|
||||
"enable_auto_install": "Download updates automatically",
|
||||
"common_redist": "Common redistributables",
|
||||
"common_redist_description": "Common redistributables are required to run some games. Installing them is recommended to avoid issues.",
|
||||
"install_common_redist": "Install"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download complete",
|
||||
|
||||
@@ -334,7 +334,10 @@
|
||||
"error_importing_theme": "Erro ao importar tema",
|
||||
"theme_imported": "Tema importado com sucesso",
|
||||
"enable_friend_request_notifications": "Quando um pedido de amizade é recebido",
|
||||
"enable_auto_install": "Baixar atualizações automaticamente"
|
||||
"enable_auto_install": "Baixar atualizações automaticamente",
|
||||
"common_redist": "Componentes recomendados",
|
||||
"common_redist_description": "Componentes recomendados são necessários para executar alguns jogos. A instalação deles é recomendada para evitar problemas.",
|
||||
"install_common_redist": "Instalar"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download concluído",
|
||||
|
||||
@@ -40,6 +40,7 @@ import "./misc/get-features";
|
||||
import "./misc/show-item-in-folder";
|
||||
import "./misc/get-badges";
|
||||
import "./misc/install-common-redist";
|
||||
import "./misc/can-install-common-redist";
|
||||
import "./torrenting/cancel-game-download";
|
||||
import "./torrenting/pause-game-download";
|
||||
import "./torrenting/resume-game-download";
|
||||
|
||||
7
src/main/events/misc/can-install-common-redist.ts
Normal file
7
src/main/events/misc/can-install-common-redist.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { CommonRedistManager } from "@main/services/common-redist-manager";
|
||||
|
||||
const canInstallCommonRedist = async (_event: Electron.IpcMainInvokeEvent) =>
|
||||
CommonRedistManager.canInstallCommonRedist();
|
||||
|
||||
registerEvent("canInstallCommonRedist", canInstallCommonRedist);
|
||||
@@ -39,6 +39,10 @@ export class CommonRedistManager {
|
||||
|
||||
const installationCompleteMessage = "Installation complete";
|
||||
|
||||
if (!fs.existsSync(this.installationLog)) {
|
||||
await fs.promises.writeFile(this.installationLog, "");
|
||||
}
|
||||
|
||||
fs.watch(this.installationLog, { signal: abortController.signal }, () => {
|
||||
fs.readFile(this.installationLog, "utf-8", (err, data) => {
|
||||
if (err) return logger.error("Error reading log file:", err);
|
||||
|
||||
@@ -295,6 +295,7 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
ipcRenderer.invoke("showItemInFolder", path),
|
||||
getFeatures: () => ipcRenderer.invoke("getFeatures"),
|
||||
getBadges: () => ipcRenderer.invoke("getBadges"),
|
||||
canInstallCommonRedist: () => ipcRenderer.invoke("canInstallCommonRedist"),
|
||||
installCommonRedist: () => ipcRenderer.invoke("installCommonRedist"),
|
||||
platform: process.platform,
|
||||
|
||||
|
||||
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
@@ -234,6 +234,7 @@ declare global {
|
||||
showItemInFolder: (path: string) => Promise<void>;
|
||||
getFeatures: () => Promise<string[]>;
|
||||
getBadges: () => Promise<Badge[]>;
|
||||
canInstallCommonRedist: () => Promise<boolean>;
|
||||
installCommonRedist: () => Promise<void>;
|
||||
onCommonRedistProgress: (
|
||||
cb: (value: { component: string; complete: boolean }) => void
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
flex-direction: column;
|
||||
gap: globals.$spacing-unit * 2;
|
||||
|
||||
&__notifications-title {
|
||||
&__section-title {
|
||||
margin-top: calc(globals.$spacing-unit * 2);
|
||||
margin-bottom: globals.$spacing-unit;
|
||||
}
|
||||
|
||||
&__common-redist-button {
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import languageResources from "@locales";
|
||||
import { orderBy } from "lodash-es";
|
||||
import { settingsContext } from "@renderer/context";
|
||||
import "./settings-general.scss";
|
||||
import { DesktopDownloadIcon } from "@primer/octicons-react";
|
||||
|
||||
interface LanguageOption {
|
||||
option: string;
|
||||
@@ -27,6 +28,8 @@ export function SettingsGeneral() {
|
||||
(state) => state.userPreferences.value
|
||||
);
|
||||
|
||||
const [canInstallCommonRedist, setCanInstallCommonRedist] = useState(false);
|
||||
|
||||
const [form, setForm] = useState({
|
||||
downloadsPath: "",
|
||||
downloadNotificationsEnabled: false,
|
||||
@@ -47,6 +50,10 @@ export function SettingsGeneral() {
|
||||
setDefaultDownloadsPath(path);
|
||||
});
|
||||
|
||||
window.electron.canInstallCommonRedist().then((canInstall) => {
|
||||
setCanInstallCommonRedist(canInstall);
|
||||
});
|
||||
|
||||
setLanguageOptions(
|
||||
orderBy(
|
||||
Object.entries(languageResources).map(([language, value]) => {
|
||||
@@ -90,7 +97,9 @@ export function SettingsGeneral() {
|
||||
}
|
||||
}, [userPreferences, defaultDownloadsPath]);
|
||||
|
||||
const handleLanguageChange = (event) => {
|
||||
const handleLanguageChange = (
|
||||
event: React.ChangeEvent<HTMLSelectElement>
|
||||
) => {
|
||||
const value = event.target.value;
|
||||
|
||||
handleChange({ language: value });
|
||||
@@ -139,9 +148,7 @@ export function SettingsGeneral() {
|
||||
}))}
|
||||
/>
|
||||
|
||||
<h2 className="settings-general__notifications-title">
|
||||
{t("notifications")}
|
||||
</h2>
|
||||
<h2 className="settings-general__section-title">{t("notifications")}</h2>
|
||||
|
||||
<CheckboxField
|
||||
label={t("enable_download_notifications")}
|
||||
@@ -186,7 +193,18 @@ export function SettingsGeneral() {
|
||||
}
|
||||
/>
|
||||
|
||||
<Button onClick={() => window.electron.installCommonRedist()}>
|
||||
<h2 className="settings-general__section-title">{t("common_redist")}</h2>
|
||||
|
||||
<p className="settings-general__common-redist-description">
|
||||
{t("common_redist_description")}
|
||||
</p>
|
||||
|
||||
<Button
|
||||
onClick={() => window.electron.installCommonRedist()}
|
||||
className="settings-general__common-redist-button"
|
||||
disabled={!canInstallCommonRedist}
|
||||
>
|
||||
<DesktopDownloadIcon />
|
||||
{t("install_common_redist")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user