增加未读消息检测
parent
50e150199e
commit
ff8b6588d2
|
@ -16,6 +16,10 @@
|
|||
|
||||
## 更新日志
|
||||
|
||||
- 2022.04.26
|
||||
1. 版本号改为`年.月.日`格式
|
||||
2. 检测未读消息, 如有, 托盘图标显示红点。
|
||||
|
||||
- 2022.04.24
|
||||
1. electron升级为18.0
|
||||
2. 修复自动登录功能
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dtalk",
|
||||
"version": "3.8.12",
|
||||
"version": "22.4.26",
|
||||
"description": "钉钉-Linux版",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
|
@ -29,7 +29,7 @@ app.once('ready', () => {
|
|||
|
||||
let win = createMainWindow(join(ROOT, './images/app.png'))
|
||||
|
||||
createTray(win)
|
||||
app.toggleTray = createTray(win)
|
||||
})
|
||||
|
||||
ipcMain.on('app', (ev, conn) => {
|
||||
|
@ -73,5 +73,12 @@ ipcMain.on('app', (ev, conn) => {
|
|||
ev.returnValue = true
|
||||
}
|
||||
break
|
||||
|
||||
case 'toggleTray':
|
||||
{
|
||||
app.toggleTray(conn.data)
|
||||
ev.returnValue = true
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
|
|
|
@ -24,5 +24,9 @@ contextBridge.exposeInMainWorld('electron', {
|
|||
|
||||
saveCookie() {
|
||||
return ipcRenderer.sendSync('app', { type: 'saveCookie' })
|
||||
},
|
||||
|
||||
toggleTray(unread) {
|
||||
return ipcRenderer.sendSync('app', { type: 'toggleTray', data: unread })
|
||||
}
|
||||
})
|
||||
|
|
|
@ -8,8 +8,11 @@ const { app, Tray, Menu } = require('electron')
|
|||
const path = require('path')
|
||||
const ROOT = __dirname
|
||||
|
||||
const TRAY_ICO = path.join(ROOT, '../images/tray.png')
|
||||
const TRAY_ICO_A = path.join(ROOT, '../images/tray_a.png')
|
||||
|
||||
module.exports = function (win) {
|
||||
app.__TRAY__ = new Tray(path.join(ROOT, '../images/tray.png'))
|
||||
let dTray = new Tray(TRAY_ICO)
|
||||
let menuList = Menu.buildFromTemplate([
|
||||
{
|
||||
label: '显示主窗口',
|
||||
|
@ -25,9 +28,25 @@ module.exports = function (win) {
|
|||
}
|
||||
}
|
||||
])
|
||||
app.__TRAY__.on('click', _ => {
|
||||
let unreadCache = false
|
||||
|
||||
dTray.on('click', _ => {
|
||||
win.show()
|
||||
})
|
||||
|
||||
app.__TRAY__.setContextMenu(menuList)
|
||||
dTray.setContextMenu(menuList)
|
||||
|
||||
return function (unread) {
|
||||
// 缓存状态, 避免频繁修改tray图标
|
||||
if (unreadCache === unread) {
|
||||
return
|
||||
}
|
||||
unreadCache = unread
|
||||
|
||||
if (unread) {
|
||||
dTray.setImage(TRAY_ICO_A)
|
||||
} else {
|
||||
dTray.setImage(TRAY_ICO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ exports.createMainWindow = function (icon) {
|
|||
win.on('ready-to-show', _ => {
|
||||
win.show()
|
||||
|
||||
// win.openDevTools()
|
||||
win.openDevTools()
|
||||
})
|
||||
|
||||
win.webContents.on('dom-ready', ev => {
|
||||
|
@ -70,6 +70,20 @@ exports.createMainWindow = function (icon) {
|
|||
location.reload()
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
function checkUnReadMsg() {
|
||||
|
||||
window.__timer = setTimeout(function() {
|
||||
var $box = document.body.querySelector('.conv-lists-box')
|
||||
var $unread = $box.querySelectorAll('.unread-num')
|
||||
|
||||
electro($unread.length > 0)
|
||||
clearTimeout(window.__timer)
|
||||
checkUnReadMsg()
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
checkUnReadMsg()
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in New Issue