Skip to content

Commit 31cbd31

Browse files
committed
fix: some css style issues
1 parent 0068b87 commit 31cbd31

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

src/components/core/dynamic-table/src/components/tool-bar/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex justify-between p-y-16px">
2+
<div class="flex justify-between p-16px">
33
<slot name="headerTitle">
44
<div class="title">
55
{{ title }}
@@ -42,7 +42,6 @@
4242
display: flex;
4343
align-items: center;
4444
justify-content: flex-start;
45-
color: rgba(0, 0, 0, 0.85);
4645
font-weight: 500;
4746
font-size: 16px;
4847
}

src/store/modules/projectConfig.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineStore } from 'pinia';
22
import darkThemeCss from 'ant-design-vue/dist/antd.dark.css?raw';
3+
import { useMutationObserver } from '@vueuse/core';
34
import { ConfigProvider } from 'ant-design-vue';
45
import type { Theme } from 'ant-design-vue/es/config-provider/';
56
import { store } from '@/store';
@@ -11,6 +12,20 @@ styleDom.dataset.type = 'theme-dark';
1112
styleDom.textContent = darkThemeCss;
1213
document.head.appendChild(styleDom);
1314

15+
useMutationObserver(
16+
document.head,
17+
(mutations) => {
18+
const hasCustomStyleEl = mutations.some((n) => Array.from(n.addedNodes).includes(styleDom));
19+
if (!hasCustomStyleEl) {
20+
document.head.appendChild(styleDom);
21+
styleDom.disabled = !document.documentElement.classList.contains('dark');
22+
}
23+
},
24+
{
25+
childList: true,
26+
},
27+
);
28+
1429
/**
1530
* 项目默认配置项
1631
* primaryColor - 默认主题色, 如果修改颜色不生效,请清理 localStorage
@@ -71,20 +86,23 @@ const setRealDarkTheme = (navTheme?: ThemeName) => {
7186
}
7287
};
7388

74-
let localThemeConfig: Partial<ThemeState> = {};
75-
try {
76-
localThemeConfig = JSON.parse(Storage.get(THEME_KEY, '{}'));
77-
const { primaryColor, navTheme } = localThemeConfig;
78-
setRealDarkTheme(navTheme);
79-
primaryColor &&
80-
ConfigProvider.config({
81-
theme: {
82-
primaryColor,
83-
},
84-
});
85-
} catch {
86-
localThemeConfig = {};
87-
}
89+
const getLocalThemeConfig = (): Partial<ThemeState> => {
90+
try {
91+
return JSON.parse(Storage.get(THEME_KEY, '{}'));
92+
} catch {
93+
return {};
94+
}
95+
};
96+
97+
const localThemeConfig = getLocalThemeConfig();
98+
const { primaryColor, navTheme } = localThemeConfig;
99+
setRealDarkTheme(navTheme);
100+
primaryColor &&
101+
ConfigProvider.config({
102+
theme: {
103+
primaryColor,
104+
},
105+
});
88106

89107
export const useThemeStore = defineStore({
90108
id: 'theme',

0 commit comments

Comments
 (0)