schangxiang@126.com
2025-05-21 ec3cfd144de6fcf5e5cbfaf02585c17805300602
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * 导出所有 widgets
 */
import type { DefineComponent } from 'vue'
 
/**
 * 控件信息
 */
type Widget = {
  is: string
  name: string
  category: string
  icon: string
  canvasView: DefineComponent // 画布视图 import XXX from 'XXX.vue'
  settingsView: DefineComponent // 设置视图 import XXXSettings from 'XXX.settings.vue'
}
 
const moduleMap = import.meta.glob('./*/index.ts', { eager: true })
const widgets: any = Object.values(moduleMap).map((module: any) => module)
 
export async function getWidgets() {
  const widgetsData = []
  for (let i = 0; i < widgets.length; i++) {
    const widget = await widgets[i]()
    widgetsData.push(widget.default)
  }
  return widgetsData
}
 
export default widgets