From 1c8084a3b1313748f8857d6a562e9ac221b7bef9 Mon Sep 17 00:00:00 2001 From: atoz03 Date: Sun, 14 Dec 2025 14:07:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E6=89=93=E5=BC=80=E4=BD=99?= =?UTF-8?q?=E9=A2=9D=E8=84=9A=E6=9C=AC=E5=BC=B9=E7=AA=97=E6=97=B6=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E8=A1=A8=E5=8D=95=EF=BC=8C=E9=81=BF=E5=85=8D=E8=B7=A8?= =?UTF-8?q?=E8=B4=A6=E6=88=B7=E6=AE=8B=E7=95=99=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 打开弹窗先重置表单字段(baseUrl/apiKey/extra 等),仅保留示例脚本\n- 若后端存在已保存配置,则加载后覆盖\n- 同步清理测试结果与 loading 状态,避免残留误导 --- .../accounts/AccountBalanceScriptModal.vue | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/web/admin-spa/src/components/accounts/AccountBalanceScriptModal.vue b/web/admin-spa/src/components/accounts/AccountBalanceScriptModal.vue index 13fd97ce..17f2be00 100644 --- a/web/admin-spa/src/components/accounts/AccountBalanceScriptModal.vue +++ b/web/admin-spa/src/components/accounts/AccountBalanceScriptModal.vue @@ -139,16 +139,6 @@ const saving = ref(false) const testing = ref(false) const testResult = ref(null) -const form = reactive({ - baseUrl: '', - apiKey: '', - token: '', - extra: '', - timeoutSeconds: 10, - autoIntervalMinutes: 0, - scriptBody: '' -}) - const presetScript = `({ request: { url: "{{baseUrl}}/api/user/self", @@ -178,8 +168,36 @@ const presetScript = `({ } })` +const form = reactive({ + baseUrl: '', + apiKey: '', + token: '', + extra: '', + timeoutSeconds: 10, + autoIntervalMinutes: 0, + scriptBody: '' +}) + +const buildDefaultForm = () => ({ + baseUrl: '', + apiKey: '', + token: '', + extra: '', + timeoutSeconds: 10, + autoIntervalMinutes: 0, + // 默认给出示例脚本,字段保持清空,避免“上一个账户的配置污染当前账户” + scriptBody: presetScript +}) + const emitClose = () => emit('close') +const resetForm = () => { + Object.assign(form, buildDefaultForm()) + testResult.value = null + saving.value = false + testing.value = false +} + const loadConfig = async () => { if (!props.account?.id || !props.account?.platform) return try { @@ -254,9 +272,8 @@ watch( () => props.show, (val) => { if (val) { - applyPreset() + resetForm() loadConfig() - testResult.value = null } } )