update start up

This commit is contained in:
nkhangg 2025-06-03 21:58:23 +07:00
parent 933bed2c81
commit 6f9442a02e
5 changed files with 28 additions and 15 deletions

View File

@ -16,8 +16,8 @@ asarUnpack:
- resources/** - resources/**
win: win:
target: portable target: nsis
executableName: New-item, executableName: New-item
publisherName: apactech publisherName: apactech
portable: portable:

9
package-lock.json generated
View File

@ -20,7 +20,8 @@
"axios": "^1.9.0", "axios": "^1.9.0",
"electron-updater": "^6.3.9", "electron-updater": "^6.3.9",
"moment": "^2.30.1", "moment": "^2.30.1",
"pusher-js": "^8.4.0" "pusher-js": "^8.4.0",
"windows-shortcuts": "^0.1.6"
}, },
"devDependencies": { "devDependencies": {
"@electron-toolkit/eslint-config-prettier": "^3.0.0", "@electron-toolkit/eslint-config-prettier": "^3.0.0",
@ -10979,6 +10980,12 @@
"string-width": "^1.0.2 || 2 || 3 || 4" "string-width": "^1.0.2 || 2 || 3 || 4"
} }
}, },
"node_modules/windows-shortcuts": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/windows-shortcuts/-/windows-shortcuts-0.1.6.tgz",
"integrity": "sha512-kjkb3Hmmmg7jwnOb+29AOmoEEA1L/JeLsMOYovpLxYpuc+fN0R+pr8sMwep3JFhUZloxyw1XTzq8n3HugXkqBA==",
"license": "MIT"
},
"node_modules/word-wrap": { "node_modules/word-wrap": {
"version": "1.2.5", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "new-item-app", "name": "new-item-app",
"version": "1.0.3", "version": "1.0.5",
"description": "new item application is active", "description": "new item application is active",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "apactech.io", "author": "apactech.io",
@ -32,7 +32,8 @@
"axios": "^1.9.0", "axios": "^1.9.0",
"electron-updater": "^6.3.9", "electron-updater": "^6.3.9",
"moment": "^2.30.1", "moment": "^2.30.1",
"pusher-js": "^8.4.0" "pusher-js": "^8.4.0",
"windows-shortcuts": "^0.1.6"
}, },
"devDependencies": { "devDependencies": {
"@electron-toolkit/eslint-config-prettier": "^3.0.0", "@electron-toolkit/eslint-config-prettier": "^3.0.0",

View File

@ -5,6 +5,7 @@ import { app, BrowserWindow, globalShortcut, ipcMain, Menu, screen, shell, Tray
import fs from 'fs' import fs from 'fs'
import path, { join } from 'path' import path, { join } from 'path'
import icon from '../../resources/icon.png?asset' import icon from '../../resources/icon.png?asset'
import ws from 'windows-shortcuts'
let mainWindow: null | BrowserWindow = null let mainWindow: null | BrowserWindow = null
let isQuiting = false let isQuiting = false
@ -111,18 +112,22 @@ function createTray() {
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.whenReady().then(() => { app.whenReady().then(() => {
const startupFlagFile = path.join(app.getPath('userData'), 'startup-set.flag') // const startupFlagFile = path.join(app.getPath('userData'), 'startup-set.flag')
const startupFolder = path.join(
app.getPath('appData'),
'Microsoft\\Windows\\Start Menu\\Programs\\Startup'
)
const shortcutPath = path.join(startupFolder, 'New Item.lnk')
if (!fs.existsSync(startupFlagFile)) { if (!fs.existsSync(shortcutPath)) {
app.setLoginItemSettings({ ws.create(shortcutPath, {
openAtLogin: true, target: process.execPath,
path: process.execPath, workingDir: path.dirname(process.execPath),
args: [] runStyle: 1,
desc: 'Start New Item with Windows',
icon: process.execPath
}) })
fs.writeFileSync(startupFlagFile, 'ok')
} }
// Set app user model id for windows // Set app user model id for windows
electronApp.setAppUserModelId('com.electron') electronApp.setAppUserModelId('com.electron')

View File

@ -20,7 +20,7 @@ const CardItem: React.FC<CardItemProps> = ({ item, hotItem }) => {
justifyContent: 'center' justifyContent: 'center'
}} }}
> >
{true ? ( {hotItem ? (
<Box <Box
style={{ style={{
position: 'absolute', position: 'absolute',