@yorha2b-lab/autodev 7.5.8 → 7.5.9

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/bin/bunker.js CHANGED
@@ -27,6 +27,13 @@ program
27
27
  const equipments = []
28
28
  const root = process.cwd()
29
29
  const { template } = program.opts()
30
+
31
+ const builderPath = path.join(__dirname, `../src/workshop/${template}/builder`)
32
+ if (!fs.existsSync(builderPath)) {
33
+ console.log(chalk.red(dialog.bunker.frameworkNotSupported(template)))
34
+ return
35
+ }
36
+
30
37
  const workshop = path.join(__dirname, `../src/workshop/${template}`)
31
38
  const quartermaster = require('../src/headquarters/quartermaster')({ dialog })
32
39
  const { hbsDir, hooksDir, utilsDir, componentsDir } = require('../src/logistics/supporter').getConfig()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "7.5.8",
3
+ "version": "7.5.9",
4
4
  "description": "基于 AI 视觉与语义协议的前端 (React+Antd) 代码构筑与旧系统重构引擎",
5
5
  "bin": {
6
6
  "bunker": "bin/bunker.js"
@@ -14,7 +14,7 @@ module.exports = bunker => {
14
14
  })
15
15
 
16
16
  missionObserver.on('add', filePath => {
17
- if (['.png', '.jpg', '.jpeg', '.webp'].includes(path.extname(filePath))) {
17
+ if (['.png', '.jpg', '.jpeg', '.webp'].includes(path.extname(filePath).toLowerCase())) {
18
18
  commander.receive({ input: filePath })
19
19
  }
20
20
  })
@@ -2,6 +2,7 @@ const { Segment, useDefault } = require('segmentit')
2
2
  const segmentit = useDefault(new Segment())
3
3
 
4
4
  const unwrapSignal = json => {
5
+ if (!json || typeof json !== 'object') return null
5
6
  if (Array.isArray(json)) return json
6
7
  const dataKeys = ['data', 'list', 'items', 'datas', 'rows', 'result', 'payload', 'results', 'dataList']
7
8
  for (const key of dataKeys) {
@@ -26,9 +27,11 @@ const getSemanticKeywords = text => {
26
27
  }
27
28
 
28
29
  const isQuerySignal = (req, json, coreData) => {
29
- const url = req.url.toLowerCase()
30
+ const pathname = req.url.split('?')[0].toLowerCase()
30
31
  const actionKeywords = ['add', 'delete', 'update', 'save', 'remove', 'edit', 'insert', 'create', 'export', 'upload']
31
- if (actionKeywords.some(key => url.includes(key))) return false
32
+ if (actionKeywords.some(key => pathname.split(/[/\-_]/).includes(key))) {
33
+ return false
34
+ }
32
35
  const hasListData = Array.isArray(coreData) && coreData.length > 0
33
36
  const hasPaginationFingerprint = ['total', 'records', 'page', 'size', 'count'].some(key => {
34
37
  const k = key.toLowerCase()
@@ -37,12 +40,14 @@ const isQuerySignal = (req, json, coreData) => {
37
40
  return hasListData || hasPaginationFingerprint
38
41
  }
39
42
 
43
+ const normalize = str => str.toLowerCase().replace(/[-_]/g, '')
44
+
40
45
  const getLocalScore = (api, pageKeywords, moduleName) => {
41
46
  let score = 0
42
47
  const path = api.path.toLowerCase()
43
48
  const desc = api.desc.toLowerCase()
44
49
  const mod = moduleName.toLowerCase()
45
- if (path.includes(mod)) score += 50
50
+ if (normalize(path).includes(normalize(mod))) score += 50
46
51
  pageKeywords.forEach(word => {
47
52
  if (desc.includes(word.toLowerCase())) score += 10
48
53
  if (path.includes(word.toLowerCase())) score += 5
@@ -0,0 +1,19 @@
1
+ import { Form, Descriptions } from 'antd'
2
+ import { MyBaseForm } from './MyBaseForm'
3
+
4
+ export const MyDescription = ({ title, column, descriptions, form: externalForm, onValuesChange }) => {
5
+
6
+ const [internalForm] = Form.useForm()
7
+ const form = externalForm || internalForm
8
+
9
+ return (
10
+ <Form form={form} preserve={false} component={false} onValuesChange={onValuesChange}>
11
+ <Descriptions title={title} column={column}>
12
+ {descriptions.map(item => (
13
+ <Descriptions.Item key={item.label} label={item.name ? undefined : item.label}>
14
+ {item.name ? <MyBaseForm item={item} form={form} /> : item.value}
15
+ </Descriptions.Item>))}
16
+ </Descriptions>
17
+ </Form>
18
+ )
19
+ }
@@ -128,7 +128,7 @@ const flattenFormItems = items => {
128
128
  * formItems={[{ label: '截止日期', name: 'deadline', type: 'date' }]}
129
129
  * />
130
130
  */
131
- export const MyModalForm = ({ width, title, footer, submit, record, visible, setModal, labelCol, formItems, wrapperCol, tableConfig, okButtonProps, onValuesChange, handleModalTableOk }) => {
131
+ export const MyModalForm = ({ extra, width, title, layout, okText, footer, submit, record, visible, setModal, labelCol, formItems, wrapperCol, cancelText, tableConfig, okButtonProps, onValuesChange, handleModalTableOk }) => {
132
132
 
133
133
  const rowKey = tableConfig?.rowKey || 'id'
134
134
 
@@ -145,7 +145,6 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
145
145
  */
146
146
  useEffect(() => {
147
147
  if (visible && !prevVisibleRef.current) {
148
- form.resetFields()
149
148
  if (record && Object.keys(record).length > 0) {
150
149
  const itemMap = new Map(flattenFormItems(formItems).map(i => [i.name, i]))
151
150
  const initialData = {}
@@ -179,7 +178,7 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
179
178
  * @description [物理加压提交] 执行表单校验,并自动启动“时间戳转换协议”。
180
179
  * 确保发射至后端的数据包符合标准 Unix 时间戳(毫秒)规范。
181
180
  */
182
- const handleOk = async () => {
181
+ const handleOk = async (extraParams = {}) => {
183
182
  try {
184
183
  const values = await form.validateFields()
185
184
  const formattedValues = { ...values }
@@ -197,7 +196,7 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
197
196
  })
198
197
  if (submit) {
199
198
  setPending(true)
200
- await submit({ ...record, ...formattedValues })
199
+ await submit({ ...record, ...formattedValues, ...extraParams })
201
200
  }
202
201
  } catch (error) {
203
202
  console.log('表单校验失败:', error)
@@ -222,6 +221,8 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
222
221
  onChange: (selectedRowKeys, selectedRows) => setSelectedTableRows(selectedRows),
223
222
  }), [rowKey, modalTable, selectedTableRows])
224
223
 
224
+ const ctx = { form, record, pending, handleOk, handleCancel, setModal }
225
+
225
226
  return (
226
227
  <Modal
227
228
  centered
@@ -229,19 +230,23 @@ export const MyModalForm = ({ width, title, footer, submit, record, visible, set
229
230
  width={width}
230
231
  open={visible}
231
232
  destroyOnClose
232
- onOk={handleOk}
233
+ okText={okText}
234
+ onOk={() => handleOk()}
235
+ cancelText={cancelText}
233
236
  onCancel={handleCancel}
234
237
  confirmLoading={pending}
235
238
  okButtonProps={okButtonProps}
236
- bodyStyle={{ paddingBottom: 0 }}
237
- footer={footer?.({ form, record, setModal })}
239
+ footer={typeof footer === 'function' ? footer(ctx) : footer}
240
+ bodyStyle={{ paddingBottom: 0, maxHeight: '80vh', overflowY: 'auto' }}
238
241
  >
239
242
  {modalTable.visible && <MyModalTable rowKey={rowKey} {...modalTable} rowSelection={tableRowSelection} onOk={modalTableOk} setModal={setModalTable} />}
240
- <Form form={form} preserve={false} labelCol={labelCol} wrapperCol={wrapperCol} onValuesChange={(changed, all) => onValuesChange?.({ changed, all, form, record })}>
243
+ {extra?.header?.(ctx)}
244
+ <Form form={form} layout={layout} preserve={false} labelCol={labelCol} wrapperCol={wrapperCol} onValuesChange={(changed, all) => onValuesChange?.({ changed, all, form, record })}>
241
245
  <Row gutter={[24, 0]}>
242
246
  <FormRenderer form={form} formItems={formItems} tableConfig={tableConfig} setModalTable={setModalTable} setSelectedTableRows={setSelectedTableRows} />
243
247
  </Row>
244
248
  </Form>
249
+ {extra?.footer?.(ctx)}
245
250
  </Modal>
246
251
  )
247
252
  }