lambo-design-bi 0.0.142 → 0.0.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  import BiPage from "../page/index.vue"
2
- import BiRow from "../layout/row.vue"
3
2
  import BiCol from "../layout/col.vue"
4
3
  import BiContainerCard from "../container/card/card-widget.vue"
5
4
  import BiNumIndex from "../num/index.vue"
@@ -12,7 +11,7 @@ import BiEmpty from "../../../pub/empty/index.vue"
12
11
  */
13
12
  export const WIDGET_MAP = {
14
13
  "20": BiPage,
15
- "32": BiRow,
14
+ "32": () => import("../layout/row.vue"), // 总是使用动态导入
16
15
  "33": BiCol,
17
16
  "40": BiContainerCard,
18
17
  "41": BiNumIndex,
@@ -21,11 +20,24 @@ export const WIDGET_MAP = {
21
20
  "_empty": BiEmpty,
22
21
  }
23
22
 
24
- export function getWidgetName(item) {
23
+ export async function getWidgetName(item) {
25
24
  console.log('getWidgetName WIDGET_MAP=', WIDGET_MAP)
26
25
  let type = item.type
27
- if (type && Object.prototype.hasOwnProperty.call(WIDGET_MAP, type) && WIDGET_MAP[type]) {
28
- return WIDGET_MAP[type]
26
+ if (type && Object.prototype.hasOwnProperty.call(WIDGET_MAP, type)) {
27
+ const component = WIDGET_MAP[type];
28
+ // 如果是函数,动态导入
29
+ if (typeof component === 'function') {
30
+ try {
31
+ const module = await component();
32
+ return module.default;
33
+ } catch (error) {
34
+ console.error('动态加载组件失败:', error);
35
+ return WIDGET_MAP['_empty'];
36
+ }
37
+ } else {
38
+ console.error('组件不是一个函数无法导入');
39
+ }
40
+ return component
29
41
  } else {
30
42
  console.warn(`未找到type=${type}对应的组件,使用默认组件`)
31
43
  console.log('getWidgetName item=', item)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambo-design-bi",
3
- "version": "0.0.142",
3
+ "version": "0.0.143",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",