Skip to content

Commit 78cb71e

Browse files
authored
feat: add app icon on title bar on desktop window (casibase#1375)
1 parent a063121 commit 78cb71e

File tree

2 files changed

+137
-35
lines changed

2 files changed

+137
-35
lines changed

web/src/OsDesktop.css

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,32 +186,125 @@
186186
}
187187

188188
.window-header {
189-
height: 30px;
189+
height: 32px;
190190
background-color: #f0f0f0;
191191
display: flex;
192192
align-items: center;
193-
padding: 0 10px;
193+
justify-content: space-between;
194+
padding-left: 12px;
195+
padding-right: 0;
194196
cursor: move;
195197
user-select: none;
198+
border-bottom: 1px solid #e5e5e5;
196199
}
197200

198-
.window-navigation {
201+
.window-header-left {
199202
display: flex;
200-
gap: 5px;
201-
margin-right: 10px;
203+
align-items: center;
204+
gap: 12px;
205+
flex-grow: 1;
206+
min-width: 0;
207+
}
208+
209+
.window-app-info {
210+
display: flex;
211+
align-items: center;
212+
gap: 8px;
213+
min-width: 0;
214+
}
215+
216+
.window-app-icon {
217+
width: 16px;
218+
height: 16px;
219+
flex-shrink: 0;
202220
}
203221

204222
.window-title {
205-
flex-grow: 1;
206223
font-size: 14px;
224+
font-weight: 400;
225+
color: #323130;
207226
white-space: nowrap;
208227
overflow: hidden;
209228
text-overflow: ellipsis;
229+
min-width: 0;
230+
}
231+
232+
.window-navigation {
233+
display: flex;
234+
gap: 4px;
235+
flex-shrink: 0;
236+
}
237+
238+
.window-navigation .ant-btn {
239+
border: none;
240+
background-color: transparent;
241+
box-shadow: none;
242+
color: #605e5c;
243+
border-radius: 4px;
244+
width: 32px;
245+
height: 24px;
246+
display: flex;
247+
align-items: center;
248+
justify-content: center;
249+
transition: all 0.2s ease;
250+
}
251+
252+
.window-controls .ant-btn {
253+
border: none;
254+
background-color: transparent;
255+
box-shadow: none;
256+
color: #605e5c;
257+
border-radius: 0;
258+
width: 46px;
259+
height: 32px;
260+
display: flex;
261+
align-items: center;
262+
justify-content: center;
263+
transition: all 0.2s ease;
264+
font-size: 12px;
265+
}
266+
267+
.window-navigation .ant-btn:disabled {
268+
color: #d2d0ce;
269+
background-color: transparent;
270+
}
271+
272+
.window-navigation .ant-btn:hover:not(:disabled) {
273+
background-color: #f3f2f1;
274+
color: #323130;
275+
}
276+
277+
.window-navigation .ant-btn:active:not(:disabled) {
278+
background-color: #edebe9;
210279
}
211280

212281
.window-controls {
213282
display: flex;
214-
gap: 5px;
283+
gap: 0;
284+
flex-shrink: 0;
285+
}
286+
287+
.window-controls .ant-btn:hover:not(.ant-btn-dangerous) {
288+
background-color: #f3f2f1;
289+
color: #323130;
290+
}
291+
292+
.window-controls .ant-btn:active:not(.ant-btn-dangerous) {
293+
background-color: #edebe9;
294+
}
295+
296+
.window-controls .ant-btn-dangerous:hover {
297+
background-color: #e81123;
298+
color: white;
299+
}
300+
301+
.window-controls .ant-btn-dangerous:active {
302+
background-color: #c50e1f;
303+
color: white;
304+
}
305+
306+
.window-controls .ant-btn .anticon {
307+
font-size: 12px;
215308
}
216309

217310
.window-content {

web/src/OsDesktop.js

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
import {Button} from "antd";
2626
import i18next from "i18next";
2727
import "./OsDesktop.css";
28-
import {LeftOutlined, RightOutlined} from "@ant-design/icons";
28+
import {CloseOutlined, LeftOutlined, MinusOutlined, RightOutlined} from "@ant-design/icons";
2929
import {useHistory} from "react-router-dom";
3030
import routeManager, {DynamicRouteComponent} from "./component/AppRouteManager";
3131
import {StaticBaseUrl} from "./Conf";
@@ -133,40 +133,49 @@ const Window = ({id, title, isMaximized, isMinimized, zIndex, position, onClose,
133133
onMaximize();
134134
}}
135135
>
136-
<div className="window-navigation">
137-
<Button
138-
icon={<LeftOutlined />}
139-
size="small"
140-
disabled={!canGoBack}
141-
onClick={(e) => {
142-
e.stopPropagation();
143-
onGoBack();
144-
}}
145-
/>
146-
<Button
147-
icon={<RightOutlined />}
148-
size="small"
149-
disabled={!canGoForward}
150-
onClick={(e) => {
151-
e.stopPropagation();
152-
onGoForward();
153-
}}
154-
/>
136+
<div className="window-header-left">
137+
<div className="window-app-info">
138+
<img
139+
src={`${StaticBaseUrl}/apps/${appConfig?.iconPath}`}
140+
alt={title}
141+
className="window-app-icon"
142+
/>
143+
<div className="window-title">{i18next.t(`${appConfig?.i18nNamespace || "general"}:${title}`)}</div>
144+
</div>
145+
<div className="window-navigation">
146+
<Button
147+
icon={<LeftOutlined />}
148+
size="small"
149+
disabled={!canGoBack}
150+
onClick={(e) => {
151+
e.stopPropagation();
152+
onGoBack();
153+
}}
154+
/>
155+
<Button
156+
icon={<RightOutlined />}
157+
size="small"
158+
disabled={!canGoForward}
159+
onClick={(e) => {
160+
e.stopPropagation();
161+
onGoForward();
162+
}}
163+
/>
164+
</div>
155165
</div>
156-
<div className="window-title">{i18next.t(`${appConfig?.i18nNamespace || "general"}:${title}`)}</div>
157166
<div className="window-controls">
158-
<Button size="small" onClick={(e) => {
167+
<Button size="small" danger icon={<MinusOutlined />} onClick={(e) => {
159168
e.stopPropagation();
160169
onMinimize();
161-
}}>_</Button>
162-
<Button size="small" onClick={(e) => {
170+
}} />
171+
<Button size="small" danger onClick={(e) => {
163172
e.stopPropagation();
164173
onMaximize();
165-
}}>{isMaximized ? "❐" : "□"}</Button>
166-
<Button size="small" danger onClick={(e) => {
174+
}} >{isMaximized ? "❐" : "□"}</Button>
175+
<Button size="small" danger icon={<CloseOutlined />} onClick={(e) => {
167176
e.stopPropagation();
168177
onClose();
169-
}}>×</Button>
178+
}} />
170179
</div>
171180
</div>
172181
<div className="window-content">
@@ -189,7 +198,7 @@ const DockItem = ({window, onClick, isActive}) => {
189198
className={`dock-item ${isActive ? "active" : ""} ${window.isMinimized ? "minimized" : ""}`}
190199
onClick={() => onClick(window.id)}
191200
style={{"--icon-gradient": window.gradient}}
192-
title={i18next.t(`general:${window.title}`)}
201+
title={i18next.t(`${window.appConfig?.i18nNamespace || "general"}:${window.title}`)}
193202
>
194203
<img
195204
src={`${StaticBaseUrl}/apps/${window.iconPath}`}

0 commit comments

Comments
 (0)