Files
live-hub-py/web/frontend
yml2213 bb767bb84a fix(automation): 保存配置时存错作业 —— 5 张卡共用一个 form 实例
## 现象(用户报的)

点「账号资料定时补全」的保存,提示却是**「积分到期补记 配置已保存」**。

## 根因:不是提示文案错,是**真的存错了作业**

`jobs.map()` 里**每张卡各包一个 `<Form form={forms}>`,但它们共用同一个
`Form.useForm()` 实例**。React 里多个 `<Form>` 绑同一实例时,
**`onFinish` 会被最后挂载的那个覆盖** —— 于是:

    点第 1 张卡的「保存」→ 触发的是**最后一张卡**(积分到期补记)的 onFinish
                        → saveJob(积分到期补记)

## 实际影响(不涉及数据损坏)

- `saveJob(job)` 读的是**那个 job 自己的**字段值 → 所以「积分到期补记」
  只是被用它自己的值**重存了一遍**(无副作用)
- 而用户真正想保存的「账号资料定时补全」**根本没被保存** —— 静默失败

## 修法

把 Form **提到外面只包一层**(`Form.Item` 靠 `[job.key, 字段]` 天然区分各自的值),
保存按钮从 `htmlType="submit"` 改成显式的 `onClick={() => saveJob(job)}` ——
不再依赖"哪个 Form 的 onFinish 生效"这种隐含约定。

并在原处留了注释说明为什么**不能**各自包 Form(否则下一个人很可能又这么写)。

## 说明

前端这类"共用实例"的错误没有自动化测试兜住(仓库没有组件测试),
所以这次是靠用户点出来的。已在代码注释里写清原因,降低复发概率。

## 验证

前端 build 通过、lint 0 errors。
2026-10-04 21:40:46 +08:00
..
2026-06-22 13:11:15 +08:00
2026-06-22 13:11:15 +08:00
2026-07-05 12:25:18 +08:00
2026-06-22 13:11:15 +08:00
2026-06-22 13:11:15 +08:00
2026-06-22 13:11:15 +08:00
2026-06-22 13:11:15 +08:00
2026-06-22 13:11:15 +08:00

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

export default defineConfig([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      // Other configs...

      // Remove tseslint.configs.recommended and replace with this
      tseslint.configs.recommendedTypeChecked,
      // Alternatively, use this for stricter rules
      tseslint.configs.strictTypeChecked,
      // Optionally, add this for stylistic rules
      tseslint.configs.stylisticTypeChecked,

      // Other configs...
    ],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.node.json', './tsconfig.app.json'],
        tsconfigRootDir: import.meta.dirname,
      },
      // other options...
    },
  },
])

You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:

// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      // Other configs...
      // Enable lint rules for React
      reactX.configs['recommended-typescript'],
      // Enable lint rules for React DOM
      reactDom.configs.recommended,
    ],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.node.json', './tsconfig.app.json'],
        tsconfigRootDir: import.meta.dirname,
      },
      // other options...
    },
  },
])