@yorha2b-lab/autodev 3.4.1 → 3.4.2
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 +1 -1
- package/src/core/context.js +1 -6
- package/src/core/react-compiler.js +1 -2
- package/src/utils/utils.js +1 -1
- package/templates/react/components/MyModalForm.js +1 -1
- package/templates/react/components/MySearchForm.js +12 -5
- package/templates/react/components/MyTable.js +1 -1
- package/templates/react/handlebars/MySearchForm.hbs +1 -1
- package/templates/react/handlebars/hookBlock.hbs +2 -2
package/package.json
CHANGED
package/src/core/context.js
CHANGED
|
@@ -61,10 +61,5 @@ module.exports = {
|
|
|
61
61
|
/**
|
|
62
62
|
* @description 全频道信号接入:获取全局上下文
|
|
63
63
|
*/
|
|
64
|
-
get: () =>
|
|
65
|
-
if (!instance) {
|
|
66
|
-
throw new Error(language('🤖 Pod 042 报警:中枢神经元尚未初始化,无法建立信号连接。', '🤖 Pod 042 Warnning:Central neuron not initialized, cannot establish signal connection.'))
|
|
67
|
-
}
|
|
68
|
-
return instance
|
|
69
|
-
}
|
|
64
|
+
get: () => instance
|
|
70
65
|
}
|
|
@@ -14,7 +14,6 @@ const resource = ({ pageConfig, resourceTpl }) => {
|
|
|
14
14
|
|
|
15
15
|
const hasTabs = pageConfig.tabs?.length > 0
|
|
16
16
|
const hasFormItems = pageConfig.formItems?.length > 0
|
|
17
|
-
const hasDateColumn = processedColumns.some(item => item.type === 'date')
|
|
18
17
|
|
|
19
18
|
const columnsData = processedColumns.map(item => {
|
|
20
19
|
delete item.type
|
|
@@ -31,7 +30,7 @@ const resource = ({ pageConfig, resourceTpl }) => {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
const bodyCode = resourceTpl(viewData)
|
|
34
|
-
const importsStr = generateSmartImports({ module: 'resource', hasTabs, bodyCode, hasFormItems
|
|
33
|
+
const importsStr = generateSmartImports({ module: 'resource', hasTabs, bodyCode, hasFormItems })
|
|
35
34
|
return cleanCode(`${importsStr}\n\n${bodyCode}`)
|
|
36
35
|
}
|
|
37
36
|
|
package/src/utils/utils.js
CHANGED
|
@@ -305,7 +305,7 @@ const copyTemplateDir = (options, templateSubDir, targetSubDir) => {
|
|
|
305
305
|
* @param {boolean} hasTabs - 是否包含标签页
|
|
306
306
|
* @returns {string} 拼接后的 import 语句
|
|
307
307
|
*/
|
|
308
|
-
const generateSmartImports = ({ module, hasTabs, bodyCode, hasFormItems
|
|
308
|
+
const generateSmartImports = ({ module, hasTabs, bodyCode, hasFormItems }) => {
|
|
309
309
|
|
|
310
310
|
const hooksLib = ['useTableQuery']
|
|
311
311
|
const utilsLib = ['timeRender', 'moneyRender']
|
|
@@ -219,7 +219,7 @@ export const MyModalForm = ({ width, title, submit, record, visible, setModal, l
|
|
|
219
219
|
const tableRowSelection = useMemo(() => ({
|
|
220
220
|
selectedRowKeys: selectedTableRows.map(row => row[rowKey]),
|
|
221
221
|
onChange: (selectedRowKeys, selectedRows) => setSelectedTableRows(selectedRows),
|
|
222
|
-
}), [rowKey,
|
|
222
|
+
}), [rowKey, selectedTableRows])
|
|
223
223
|
|
|
224
224
|
return (
|
|
225
225
|
<Modal centered title={title} width={width} open={visible} onOk={handleOk} destroyOnClose onCancel={handleCancel} confirmLoading={pending}>
|
|
@@ -22,6 +22,7 @@ import { Row, Col, Form, Button, Space } from 'antd'
|
|
|
22
22
|
* @param {React.ReactNode} [props.extraOperate] - 额外挂件:在按钮区域注入自定义战术单元
|
|
23
23
|
* @param {boolean} props.loading - 战场负载状态:请求中时锁定按钮,防止由于重复指令导致的逻辑冲突
|
|
24
24
|
* @param {boolean} [props.syncUrlParams=true] - 物理同步开关:是否将搜索状态实时镜像至 URL 链接中
|
|
25
|
+
* @param {Object} props.initialParams - [重要] 战术底价:定义不可被重置协议核平的核心业务参数(如 projectId)
|
|
25
26
|
*
|
|
26
27
|
* @example
|
|
27
28
|
* <MySearchForm
|
|
@@ -31,7 +32,7 @@ import { Row, Col, Form, Button, Space } from 'antd'
|
|
|
31
32
|
* formItems={[{ label: '状态', name: 'status', type: 'select', options: [...] }]}
|
|
32
33
|
* />
|
|
33
34
|
*/
|
|
34
|
-
export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formItems, showLimit = 7, initialValues, customReset, extraOperate, customFinish, onValuesChange, syncUrlParams = true, defaultPageSize = 10 }) => {
|
|
35
|
+
export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formItems, showLimit = 7, initialParams, initialValues, customReset, extraOperate, customFinish, onValuesChange, syncUrlParams = true, defaultPageSize = 10 }) => {
|
|
35
36
|
|
|
36
37
|
const [limit, setLimit] = useState(showLimit)
|
|
37
38
|
|
|
@@ -42,14 +43,19 @@ export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formI
|
|
|
42
43
|
const handleReset = () => {
|
|
43
44
|
form.resetFields()
|
|
44
45
|
if (syncUrlParams) {
|
|
45
|
-
//
|
|
46
|
-
|
|
46
|
+
// 💡 修正逻辑:只有当 formItems 里【没有任何一项】包含这个 key 时,才视为默认参数
|
|
47
|
+
const defaultQueryEntries = Object.entries(initialValues).filter(([key, _]) => !formItems.some(item => item.name.includes(key)))
|
|
48
|
+
const defaultQuery = Object.fromEntries(defaultQueryEntries)
|
|
49
|
+
const params = new URLSearchParams(defaultQuery)
|
|
50
|
+
// 💡 执行物理重写:将 URL 恢复为仅含默认参数的状态
|
|
51
|
+
const newUrl = params.toString() ? `${window.location.pathname}?${params.toString()}` : window.location.pathname
|
|
52
|
+
window.history.replaceState(null, '', newUrl)
|
|
47
53
|
}
|
|
48
54
|
if (customReset) {
|
|
49
55
|
customReset()
|
|
50
56
|
} else {
|
|
51
57
|
// 逻辑重置:强制返回第一页,并恢复默认吞吐量
|
|
52
|
-
setSearch({ pageNo: 1, pageSize: search.pageSize ?? defaultPageSize })
|
|
58
|
+
setSearch({ pageNo: 1, pageSize: search.pageSize ?? defaultPageSize, ...initialParams })
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -79,7 +85,8 @@ export const MySearchForm = ({ form, search, loading, labelCol, setSearch, formI
|
|
|
79
85
|
})
|
|
80
86
|
if (syncUrlParams) {
|
|
81
87
|
// 💡 [黑科技 2] 镜像至 URL
|
|
82
|
-
const
|
|
88
|
+
const currentQuery = Object.fromEntries(new URLSearchParams(window.location.search).entries())
|
|
89
|
+
const params = new URLSearchParams(Object.fromEntries(Object.entries({ ...currentQuery, ...formattedValues }).filter(([key, value]) => !['', null, undefined].includes(value))))
|
|
83
90
|
window.history.replaceState(null, '', `${window.location.pathname}?${params.toString()}`)
|
|
84
91
|
}
|
|
85
92
|
if (customFinish) {
|
|
@@ -183,7 +183,7 @@ export const MyTable = ({ size, query, total, search, autoScroll, onChange, pagi
|
|
|
183
183
|
pagination={paginationConfig}
|
|
184
184
|
components={isEditable ? components : undefined}
|
|
185
185
|
// 💡 信号注入:将行监听协议绑定至底层 tr
|
|
186
|
-
onRow={(record, index) => ({ record, index, onValuesChange: lineFormChange })}
|
|
186
|
+
onRow={(record, index) => ({ record, index, ...(typeof onValuesChange === 'function' ? { onValuesChange: lineFormChange } : {}) })}
|
|
187
187
|
rowClassName={(record, index) => {
|
|
188
188
|
const externalClass = typeof rowClassName === 'function' ? rowClassName(record, index) : rowClassName
|
|
189
189
|
const classes = [externalClass]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<MySearchForm form={form} search={search} initialValues={query} loading={loading} setSearch={setSearch} formItems={ {{formItems}} } />
|
|
1
|
+
<MySearchForm form={form} search={search} initialValues={query} loading={loading} setSearch={setSearch} formItems={ {{formItems}} } initialParams={initialParams} />
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const initialParams = {{#if hasTabs}}{ type: tabs[0].key }{{else}}{}{{/if}}
|
|
2
2
|
|
|
3
3
|
const query = formatQuery(Object.fromEntries(new URLSearchParams(location.search).entries()), {{formItems}})
|
|
4
4
|
|
|
5
5
|
const { total, columns, loading, dataSource, search, setSearch, setDataSource, refresh } = useTableQuery({
|
|
6
6
|
api: async params => await request('/api/{{fileName}}', { method: 'POST', body: params }),
|
|
7
|
-
initialParams: { pageNo: 1, pageSize: 10, ...
|
|
7
|
+
initialParams: { pageNo: 1, pageSize: 10, ...initialParams, ...query },
|
|
8
8
|
cols:tableColumns,
|
|
9
9
|
formatResponse: response => {
|
|
10
10
|
return {
|