lambo-design-bi 0.0.140 → 0.0.141
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.
package/bi/widget/layout/row.vue
CHANGED
|
@@ -12,7 +12,7 @@ import BiEmpty from "../../../pub/empty/index.vue"
|
|
|
12
12
|
*/
|
|
13
13
|
export const WIDGET_MAP = {
|
|
14
14
|
"20": BiPage,
|
|
15
|
-
"32": BiRow,
|
|
15
|
+
"32": typeof BiRow !== 'undefined' ? BiRow : () => import("../layout/row.vue"),
|
|
16
16
|
"33": BiCol,
|
|
17
17
|
"40": BiContainerCard,
|
|
18
18
|
"41": BiNumIndex,
|
|
@@ -21,11 +21,46 @@ export const WIDGET_MAP = {
|
|
|
21
21
|
"_empty": BiEmpty,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
// 获取组件的工具函数
|
|
25
|
+
export async function getWidgetComponent(key) {
|
|
26
|
+
try {
|
|
27
|
+
const componentOrFunction = WIDGET_MAP[key];
|
|
28
|
+
|
|
29
|
+
if (!componentOrFunction) {
|
|
30
|
+
console.warn(`未找到键为 ${key} 的组件`);
|
|
31
|
+
return WIDGET_MAP['_empty'];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 如果是函数(动态导入)
|
|
35
|
+
if (typeof componentOrFunction === 'function') {
|
|
36
|
+
const module = await componentOrFunction();
|
|
37
|
+
return module.default || module;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 如果是组件对象(静态导入)
|
|
41
|
+
return componentOrFunction;
|
|
42
|
+
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(`加载组件 ${key} 失败:`, error);
|
|
45
|
+
return WIDGET_MAP['_empty'];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function getWidgetName(item) {
|
|
25
50
|
console.log('getWidgetName WIDGET_MAP=', WIDGET_MAP)
|
|
26
51
|
let type = item.type
|
|
27
|
-
|
|
28
|
-
|
|
52
|
+
|
|
53
|
+
if (type && Object.prototype.hasOwnProperty.call(WIDGET_MAP, type)) {
|
|
54
|
+
try {
|
|
55
|
+
const component = await getWidgetComponent(type);
|
|
56
|
+
if (component) {
|
|
57
|
+
return component;
|
|
58
|
+
} else {
|
|
59
|
+
console.warn(`类型 ${type} 对应的组件加载失败`);
|
|
60
|
+
}
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error(`获取组件 ${type} 时发生错误:`, error);
|
|
63
|
+
}
|
|
29
64
|
} else {
|
|
30
65
|
console.warn(`未找到type=${type}对应的组件,使用默认组件`)
|
|
31
66
|
console.log('getWidgetName item=', item)
|
|
@@ -36,6 +71,7 @@ export function getWidgetName(item) {
|
|
|
36
71
|
} else {
|
|
37
72
|
console.log('getWidgetName 类型无效值或者不包含 type=', type)
|
|
38
73
|
}
|
|
39
|
-
return WIDGET_MAP['_empty']
|
|
40
74
|
}
|
|
41
|
-
|
|
75
|
+
|
|
76
|
+
return WIDGET_MAP['_empty'];
|
|
77
|
+
}
|