完成仓库模块

This commit is contained in:
Zy
2026-04-23 17:59:36 +08:00
parent 985860c9de
commit 9d4416b238
39 changed files with 5040 additions and 80 deletions

10
src/utils/map.ts Normal file
View File

@@ -0,0 +1,10 @@
/**
* 合并两个对象数组并去重(基于 id,后面的覆盖前面的)
*/
export function mergeObjectsAndDedupe<T extends { id?: string }>(arr1: T[], arr2: T[]): T[] {
const map = new Map(arr1.map((item) => [item.id, item]));
arr2.forEach((item) => {
if (item.id) map.set(item.id, item);
});
return [...map.values()];
}