diff --git a/package.json b/package.json index 961aee6..6cd4eae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new-item-app", - "version": "1.0.0", + "version": "1.0.3", "description": "An Electron application with React and TypeScript", "main": "./out/main/index.js", "author": "example.com", diff --git a/src/main/index.ts b/src/main/index.ts index 24a7a7d..b9ffa1a 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -8,6 +8,8 @@ import icon from '../../resources/icon.png?asset' let mainWindow: null | BrowserWindow = null let isQuiting = false +const startupFlagFile = path.join(app.getPath('userData'), 'startup-set.flag') + function createWindow(): void { // Get Screen width, height const { width, height } = screen.getPrimaryDisplay().workAreaSize @@ -39,10 +41,7 @@ function createWindow(): void { // Make the window always on top mainWindow.setAlwaysOnTop(true, 'normal') - // Right-click to Inspect Element - // mainWindow.webContents.on('context-menu', (_, params) => { - // mainWindow?.webContents.inspectElement(params.x, params.y) - // }) + // mainWindow.webContents.openDevTools() // Inspect element with shortcut mainWindow.webContents.once('did-finish-load', () => { @@ -113,6 +112,16 @@ function createTray() { // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.whenReady().then(() => { + if (!fs.existsSync(startupFlagFile)) { + app.setLoginItemSettings({ + openAtLogin: true, + path: process.execPath, + args: [] + }) + + fs.writeFileSync(startupFlagFile, 'ok') + } + // Set app user model id for windows electronApp.setAppUserModelId('com.electron') diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 555e6da..9fc55a6 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -156,6 +156,12 @@ function App(): React.JSX.Element { ) : ( newItems?.map((item: Product) => { + console.log({ + hotItem, + item, + is_host: isHotItem(item) + }) + return (