@yorha2b-lab/autodev 2.1.7 → 2.1.8

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": "@yorha2b-lab/autodev",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "基于视觉大模型的前端(react+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -43,8 +43,6 @@ export const MyModalForm = ({ width, title, submit, record, visible, setModal, l
43
43
  }
44
44
  } catch (error) {
45
45
  console.log('表单校验失败:', error)
46
- } finally {
47
- setPending(false)
48
46
  }
49
47
  }
50
48
 
@@ -1,3 +1,4 @@
1
+ import { useState } from 'react'
1
2
  import { MyTable } from './MyTable'
2
3
  import { Modal, Space, Button } from 'antd'
3
4
  import { MySearchForm } from './MySearchForm'
@@ -6,6 +7,8 @@ import { useTableQuery } from '../hooks/useTableQuery'
6
7
 
7
8
  export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns, setModal, formItems, rowSelection, formatResponse, functionButtons, extraParams = {} }) => {
8
9
 
10
+ const [pending, setPending] = useState(false)
11
+
9
12
  const { total, loading, dataSource, search, setSearch } = useTableQuery(api, formatResponse, extraParams)
10
13
 
11
14
  const handleSearch = values => setSearch({ ...search, ...values, pageNo: 1 })
@@ -14,13 +17,19 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
14
17
 
15
18
  const handleOk = () => {
16
19
  if (onOk) {
17
- onOk()
20
+ try {
21
+ setPending(true)
22
+ onOk()
23
+ setPending(false)
24
+ } catch (error) {
25
+ console.log('操作失败:', error)
26
+ }
18
27
  }
19
28
  setModal({ visible: false })
20
29
  }
21
30
 
22
31
  return (
23
- <Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })}>
32
+ <Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })} confirmLoading={pending}>
24
33
  {formItems?.length > 0 && <MySearchForm search={search} formItems={formItems} setSearch={handleSearch} syncUrlParams={false} />}
25
34
  {functionButtons?.length > 0 && <Space>{functionButtons.map(item => <Button key={item.name} type={item.type} onClick={item.onClick}>{item.name}</Button>)}</Space>}
26
35
  <MyTable
@@ -1,5 +1,5 @@
1
- import { useState } from 'react'
2
1
  import { initOSS } from '../utils/utils'
2
+ import { useState, useEffect } from 'react'
3
3
  import { UploadOutlined } from '@ant-design/icons'
4
4
  import { Button, Tree, Radio, Input, Upload, Select, Cascader, Checkbox, DatePicker, InputNumber, TreeSelect, AutoComplete } from 'antd'
5
5
 
@@ -18,6 +18,12 @@ const AliyunOSSUpload = ({ value, onChange, ...restProps }) => {
18
18
  }
19
19
  }
20
20
 
21
+ useEffect(() => {
22
+ if (!OSSData) {
23
+ init()
24
+ }
25
+ }, [])
26
+
21
27
  const handleChange = ({ fileList }) => onChange?.([...fileList])
22
28
 
23
29
  const onRemove = file => {
@@ -35,10 +41,10 @@ const AliyunOSSUpload = ({ value, onChange, ...restProps }) => {
35
41
 
36
42
  const beforeUpload = async file => {
37
43
  const expire = Number(OSSData.expire) * 1000
38
- if (expire < Date.now() || !OSSData) {
44
+ if (expire < Date.now()) {
39
45
  await init()
40
46
  }
41
- file.url = `${OSSData.dir ?? path}/${file.uid}_${file.name}`.replace(/\/\//g, '/')
47
+ file.url = `${OSSData?.dir ?? path}/${file.uid}_${file.name}`.replace(/\/\//g, '/')
42
48
  return file
43
49
  }
44
50