安装与快速开始
要求 Vue 3.5+,推荐 Node 22.12+ 和 pnpm 10。包尚未发布;本地先 pnpm build,然后在 packages/ui 下 pnpm pack,将生成的 .tgz 安装到消费者。
发布到组织 Registry 后:
sh
pnpm add @wizdomt/ui无需在业务项目额外安装 PrimeVue 或 UnoCSS。
应用配置
ts
import { createApp } from 'vue'
import { WizdomtUI } from '@wizdomt/ui'
import '@wizdomt/ui/style.css'
import App from './App.vue'
createApp(App).use(WizdomtUI).mount('#app')插件安装主题与 Toast 服务,不全局注册组件。组件按需导入,保持 Tree Shaking。
vue
<script setup lang="ts">
import { ref } from 'vue'
import { WButton, WInput, WDialog } from '@wizdomt/ui'
const name = ref('')
const visible = ref(false)
</script>
<template>
<label for="name">名称</label>
<WInput id="name" v-model="name" />
<WButton label="打开" @click="visible = true" />
<WDialog v-model:visible="visible" header="你好" modal>
{{ name }}
</WDialog>
</template>子路径导入
每个组件和指令都有独立子路径,路径为导出名去掉 W 后的 kebab-case:
| 导出名 | 子路径 |
|---|---|
WButton | @wizdomt/ui/button |
WAccordionPanel | @wizdomt/ui/accordion-panel |
WBlockUI | @wizdomt/ui/block-ui |
WPillTabs | @wizdomt/ui/pill-tabs |
WTooltip | @wizdomt/ui/tooltip |
ts
import { WButton, type WButtonProps } from '@wizdomt/ui/button'子路径与根入口导出的是同一个组件,可以混用。子路径不包含样式,仍需引入 @wizdomt/ui/style.css。WTreeNode、WMenuItem 等跨组件共享的类型,以及插件、组合式函数和服务,从根入口 @wizdomt/ui 导入。
类型与输出
ts
import type { WButtonProps, WDialogProps, WSelectChangeEvent } from '@wizdomt/ui'
import { blue, BREAKPOINTS } from '@wizdomt/ui/tokens'本期发布 ESM(import),不提供 CommonJS require 入口;上游 PrimeVue/PrimeUIX 使用 ESM,避免提供无法独立运行的伪 CJS 包。Vue 为 peer dependency,PrimeVue 与主题为精确版本的直接 dependency。
使用图标
文档站统一使用 @wizdomt/icons。在业务项目中使用同样的图标时,单独安装图标包:
sh
pnpm add @wizdomt/iconsvue
<script setup lang="ts">
import { WButton } from '@wizdomt/ui'
import { Add1Icon } from '@wizdomt/icons'
</script>
<template>
<WButton label="添加">
<template #icon><Add1Icon :size="18" /></template>
</WButton>
</template>图标默认继承 currentColor,随按钮和明暗主题变色。装饰图标自动隐藏于无障碍树;纯图标按钮仍需要设置 aria-label。