Rename to Plugin Compass, add mobile onboarding/signin, implement self-update for desktop, and fix workflow paths

This commit is contained in:
southseact-3d
2026-02-16 12:05:30 +00:00
parent 63698e1d19
commit d6e2af3a29
11 changed files with 945 additions and 138 deletions

View File

@@ -1,4 +1,5 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const { autoUpdater } = require('electron-updater');
const path = require('path');
const fs = require('fs');
const https = require('https');
@@ -65,7 +66,7 @@ function createWindow() {
contextIsolation: true,
nodeIntegration: false,
},
title: 'ShopifyAI Desktop',
title: 'Plugin Compass',
show: false,
});
@@ -81,10 +82,16 @@ function createWindow() {
} else {
mainWindow.loadURL('http://localhost:3000');
}
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents.send('app-version', app.getVersion());
});
}
app.whenReady().then(() => {
createWindow();
autoUpdater.checkForUpdatesAndNotify();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
@@ -99,6 +106,64 @@ app.on('window-all-closed', () => {
}
});
autoUpdater.on('update-available', () => {
if (mainWindow) {
mainWindow.webContents.send('update-available');
}
});
autoUpdater.on('update-downloaded', () => {
if (mainWindow) {
mainWindow.webContents.send('update-downloaded');
}
});
autoUpdater.on('error', (err) => {
if (mainWindow) {
mainWindow.webContents.send('update-error', err.message);
}
});
autoUpdater.on('download-progress', (progressObj) => {
if (mainWindow) {
mainWindow.webContents.send('download-progress', {
percent: progressObj.percent,
transferred: progressObj.transferred,
total: progressObj.total,
});
}
});
ipcMain.handle('check-for-updates', async () => {
try {
const result = await autoUpdater.checkForUpdates();
return {
available: result && result.updateInfo && result.updateInfo.version !== app.getVersion(),
currentVersion: app.getVersion(),
latestVersion: result ? result.updateInfo.version : app.getVersion(),
};
} catch (err) {
return { error: err.message };
}
});
ipcMain.handle('download-update', async () => {
try {
await autoUpdater.downloadUpdate();
return { success: true };
} catch (err) {
return { error: err.message };
}
});
ipcMain.handle('install-update', () => {
autoUpdater.quitAndInstall();
});
ipcMain.handle('get-version', () => {
return app.getVersion();
});
ipcMain.handle('save-api-key', async (event, token) => {
if (!token || typeof token !== 'string' || token.trim() === '') {
throw new Error('token is required');