Skip to content

Commit

Permalink
fix: enhance tray icon visual effect in Windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs committed Nov 19, 2024
1 parent d077516 commit 64c891f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions apps/main/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
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 = {
prod: path.join(__dirname, "../../resources/icon.png"),
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()
}

0 comments on commit 64c891f

Please sign in to comment.