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

This commit is contained in:
MaysWind
2025-09-14 01:40:53 +08:00
parent 67bc81d3e2
commit 4700446ca0
38 changed files with 389 additions and 597 deletions
@@ -111,7 +111,7 @@
v-if="(showHidden || !account.hidden) && account.type === AccountType.MultiSubAccounts.type && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])">
<template :key="subAccount.id"
v-for="(subAccount, subIdx) in accountCategory.allSubAccounts[account.id]">
<v-divider v-if="showHidden ? subIdx > 0 : (!subAccount.hidden ? subIdx > accountCategory.allFirstVisibleSubAccountIndexes[account.id] : false)"/>
<v-divider v-if="showHidden ? subIdx > 0 : (!subAccount.hidden ? subIdx > (accountCategory.allFirstVisibleSubAccountIndexes[account.id] as number) : false)"/>
<v-list-item v-if="showHidden || !subAccount.hidden">
<template #prepend>
@@ -108,7 +108,7 @@
v-if="(showHidden || !category.hidden) && ((showHidden && transactionType.allSubCategories[category.id]) || transactionType.allVisibleSubCategoryCounts[category.id])">
<template :key="subCategory.id"
v-for="(subCategory, subIdx) in transactionType.allSubCategories[category.id]">
<v-divider v-if="showHidden ? subIdx > 0 : (!subCategory.hidden ? subIdx > transactionType.allFirstVisibleSubCategoryIndexes[category.id] : false)"/>
<v-divider v-if="showHidden ? subIdx > 0 : (!subCategory.hidden ? subIdx > (transactionType.allFirstVisibleSubCategoryIndexes[category.id] as number) : false)"/>
<v-list-item v-if="showHidden || !subCategory.hidden">
<template #prepend>
+1 -2
View File
@@ -227,8 +227,7 @@ function reload(force: boolean): void {
const exchangeRates = exchangeRatesData.value.exchangeRates;
let foundDefaultCurrency = false;
for (let i = 0; i < exchangeRates.length; i++) {
const exchangeRate = exchangeRates[i];
for (const exchangeRate of exchangeRates) {
if (exchangeRate.currency === baseCurrency.value) {
foundDefaultCurrency = true;
break;
@@ -696,7 +696,7 @@ function close(completed: boolean): void {
watch(fileType, () => {
if (allFileSubTypes.value && allFileSubTypes.value.length) {
fileSubType.value = allFileSubTypes.value[0].type;
fileSubType.value = allFileSubTypes.value[0]!.type;
}
importFile.value = null;
@@ -145,6 +145,7 @@ import { useRootStore } from '@/stores/index.ts';
import { useSettingsStore } from '@/stores/setting.ts';
import { useTokensStore } from '@/stores/token.ts';
import { itemAndIndex, reversedItemAndIndex } from '@/core/base.ts';
import { type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
import { isEquals } from '@/lib/common.ts';
@@ -203,8 +204,7 @@ const sessions = computed<DesktopPageSessionInfo[]>(() => {
return sessions;
}
for (let i = 0; i < tokens.value.length; i++) {
const token = tokens.value[i];
for (const token of tokens.value) {
const sessionInfo = parseSessionInfo(token);
sessions.push(new DesktopPageSessionInfo(sessionInfo));
}
@@ -336,9 +336,9 @@ function revokeSession(session: SessionInfo): void {
}).then(() => {
loadingSession.value = false;
for (let i = 0; i < tokens.value.length; i++) {
if (tokens.value[i].tokenId === session.tokenId) {
tokens.value.splice(i, 1);
for (const [token, index] of itemAndIndex(tokens.value)) {
if (token.tokenId === session.tokenId) {
tokens.value.splice(index, 1);
}
}
}).catch(error => {
@@ -362,9 +362,9 @@ function revokeAllSessions(): void {
tokensStore.revokeAllTokens().then(() => {
loadingSession.value = false;
for (let i = tokens.value.length - 1; i >= 0; i--) {
if (!tokens.value[i].isCurrent) {
tokens.value.splice(i, 1);
for (const [token, index] of reversedItemAndIndex(tokens.value)) {
if (!token.isCurrent) {
tokens.value.splice(index, 1);
}
}