Skip to content

Commit 202dc91

Browse files
committed
Fix: Fix the title bar for mac
1 parent 78abee6 commit 202dc91

File tree

2 files changed

+59
-38
lines changed

2 files changed

+59
-38
lines changed

src/components/layout/TopBar.tsx

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const TopBar: React.FC<TopBarProps> = ({ onSelectModel, onOpenSettingsDialog })
1616
const [selectedModelName, setSelectedModelName] = useState('');
1717
const [selectedProvider, setSelectedProvider] = useState('');
1818
const [isMaximized, setIsMaximized] = useState(false);
19+
const [platform, setPlatform] = useState('');
1920

2021
// Check if window is maximized on mount
2122
useEffect(() => {
@@ -31,6 +32,11 @@ const TopBar: React.FC<TopBarProps> = ({ onSelectModel, onOpenSettingsDialog })
3132
window.electron.onWindowMaximizedChange((_event, maximized) => {
3233
setIsMaximized(maximized);
3334
});
35+
36+
window.electron.getPlatform().then((platform) => {
37+
setPlatform(platform);
38+
});
39+
3440
}, []);
3541

3642
// Window control handlers
@@ -86,19 +92,26 @@ const TopBar: React.FC<TopBarProps> = ({ onSelectModel, onOpenSettingsDialog })
8692
return (
8793
<div className="flex items-center justify-between h-16 bg-main-background-color app-region-drag">
8894
{/* Logo area */}
89-
<div className="w-[68px] aspect-square flex items-center justify-center h-16">
90-
<div className="flex items-center justify-center w-10 h-10">
91-
<img
92-
src={tensorBlockLogo}
93-
alt="TensorBlock Logo"
94-
className="w-8 h-8"
95-
onError={(e) => {
96-
const target = e.target as HTMLImageElement;
97-
target.src = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="20" rx="5" ry="5" /><path d="M16 16h.01" /><path d="M8 16h.01" /><path d="M12 8v8" /></svg>';
98-
}}
99-
/>
95+
{
96+
platform === 'darwin' ?
97+
<div className='w-[68px] aspect-square flex items-center justify-center h-16'>
10098
</div>
101-
</div>
99+
:
100+
<div className="w-[68px] aspect-square flex items-center justify-center h-16">
101+
<div className="flex items-center justify-center w-10 h-10">
102+
<img
103+
src={tensorBlockLogo}
104+
alt="TensorBlock Logo"
105+
className="w-8 h-8"
106+
onError={(e) => {
107+
const target = e.target as HTMLImageElement;
108+
target.src = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="20" rx="5" ry="5" /><path d="M16 16h.01" /><path d="M8 16h.01" /><path d="M12 8v8" /></svg>';
109+
}}
110+
/>
111+
</div>
112+
</div>
113+
}
114+
102115

103116
<div className='flex items-center justify-center w-full gap-2'>
104117
<div className="flex items-center w-3/5 gap-2 md:w-2/5">
@@ -140,34 +153,41 @@ const TopBar: React.FC<TopBarProps> = ({ onSelectModel, onOpenSettingsDialog })
140153
/>
141154
</div>
142155

143-
<div className='flex items-start justify-center h-full gap-1'>
144-
<button
145-
className='btn hover:bg-gray-200 bg-transparent border-0 px-3 py-1.5 text-sm font-medium text-gray-600 flex justify-center items-center app-region-no-drag'
146-
onClick={handleMinimize}
147-
>
148-
<Minus className='w-5 h-5' />
149-
</button>
156+
{platform === 'darwin' ?
157+
<div className='flex items-start justify-center h-full gap-1'>
158+
</div>
159+
:
160+
<div className='flex items-start justify-center h-full gap-1'>
161+
<button
162+
className='btn hover:bg-gray-200 bg-transparent border-0 px-3 py-1.5 text-sm font-medium text-gray-600 flex justify-center items-center app-region-no-drag'
163+
onClick={handleMinimize}
164+
>
165+
<Minus className='w-5 h-5' />
166+
</button>
150167

151-
<button
152-
className='btn hover:bg-gray-200 bg-transparent border-0 px-3 py-1.5 text-sm font-medium text-gray-600 flex justify-center items-center app-region-no-drag'
153-
onClick={handleMaximize}
154-
>
155-
{isMaximized ?
156-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" className='w-5 h-5 py-0.5'>
157-
<path d="M2 16.5V6.5C2 5.67157 2.67157 5 3.5 5H13.5C14.3284 5 15 5.67157 15 6.5V16.5C15 17.3284 14.3284 18 13.5 18H3.5C2.67157 18 2 17.3284 2 16.5Z" stroke="#111" stroke-width="1.67"/>
158-
<path d="M6 5V3.5C6 2.67157 6.67157 2 7.5 2H16.5C17.3284 2 18 2.67157 18 3.5V12.5C18 13.3284 17.3284 14 16.5 14H15" stroke="#111" stroke-width="1.67" stroke-linecap="round"/>
159-
</svg>
160-
:
161-
<Square className='w-5 h-5 p-0.5' />}
162-
</button>
168+
<button
169+
className='btn hover:bg-gray-200 bg-transparent border-0 px-3 py-1.5 text-sm font-medium text-gray-600 flex justify-center items-center app-region-no-drag'
170+
onClick={handleMaximize}
171+
>
172+
{isMaximized ?
173+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" className='w-5 h-5 py-0.5'>
174+
<path d="M2 16.5V6.5C2 5.67157 2.67157 5 3.5 5H13.5C14.3284 5 15 5.67157 15 6.5V16.5C15 17.3284 14.3284 18 13.5 18H3.5C2.67157 18 2 17.3284 2 16.5Z" stroke="#111" stroke-width="1.67"/>
175+
<path d="M6 5V3.5C6 2.67157 6.67157 2 7.5 2H16.5C17.3284 2 18 2.67157 18 3.5V12.5C18 13.3284 17.3284 14 16.5 14H15" stroke="#111" stroke-width="1.67" stroke-linecap="round"/>
176+
</svg>
177+
:
178+
<Square className='w-5 h-5 p-0.5' />}
179+
</button>
163180

164-
<button
165-
className='btn hover:bg-red-500 bg-transparent border-0 px-3 py-1.5 text-sm font-medium text-gray-600 hover:text-white flex justify-center items-center app-region-no-drag'
166-
onClick={handleClose}
167-
>
168-
<X className='w-5 h-5' />
169-
</button>
170-
</div>
181+
<button
182+
className='btn hover:bg-red-500 bg-transparent border-0 px-3 py-1.5 text-sm font-medium text-gray-600 hover:text-white flex justify-center items-center app-region-no-drag'
183+
onClick={handleClose}
184+
>
185+
<X className='w-5 h-5' />
186+
</button>
187+
</div>
188+
}
189+
190+
171191
</div>
172192
);
173193
};

src/types/window.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface Window {
55
minimize: () => Promise<boolean>;
66
isMaximized: () => Promise<boolean>;
77
closeApp: () => Promise<void>;
8+
getPlatform: () => Promise<string>;
89
getDeviceInfo: () => Promise<{
910
totalMemory: number;
1011
freeMemory: number;

0 commit comments

Comments
 (0)