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_metadata": "Baixando metadados de {{title}}…",
"downloading": "Baixando {{title}}… ({{percentage}} concluído) - Conclusão {{eta}} - {{speed}}", "downloading": "Baixando {{title}}… ({{percentage}} concluído) - Conclusão {{eta}} - {{speed}}",
"calculating_eta": "Baixando {{title}}… ({{percentage}} concluído) - Calculando tempo restante…", "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": { "game_details": {
"open_download_options": "Ver opções de download", "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", { WindowManager.mainWindow?.webContents.send("common-redist-progress", {
component: component, log: tail,
complete: tail?.includes(installationCompleteMessage), complete: tail?.includes(installationCompleteMessage),
}); });
}); });

View File

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

View File

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

View File

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