Commit 7ca007ecd510379d7c1b1fc7be98e83074371dca
Committed by
GitHub
1 parent
361a189f
fix(deepMerge): fix recursive merge data without removing duplicate bugs (#2831)
Co-authored-by: luojingzhou <luojingzhou@kezaihui.com>
Showing
1 changed file
with
3 additions
and
3 deletions
src/utils/index.ts
1 | -import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router'; | |
2 | 1 | import type { App, Component } from 'vue'; |
2 | +import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router'; | |
3 | 3 | |
4 | +import { cloneDeep, mergeWith, uniq } from 'lodash-es'; | |
4 | 5 | import { unref } from 'vue'; |
5 | 6 | import { isArray, isObject } from '/@/utils/is'; |
6 | -import { cloneDeep, isEqual, mergeWith, unionWith } from 'lodash-es'; | |
7 | 7 | |
8 | 8 | export const noop = () => {}; |
9 | 9 | |
... | ... | @@ -49,7 +49,7 @@ export function deepMerge<T extends object | null | undefined, U extends object |
49 | 49 | if (isObject(objValue) && isObject(srcValue)) { |
50 | 50 | return mergeWith(cloneDeep(objValue), srcValue, (prevValue, nextValue) => { |
51 | 51 | // 如果是数组,合并数组(去重) If it is an array, merge the array (remove duplicates) |
52 | - return isArray(prevValue) ? unionWith(prevValue, nextValue, isEqual) : undefined; | |
52 | + return isArray(prevValue) ? uniq(prevValue, nextValue) : undefined; | |
53 | 53 | }); |
54 | 54 | } |
55 | 55 | }); | ... | ... |