diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..1bc24a9 --- /dev/null +++ b/changelog.md @@ -0,0 +1,9 @@ +### New Features + +- 托盘图标显示网速信息 +- MacOS允许隐藏Dock图标 +- Windows支持数据存储到安装目录 + +### Bug Fixes + +- 修复修改混合端口后无法检查更新的问题 diff --git a/package.json b/package.json index ae59993..fed4f6c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main/core/mihomoApi.ts b/src/main/core/mihomoApi.ts index 1d05fe2..4ef0c44 100644 --- a/src/main/core/mihomoApi.ts +++ b/src/main/core/mihomoApi.ts @@ -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 => { if (axiosIns && !force) return axiosIns @@ -154,17 +155,22 @@ const mihomoTraffic = async (): Promise => { 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)