Skip to content

Commit d20f0d2

Browse files
committed
fix: 修改macos窗口按钮和icon显示
1 parent f5fcd46 commit d20f0d2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

electron/main.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { app, BrowserWindow, nativeImage } from "electron";
1+
import { app, BrowserWindow } from "electron";
22
import isDev from "electron-is-dev";
33
import log from "electron-log";
44
import path from "node:path";
@@ -24,7 +24,10 @@ let mainWindow: BrowserWindow | null;
2424
function createWindow() {
2525
mainWindow = new BrowserWindow({
2626
title: "Biu",
27-
icon: path.resolve(IconBase, ELECTRON_ICON_BASE_PATH, process.platform === "win32" ? "logo.ico" : "logo.icns"),
27+
icon:
28+
process.platform === "darwin"
29+
? undefined
30+
: path.resolve(IconBase, ELECTRON_ICON_BASE_PATH, process.platform === "win32" ? "logo.ico" : "logo.png"),
2831
show: true,
2932
hasShadow: true,
3033
width: 1200,
@@ -52,7 +55,7 @@ function createWindow() {
5255
},
5356
}
5457
: {}),
55-
trafficLightPosition: { x: 0, y: 0 },
58+
trafficLightPosition: { x: 16, y: 18 },
5659
webPreferences: {
5760
preload: path.join(__dirname, "preload.cjs"),
5861
webSecurity: true,
@@ -74,12 +77,6 @@ function createWindow() {
7477
event.preventDefault();
7578
});
7679

77-
// MAC dock icon
78-
if (process.platform === "darwin") {
79-
const dockIcon = nativeImage.createFromPath(path.resolve(IconBase, ELECTRON_ICON_BASE_PATH, "logo.png"));
80-
app.dock?.setIcon(dockIcon);
81-
}
82-
8380
const indexPath = path.resolve(__dirname, "../dist/web/index.html");
8481
mainWindow.loadFile(indexPath);
8582
if (isDev) {

src/layout/side/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Card } from "@heroui/react";
2+
import { twMerge } from "tailwind-merge";
23

34
import { ReactComponent as Logo } from "@/assets/icons/logo.svg";
45
import ScrollContainer from "@/components/scroll-container";
@@ -7,9 +8,16 @@ import Collection from "./collection";
78
import Menu from "./menu";
89

910
const SideNav = () => {
11+
const isMac = window.electron?.getPlatform() === "macos";
12+
1013
return (
1114
<Card radius="none" shadow="none" className="flex h-full flex-none flex-col md:w-[220px]">
12-
<div className="window-drag text-primary flex flex-none items-center space-x-2 px-7 py-4">
15+
<div
16+
className={twMerge(
17+
"window-drag text-primary flex flex-none items-center space-x-2 px-7 py-4",
18+
isMac && "pt-12",
19+
)}
20+
>
1321
<Logo className="h-10 w-10" />
1422
<span className="text-3xl leading-none font-bold">Biu</span>
1523
</div>

0 commit comments

Comments
 (0)