Skip to content

Commit 8631446

Browse files
author
Working On It
committed
fix: improve dark mode
1 parent 699f4de commit 8631446

File tree

7 files changed

+49
-29
lines changed

7 files changed

+49
-29
lines changed

web/src/ActivityPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class ActivityPage extends BaseListPage {
425425

426426
render() {
427427
return (
428-
<div>
428+
<div style={{backgroundColor: Setting.isDarkMode() ? "black" : "white"}}>
429429
<Row style={{marginTop: "20px"}} >
430430
<Col span={1} />
431431
<Col span={17} >

web/src/App.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,14 @@ class App extends Component {
341341
localStorage.setItem("themeAlgorithm", JSON.stringify(nextThemeAlgorithm));
342342
};
343343

344+
getLogo(themes) {
345+
return Setting.getLogo(themes);
346+
}
347+
348+
getFooterHtml(themes) {
349+
return Setting.getFooterHtml(themes);
350+
}
351+
344352
renderAvatar() {
345353
if (this.state.account.avatar === "") {
346354
return (
@@ -813,7 +821,7 @@ class App extends Component {
813821
};
814822

815823
return (
816-
<Header style={{padding: "0", marginBottom: "3px", backgroundColor: this.state.themeAlgorithm.includes("dark") ? "black" : "white", display: "flex", justifyContent: "space-between"}}>
824+
<Header style={{padding: "0", marginBottom: "3px", display: "flex", justifyContent: "space-between", backgroundColor: Setting.isDarkMode() ? "#1f1f1f" : "#fff"}}>
817825
<div style={{display: "flex", alignItems: "center", flex: 1, overflow: "hidden"}}>
818826
{Setting.isMobile() ? null : (
819827
<Link to={"/"}>
@@ -838,7 +846,7 @@ class App extends Component {
838846
</React.Fragment>
839847
) : (
840848
<div style={{display: "flex", marginLeft: "10px", flex: 1, minWidth: 0, overflow: "auto", paddingRight: "20px"}}>
841-
<Menu style={{minWidth: 0, width: "100%"}} onClick={onClick} items={this.getMenuItems()} mode={"horizontal"} selectedKeys={[this.state.selectedMenuKey]} />
849+
<Menu style={{minWidth: 0, width: "100%", backgroundColor: Setting.isDarkMode() ? "#1f1f1f" : "#fff"}} onClick={onClick} items={this.getMenuItems()} mode={"horizontal"} selectedKeys={[this.state.selectedMenuKey]} />
842850
</div>
843851
)}
844852
</div>
@@ -864,7 +872,7 @@ class App extends Component {
864872
height: "67px",
865873
}
866874
}>
867-
<div dangerouslySetInnerHTML={{__html: Setting.getFooterHtml(this.state.themeAlgorithm)}} />
875+
<div dangerouslySetInnerHTML={{__html: this.getFooterHtml(this.state.themeAlgorithm)}} />
868876
</Footer>
869877
</React.Fragment>
870878
);

web/src/OsDesktop.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
height: calc(100vh - 64px);
44
display: flex;
55
flex-direction: column;
6-
background-color: #f0f2f5;
76
overflow: hidden;
87
}
98

@@ -32,7 +31,6 @@
3231
height: 30px;
3332
line-height: 30px;
3433
margin-right: 5px;
35-
background-color: #1a2d3e;
3634
border-radius: 3px;
3735
cursor: pointer;
3836
white-space: nowrap;
@@ -147,7 +145,6 @@
147145

148146
.desktop-icon .icon-name {
149147
text-align: center;
150-
color: #333;
151148
font-size: 14px;
152149
font-weight: 500;
153150
padding: 4px 8px;
@@ -157,7 +154,6 @@
157154
overflow: hidden;
158155
text-overflow: ellipsis;
159156
transition: all 0.2s ease;
160-
text-shadow: 0 1px 2px rgb(255 255 255 / 80%);
161157
background: transparent;
162158
}
163159

@@ -168,7 +164,6 @@
168164
}
169165

170166
.desktop-window {
171-
background-color: white;
172167
border-radius: 5px;
173168
box-shadow: 0 2px 10px rgb(0 0 0 / 20%);
174169
overflow: hidden;
@@ -259,7 +254,6 @@
259254

260255
.window-header {
261256
height: 32px;
262-
background-color: #f5f5f5;
263257
display: flex;
264258
align-items: center;
265259
justify-content: space-between;
@@ -296,7 +290,6 @@
296290
.window-title {
297291
font-size: 14px;
298292
font-weight: 400;
299-
color: #323130;
300293
white-space: nowrap;
301294
overflow: hidden;
302295
text-overflow: ellipsis;
@@ -361,17 +354,12 @@
361354

362355
.window-minimize .control-icon {
363356
font-weight: bold;
364-
color: rgb(0 0 0 / 50%) !important;
365357
}
366358

367359
.window-minimize:active {
368360
background-color: #e6a926 !important;
369361
}
370362

371-
.window-maximize .control-icon {
372-
color: rgb(0 0 0 / 50%) !important;
373-
}
374-
375363
.window-maximize:active {
376364
background-color: #24b53b !important;
377365
}
@@ -419,7 +407,6 @@
419407
.window-content {
420408
flex-grow: 1;
421409
overflow: auto;
422-
background-color: white;
423410
}
424411

425412
.dock {
@@ -428,7 +415,6 @@
428415
left: 50%;
429416
transform: translateX(-50%);
430417
z-index: 2000;
431-
background: rgb(255 255 255 / 90%);
432418
backdrop-filter: blur(10px);
433419
border-radius: 15px;
434420
padding: 8px 16px;

web/src/OsDesktop.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import routeManager, {DynamicRouteComponent} from "./component/AppRouteManager";
2323
import {StaticBaseUrl} from "./Conf";
2424
import {Draggable} from "./component/DragDrop/Draggable";
2525
import {Droppable} from "./component/DragDrop/Droppable";
26-
import {getRandomName} from "./Setting";
26+
import {getRandomName, isDarkMode} from "./Setting";
2727

2828
const getIconUrl = (appType) => {
2929
return `${StaticBaseUrl}/apps/${appType}.svg`;
@@ -182,7 +182,14 @@ const Window = ({title, isMaximized, onClose, onMaximize, onMinimize, onFocus, a
182182
</Button>
183183
</div>
184184
</div>
185-
<div className="window-content">
185+
<div className="window-content" style={{
186+
backgroundColor: isDarkMode() ? "rgba(20, 20, 20, 0.95)" : "rgba(255, 255, 255, 0.95)",
187+
height: "100%",
188+
width: "100%",
189+
overflow: "auto",
190+
padding: "16px",
191+
color: isDarkMode() ? "#fff" : "#000",
192+
}}>
186193
<WindowContent
187194
appType={appType}
188195
account={account}

web/src/Setting.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,3 +2068,13 @@ export function getFooterHtml(themes) {
20682068
return FooterHtml;
20692069
}
20702070
}
2071+
2072+
export function isDarkMode() {
2073+
let storageThemeAlgorithm = [];
2074+
try {
2075+
storageThemeAlgorithm = localStorage.getItem("themeAlgorithm") ? JSON.parse(localStorage.getItem("themeAlgorithm")) : ["default"];
2076+
} catch {
2077+
storageThemeAlgorithm = ["default"];
2078+
}
2079+
return storageThemeAlgorithm.includes("dark") ? true : false;
2080+
}

web/src/UsagePage.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ class UsagePage extends BaseListPage {
521521
trigger: "axis",
522522
axisPointer: {
523523
type: "cross",
524+
crossStyle: {
525+
color: Setting.isDarkMode() ? "rgba(0, 0, 0, 1)" : "#999",
526+
},
524527
},
525528
},
526529
legend: {
@@ -658,10 +661,13 @@ class UsagePage extends BaseListPage {
658661
height: "400px",
659662
width: "100%",
660663
display: "inline-block",
664+
backgroundColor: Setting.isDarkMode() ? "#000" : "#fff",
661665
}}
662666
showLoading={this.state.usages === null}
663667
loadingOption={{
664668
color: localStorage.getItem("themeColor"),
669+
textColor: Setting.isDarkMode() ? "rgba(255, 255, 255, 1)" : "#000",
670+
maskColor: Setting.isDarkMode() ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 0.8)",
665671
fontSize: "16px",
666672
spinnerRadius: 6,
667673
lineWidth: 3,
@@ -677,10 +683,13 @@ class UsagePage extends BaseListPage {
677683
height: "400px",
678684
width: "100%",
679685
display: "inline-block",
686+
backgroundColor: Setting.isDarkMode() ? "#000" : "#fff",
680687
}}
681688
showLoading={this.state.usages === null}
682689
loadingOption={{
683690
color: localStorage.getItem("themeColor"),
691+
textColor: Setting.isDarkMode() ? "rgba(255, 255, 255, 1)" : "#000",
692+
maskColor: Setting.isDarkMode() ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 0.8)",
684693
fontSize: "16px",
685694
spinnerRadius: 6,
686695
lineWidth: 3,
@@ -705,10 +714,13 @@ class UsagePage extends BaseListPage {
705714
height: "400px",
706715
width: "48%",
707716
display: "inline-block",
717+
backgroundColor: Setting.isDarkMode() ? "#000" : "#fff",
708718
}}
709719
showLoading={rangeUsages === null}
710720
loadingOption={{
711721
color: localStorage.getItem("themeColor"),
722+
textColor: Setting.isDarkMode() ? "rgba(255, 255, 255, 1)" : "#000",
723+
maskColor: Setting.isDarkMode() ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 0.8)",
712724
fontSize: "16px",
713725
spinnerRadius: 6,
714726
lineWidth: 3,
@@ -722,10 +734,13 @@ class UsagePage extends BaseListPage {
722734
height: "400px",
723735
width: "48%",
724736
display: "inline-block",
737+
backgroundColor: Setting.isDarkMode() ? "#000" : "#fff",
725738
}}
726739
showLoading={rangeUsages === null}
727740
loadingOption={{
728741
color: localStorage.getItem("themeColor"),
742+
textColor: Setting.isDarkMode() ? "rgba(255, 255, 255, 1)" : "#000",
743+
maskColor: Setting.isDarkMode() ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 0.8)",
729744
fontSize: "16px",
730745
spinnerRadius: 6,
731746
lineWidth: 3,
@@ -740,7 +755,7 @@ class UsagePage extends BaseListPage {
740755

741756
render() {
742757
return (
743-
<div>
758+
<div style={{backgroundColor: Setting.isDarkMode() ? "black" : "white"}}>
744759
<Row style={{marginTop: "20px"}} >
745760
<Col span={1} />
746761
<Col span={17} >

web/src/chat/ChatInput.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {LinkOutlined} from "@ant-design/icons";
1919
import ChatFileInput from "./ChatFileInput";
2020
import UploadFileArea from "./UploadFileArea";
2121
import i18next from "i18next";
22+
import {isDarkMode} from "../Setting";
2223

2324
const ChatInput = ({
2425
value,
@@ -36,13 +37,6 @@ const ChatInput = ({
3637
isVoiceInput,
3738
}) => {
3839

39-
let storageThemeAlgorithm = [];
40-
try {
41-
storageThemeAlgorithm = localStorage.getItem("themeAlgorithm") ? JSON.parse(localStorage.getItem("themeAlgorithm")) : ["default"];
42-
} catch {
43-
storageThemeAlgorithm = ["default"];
44-
}
45-
4640
const sendButtonDisabled = messageError || (value === "" && files.length === 0) || disableInput;
4741

4842
async function handleInputChange(file) {
@@ -136,7 +130,7 @@ const ChatInput = ({
136130
}
137131
loading={loading}
138132
disabled={disableInput}
139-
style={{flex: 1, borderRadius: "8px", background: storageThemeAlgorithm.includes("dark") ? "black" : "white"}}
133+
style={{flex: 1, borderRadius: "8px", background: isDarkMode() ? "black" : "white"}}
140134
placeholder={messageError ? "" : i18next.t("chat:Type message here")}
141135
// if we have some files uploaded but no text was input (value === ""), Sender wont invoke onSubmit.
142136
value={(files.length > 0 && value === "") ? " " + value : value}

0 commit comments

Comments
 (0)