mirror of
https://github.com/open-webui/desktop
synced 2025-06-26 18:15:59 +00:00
enh: main
This commit is contained in:
parent
6d6b84d43c
commit
81716fcc00
18
src/main.ts
18
src/main.ts
@ -223,7 +223,23 @@ if (!gotTheLock) {
|
||||
|
||||
ipcMain.handle('install', async (event) => {
|
||||
console.log('Installing package...');
|
||||
installPackage();
|
||||
|
||||
try {
|
||||
const res = await installPackage();
|
||||
if (res) {
|
||||
mainWindow.webContents.send('main:data', {
|
||||
type: 'install:status',
|
||||
data: true
|
||||
});
|
||||
|
||||
await startServerHandler();
|
||||
}
|
||||
} catch (error) {
|
||||
mainWindow.webContents.send('main:data', {
|
||||
type: 'install:status',
|
||||
data: false
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('install:status', async (event) => {
|
||||
|
@ -188,12 +188,12 @@ export function createAdHocSignCommand(envPath: string): string {
|
||||
return `cd ${envPath} && codesign -s - -o 0x2 -f ${signList.join(' ')} && cd -`;
|
||||
}
|
||||
|
||||
export async function installOpenWebUI(installationPath: string) {
|
||||
export async function installOpenWebUI(installationPath: string, version?: string) {
|
||||
console.log(installationPath);
|
||||
let unpackCommand =
|
||||
process.platform === 'win32'
|
||||
? `${installationPath}\\Scripts\\activate.bat && uv pip install open-webui -U`
|
||||
: `source "${installationPath}/bin/activate" && uv pip install open-webui -U`;
|
||||
? `${installationPath}\\Scripts\\activate.bat && uv pip install open-webui${version ? `==${version}` : ' -U'}`
|
||||
: `source "${installationPath}/bin/activate" && uv pip install open-webui${version ? `==${version}` : ' -U'}`;
|
||||
|
||||
// only unsign when installing from bundled installer
|
||||
// if (platform === "darwin") {
|
||||
@ -215,6 +215,13 @@ export async function installOpenWebUI(installationPath: string) {
|
||||
commandProcess.on('exit', (code) => {
|
||||
console.log(`Child exited with code ${code}`);
|
||||
logEmitter.emit('log', `Child exited with code ${code}`);
|
||||
|
||||
if (code !== 0) {
|
||||
log.error(`Failed to install open-webui: ${code}`);
|
||||
logEmitter.emit('log', `Failed to install open-webui: ${code}`);
|
||||
} else {
|
||||
logEmitter.emit('log', 'open-webui installed successfully');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -274,19 +281,25 @@ export async function installPackage(installationPath?: string) {
|
||||
// }
|
||||
// }
|
||||
|
||||
console.log('Installing python...');
|
||||
|
||||
try {
|
||||
await installBundledPython(installationPath);
|
||||
} catch (error) {
|
||||
log.error('Failed to install bundled Python', error);
|
||||
return Promise.reject('Failed to install bundled Python');
|
||||
|
||||
throw new Error('Failed to install bundled Python');
|
||||
}
|
||||
|
||||
console.log('Installing open-webui...');
|
||||
try {
|
||||
await installOpenWebUI(installationPath);
|
||||
} catch (error) {
|
||||
log.error('Failed to install open-webui', error);
|
||||
return Promise.reject('Failed to install open-webui');
|
||||
throw new Error('Failed to install open-webui');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function removePackage(installationPath?: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user