From 4418eccfab178bbca5cf54ca74692598f19f5a6e Mon Sep 17 00:00:00 2001 From: Cherelle Spencer <454690789@qq.com> Date: Tue, 4 Apr 2023 16:59:30 +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=20(#2667)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 苗大 --- 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 0ef6b074..945ed086 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 = () => {}; @@ -48,7 +48,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; }); } }); -- GitLab