fix: enhance tray icon visual effect in Windows platform

This commit is contained in:
lawvs 2024-11-20 01:34:02 +08:00
parent d0775162af
commit 64c891f30c
1 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import path from "node:path"
import { fileURLToPath } from "node:url"
import { isMacOS } from "./env"
import { isMacOS, isWindows } from "./env"
const __dirname = fileURLToPath(new URL(".", import.meta.url))
const iconMap = {
@ -9,5 +9,13 @@ const iconMap = {
dev: path.join(__dirname, "../../static/icon-dev.png"),
}
export const getIconPath = () => iconMap[process.env.NODE_ENV === "development" ? "dev" : "prod"]
export const getTrayIconPath = () =>
isMacOS ? path.join(__dirname, "../../resources/tray-icon.png") : getIconPath()
export const getTrayIconPath = () => {
if (isMacOS) {
return path.join(__dirname, "../../resources/tray-icon.png")
}
if (isWindows) {
// https://www.electronjs.org/docs/latest/api/tray#:~:text=Windows,best%20visual%20effects.
return path.join(__dirname, "../../resources/icon.ico")
}
return getIconPath()
}