UNPKG

dify-components

Version:

This is a modern component library template based on Turborepo+Vue 3.5+TypeScript.

22 lines (18 loc) 666 B
import { App, type Component } from 'vue'; // 如果报:“找不到模块“@difylib/ui”或其相应的类型声明”的错误,记得先build打包一下 import * as UI from '@difylib/ui'; export function useGlobalComp(app: App) { // 注册 UI 组件 Object.entries(UI).forEach(([key, component]) => { if (key !== 'default' && isVueComponent(component)) { app.component(key, component); } }); // 注册 其他 组件 // app.component('Demo', Demo); } function isVueComponent(component: any): component is Component { return ( typeof component === 'object' && (component.install || component.render || component.setup) ); }