feat: adding optional common redist install

This commit is contained in:
Chubby Granny Chaser
2025-04-06 22:17:54 +01:00
parent 1520e2b2ae
commit f8ea4f29d9
5 changed files with 18 additions and 7 deletions

View File

@@ -44,7 +44,10 @@
"downloading_metadata": "Baixando metadados de {{title}}…",
"downloading": "Baixando {{title}}… ({{percentage}} concluído) - Conclusão {{eta}} - {{speed}}",
"calculating_eta": "Baixando {{title}}… ({{percentage}} concluído) - Calculando tempo restante…",
"checking_files": "Verificando arquivos de {{title}}…"
"checking_files": "Verificando arquivos de {{title}}…",
"installing_common_redist": "{{log}}…",
"installation_complete": "Instalação concluída",
"installation_complete_message": "Componentes recomendados instalados com sucesso"
},
"game_details": {
"open_download_options": "Ver opções de download",

View File

@@ -56,10 +56,8 @@ export class CommonRedistManager {
}
}
const [_, component] = tail?.split("Installing ") ?? [];
WindowManager.mainWindow?.webContents.send("common-redist-progress", {
component: component,
log: tail,
complete: tail?.includes(installationCompleteMessage),
});
});

View File

@@ -313,11 +313,11 @@ contextBridge.exposeInMainWorld("electron", {
};
},
onCommonRedistProgress: (
cb: (value: { component: string; complete: boolean }) => void
cb: (value: { log: string; complete: boolean }) => void
) => {
const listener = (
_event: Electron.IpcRendererEvent,
value: { component: string; complete: boolean }
value: { log: string; complete: boolean }
) => cb(value);
ipcRenderer.on("common-redist-progress", listener);
return () => ipcRenderer.removeListener("common-redist-progress", listener);

View File

@@ -237,7 +237,7 @@ declare global {
canInstallCommonRedist: () => Promise<boolean>;
installCommonRedist: () => Promise<void>;
onCommonRedistProgress: (
cb: (value: { component: string; complete: boolean }) => void
cb: (value: { log: string; complete: boolean }) => void
) => () => Electron.IpcRenderer;
platform: NodeJS.Platform;

View File

@@ -54,6 +54,12 @@ export function SettingsGeneral() {
setCanInstallCommonRedist(canInstall);
});
const interval = setInterval(() => {
window.electron.canInstallCommonRedist().then((canInstall) => {
setCanInstallCommonRedist(canInstall);
});
}, 1000 * 5);
setLanguageOptions(
orderBy(
Object.entries(languageResources).map(([language, value]) => {
@@ -66,6 +72,10 @@ export function SettingsGeneral() {
"asc"
)
);
return () => {
clearInterval(interval);
};
}, []);
useEffect(() => {