This commit is contained in:
pompurin404 2024-08-15 15:50:08 +08:00
parent 160537bd48
commit 78d6cd6535
No known key found for this signature in database
3 changed files with 24 additions and 9 deletions

9
changelog.md Normal file
View File

@ -0,0 +1,9 @@
### New Features
- 托盘图标显示网速信息
- MacOS允许隐藏Dock图标
- Windows支持数据存储到安装目录
### Bug Fixes
- 修复修改混合端口后无法检查更新的问题

View File

@ -1,6 +1,6 @@
{
"name": "mihomo-party",
"version": "0.5.3",
"version": "0.5.4",
"description": "Mihomo Party",
"main": "./out/main/index.js",
"author": "mihomo-party",

View File

@ -14,6 +14,7 @@ let mihomoLogsWs: WebSocket | null = null
let logsRetry = 10
let mihomoConnectionsWs: WebSocket | null = null
let connectionsRetry = 10
let trafficHopping = false
export const getAxios = async (force: boolean = false): Promise<AxiosInstance> => {
if (axiosIns && !force) return axiosIns
@ -154,17 +155,22 @@ const mihomoTraffic = async (): Promise<void> => {
mihomoTrafficWs.onmessage = (e): void => {
const data = e.data as string
const json = JSON.parse(data) as IMihomoTrafficInfo
tray?.setTitle(
'↑' +
`${calcTraffic(json.up)}/s`.padStart(16) +
'\n↓' +
`${calcTraffic(json.down)}/s`.padStart(16)
)
if (trafficHopping) {
tray?.setTitle('↑' + `${calcTraffic(json.up)}/s`.padStart(14), {
fontType: 'monospacedDigit'
})
} else {
tray?.setTitle('↓' + `${calcTraffic(json.down)}/s`.padStart(14), {
fontType: 'monospacedDigit'
})
}
trafficHopping = !trafficHopping
tray?.setToolTip(
'↑' +
`${calcTraffic(json.up)}/s`.padStart(16) +
`${calcTraffic(json.up)}/s`.padStart(14) +
'\n↓' +
`${calcTraffic(json.down)}/s`.padStart(16)
`${calcTraffic(json.down)}/s`.padStart(14)
)
trafficRetry = 10
mainWindow?.webContents.send('mihomoTraffic', json)