lambo-design-bi 0.0.141 → 0.0.142

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.
@@ -4,7 +4,7 @@
4
4
  <el-row class="custom-row"
5
5
  :gutter="(widget.options && widget.options.gutter) ? parseInt(widget.options.gutter) : 0">
6
6
  <template v-for="(item, index) in widget.widgets">
7
- <component :is="getWidgetName(item)" :widget="item" :key="index" :params="params">
7
+ <component :is="getWidgetNameSync(item)" :widget="item" :key="index" :params="params">
8
8
  <template v-for="slot in Object.keys($scopedSlots)" v-slot:[slot]="scope">
9
9
  <slot :name="slot" v-bind="scope" />
10
10
  </template>
@@ -14,7 +14,7 @@
14
14
  </div>
15
15
  </template>
16
16
  <script>
17
- import { getWidgetName } from '../util/widget-map'
17
+ import { getWidgetNameSync } from '../util/widget-map'
18
18
 
19
19
  export default {
20
20
  name: 'BiRow',
@@ -35,7 +35,7 @@ export default {
35
35
  }
36
36
  },
37
37
  methods: {
38
- getWidgetName
38
+ getWidgetNameSync
39
39
  },
40
40
  created() {
41
41
 
@@ -2,9 +2,9 @@ import BiPage from "../page/index.vue"
2
2
  import BiRow from "../layout/row.vue"
3
3
  import BiCol from "../layout/col.vue"
4
4
  import BiContainerCard from "../container/card/card-widget.vue"
5
- import BiPagingTable from "../table/paging-table.vue"
6
5
  import BiNumIndex from "../num/index.vue"
7
6
  import BiDetailTable from "../table/detail-table.vue"
7
+ import BiPagingTable from "../table/paging-table.vue"
8
8
  import BiEmpty from "../../../pub/empty/index.vue"
9
9
 
10
10
  /**
@@ -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": typeof BiRow !== 'undefined' ? BiRow : () => import("../layout/row.vue"),
15
+ "32": BiRow,
16
16
  "33": BiCol,
17
17
  "40": BiContainerCard,
18
18
  "41": BiNumIndex,
@@ -21,46 +21,11 @@ export const WIDGET_MAP = {
21
21
  "_empty": BiEmpty,
22
22
  }
23
23
 
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) {
24
+ export function getWidgetName(item) {
50
25
  console.log('getWidgetName WIDGET_MAP=', WIDGET_MAP)
51
26
  let type = item.type
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
- }
27
+ if (type && Object.prototype.hasOwnProperty.call(WIDGET_MAP, type) && WIDGET_MAP[type]) {
28
+ return WIDGET_MAP[type]
64
29
  } else {
65
30
  console.warn(`未找到type=${type}对应的组件,使用默认组件`)
66
31
  console.log('getWidgetName item=', item)
@@ -71,7 +36,24 @@ export async function getWidgetName(item) {
71
36
  } else {
72
37
  console.log('getWidgetName 类型无效值或者不包含 type=', type)
73
38
  }
39
+ return WIDGET_MAP['_empty']
74
40
  }
75
-
76
- return WIDGET_MAP['_empty'];
41
+ }
42
+
43
+
44
+ // 同步版本(返回组件名而不是组件对象)
45
+ export function getWidgetNameSync(item) {
46
+ const type = item.type;
47
+ const nameMap = {
48
+ '20': 'BiPage',
49
+ '32': 'BiRow', // 返回组件名
50
+ '33': 'BiCol',
51
+ '40': 'BiContainerCard',
52
+ '41': 'BiNumIndex',
53
+ '50': 'BiPagingTable',
54
+ '51': 'BiDetailTable',
55
+ '_empty': 'BiEmpty'
56
+ };
57
+
58
+ return nameMap[type] || nameMap['_empty'];
77
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambo-design-bi",
3
- "version": "0.0.141",
3
+ "version": "0.0.142",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",