@yorha2b-lab/autodev 1.0.31 → 1.0.33
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/README.md +1 -1
- package/README_EN.md +1 -1
- package/package.json +1 -1
- package/src/utils/utils.js +1 -1
- package/templates/react/components/MyModalForm.js +4 -4
- package/templates/react/components/MyModalTable.js +1 -1
- package/templates/react/components/MySearchForm.js +2 -3
- package/templates/react/components/MyTable.js +1 -8
- package/templates/react/index.hbs +1 -1
- package/templates/react/utils/utils.js +12 -5
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/yorha2b-lab/auto-crud-copilot/stargazers)
|
|
8
8
|
[](https://github.com/yorha2b-lab/auto-crud-copilot/blob/main/LICENSE)
|
|
9
9
|
|
|
10
|
-
基于视觉大模型的前端(
|
|
10
|
+
基于视觉大模型的前端(React+Antd)全自动 CRUD 代码生成器 🚀
|
|
11
11
|
|
|
12
12
|
<video src="https://github.com/user-attachments/assets/6d42fce1-c815-482b-8c6a-4a3b9415ba47.mp4" controls="controls" muted="muted" style="max-width: 100%; display: block; margin: 20px auto;">
|
|
13
13
|
</video>
|
package/README_EN.md
CHANGED
|
@@ -7,7 +7,7 @@ English | [简体中文](./README.md)
|
|
|
7
7
|
[](https://github.com/yorha2b-lab/auto-crud-copilot/stargazers)
|
|
8
8
|
[](https://github.com/yorha2b-lab/auto-crud-copilot/blob/main/LICENSE)
|
|
9
9
|
|
|
10
|
-
An AI-powered frontend CRUD code generator based on vision models (
|
|
10
|
+
An AI-powered frontend CRUD code generator based on vision models (React+Antd) 🚀
|
|
11
11
|
|
|
12
12
|
<video src="https://github.com/user-attachments/assets/6d42fce1-c815-482b-8c6a-4a3b9415ba47.mp4" controls="controls" muted="muted" style="max-width: 100%; display: block; margin: 20px auto;">
|
|
13
13
|
</video>
|
package/package.json
CHANGED
package/src/utils/utils.js
CHANGED
|
@@ -77,8 +77,8 @@ const generateSmartImports = (codeStr, hasTabs) => {
|
|
|
77
77
|
// 构建 import 语句数组
|
|
78
78
|
const imports = [
|
|
79
79
|
usedReact.length && `import { ${usedReact.join(', ')} } from 'react'`,
|
|
80
|
-
`import { Link, history } from 'umi'`,
|
|
81
80
|
`import { request } from '../../utils/request'`,
|
|
81
|
+
`import { formatQuery } from '../../utils/utils'`,
|
|
82
82
|
`import { ${hasTabs ? 'tabs, ' : ''}columns, formItems, modalItems } from './resource'`,
|
|
83
83
|
...usedHooks.map(hook => `import { ${hook} } from '../../hooks/${hook}'`),
|
|
84
84
|
...usedComps.map(comp => `import { ${comp} } from '../../components/${comp}'`),
|
|
@@ -18,11 +18,11 @@ export const MyModalForm = ({ width, title, submit, record, visible, setModal, l
|
|
|
18
18
|
const config = itemMap.get(key)
|
|
19
19
|
if (config?.type?.includes('date') && value) {
|
|
20
20
|
if (Array.isArray(value)) {
|
|
21
|
-
initialData[key] = value.map(v => dayjs(
|
|
21
|
+
initialData[key] = value.map(v => dayjs(v))
|
|
22
22
|
} else if (typeof value === 'string' && value.includes(',')) {
|
|
23
|
-
initialData[key] = value.split(',').map(v => dayjs(
|
|
23
|
+
initialData[key] = value.split(',').map(v => dayjs(v))
|
|
24
24
|
} else {
|
|
25
|
-
initialData[key] = dayjs(
|
|
25
|
+
initialData[key] = dayjs(value)
|
|
26
26
|
}
|
|
27
27
|
} else {
|
|
28
28
|
initialData[key] = value
|
|
@@ -54,7 +54,7 @@ export const MyModalForm = ({ width, title, submit, record, visible, setModal, l
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
-
<Modal centered title={title} width={width} open={visible} onOk={handleOk}
|
|
57
|
+
<Modal centered title={title} width={width} open={visible} onOk={handleOk} destroyOnClose onCancel={handleCancel} confirmLoading={pending}>
|
|
58
58
|
<Form form={form} preserve={false} labelCol={labelCol} wrapperCol={wrapperCol} onValuesChange={(changed, all) => onValuesChange?.({ changed, all, form, record })}>
|
|
59
59
|
<Row gutter={[24, 0]}>
|
|
60
60
|
{formItems.map((item, index) =>
|
|
@@ -20,7 +20,7 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<Modal centered
|
|
23
|
+
<Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })}>
|
|
24
24
|
{formItems?.length > 0 && <MySearchForm search={search} formItems={formItems} setSearch={handleSearch} syncUrlParams={false} />}
|
|
25
25
|
<MyTable
|
|
26
26
|
loading={loading}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import dayjs from 'dayjs'
|
|
2
|
-
import { history } from 'umi'
|
|
3
2
|
import { MyBaseForm } from './MyBaseForm'
|
|
4
3
|
import { useState, useEffect } from 'react'
|
|
5
4
|
import { Row, Col, Form, Button, Space } from 'antd'
|
|
@@ -10,7 +9,7 @@ export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formI
|
|
|
10
9
|
|
|
11
10
|
const handleReset = () => {
|
|
12
11
|
if (syncUrlParams) {
|
|
13
|
-
history.
|
|
12
|
+
window.history.replaceState(null, '', window.location.pathname)
|
|
14
13
|
}
|
|
15
14
|
if (customReset) {
|
|
16
15
|
customReset()
|
|
@@ -37,7 +36,7 @@ export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formI
|
|
|
37
36
|
}
|
|
38
37
|
})
|
|
39
38
|
const params = new URLSearchParams(Object.fromEntries(Object.entries(formattedValues).filter(([key, value]) => !['', null, undefined].includes(value))))
|
|
40
|
-
history.
|
|
39
|
+
window.history.replaceState(null, '', `${window.location.pathname}?${params.toString()}`)
|
|
41
40
|
}
|
|
42
41
|
if (customFinish) {
|
|
43
42
|
customFinish(formattedValues)
|
|
@@ -48,8 +48,7 @@ export const MyTable = ({ size, query, onSave, autoScroll, onChange, pagination,
|
|
|
48
48
|
const tr = trList[Number(query.rowIndex)]
|
|
49
49
|
if (tr) {
|
|
50
50
|
tr.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
51
|
-
tr.
|
|
52
|
-
setTimeout(() => tr.classList.remove('row-highlight-pulse'), 1000)
|
|
51
|
+
tr.style.backgroundColor = '#e6f4ff'
|
|
53
52
|
hasScrolledRef.current = query.rowIndex
|
|
54
53
|
}
|
|
55
54
|
}, 300)
|
|
@@ -78,12 +77,6 @@ export const MyTable = ({ size, query, onSave, autoScroll, onChange, pagination,
|
|
|
78
77
|
return classes.filter(Boolean).join(' ')
|
|
79
78
|
}}
|
|
80
79
|
/>
|
|
81
|
-
<style jsx>{`
|
|
82
|
-
:global(.row-highlight-pulse) {
|
|
83
|
-
background-color: #e6f4ff !important;
|
|
84
|
-
transition: background-color 0.5s ease;
|
|
85
|
-
}
|
|
86
|
-
`}</style>
|
|
87
80
|
</div>
|
|
88
81
|
)
|
|
89
82
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default props => {
|
|
2
2
|
|
|
3
|
-
const query = Object.fromEntries(new URLSearchParams(location.search).entries())
|
|
3
|
+
const query = formatQuery(Object.fromEntries(new URLSearchParams(location.search).entries()), formItems)
|
|
4
4
|
|
|
5
5
|
const [form] = Form.useForm()
|
|
6
6
|
const [modal, setModal] = useState({})
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import dayjs from 'dayjs'
|
|
2
2
|
import { request } from './request'
|
|
3
3
|
|
|
4
|
-
export const paramsFormat = params => {
|
|
5
|
-
const cleanParams = Object.fromEntries(Object.entries(params).filter(([_, v]) => ![null, undefined, ''].includes(v)))
|
|
6
|
-
return new URLSearchParams(cleanParams).toString()
|
|
7
|
-
}
|
|
8
|
-
|
|
9
4
|
export const initOSS = async (url, options) => {
|
|
10
5
|
const OSS = require('ali-oss')
|
|
11
6
|
const crypto = require('crypto-js')
|
|
@@ -22,6 +17,18 @@ export const initOSS = async (url, options) => {
|
|
|
22
17
|
return { client, policy, signature, ...response?.data }
|
|
23
18
|
}
|
|
24
19
|
|
|
20
|
+
export const formatQuery = (params, formItems) => {
|
|
21
|
+
const cleanParams = {}
|
|
22
|
+
Object.keys(params).forEach(key => {
|
|
23
|
+
if (formItems.some(item => item.name.includes(key) && item.type?.includes('date'))) {
|
|
24
|
+
cleanParams[key] = Number(params[key])
|
|
25
|
+
} else {
|
|
26
|
+
cleanParams[key] = params[key] ?? null
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
return cleanParams
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
export const timeRender = ({ time, date, minute }) => {
|
|
26
33
|
if (!time) {
|
|
27
34
|
return ''
|