@yorha2b-lab/autodev 1.0.0
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/.env.example +12 -0
- package/CONTRIBUTING.md +118 -0
- package/LICENSE +21 -0
- package/README.md +173 -0
- package/bin/autodev.js +40 -0
- package/config.js +28 -0
- package/package.json +50 -0
- package/src/commands/watch-api.js +41 -0
- package/src/commands/watch-page.js +94 -0
- package/src/commands/watch-part.js +46 -0
- package/src/core/react-compiler.js +53 -0
- package/src/core/task-queue.js +38 -0
- package/src/prompts/mock.js +5 -0
- package/src/prompts/system.js +9 -0
- package/src/prompts/watch-api.js +11 -0
- package/src/prompts/watch-page.js +39 -0
- package/src/prompts/watch-part.js +26 -0
- package/src/services/llm.js +66 -0
- package/src/utils/utils.js +69 -0
- package/templates/react/components/EditableCell.js +76 -0
- package/templates/react/components/MyBaseForm.js +47 -0
- package/templates/react/components/MyModalForm.js +51 -0
- package/templates/react/components/MyModalTable.js +40 -0
- package/templates/react/components/MySearchForm.js +46 -0
- package/templates/react/components/MyTable.js +48 -0
- package/templates/react/components/index.js +40 -0
- package/templates/react/hooks/useTableQuery.js +40 -0
- package/templates/react/index.hbs +110 -0
- package/templates/react/resource.hbs +18 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export default props => {
|
|
2
|
+
|
|
3
|
+
const [form] = Form.useForm()
|
|
4
|
+
const [modal, setModal] = useState({})
|
|
5
|
+
{{#if hasTabs}}
|
|
6
|
+
const [activeKey, setActiveKey] = useState(tabs[0].key)
|
|
7
|
+
{{/if}}
|
|
8
|
+
{{#if hasRowSelection}}
|
|
9
|
+
const [selectedRows, setSelectedRows] = useState([])
|
|
10
|
+
{{/if}}
|
|
11
|
+
|
|
12
|
+
const initParams = {{#if hasTabs}}{ type: tabs[0].key }{{else}}{}{{/if}}
|
|
13
|
+
|
|
14
|
+
const { total, loading, dataSource, search, setSearch, refresh } = useTableQuery(
|
|
15
|
+
async params => await request('/api/{{fileName}}', { method: 'POST', body: params }),
|
|
16
|
+
response => response?.data ?? [],
|
|
17
|
+
initParams,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
{{#each operations}}
|
|
21
|
+
const {{this.action}} = async record => {
|
|
22
|
+
const response = await request('/api')
|
|
23
|
+
refresh()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
{{/each}}
|
|
27
|
+
|
|
28
|
+
{{#each functionButtons}}
|
|
29
|
+
const {{this.action}} = () => {
|
|
30
|
+
Modal.confirm({
|
|
31
|
+
title: '确认',
|
|
32
|
+
centered: true,
|
|
33
|
+
content: '确认{{this.btn}}吗?',
|
|
34
|
+
onOk: async () => {
|
|
35
|
+
const response = await request('/api')
|
|
36
|
+
refresh()
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
{{/each}}
|
|
42
|
+
|
|
43
|
+
{{#if hasTabs}}
|
|
44
|
+
const onTabChange = key => {
|
|
45
|
+
setActiveKey(key)
|
|
46
|
+
{{#if hasRowSelection}}setSelectedRows([]){{/if}}
|
|
47
|
+
setSearch({ pageNo: 1, pageSize: 10, type: key })
|
|
48
|
+
}
|
|
49
|
+
{{/if}}
|
|
50
|
+
|
|
51
|
+
const modalSubmit = async values => {
|
|
52
|
+
const response = await request('/api')
|
|
53
|
+
refresh()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
{{#if hasOperate}}
|
|
57
|
+
const operate = {
|
|
58
|
+
title: '操作',
|
|
59
|
+
render: (_, record) => (
|
|
60
|
+
<Space>
|
|
61
|
+
{{#each operations}}
|
|
62
|
+
<a onClick={()=> {{this.action}}(record)}>{{this.label}}</a>
|
|
63
|
+
{{/each}}
|
|
64
|
+
</Space>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
{{/if}}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Card {{#if hasTabs}}tabList={tabs} activeTabKey={activeKey} onTabChange={onTabChange}{{/if}}>
|
|
71
|
+
{modal.visible && <MyModalForm {...modal} formItems={modalItems} submit={modalSubmit} setModal={setModal} />}
|
|
72
|
+
<MySearchForm form={form} search={search} setSearch={setSearch} formItems={ {{#if hasTabs}}formItems[activeKey]{{else}}formItems{{/if}} } />
|
|
73
|
+
{{#if hasTabs}}
|
|
74
|
+
{{#each tabs}}
|
|
75
|
+
{activeKey === '{{this.key}}' &&
|
|
76
|
+
<Space style=\{{ marginBottom: 16 }}>
|
|
77
|
+
{{#each ../functionButtons}}
|
|
78
|
+
<Button type='primary' onClick={ {{this.action}} }>{{this.btn}}</Button>
|
|
79
|
+
{{/each}}
|
|
80
|
+
</Space>}
|
|
81
|
+
{{/each}}
|
|
82
|
+
{{else}}
|
|
83
|
+
<Space style=\{{ marginBottom: 16 }}>
|
|
84
|
+
{{#each functionButtons}}
|
|
85
|
+
<Button type='primary' onClick={ {{this.action}} }>{{this.btn}}</Button>
|
|
86
|
+
{{/each}}
|
|
87
|
+
</Space>
|
|
88
|
+
{{/if}}
|
|
89
|
+
{{#if hasStaticInfo}}
|
|
90
|
+
<Alert showIcon title='{{staticInfoText}}' type='info' style=\{{ marginBottom: 16 }} />
|
|
91
|
+
{{/if}}
|
|
92
|
+
<MyTable
|
|
93
|
+
rowKey='id'
|
|
94
|
+
loading={loading}
|
|
95
|
+
dataSource={dataSource}
|
|
96
|
+
columns={ {{columnsValue}} }
|
|
97
|
+
{{#if hasPagination}}
|
|
98
|
+
pagination=\{{ total, showSizeChanger: true, current: search.pageNo, pageSize: search.pageSize }}
|
|
99
|
+
onChange={(pagination, filters, sorter) => setSearch({ ...search , pageNo: pagination.current, pageSize: pagination.pageSize, orderBy: sorter.column ? sorter.field : undefined })}
|
|
100
|
+
{{/if}}
|
|
101
|
+
{{#if hasRowSelection}}
|
|
102
|
+
rowSelection=\{{
|
|
103
|
+
selectedRowKeys: selectedRows.map(item => item.id),
|
|
104
|
+
onChange: (keys, rows) => setSelectedRows(rows)
|
|
105
|
+
}}
|
|
106
|
+
{{/if}}
|
|
107
|
+
/>
|
|
108
|
+
</Card>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { timeRender } from '../../utils/utils'
|
|
2
|
+
|
|
3
|
+
{{#if hasTabs}}
|
|
4
|
+
export const tabs = {{{stringify tabs 50}}}
|
|
5
|
+
{{/if}}
|
|
6
|
+
|
|
7
|
+
{{#each dictBlocks}}
|
|
8
|
+
export const {{this.name}} = {{{stringify this.data 50}}}
|
|
9
|
+
|
|
10
|
+
{{/each}}
|
|
11
|
+
|
|
12
|
+
{{#if formItems.length}}
|
|
13
|
+
export const formItems = {{{stringify formItemsData 150}}}
|
|
14
|
+
{{/if}}
|
|
15
|
+
|
|
16
|
+
export const columns = {{{stringify columnsData 200}}}
|
|
17
|
+
|
|
18
|
+
export const modalItems = []
|