fix: dealing with switching topics modal, notification, message does not take effect close #6512 (#6518)
* fix: resolve dark mode not support * fix: unified expressionpull/6527/head
parent
61d6312783
commit
b103b7570d
|
@ -21,7 +21,7 @@ import statisticToken, { merge as mergeToken, statistic } from './util/statistic
|
||||||
import type { VueNode } from '../_util/type';
|
import type { VueNode } from '../_util/type';
|
||||||
import { objectType } from '../_util/type';
|
import { objectType } from '../_util/type';
|
||||||
import type { ComputedRef, InjectionKey, Ref } from 'vue';
|
import type { ComputedRef, InjectionKey, Ref } from 'vue';
|
||||||
import { defineComponent, provide, computed, inject } from 'vue';
|
import { defineComponent, provide, computed, inject, watchEffect, ref } from 'vue';
|
||||||
import { toReactive } from '../_util/toReactive';
|
import { toReactive } from '../_util/toReactive';
|
||||||
|
|
||||||
const defaultTheme = createTheme(defaultDerivative);
|
const defaultTheme = createTheme(defaultDerivative);
|
||||||
|
@ -63,12 +63,17 @@ export interface DesignTokenContext {
|
||||||
//defaultConfig
|
//defaultConfig
|
||||||
const DesignTokenContextKey: InjectionKey<DesignTokenContext> = Symbol('DesignTokenContext');
|
const DesignTokenContextKey: InjectionKey<DesignTokenContext> = Symbol('DesignTokenContext');
|
||||||
|
|
||||||
|
export const globalDesignTokenApi = ref<DesignTokenContext>();
|
||||||
|
|
||||||
export const useDesignTokenProvider = (value: DesignTokenContext) => {
|
export const useDesignTokenProvider = (value: DesignTokenContext) => {
|
||||||
provide(DesignTokenContextKey, value);
|
provide(DesignTokenContextKey, value);
|
||||||
|
watchEffect(() => {
|
||||||
|
globalDesignTokenApi.value = value;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useDesignTokenInject = () => {
|
export const useDesignTokenInject = () => {
|
||||||
return inject(DesignTokenContextKey, defaultConfig);
|
return inject(DesignTokenContextKey, globalDesignTokenApi.value || defaultConfig);
|
||||||
};
|
};
|
||||||
export const DesignTokenProvider = defineComponent({
|
export const DesignTokenProvider = defineComponent({
|
||||||
props: {
|
props: {
|
||||||
|
@ -87,7 +92,10 @@ export function useToken(): [
|
||||||
ComputedRef<GlobalToken>,
|
ComputedRef<GlobalToken>,
|
||||||
ComputedRef<string>,
|
ComputedRef<string>,
|
||||||
] {
|
] {
|
||||||
const designTokenContext = inject(DesignTokenContextKey, defaultConfig);
|
const designTokenContext = inject<DesignTokenContext>(
|
||||||
|
DesignTokenContextKey,
|
||||||
|
globalDesignTokenApi.value || defaultConfig,
|
||||||
|
);
|
||||||
|
|
||||||
const salt = computed(() => `${version}-${designTokenContext.hashed || ''}`);
|
const salt = computed(() => `${version}-${designTokenContext.hashed || ''}`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue