Skip to content

Commit 7df8856

Browse files
committed
添加暗黑主题支持,抽离 CSS 变量以简化主题样式管理,优化加载动画逻辑,完善主题切换功能。
1 parent 1a147e4 commit 7df8856

File tree

3 files changed

+58
-15
lines changed

3 files changed

+58
-15
lines changed

composeApp/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ repositories {
1616
}
1717
google()
1818
mavenCentral()
19-
maven {
20-
url = rootDir.resolve("libs").toURI()
21-
mavenContent {
22-
includeGroup("com.squareup")
23-
}
24-
}
19+
// maven {
20+
// url = rootDir.resolve("libs").toURI()
21+
// mavenContent {
22+
// includeGroup("com.squareup")
23+
// }
24+
// }
2525
}
2626

2727
// 刷新snapshot

composeApp/src/wasmJsMain/resources/loading.css

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@
88
--background-color: #fafafa;
99
--text-color: #333;
1010
--shadow-color: rgba(0, 0, 0, 0.05);
11+
--progress-bg-color: rgba(0, 0, 0, 0.05);
12+
--info-text-color: rgba(0, 0, 0, 0.5);
13+
--code-text-color: rgba(0, 0, 0, 0.4);
14+
--tag-bg-color: rgba(74, 134, 232, 0.1);
15+
--shine-gradient: rgba(255, 255, 255, 0.5);
16+
}
17+
18+
/* Dark Theme Variables */
19+
:root.dark-theme {
20+
--primary-color: #6ba3f5;
21+
--secondary-color: #8bb5f0;
22+
--accent-color: #a5c7f2;
23+
--background-color: #1a1a1a;
24+
--text-color: #e0e0e0;
25+
--shadow-color: rgba(255, 255, 255, 0.05);
26+
--progress-bg-color: rgba(255, 255, 255, 0.1);
27+
--info-text-color: rgba(255, 255, 255, 0.7);
28+
--code-text-color: rgba(255, 255, 255, 0.6);
29+
--tag-bg-color: rgba(107, 163, 245, 0.2);
30+
--shine-gradient: rgba(255, 255, 255, 0.3);
1131
}
1232

1333
/* Loading Container */
@@ -194,7 +214,7 @@
194214
.progress-container {
195215
width: 320px;
196216
height: 4px;
197-
background-color: rgba(0, 0, 0, 0.05);
217+
background-color: var(--progress-bg-color);
198218
border-radius: 2px;
199219
margin: 40px auto 15px;
200220
overflow: hidden;
@@ -219,9 +239,9 @@
219239
width: 100%;
220240
height: 100%;
221241
background: linear-gradient(90deg,
222-
rgba(255, 255, 255, 0) 0%,
223-
rgba(255, 255, 255, 0.5) 50%,
224-
rgba(255, 255, 255, 0) 100%);
242+
transparent 0%,
243+
var(--shine-gradient) 50%,
244+
transparent 100%);
225245
transform: translateX(-100%);
226246
animation: shine 1.5s infinite;
227247
}
@@ -244,7 +264,7 @@
244264
/* Info Text */
245265
.info-text {
246266
font-size: 12px;
247-
color: rgba(0, 0, 0, 0.5);
267+
color: var(--info-text-color);
248268
text-align: center;
249269
max-width: 320px;
250270
line-height: 1.6;
@@ -254,7 +274,7 @@
254274
.code-animation {
255275
font-family: 'Courier New', monospace;
256276
font-size: 12px;
257-
color: rgba(0, 0, 0, 0.4);
277+
color: var(--code-text-color);
258278
text-align: center;
259279
margin-top: 20px;
260280
height: 16px;
@@ -296,7 +316,7 @@
296316

297317
.tag {
298318
padding: 4px 10px;
299-
background-color: rgba(74, 134, 232, 0.1);
319+
background-color: var(--tag-bg-color);
300320
border-radius: 12px;
301321
font-size: 10px;
302322
color: var(--primary-color);
@@ -347,4 +367,4 @@
347367
top: 0;
348368
left: 0;
349369
overflow: hidden;
350-
}
370+
}

composeApp/src/wasmJsMain/resources/loading.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ function loadComposeScript() {
9393
});
9494
}
9595

96+
// Theme detection and application
97+
function applyTheme() {
98+
try {
99+
const savedTheme = localStorage.getItem('simbot_codegen_theme_preference');
100+
const isDarkTheme = savedTheme === 'DARK';
101+
102+
if (isDarkTheme) {
103+
document.documentElement.classList.add('dark-theme');
104+
} else {
105+
document.documentElement.classList.remove('dark-theme');
106+
}
107+
108+
console.log(`Applied theme: ${isDarkTheme ? 'DARK' : 'LIGHT'}`);
109+
} catch (e) {
110+
// Fallback to light theme on error
111+
document.documentElement.classList.remove('dark-theme');
112+
console.warn('Failed to load theme preference, using light theme as fallback');
113+
}
114+
}
115+
96116
// Main initialization function
97117
function initializeLoadingScreen() {
98118
const loadingContainer = document.getElementById('loading-container');
@@ -104,6 +124,9 @@ function initializeLoadingScreen() {
104124
return;
105125
}
106126

127+
// Apply theme before showing animations
128+
applyTheme();
129+
107130
// Create optimized animations
108131
createFloatingParticles();
109132
const codeLineInterval = animateCodeLines();
@@ -182,4 +205,4 @@ if (document.readyState === 'loading') {
182205
} else {
183206
// DOM already loaded
184207
initializeLoadingScreen();
185-
}
208+
}

0 commit comments

Comments
 (0)