mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
use for-of statements to replace for and for-in
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user