feat: 数据集 id 避免嵌套堆叠

This commit is contained in:
unanmed 2025-03-23 13:10:18 +08:00
parent cc2fc3e96c
commit ad2715cd59

View File

@ -20,11 +20,18 @@ export function mergeDataset<T>(
if (datasets.length === 1) {
return datasets[0];
}
const usedKeys = new Set<string>();
const data: Record<string, T> = {};
datasets.forEach(v => {
for (const [key, value] of Object.entries(v.data)) {
const dataKey = `${v.datasetId}/${key}`;
data[dataKey] = value;
if (usedKeys.has(key)) {
const dataKey = `${v.datasetId}/${key}`;
data[dataKey] = value;
usedKeys.add(dataKey);
} else {
data[key] = value;
usedKeys.add(key);
}
}
});