From 65428aa49fadcbdacf6f4b784fbf57e4893893c7 Mon Sep 17 00:00:00 2001 From: Ruochen <1051989940@qq.com> Date: Wed, 18 Jun 2025 23:58:09 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=95=86=E4=BF=9D=E5=AD=98=E6=B5=81=E7=A8=8B=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DUI=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/views/ProviderPage.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dashboard/src/views/ProviderPage.vue b/dashboard/src/views/ProviderPage.vue index abae10aef..683085eb8 100644 --- a/dashboard/src/views/ProviderPage.vue +++ b/dashboard/src/views/ProviderPage.vue @@ -405,6 +405,16 @@ export default { } }, + watch: { + showKeyConfirm(newValue) { + // 当对话框关闭时,如果 Promise 还在等待,则拒绝它以防止内存泄漏 + if (!newValue && this.keyConfirmResolve) { + this.keyConfirmResolve(false); + this.keyConfirmResolve = null; + } + } + }, + computed: { // 根据选择的标签过滤提供商列表 filteredProviders() { @@ -598,14 +608,14 @@ export default { } this.loading = true; + const wasUpdating = this.updatingMode; try { - if (this.updatingMode) { + if (wasUpdating) { const res = await axios.post('/api/config/provider/update', { id: this.newSelectedProviderName, config: this.newSelectedProviderConfig }); this.showSuccess(res.data.message || "更新成功!"); - this.updatingMode = false; } else { const res = await axios.post('/api/config/provider/new', this.newSelectedProviderConfig); this.showSuccess(res.data.message || "添加成功!"); @@ -616,6 +626,9 @@ export default { this.showError(err.response?.data?.message || err.message); } finally { this.loading = false; + if (wasUpdating) { + this.updatingMode = false; + } } },