From 6bfcd053457c37fddf78e525b64dec146fe6f068 Mon Sep 17 00:00:00 2001 From: linkong Date: Wed, 1 Apr 2026 15:46:02 +0800 Subject: [PATCH] fix: stabilize settings form hydration --- VERSION | 2 +- docs/CHANGELOG.md | 21 +++++++++++++++++ frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- frontend/src/pages/Settings/Settings.tsx | 30 +++++++++++++++++++++--- pyproject.toml | 2 +- uv.lock | 2 +- 7 files changed, 54 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 9e432c86..eca6a4a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.22.7 +0.22.8 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 50e86f8a..9bd7f584 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,27 @@ This project follows the repository versioning rule: - `feature` -> `+0.1.0` - `bugfix` -> `+0.0.1` +## 0.22.8 + +Released: 2026-04-01 + +### Highlights + +- Fixed the configuration center form lifecycle so revisiting the Settings page no longer triggers Ant Design's `useForm` warning during async settings hydration. +- Aligned repository version metadata across the backend, frontend, and lockfiles so the new bugfix release reports a consistent `0.22.8` version everywhere. + +### Improved + +- Improved settings data hydration in [Settings.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Settings/Settings.tsx) by staging fetched system, notification, and security payloads in React state first instead of writing directly into form instances during the request callback. +- Improved settings form synchronization in [Settings.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Settings/Settings.tsx) by delaying `setFieldsValue(...)` until the page loading skeleton is gone, ensuring each Ant Design form is actually mounted before values are pushed into it. +- Improved tab readiness in [Settings.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Settings/Settings.tsx) by keeping the primary configuration tabs force-rendered so revisits and tab switches no longer race form instance registration. +- Improved release consistency by updating [VERSION](/home/ray/dev/linkong/planet/VERSION), [pyproject.toml](/home/ray/dev/linkong/planet/pyproject.toml), [frontend/package.json](/home/ray/dev/linkong/planet/frontend/package.json), [frontend/package-lock.json](/home/ray/dev/linkong/planet/frontend/package-lock.json), and [uv.lock](/home/ray/dev/linkong/planet/uv.lock) to the same bugfix version. + +### Fixed + +- Fixed the `Instance created by useForm is not connected to any Form element` warning in [Settings.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Settings/Settings.tsx), which could still reappear after navigating away from the configuration center and returning while settings were being refetched. +- Fixed the timing bug where the page attempted to hydrate hidden/loading tab forms before the enclosing `Card loading` state had mounted the real form tree. + ## 0.22.7 Released: 2026-04-01 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 961ce692..906af7a7 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "planet-frontend", - "version": "0.22.7", + "version": "0.22.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "planet-frontend", - "version": "0.22.7", + "version": "0.22.8", "dependencies": { "@ant-design/icons": "^5.2.6", "antd": "^5.12.5", diff --git a/frontend/package.json b/frontend/package.json index 1d199e38..75eb6320 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "planet-frontend", - "version": "0.22.7", + "version": "0.22.8", "private": true, "dependencies": { "@ant-design/icons": "^5.2.6", diff --git a/frontend/src/pages/Settings/Settings.tsx b/frontend/src/pages/Settings/Settings.tsx index e7d7fc7f..670f261d 100644 --- a/frontend/src/pages/Settings/Settings.tsx +++ b/frontend/src/pages/Settings/Settings.tsx @@ -75,6 +75,9 @@ function Settings() { const [loading, setLoading] = useState(true) const [savingCollectorId, setSavingCollectorId] = useState(null) const [collectors, setCollectors] = useState([]) + const [systemSettings, setSystemSettings] = useState(null) + const [notificationSettings, setNotificationSettings] = useState(null) + const [securitySettings, setSecuritySettings] = useState(null) const collectorTableRegionRef = useRef(null) const [collectorTableHeight, setCollectorTableHeight] = useState(360) const [systemForm] = Form.useForm() @@ -85,9 +88,9 @@ function Settings() { try { setLoading(true) const response = await axios.get('/api/v1/settings') - systemForm.setFieldsValue(response.data.system) - notificationForm.setFieldsValue(response.data.notifications) - securityForm.setFieldsValue(response.data.security) + setSystemSettings(response.data.system) + setNotificationSettings(response.data.notifications) + setSecuritySettings(response.data.security) setCollectors(response.data.collectors || []) } catch (error) { message.error('获取系统配置失败') @@ -101,6 +104,24 @@ function Settings() { fetchSettings() }, []) + useEffect(() => { + if (!loading && systemSettings) { + systemForm.setFieldsValue(systemSettings) + } + }, [loading, systemForm, systemSettings]) + + useEffect(() => { + if (!loading && notificationSettings) { + notificationForm.setFieldsValue(notificationSettings) + } + }, [loading, notificationForm, notificationSettings]) + + useEffect(() => { + if (!loading && securitySettings) { + securityForm.setFieldsValue(securitySettings) + } + }, [loading, securityForm, securitySettings]) + useEffect(() => { const updateTableHeight = () => { const regionHeight = collectorTableRegionRef.current?.offsetHeight || 0 @@ -257,6 +278,7 @@ function Settings() { { key: 'system', label: '系统显示', + forceRender: true, children: (
saveSection('system', values)}> @@ -283,6 +305,7 @@ function Settings() { { key: 'notifications', label: '通知策略', + forceRender: true, children: ( saveSection('notifications', values)}> @@ -309,6 +332,7 @@ function Settings() { { key: 'security', label: '安全策略', + forceRender: true, children: ( saveSection('security', values)}> diff --git a/pyproject.toml b/pyproject.toml index 8c96ddc6..cd6090b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "planet" -version = "0.22.6" +version = "0.22.8" description = "智能星球计划 - 态势感知系统" requires-python = ">=3.14" dependencies = [ diff --git a/uv.lock b/uv.lock index 259fe961..61bc6737 100644 --- a/uv.lock +++ b/uv.lock @@ -475,7 +475,7 @@ wheels = [ [[package]] name = "planet" -version = "0.22.7" +version = "0.22.8" source = { virtual = "." } dependencies = [ { name = "aiofiles" },