code refactor

This commit is contained in:
MaysWind
2023-07-17 23:13:54 +08:00
parent f0ef9ad51e
commit 714933df56
9 changed files with 43 additions and 63 deletions
+5 -9
View File
@@ -70,7 +70,7 @@
@click="changeLanguage(locale)"
>
<template #after>
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="$i18n.locale === locale"></f7-icon>
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="currentLanguageCode === locale"></f7-icon>
</template>
</f7-list-item>
</f7-list>
@@ -183,15 +183,11 @@ export default {
return 'Use a backup code';
}
},
currentLanguageCode() {
return this.$locale.getCurrentLanguageCode();
},
currentLanguageName() {
const currentLocale = this.$i18n.locale;
let lang = this.$locale.getLanguageInfo(currentLocale);
if (!lang) {
lang = this.$locale.getLanguageInfo(this.$locale.getDefaultLanguage());
}
return lang.displayName;
return this.$locale.getCurrentLanguageDisplayName();
}
},
methods: {
+2 -2
View File
@@ -103,7 +103,7 @@ export default {
const self = this;
return {
currentLocale: self.$i18n.locale,
currentLocale: self.$locale.getCurrentLanguageCode(),
logouting: false
};
},
@@ -196,7 +196,7 @@ export default {
},
methods: {
onPageAfterIn() {
this.currentLocale = this.$i18n.locale;
this.currentLocale = this.$locale.getCurrentLanguageCode();
},
logout() {
const self = this;
+2 -2
View File
@@ -198,7 +198,7 @@ export default {
confirmPassword: '',
email: '',
nickname: '',
language: self.$i18n.locale,
language: self.$locale.getCurrentLanguageCode(),
defaultCurrency: settingsStore.localeDefaultSettings.currency,
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
},
@@ -227,7 +227,7 @@ export default {
},
currentLocale: {
get: function () {
return this.$i18n.locale;
return this.$locale.getCurrentLanguageCode();
},
set: function (value) {
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.localeDefaultSettings.currency;
+5 -9
View File
@@ -48,7 +48,7 @@
@click="changeLanguage(locale)"
>
<template #after>
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="$i18n.locale === locale"></f7-icon>
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="currentLanguageCode === locale"></f7-icon>
</template>
</f7-list-item>
</f7-list>
@@ -94,15 +94,11 @@ export default {
&& this.$user.getWebAuthnCredentialId()
&& webauthn.isSupported();
},
currentLanguageCode() {
return this.$locale.getCurrentLanguageCode();
},
currentLanguageName() {
const currentLocale = this.$i18n.locale;
let lang = this.$locale.getLanguageInfo(currentLocale);
if (!lang) {
lang = this.$locale.getLanguageInfo(this.$locale.getDefaultLanguage());
}
return lang.displayName;
return this.$locale.getCurrentLanguageDisplayName();
}
},
methods: {
+1 -1
View File
@@ -71,7 +71,7 @@ export default {
return {
loadingError: null,
currentLocale: self.$i18n.locale,
currentLocale: self.$locale.getCurrentLanguageCode(),
categoryType: 0,
allCategories: [],
submitting: false,