mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-19 14:00:50 +08:00
refactor(config-consumer): ts
This commit is contained in:
parent
679db42559
commit
defbb58129
@ -1,2 +1,2 @@
|
||||
/* istanbul ignore file */
|
||||
export { default as NConfigConsumer } from './src/ConfigConsumer.js'
|
||||
export { default as NConfigConsumer } from './src/ConfigConsumer'
|
@ -1,4 +1,5 @@
|
||||
import { defineComponent, inject, toRef, watch } from 'vue'
|
||||
import { ConfigProviderInjection } from '../../config-provider'
|
||||
import useLegacy from './use-legacy'
|
||||
|
||||
export default defineComponent({
|
||||
@ -24,7 +25,10 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
setup (props) {
|
||||
const NConfigProvider = inject('NConfigProvider', null)
|
||||
const NConfigProvider = inject<ConfigProviderInjection | null>(
|
||||
'NConfigProvider',
|
||||
null
|
||||
)
|
||||
if (NConfigProvider) {
|
||||
watch(toRef(NConfigProvider, 'mergedNamespace'), (value, oldValue) => {
|
||||
const { onNamespaceChange } = props
|
@ -1,7 +1,18 @@
|
||||
import { computed, watch, toRef } from 'vue'
|
||||
import { ConfigProviderInjection } from '../../config-provider'
|
||||
import styleScheme from '../../_deprecated/style-scheme'
|
||||
|
||||
export default function useLegacy (NConfigProvider, props) {
|
||||
interface UseLegacyProps {
|
||||
onLanguageChange: (
|
||||
lang: string | undefined,
|
||||
oldLang: string | undefined
|
||||
) => void
|
||||
}
|
||||
|
||||
export default function useLegacy (
|
||||
NConfigProvider: ConfigProviderInjection | null,
|
||||
props: UseLegacyProps
|
||||
) {
|
||||
if (NConfigProvider) {
|
||||
watch(toRef(NConfigProvider, 'mergedLanguage'), (value, oldValue) => {
|
||||
const { onLanguageChange } = props
|
||||
@ -22,7 +33,7 @@ export default function useLegacy (NConfigProvider, props) {
|
||||
: null
|
||||
}),
|
||||
legacyStyleScheme: computed(() => {
|
||||
return styleScheme[NConfigProvider.mergedTheme || 'light']
|
||||
return (styleScheme as any)[NConfigProvider?.mergedTheme || 'light']
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user