diff --git a/admin/src/views/config/center/CredsPane.vue b/admin/src/views/config/center/CredsPane.vue index 3850992..31deb99 100644 --- a/admin/src/views/config/center/CredsPane.vue +++ b/admin/src/views/config/center/CredsPane.vue @@ -411,7 +411,8 @@ (e: 'dirty', value: boolean): void }>() - // ---- 编辑态(组引用变化 = 保存回写/租户切换/重载 → 重置表单与密钥态) ---------------- + // ---- 编辑态(单组引用变化 = 该卡保存回写/重载 → 只重置该卡;切租户/回滚时 + // 父层整份快照换新 → 三组引用齐变 → 三卡各自重置) ------------------------------------ const emailForm = reactive(normalizeEmailCredsGroup(undefined).form) const pushForm = reactive(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(null) const pushProbeError = ref('') - function resetAll( - emailGroup: Record | null | undefined, - pushGroup: Record | null | undefined, - aiGroup: Record | null | undefined - ): void { + /** 单卡重置:只重建该卡的表单/密钥态/备注/错误/测试态——单卡保存回写 + * 不再联动丢弃兄弟卡未保存草稿(Task 14 评审挂账,Task 15 修复) */ + function resetEmailCard(emailGroup: Record | 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 | 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 | 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 = 显式清除)——密钥输入框基线恒空串,只能独立判定 */