mirror of
https://github.com/unanmed/ginka-generator.git
synced 2026-05-21 10:21:15 +08:00
feat: 数据集 id 避免嵌套堆叠
This commit is contained in:
parent
cc2fc3e96c
commit
ad2715cd59
@ -20,11 +20,18 @@ export function mergeDataset<T>(
|
|||||||
if (datasets.length === 1) {
|
if (datasets.length === 1) {
|
||||||
return datasets[0];
|
return datasets[0];
|
||||||
}
|
}
|
||||||
|
const usedKeys = new Set<string>();
|
||||||
const data: Record<string, T> = {};
|
const data: Record<string, T> = {};
|
||||||
datasets.forEach(v => {
|
datasets.forEach(v => {
|
||||||
for (const [key, value] of Object.entries(v.data)) {
|
for (const [key, value] of Object.entries(v.data)) {
|
||||||
const dataKey = `${v.datasetId}/${key}`;
|
if (usedKeys.has(key)) {
|
||||||
data[dataKey] = value;
|
const dataKey = `${v.datasetId}/${key}`;
|
||||||
|
data[dataKey] = value;
|
||||||
|
usedKeys.add(dataKey);
|
||||||
|
} else {
|
||||||
|
data[key] = value;
|
||||||
|
usedKeys.add(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user