fix: use filter to replace find
This commit is contained in:
@@ -417,9 +417,8 @@ export default {
|
|||||||
const activityNodeArray = nodes.filter(node => node.data.type === 'activity');
|
const activityNodeArray = nodes.filter(node => node.data.type === 'activity');
|
||||||
// 找出除了 start, end 以外所有的 node 的 option value
|
// 找出除了 start, end 以外所有的 node 的 option value
|
||||||
activityNodeArray.map(node => nodeOptionArr.push(node.data[this.dataLayerType][this.dataLayerOption]));
|
activityNodeArray.map(node => nodeOptionArr.push(node.data[this.dataLayerType][this.dataLayerOption]));
|
||||||
// 刪掉重複的元素,將node的option值從小到大排序(映對色階淺到深)
|
// 將node的option值從小到大排序(映對色階淺到深)
|
||||||
nodeOptionArr = [...new Set(nodeOptionArr)].sort((a, b) => a - b);
|
nodeOptionArr = nodeOptionArr.sort((a, b) => a - b);
|
||||||
|
|
||||||
for(let i = 0; i < ImgCapsules.length; i++) {
|
for(let i = 0; i < ImgCapsules.length; i++) {
|
||||||
const startIdx = i * groupSize;
|
const startIdx = i * groupSize;
|
||||||
const endIdx = (i === ImgCapsules.length - 1) ? activityNodeArray.length : startIdx + groupSize;
|
const endIdx = (i === ImgCapsules.length - 1) ? activityNodeArray.length : startIdx + groupSize;
|
||||||
@@ -427,14 +426,16 @@ export default {
|
|||||||
}
|
}
|
||||||
for(let level = 0; level < leveledGroups.length; level++) {
|
for(let level = 0; level < leveledGroups.length; level++) {
|
||||||
leveledGroups[level].map(option => {
|
leveledGroups[level].map(option => {
|
||||||
const curNode = activityNodeArray.find(activityNode => activityNode.data[this.dataLayerType][this.dataLayerOption] === option);
|
// 考慮可能有名次一樣的情形
|
||||||
|
const curNodes = activityNodeArray.filter(activityNode => activityNode.data[this.dataLayerType][this.dataLayerOption] === option);
|
||||||
|
curNodes.map(curNode => {
|
||||||
curNode.data = {
|
curNode.data = {
|
||||||
...curNode.data,
|
...curNode.data,
|
||||||
nodeImageUrl: ImgCapsules[level],
|
nodeImageUrl: ImgCapsules[level],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
|
|||||||
Reference in New Issue
Block a user