code refactor

This commit is contained in:
MaysWind
2025-01-05 21:39:39 +08:00
parent 49f1f3c86b
commit 6dc0ebcac6
22 changed files with 279 additions and 229 deletions
+11 -5
View File
@@ -76,6 +76,12 @@ import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import logger from '@/lib/logger.ts';
import webauthn from '@/lib/webauthn.js';
import {
unlockTokenByWebAuthn,
unlockTokenByPinCode,
hasWebAuthnConfig,
getWebAuthnCredentialId
} from '@/lib/userstate.ts';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
import { isModalShowing } from '@/lib/ui/mobile.js';
@@ -101,7 +107,7 @@ export default {
},
isWebAuthnAvailable() {
return this.settingsStore.appSettings.applicationLockWebAuthn
&& this.$user.getWebAuthnCredentialId()
&& hasWebAuthnConfig()
&& webauthn.isSupported();
},
currentLanguageCode() {
@@ -116,7 +122,7 @@ export default {
const self = this;
const router = self.f7router;
if (!self.settingsStore.appSettings.applicationLockWebAuthn || !self.$user.getWebAuthnCredentialId()) {
if (!self.settingsStore.appSettings.applicationLockWebAuthn || !hasWebAuthnConfig()) {
self.$toast('WebAuthn is not enabled');
return;
}
@@ -130,11 +136,11 @@ export default {
webauthn.verifyCredential(
self.userStore.currentUserBasicInfo,
self.$user.getWebAuthnCredentialId()
getWebAuthnCredentialId()
).then(({ id, userName, userSecret }) => {
self.$hideLoading();
self.$user.unlockTokenByWebAuthn(id, userName, userSecret);
unlockTokenByWebAuthn(id, userName, userSecret);
self.transactionsStore.initTransactionDraft();
self.tokensStore.refreshTokenAndRevokeOldToken().then(response => {
if (response.user) {
@@ -189,7 +195,7 @@ export default {
}
try {
self.$user.unlockTokenByPinCode(user.username, pinCode);
unlockTokenByPinCode(user.username, pinCode);
self.transactionsStore.initTransactionDraft();
self.tokensStore.refreshTokenAndRevokeOldToken().then(response => {
if (response.user) {