luke hace 6 años
padre
commit
dab1eea37f

+ 4 - 0
service_exe/package.json

@@ -48,6 +48,10 @@
     },
     "linux": {
       "icon": "build/icons/icon.png"
+    },
+    "extraResources":  {
+      "from": "build/icons/",
+      "to": "./"
     }
   },
   "dependencies": {

+ 26 - 2
service_exe/src/main/index.js

@@ -24,8 +24,31 @@ const winURL = process.env.NODE_ENV === 'development'
 function createWindow() {
 	let timer = null
 	let count = 0;
-	tray = new Tray(icon)
+
+	tray = new Tray(icon);
+	const trayMenuTemplate = [
+		{
+			label: '退出',
+			click: function () {
+				if (tray) {
+					tray.destroy()
+				}
+				app.exit(0)
+			}
+		}
+	]
+	// 图标的上下文菜单
+	const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
+	// 设置此托盘图标的悬停提示内容
+	tray.setToolTip('欢迎使大博客服系统')
+	// 设置此图标的上下文菜单
+	if (process.platform === 'win32' || process.platform === 'win64') {
+		tray.setContextMenu(contextMenu)
+	}
+
+
 	ipcMain.on('haveMessage', (event,arg) => {
+		mainWindow.flashFrame(true)
 		timer = setInterval(() => {
 			count += 1
 			if (count % 2 === 0) {
@@ -36,6 +59,7 @@ function createWindow() {
 		}, 500)
 	})
 	tray.on('click', () => {
+		mainWindow.flashFrame(false)
 		if (mainWindow.isVisible()) {
 			mainWindow.hide()
 		} else {
@@ -52,7 +76,7 @@ function createWindow() {
 	mainWindow = new BrowserWindow({
 		height: 563,
 		useContentSize: true,
-		width: 1000
+		width: 1000,
 	})
 
 	mainWindow.loadURL(winURL)

BIN
service_exe/static/empty.png


BIN
service_exe/static/icon.png