@skyfox2000/webui 1.4.11 → 1.4.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -180,6 +180,14 @@ onMounted(async () => {
180
180
  pagination.value.total = gridCtrl.total.value ?? 0;
181
181
  }
182
182
  } else if (gridCtrl.autoload !== false) {
183
+ if (gridCtrl.page) {
184
+ if (gridCtrl.gridUrl?.url === gridCtrl.page.urls.list) {
185
+ gridCtrl.remotePage = false;
186
+ }
187
+ if (gridCtrl.gridUrl?.url === gridCtrl.page.urls.find) {
188
+ gridCtrl.remotePage = true;
189
+ }
190
+ }
183
191
  if (gridCtrl.remotePage) {
184
192
  dataList.value = (await gridQueryFind(gridCtrl)).rows;
185
193
  } else {
@@ -25,6 +25,7 @@ interface ApiResponseData {
25
25
  class MicroAppSDK {
26
26
  private static messageId = 0;
27
27
  private static callbacks = new Map<number, { resolve: Function; reject: Function }>();
28
+ private static pendingRequests = new Map<string, Promise<any>>();
28
29
 
29
30
  /**
30
31
  * 检查是否在微前端环境中运行
@@ -46,6 +47,15 @@ class MicroAppSDK {
46
47
  throw new Error(`未配置${method}接口!`);
47
48
  }
48
49
 
50
+ // 生成请求标识符(方法名+参数JSON字符串)
51
+ const requestKey = `${method}_${JSON.stringify(params)}`;
52
+
53
+ // 检查是否已有相同请求正在进行
54
+ if (this.pendingRequests.has(requestKey)) {
55
+ // 返回正在进行的请求的Promise
56
+ return this.pendingRequests.get(requestKey);
57
+ }
58
+
49
59
  // 生成唯一消息ID
50
60
  const id = ++this.messageId;
51
61
 
@@ -57,11 +67,15 @@ class MicroAppSDK {
57
67
  setTimeout(() => {
58
68
  if (this.callbacks.has(id)) {
59
69
  this.callbacks.delete(id);
70
+ this.pendingRequests.delete(requestKey);
60
71
  reject(new Error(`API调用超时: ${method}`));
61
72
  }
62
73
  }, 10000); // 10秒超时
63
74
  });
64
75
 
76
+ // 保存正在进行的请求
77
+ this.pendingRequests.set(requestKey, promise);
78
+
65
79
  // 构造请求数据
66
80
  const requestData: ApiRequestData = {
67
81
  type: 'API_REQUEST',
@@ -74,7 +88,14 @@ class MicroAppSDK {
74
88
  (window as any).microApp.dispatch(requestData);
75
89
 
76
90
  // 等待结果
77
- return promise;
91
+ try {
92
+ const result = await promise;
93
+ this.pendingRequests.delete(requestKey);
94
+ return result;
95
+ } catch (error) {
96
+ this.pendingRequests.delete(requestKey);
97
+ throw error;
98
+ }
78
99
  }
79
100
 
80
101
  /**
@@ -165,4 +186,4 @@ export const MicroOpenApis = {
165
186
  userLogout: MicroAppSDK.userLogout.bind(MicroAppSDK),
166
187
  mainAppPush: MicroAppSDK.mainAppPush.bind(MicroAppSDK),
167
188
  isInMicroApp: MicroAppSDK.isInMicroApp.bind(MicroAppSDK),
168
- };
189
+ };
@@ -96,7 +96,6 @@ export const mergeColumns = (newColumns: TableColumn[], oldColumns?: TableColumn
96
96
  * @returns
97
97
  */
98
98
  export const gridQueryList = <T>(gridCtrl: GridControl<T>): Promise<T[]> => {
99
- gridCtrl.remotePage = false;
100
99
  return gridQueryFind(gridCtrl).then((result) => {
101
100
  return result.rows as T[];
102
101
  });