fix(consignment): 兼容旧配置缺少 internalMatch 并刷新配置缓存
- toFormValues/buildPayload 对 internalMatch 使用可选链,避免旧配置或旧缓存导致页面崩溃 - admin-consignment-profiles 查询增加 staleTime: 0,后台配置页每次进入重拉 - 补充前端回归断言
This commit is contained in:
@@ -214,11 +214,12 @@ function toFormValues(profile: ConsignmentProfile): ConfigFormValues {
|
||||
},
|
||||
internalMatch: {
|
||||
// 内部等待只属于手动匹配;非手动模式切回手动时给默认 30 分钟。
|
||||
// 兼容旧配置/旧缓存缺少 internalMatch 的情况,不能直接读嵌套字段。
|
||||
delayMinutes:
|
||||
config.matching.mode === 'manual'
|
||||
? Number(config.internalMatch.delayMinutes || 0)
|
||||
: Number(config.internalMatch.delayMinutes) > 0
|
||||
? Number(config.internalMatch.delayMinutes)
|
||||
? Number(config.internalMatch?.delayMinutes || 0)
|
||||
: Number(config.internalMatch?.delayMinutes ?? 0) > 0
|
||||
? Number(config.internalMatch?.delayMinutes)
|
||||
: 30,
|
||||
},
|
||||
timeout: {
|
||||
@@ -344,7 +345,7 @@ function buildPayload(
|
||||
internalMatch: {
|
||||
// 内部等待只属于手动匹配:关闭匹配不再等待;自动匹配不使用等待窗口。
|
||||
delayMinutes:
|
||||
values.matching.mode === 'off' ? 0 : Number(values.internalMatch.delayMinutes || 0),
|
||||
values.matching.mode === 'off' ? 0 : Number(values.internalMatch?.delayMinutes || 0),
|
||||
},
|
||||
timeout: {
|
||||
minutes: Math.max(0, Math.round(Number(values.timeout.hours || 0) * 60)),
|
||||
@@ -606,6 +607,8 @@ export default function ConsignmentConfigPanel() {
|
||||
const profilesQuery = useQuery({
|
||||
queryKey: ['admin-consignment-profiles'],
|
||||
queryFn: () => fetchAdminConsignmentProfiles(),
|
||||
// 后台配置页每次进入都重拉,避免旧缓存缺少新增字段(如 internalMatch)。
|
||||
staleTime: 0,
|
||||
})
|
||||
const data = profilesQuery.data?.data
|
||||
const categories = data?.categories || []
|
||||
|
||||
Reference in New Issue
Block a user