@ruixinkeji/prism-ui 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/store/app.js +9 -6
package/package.json
CHANGED
package/store/app.js
CHANGED
|
@@ -26,7 +26,6 @@ export const useAppStore = defineStore('app', {
|
|
|
26
26
|
// H5 环境 - 给根元素添加 dark-mode 类以更新 CSS 变量
|
|
27
27
|
const htmlElement = document.documentElement;
|
|
28
28
|
const bodyElement = document.body;
|
|
29
|
-
const bgColor = isDark ? '#121212' : '#F5F7FA';
|
|
30
29
|
|
|
31
30
|
if (isDark) {
|
|
32
31
|
htmlElement.classList.add('dark-mode');
|
|
@@ -34,12 +33,16 @@ export const useAppStore = defineStore('app', {
|
|
|
34
33
|
htmlElement.classList.remove('dark-mode');
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
//
|
|
38
|
-
htmlElement.style.backgroundColor = bgColor;
|
|
39
|
-
bodyElement.style.backgroundColor = bgColor;
|
|
40
|
-
|
|
41
|
-
// 更新 meta theme-color 和 color-scheme
|
|
36
|
+
// 从 CSS 变量获取背景色,防止页面切换时闪白
|
|
42
37
|
setTimeout(() => {
|
|
38
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
39
|
+
const bgColor = computedStyle.getPropertyValue('--prism-bg-color-page').trim();
|
|
40
|
+
if (bgColor) {
|
|
41
|
+
htmlElement.style.backgroundColor = bgColor;
|
|
42
|
+
bodyElement.style.backgroundColor = bgColor;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 更新 meta theme-color 和 color-scheme
|
|
43
46
|
const themeColor = isDark ? '#0F0F0F' : '#F5F7FA';
|
|
44
47
|
const colorScheme = isDark ? 'dark' : 'light';
|
|
45
48
|
|