use for-of statements to replace for and for-in

This commit is contained in:
MaysWind
2025-09-14 17:18:01 +08:00
parent 4700446ca0
commit 1a8ce7d58d
29 changed files with 455 additions and 579 deletions
@@ -78,9 +78,7 @@ const hasAnyData = computed<boolean>(() => {
return false;
}
for (let i = 0; i < props.data.length; i++) {
const item = props.data[i];
for (const item of props.data) {
if (item.incomeAmount > 0 || item.incomeAmount < 0 || item.expenseAmount > 0 || item.expenseAmount < 0) {
return true;
}
@@ -99,8 +97,7 @@ const chartOptions = computed<object>(() => {
const expenseIncomeAmountColor = getExpenseAndIncomeAmountColor(userStore.currentUserExpenseAmountColor, userStore.currentUserIncomeAmountColor, props.isDarkMode);
if (props.data) {
for (let i = 0; i < props.data.length; i++) {
const item = props.data[i];
for (const item of props.data) {
const monthShortName = formatUnixTimeToGregorianLikeShortMonth(item.monthStartTime);
monthNames.push(monthShortName);
@@ -145,10 +142,9 @@ const chartOptions = computed<object>(() => {
let incomeAmount: string | null = null;
let expenseAmount: string | null = null;
for (let i = 0; i < params.length; i++) {
const param = params[i];
for (const param of params) {
const dataIndex = param.dataIndex;
const data = props.data[dataIndex];
const data = props.data[dataIndex] as TransactionMonthlyIncomeAndExpenseData;
if (param.seriesId === 'seriesIncome') {
incomeAmount = getDisplayIncomeAmount(data);
@@ -160,7 +156,7 @@ const chartOptions = computed<object>(() => {
return `<table>` +
`<thead>` +
`<tr>` +
`<td colspan="2" class="text-start">${params[0].name}</td>` +
`<td colspan="2" class="text-start">${params[0]?.name}</td>` +
`</tr>` +
`</thead>` +
`<tbody>` +