@longhongguo/form-create-ant-design-vue 3.2.90 → 3.2.91

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": "@longhongguo/form-create-ant-design-vue",
3
- "version": "3.2.90",
3
+ "version": "3.2.91",
4
4
  "description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
5
5
  "main": "./dist/form-create.min.js",
6
6
  "module": "./dist/form-create.esm.js",
@@ -188,23 +188,27 @@ export default {
188
188
  const savedPageParamName = pageParamName
189
189
  const savedPageSizeParamName = pageSizeParamName
190
190
  const savedOriginalBeforeFetch = originalFetch.beforeFetch
191
+ // 在闭包中保存 rule 的引用,因为 beforeFetch 只接收 (config, {api}) 参数
192
+ const savedRule = rule
191
193
 
192
- // 只有当前还没有 beforeFetch 钩子,或者 beforeFetch 不是我们添加的时才添加
193
- // 通过检查 savedOriginalBeforeFetch 是否包含我们的逻辑来判断
194
- if (
195
- !savedOriginalBeforeFetch ||
196
- typeof savedOriginalBeforeFetch !== 'function'
197
- ) {
194
+ // 检查是否已经添加过我们的 beforeFetch 钩子(通过检查函数是否包含特定标记)
195
+ const isOurBeforeFetch =
196
+ savedOriginalBeforeFetch &&
197
+ savedOriginalBeforeFetch._accTablePaginationHook === true
198
+
199
+ if (!isOurBeforeFetch) {
198
200
  // 添加 beforeFetch 钩子来注入分页参数
199
- originalFetch.beforeFetch = (config, { rule: r, api: a }) => {
201
+ // 注意:form-create 的 beforeFetch 只接收 (config, {api}) 参数,没有 rule
202
+ originalFetch.beforeFetch = (config, { api }) => {
200
203
  console.log('[accTable] beforeFetch 被调用:', {
201
- configBefore: JSON.parse(JSON.stringify(config)),
202
- ruleProps: r.props,
203
- pagination: r.props?.pagination
204
+ configAction: config?.action,
205
+ hasApi: !!api,
206
+ ruleProps: savedRule?.props,
207
+ pagination: savedRule?.props?.pagination
204
208
  })
205
209
 
206
- // 获取当前分页配置
207
- const currentPagination = r.props?.pagination
210
+ // 从闭包中获取当前分页配置
211
+ const currentPagination = savedRule?.props?.pagination
208
212
  console.log('[accTable] 当前分页配置:', {
209
213
  currentPagination,
210
214
  isObject: typeof currentPagination === 'object',
@@ -256,12 +260,13 @@ export default {
256
260
  }
257
261
 
258
262
  // 调用原始的 beforeFetch 钩子(如果存在)
263
+ // 原始钩子可能也只接收 (config, {api}) 参数
259
264
  if (
260
265
  savedOriginalBeforeFetch &&
261
266
  typeof savedOriginalBeforeFetch === 'function'
262
267
  ) {
263
268
  console.log('[accTable] 调用原始 beforeFetch 钩子')
264
- return savedOriginalBeforeFetch(config, { rule: r, api: a })
269
+ return savedOriginalBeforeFetch(config, { api })
265
270
  }
266
271
 
267
272
  console.log('[accTable] beforeFetch 完成,最终 config:', {
@@ -270,8 +275,14 @@ export default {
270
275
  action: config.action
271
276
  })
272
277
  }
278
+
279
+ // 标记这是我们添加的钩子,避免重复添加
280
+ originalFetch.beforeFetch._accTablePaginationHook = true
281
+ console.log('[accTable] ✅ beforeFetch 钩子已添加并标记')
282
+ } else {
283
+ console.log('[accTable] ⚠️ beforeFetch 钩子已存在,跳过添加')
273
284
  }
274
- console.log('[accTable] beforeFetch 钩子已添加')
285
+ console.log('[accTable] beforeFetch 钩子处理完成')
275
286
  } else {
276
287
  console.warn('[accTable] fetch 配置不是对象类型:', {
277
288
  type: typeof originalFetch,