add furture auto open

This commit is contained in:
Admin 2025-05-28 08:27:27 +07:00
parent 87eca555a2
commit ad585e276e
3 changed files with 20 additions and 5 deletions

View File

@ -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",

View File

@ -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')

View File

@ -156,6 +156,12 @@ function App(): React.JSX.Element {
</Box>
) : (
newItems?.map((item: Product) => {
console.log({
hotItem,
item,
is_host: isHotItem(item)
})
return (
<CardItem
key={item?.id}