Fix getters mutating state on repeated access

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 07:31:59 +08:00
parent ef8ce0d778
commit eeea16be38
4 changed files with 77 additions and 35 deletions

View File

@@ -124,23 +124,22 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
},
filterAttrs: state => {
if(state.allFilterAttrs !== null){
state.allFilterAttrs.forEach(att => {
switch (att.type) {
return state.allFilterAttrs.map(att => {
const copy = { ...att };
switch (copy.type) {
case 'date':
att.min = att.min !== null ? moment(att.min).format('YYYY/MM/DD HH:mm') : null;
att.max = att.max !== null ? moment(att.max).format('YYYY/MM/DD HH:mm') : null;
copy.min = copy.min !== null ? moment(copy.min).format('YYYY/MM/DD HH:mm') : null;
copy.max = copy.max !== null ? moment(copy.max).format('YYYY/MM/DD HH:mm') : null;
break;
case 'float':
// Decimal.ROUND_UP|0: 無條件進位; Decimal.ROUND_DOWN|1: 無條件捨去。
att.min = att.min !== null ? Number(new Decimal(att.min).toFixed(2, 1)) : null;
att.max = att.max !== null ? Number(new Decimal(att.max).toFixed(2, 0)) : null;
copy.min = copy.min !== null ? Number(new Decimal(copy.min).toFixed(2, 1)) : null;
copy.max = copy.max !== null ? Number(new Decimal(copy.max).toFixed(2, 0)) : null;
break
default:
break;
}
return att;
return copy;
});
return state.allFilterAttrs;
}
},
allFunnels: state => {