Compare commits

...

3 Commits

Author SHA1 Message Date
6f22f963b4 feat: add global register 2023-03-10 22:18:22 +08:00
1e19c7fac2 feat: add button 2023-03-10 22:11:33 +08:00
a2dd8a0336 fix: fix hashId is not reactivty 2023-03-10 21:39:50 +08:00
8 changed files with 40 additions and 8 deletions

View File

@ -0,0 +1,13 @@
import { defineComponent } from 'vue'
const Button = defineComponent({
name: 'AButton',
props: {},
setup(props, { slots }) {
return () => {
return <button>{slots.default?.()}</button>
}
}
})
export default Button

View File

@ -0,0 +1,8 @@
import type { App } from 'vue'
import Button from './button'
Button.install = function (app: App) {
app.component(Button.name, Button)
}
export default Button

1
components/components.ts Normal file
View File

@ -0,0 +1 @@
export { default as Button } from './button'

View File

@ -1,7 +1,13 @@
export {}
import type { App } from 'vue'
import * as components from './components'
const aaa = () => {
// TODO
export default {
install(app: App) {
for (const componentsKey in components) {
const component = (components as any)[componentsKey]
if (component.install) {
app.use(component)
}
}
}
}
export default aaa

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] : ''))]
}
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

View File

@ -92,7 +92,7 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
flush(component, mergedComponentToken)
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
import DefaultTheme from 'vitepress/theme'
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'
import Antd from '../../../components'
export default {
...DefaultTheme,
enhanceApp(ctx) {
DefaultTheme.enhanceApp?.(ctx)
ctx.app.component('Demo', AntdTheme)
ctx.app.use(Antd)
}
} as Theme

View File

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