fix(admin): CredsPane 单卡保存不再联动重置兄弟卡
旧 array-source watch 盯 [emailGroup, pushGroup, aiGroup] 三元数组——任一
组引用变化即 resetAll 三卡齐重建:单卡保存(如 email)后父层 onPaneSaved
换整份快照引用,push/ai 卡上未保存的编辑被静默丢弃(Task 14 评审挂账)。
改为三表各自 watch 本组 props 引用:父层保存回写是 {...snapshot, [group]:
config} 展开——只有被保存组引用换新,兄弟组引用不动 → 只重建该卡;切租户/
回滚时快照先置 null 再整份换新,三组引用齐变 → 三卡全量重置(行为保持)。
resetAll 相应拆为 resetEmailCard / resetPushCard / resetAiCard(备注/错误/
测试态随所属卡重置)。
自查两场景:改 email 保存 → push 草稿与 dirty 均保留;切租户 → 三卡齐重置。
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -411,7 +411,8 @@
|
||||
(e: 'dirty', value: boolean): void
|
||||
}>()
|
||||
|
||||
// ---- 编辑态(组引用变化 = 保存回写/租户切换/重载 → 重置表单与密钥态) ----------------
|
||||
// ---- 编辑态(单组引用变化 = 该卡保存回写/重载 → 只重置该卡;切租户/回滚时
|
||||
// 父层整份快照换新 → 三组引用齐变 → 三卡各自重置) ------------------------------------
|
||||
|
||||
const emailForm = reactive<EmailCredsForm>(normalizeEmailCredsGroup(undefined).form)
|
||||
const pushForm = reactive<PushCredsForm>(normalizePushCredsGroup(undefined).form)
|
||||
@@ -434,8 +435,8 @@
|
||||
const emailError = ref('')
|
||||
const pushError = ref('')
|
||||
const aiError = ref('')
|
||||
/** dirty 基线(三表单各自 normalize*Group().form 的 JSON 快照——与
|
||||
* resetAll 同 watch 刷新;密钥输入不进基线:掩码 GET 本就无原值可比,
|
||||
/** dirty 基线(三表单各自 normalize*Group().form 的 JSON 快照——随各组
|
||||
* watch 刷新;密钥输入不进基线:掩码 GET 本就无原值可比,
|
||||
* 由 dirty 计算里的三态判定补足) */
|
||||
const emailBaseline = ref(JSON.stringify(normalizeEmailCredsGroup(undefined).form))
|
||||
const pushBaseline = ref(JSON.stringify(normalizePushCredsGroup(undefined).form))
|
||||
@@ -453,44 +454,50 @@
|
||||
const pushProbe = ref<PushTestResponse | null>(null)
|
||||
const pushProbeError = ref('')
|
||||
|
||||
function resetAll(
|
||||
emailGroup: Record<string, unknown> | null | undefined,
|
||||
pushGroup: Record<string, unknown> | null | undefined,
|
||||
aiGroup: Record<string, unknown> | null | undefined
|
||||
): void {
|
||||
/** 单卡重置:只重建该卡的表单/密钥态/备注/错误/测试态——单卡保存回写
|
||||
* 不再联动丢弃兄弟卡未保存草稿(Task 14 评审挂账,Task 15 修复) */
|
||||
function resetEmailCard(emailGroup: Record<string, unknown> | null | undefined): void {
|
||||
const es = normalizeEmailCredsGroup(emailGroup)
|
||||
Object.assign(emailForm, es.form)
|
||||
emailPasswordMasked.value = es.passwordMasked
|
||||
emailPasswordCleared.value = false
|
||||
emailBaseline.value = JSON.stringify(es.form)
|
||||
emailComment.value = ''
|
||||
emailError.value = ''
|
||||
emailTestResult.value = null
|
||||
emailTesting.value = false
|
||||
}
|
||||
|
||||
function resetPushCard(pushGroup: Record<string, unknown> | null | undefined): void {
|
||||
const ps = normalizePushCredsGroup(pushGroup)
|
||||
Object.assign(pushForm, ps.form)
|
||||
pushApiKeyMasked.value = ps.apiKeyMasked
|
||||
pushApiKeyCleared.value = false
|
||||
pushBaseline.value = JSON.stringify(ps.form)
|
||||
const as = normalizeAiCredsGroup(aiGroup)
|
||||
Object.assign(aiForm, as.form)
|
||||
aiApiKeyMasked.value = as.apiKeyMasked
|
||||
aiApiKeyCleared.value = false
|
||||
aiBaseline.value = JSON.stringify(as.form)
|
||||
emailComment.value = ''
|
||||
pushComment.value = ''
|
||||
aiComment.value = ''
|
||||
emailError.value = ''
|
||||
pushError.value = ''
|
||||
aiError.value = ''
|
||||
emailTestResult.value = null
|
||||
emailTesting.value = false
|
||||
pushProbe.value = null
|
||||
pushProbeError.value = ''
|
||||
pushProbing.value = false
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.emailGroup, props.pushGroup, props.aiGroup],
|
||||
([emailGroup, pushGroup, aiGroup]) => resetAll(emailGroup, pushGroup, aiGroup),
|
||||
{ immediate: true }
|
||||
)
|
||||
function resetAiCard(aiGroup: Record<string, unknown> | null | undefined): void {
|
||||
const as = normalizeAiCredsGroup(aiGroup)
|
||||
Object.assign(aiForm, as.form)
|
||||
aiApiKeyMasked.value = as.apiKeyMasked
|
||||
aiApiKeyCleared.value = false
|
||||
aiBaseline.value = JSON.stringify(as.form)
|
||||
aiComment.value = ''
|
||||
aiError.value = ''
|
||||
}
|
||||
|
||||
// 分组 watch(替代旧 array-source 全量 resetAll):父层 onPaneSaved 对快照做
|
||||
// {...snapshot, [group]: config} 展开——只有被保存组引用换新,兄弟组引用不动
|
||||
// → 只重建该卡;切租户/回滚时快照先置 null 再整份换新,三组引用齐变 → 三卡
|
||||
// 全量重置(保持既有行为)
|
||||
watch(() => props.emailGroup, resetEmailCard, { immediate: true })
|
||||
watch(() => props.pushGroup, resetPushCard, { immediate: true })
|
||||
watch(() => props.aiGroup, resetAiCard, { immediate: true })
|
||||
|
||||
/** 未保存判定:三表单任一偏离基线,或密钥三态(输入非空 = 覆盖新值 /
|
||||
* cleared = 显式清除)——密钥输入框基线恒空串,只能独立判定 */
|
||||
|
||||
Reference in New Issue
Block a user