这一版本优化了很多

This commit is contained in:
王利强
2026-06-03 10:16:37 +08:00
parent 8046316216
commit 2af9f1fd59
954 changed files with 58194 additions and 1609 deletions

View File

@@ -0,0 +1,54 @@
<template>
<view :class="themeClass" :style="rootStyle">
<slot />
</view>
</template>
<script lang="ts">
export default {
name: 'wd-config-provider',
options: {
virtualHost: true,
addGlobalClass: true,
styleIsolation: 'shared'
}
}
</script>
<script lang="ts" setup>
import { computed, inject } from 'vue'
import { configProviderProps, CONFIG_PROVIDER_KEY, type ConfigProviderProvide } from './types'
import { objToStyle } from '../common/util'
import { useChildren } from '../composables/useChildren'
import { mapThemeVarsToCSSVars } from '../composables/useConfigProvider'
import { USE_CONFIG_PROVIDER_KEY } from '../composables/useConfigProvider'
const None = Symbol('None')
const hooksProvider = inject<ConfigProviderProvide | typeof None>(USE_CONFIG_PROVIDER_KEY, None)
const props = defineProps(configProviderProps)
const { linkChildren } = useChildren(CONFIG_PROVIDER_KEY)
const themeClass = computed(() => {
return `wot-theme-${props.theme} ${props.customClass}`
})
const themeStyle = computed(() => {
if (hooksProvider !== None) {
return hooksProvider.themeStyle.value
}
const styleObj = mapThemeVarsToCSSVars(props.themeVars)
return styleObj ? `${objToStyle(styleObj)}` : ''
})
const rootStyle = computed(() => {
const style = `${themeStyle.value}${props.customStyle}`
return style
})
linkChildren({
themeStyle
} as ConfigProviderProvide)
</script>
<style lang="scss" scoped></style>