chore: resolve reflict

This commit is contained in:
zhuzhengjian 2023-03-17 15:48:39 +08:00
commit 6c7f67df60
5 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import { computed, defineComponent } from 'vue' import { computed, defineComponent } from 'vue'
import { useProviderConfigState } from '../config-provider/context' import { useProviderConfigState } from '../config-provider/context'
import useStyle from './style' import useStyle from './style'
export default defineComponent({ const Button = defineComponent({
name: 'AButton', name: 'AButton',
inheritAttrs: false, inheritAttrs: false,
props: { props: {
@ -9,7 +9,7 @@ export default defineComponent({
type: String type: String
} }
}, },
setup(props, { slots }) { setup(props, { slots, attrs }) {
const { getPrefixCls } = useProviderConfigState() const { getPrefixCls } = useProviderConfigState()
const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls)) const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls))
const [wrapSSR, hashId] = useStyle(prefixCls) const [wrapSSR, hashId] = useStyle(prefixCls)
@ -18,7 +18,9 @@ export default defineComponent({
[prefixCls.value]: true, [prefixCls.value]: true,
[hashId.value]: true [hashId.value]: true
} }
return wrapSSR(<button class={cls}>{slots.default?.()}</button>) return wrapSSR(<button class={[cls, attrs.class]}>{slots.default?.()}</button>)
} }
} }
}) })
export default Button

View File

@ -77,6 +77,6 @@ export function useToken(): [ComputedRef<Theme<SeedToken, MapToken>>, ComputedRe
return [mergedTheme, computed(() => cacheToken.value?.[0]), computed(() => (designTokenContext.hashed ? cacheToken.value?.[1] : ''))] return [mergedTheme, computed(() => cacheToken.value?.[0]), computed(() => (designTokenContext.hashed ? cacheToken.value?.[1] : ''))]
} }
export type UseComponentStyleResult = [(node: VNodeChild) => VNodeChild, string] export type UseComponentStyleResult = [(node: VNodeChild) => VNodeChild, ComputedRef<string>]
export type GenerateStyle<ComponentToken extends object = AliasToken, ReturnType = CSSInterpolation> = (token: ComponentToken) => ReturnType export type GenerateStyle<ComponentToken extends object = AliasToken, ReturnType = CSSInterpolation> = (token: ComponentToken) => ReturnType

View File

@ -92,7 +92,7 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
flush(component, mergedComponentToken) flush(component, mergedComponentToken)
return [genCommonStyle(token.value, prefixCls.value), styleInterpolation] return [genCommonStyle(token.value, prefixCls.value), styleInterpolation]
}), }),
hashId.value hashId
] ]
} }
} }

View File

@ -2,11 +2,13 @@ import type { Theme } from 'vitepress'
// eslint-disable-next-line import/no-named-as-default // eslint-disable-next-line import/no-named-as-default
import DefaultTheme from 'vitepress/theme' import DefaultTheme from 'vitepress/theme'
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme' import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'
import Antd from '../../../components'
export default { export default {
...DefaultTheme, ...DefaultTheme,
enhanceApp(ctx) { enhanceApp(ctx) {
DefaultTheme.enhanceApp?.(ctx) DefaultTheme.enhanceApp?.(ctx)
ctx.app.component('Demo', AntdTheme) ctx.app.component('Demo', AntdTheme)
ctx.app.use(Antd)
} }
} as Theme } as Theme

View File

@ -10,7 +10,9 @@ title: 基础按钮
<script lang="ts" setup></script> <script lang="ts" setup></script>
<template> <template>
<div></div> <div>
<a-button>这是按钮</a-button>
</div>
</template> </template>
<style scoped></style> <style scoped></style>