feat: getInstallationStatus event to catch up after rending registers

This commit is contained in:
a7m-1st 2025-09-23 21:40:46 +03:00
parent 2b567189ba
commit 761d11dae2
3 changed files with 39 additions and 0 deletions

View file

@ -151,6 +151,36 @@ const installedLockPath = path.join(backendPath, 'uv_installed.lock')
// const proxyArgs = ['--default-index', 'https://pypi.tuna.tsinghua.edu.cn/simple']
const proxyArgs = ['--default-index', 'https://mirrors.aliyun.com/pypi/simple/']
/**
* Get current installation status by checking lock files
* @returns Object with installation status information
*/
export async function getInstallationStatus(): Promise<{
isInstalling: boolean;
hasLockFile: boolean;
installedExists: boolean;
}> {
try {
const installingExists = fs.existsSync(installingLockPath);
const installedExists = fs.existsSync(installedLockPath);
// If installing lock exists, installation is in progress
// If installed lock exists, installation completed previously
return {
isInstalling: installingExists,
hasLockFile: installingExists || installedExists,
installedExists: installedExists
};
} catch (error) {
console.error('[getInstallationStatus] Error checking installation status:', error);
return {
isInstalling: false,
hasLockFile: false,
installedExists: false
};
}
}
class InstallLogs {
private node_process;

View file

@ -64,6 +64,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
// install dependencies related API
checkAndInstallDepsOnUpdate: () => ipcRenderer.invoke('install-dependencies'),
checkInstallBrowser: () => ipcRenderer.invoke('check-install-browser'),
getInstallationStatus: () => ipcRenderer.invoke('get-installation-status'),
onInstallDependenciesStart: (callback: () => void) => {
ipcRenderer.on('install-dependencies-start', callback);
},

View file

@ -47,6 +47,14 @@ interface ElectronAPI {
executeCommand: (command: string,email:string) => Promise<{ success: boolean; stdout?: string; stderr?: string; error?: string }>;
checkAndInstallDepsOnUpdate: () => Promise<{ success: boolean; error?: string }>;
checkInstallBrowser: () => Promise<{ data:any[] }>;
getInstallationStatus: () => Promise<{
success: boolean;
isInstalling?: boolean;
hasLockFile?: boolean;
installedExists?: boolean;
timestamp?: number;
error?: string
}>;
onInstallDependenciesStart: (callback: () => void) => void;
onInstallDependenciesLog: (callback: (data: { type: string; data: string }) => void) => void;
onInstallDependenciesComplete: (callback: (data: { success: boolean; code?: number; error?: string }) => void) => void;