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
@@ -202,6 +202,7 @@ import { useAccountEditPageBaseBase } from '@/views/base/accounts/AccountEditPag
import { useUserStore } from '@/stores/user.ts';
import { useAccountsStore } from '@/stores/account.ts';
import { itemAndIndex } from '@/core/base.ts';
import { AccountType } from '@/core/account.ts';
import { ALL_ACCOUNT_ICONS } from '@/consts/icon.ts';
import { ALL_ACCOUNT_COLORS } from '@/consts/color.ts';
@@ -365,11 +366,11 @@ function save(): void {
});
}
function removeSubAccount(subAccount: Account): void {
function removeSubAccount(currentSubAccount: Account): void {
confirmDialog.value?.open('Are you sure you want to remove this sub-account?').then(() => {
for (let i = 0; i < subAccounts.value.length; i++) {
if (subAccounts.value[i] === subAccount) {
subAccounts.value.splice(i, 1);
for (const [subAccount, index] of itemAndIndex(subAccounts.value)) {
if (subAccount === currentSubAccount) {
subAccounts.value.splice(index, 1);
if (currentAccountIndex.value >= subAccounts.value.length) {
currentAccountIndex.value = subAccounts.value.length - 1;