From a8a52e5c07ac766b1f76a5929a6ff5f0318339df Mon Sep 17 00:00:00 2001 From: xingyuv Date: Tue, 4 Apr 2023 09:13:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(deepMerge):=20=E4=BF=AE=E5=A4=8D=E9=80=92?= =?UTF-8?q?=E5=BD=92=E5=90=88=E5=B9=B6=E6=93=8D=E4=BD=9C,=20=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E6=95=B0=E7=BB=84=E6=9C=AA=E5=8E=BB=E9=87=8D=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 6cb59859..cb7a2ab4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -3,7 +3,7 @@ import type { App, Component } from 'vue' import { unref } from 'vue' import { isArray, isObject } from '@/utils/is' -import { cloneDeep, mergeWith } from 'lodash-es' +import { cloneDeep, isEqual, mergeWith, unionWith } from 'lodash-es' export const noop = () => {} @@ -44,7 +44,8 @@ export function deepMerge { if (isObject(objValue) && isObject(srcValue)) { return mergeWith(cloneDeep(objValue), srcValue, (prevValue, nextValue) => { - return isArray(prevValue) ? prevValue.concat(nextValue) : undefined + // 如果是数组,合并数组(去重) If it is an array, merge the array (remove duplicates) + return isArray(prevValue) ? unionWith(prevValue, nextValue, isEqual) : undefined }) } })