From 8861effc7eb2c5633027b294c55f01843d6cc19c Mon Sep 17 00:00:00 2001 From: zhangyu Date: Wed, 30 Mar 2022 16:12:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=8C=89=E9=92=AE=20=E4=B8=8D=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/components/common/js/tools.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index 25f955a6e..8c923cae4 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -162,9 +162,9 @@ export const cancelWithChange = { if (!binding.value || !binding.value.obj) return const unsavedChange = localStorage.getItem('nz-unnsaved-change') const oldValue = JSON.parse(JSON.stringify(binding.value.obj)) + el.__newValue__ = oldValue function domClick (e) { - const newValue = JSON.parse(JSON.stringify(binding.value.obj)) - if (unsavedChange == 'on' && !isEqual(oldValue, newValue)) { + if (unsavedChange == 'on' && !isEqual(oldValue, el.__newValue__)) { MessageBox.confirm(i18n.t('tip.confirmCancel'), { confirmButtonText: i18n.t('tip.yes'), cancelButtonText: i18n.t('tip.no'), @@ -181,6 +181,9 @@ export const cancelWithChange = { el.__vueDomClick__ = domClick el.addEventListener('click', domClick) }, + update (el, binding, vnode) { + el.__newValue__ = binding.value.obj + }, unbind: function (el, binding) { // 解除事件监听 document.removeEventListener('click', el.__vueDomClick__)