diff --git a/src/mobile-main.js b/src/mobile-main.js index 6137cb4e..fd4748b0 100644 --- a/src/mobile-main.js +++ b/src/mobile-main.js @@ -44,6 +44,7 @@ const i18n = new VueI18n(getI18nOptions()); Vue.prototype.$version = version.getVersion; Vue.prototype.$buildTime = version.getBuildTime; + Vue.prototype.$licenses = licenses; Vue.prototype.$constants = { currency: currency, @@ -51,44 +52,46 @@ Vue.prototype.$constants = { icons: icons, account: account, }; + Vue.prototype.$utilities = utils; Vue.prototype.$logger = logger; Vue.prototype.$webauthn = webauthn; Vue.prototype.$settings = settings; -Vue.prototype.$getDefaultLanguage = getDefaultLanguage; -Vue.prototype.$getAllLanguages = getAllLanguages; -Vue.prototype.$getLanguage = getLanguage; -Vue.prototype.$setLanguage = function (locale) { - if (settings.getLanguage() !== locale) { - settings.setLanguage(locale); +Vue.prototype.$locale = { + getDefaultLanguage: getDefaultLanguage, + getAllLanguages: getAllLanguages, + getLanguage: getLanguage, + setLanguage: function (locale) { + if (settings.getLanguage() !== locale) { + settings.setLanguage(locale); + } + + i18n.locale = locale; + moment.locale(locale); + services.setLocale(locale); + document.querySelector('html').setAttribute('lang', locale); + return locale; + }, + getAllCurrencies: function () { + const allCurrencyCodes = currency.all; + const allCurrencies = []; + + for (let i = 0; i < allCurrencyCodes.length; i++) { + const code = allCurrencyCodes[i]; + + allCurrencies.push({ + code: code, + displayName: i18n.t(`currency.${code}`) + }); + } + + allCurrencies.sort(function(c1, c2){ + return c1.displayName.localeCompare(c2.displayName); + }) + + return allCurrencies; } - - i18n.locale = locale; - moment.locale(locale); - services.setLocale(locale); - document.querySelector('html').setAttribute('lang', locale); - return locale; }; -Vue.prototype.$getAllCurrencies = function () { - const allCurrencyCodes = currency.all; - const allCurrencies = []; - - for (let i = 0; i < allCurrencyCodes.length; i++) { - const code = allCurrencyCodes[i]; - - allCurrencies.push({ - code: code, - displayName: i18n.t(`currency.${code}`) - }); - } - - allCurrencies.sort(function(c1, c2){ - return c1.displayName.localeCompare(c2.displayName); - }) - - return allCurrencies; -}; -Vue.prototype.$isUserRegistrationEnabled = settings.isUserRegistrationEnabled; Vue.prototype.$alert = function (message, confirmCallback) { let parameters = {}; @@ -171,7 +174,7 @@ if (settings.getLanguage()) { logger.info(`No language is set, use browser default ${getDefaultLanguage()}`); } -Vue.prototype.$setLanguage(settings.getLanguage() || getDefaultLanguage()); +Vue.prototype.$locale.setLanguage(settings.getLanguage() || getDefaultLanguage()); if (userstate.isUserLogined()) { if (!settings.isEnableApplicationLock()) { diff --git a/src/views/mobile/Login.vue b/src/views/mobile/Login.vue index d39b9be5..feb50f4b 100644 --- a/src/views/mobile/Login.vue +++ b/src/views/mobile/Login.vue @@ -110,10 +110,10 @@ export default { return 'v' + this.$version(); }, allLanguages() { - return this.$getAllLanguages(); + return this.$locale.getAllLanguages(); }, isUserRegistrationEnabled() { - return this.$isUserRegistrationEnabled(); + return this.$settings.isUserRegistrationEnabled(); }, inputIsEmpty() { return !this.username || !this.password; @@ -134,10 +134,10 @@ export default { }, currentLanguageName() { const currentLocale = this.$i18n.locale; - let lang = this.$getLanguage(currentLocale); + let lang = this.$locale.getLanguage(currentLocale); if (!lang) { - lang = this.$getLanguage(this.$getDefaultLanguage()); + lang = this.$locale.getLanguage(this.$locale.getDefaultLanguage()); } return lang.displayName; @@ -289,7 +289,7 @@ export default { } }, changeLanguage(locale) { - this.$setLanguage(locale); + this.$locale.setLanguage(locale); } } }; diff --git a/src/views/mobile/Settings.vue b/src/views/mobile/Settings.vue index ea16592a..8d9ffb03 100644 --- a/src/views/mobile/Settings.vue +++ b/src/views/mobile/Settings.vue @@ -92,14 +92,14 @@ export default { return userInfo.nickname || userInfo.username || this.$t('User'); }, allLanguages() { - return this.$getAllLanguages(); + return this.$locale.getAllLanguages(); }, currentLocale: { get: function () { return this.$i18n.locale; }, set: function (value) { - this.$setLanguage(value); + this.$locale.setLanguage(value); } }, isEnableApplicationLock() { diff --git a/src/views/mobile/Signup.vue b/src/views/mobile/Signup.vue index 63c1965c..02b4f600 100644 --- a/src/views/mobile/Signup.vue +++ b/src/views/mobile/Signup.vue @@ -93,7 +93,7 @@ export default { }, computed: { allCurrencies() { - return this.$getAllCurrencies(); + return this.$locale.getAllCurrencies(); }, inputIsEmpty() { return !!this.inputEmptyProblemMessage; @@ -161,6 +161,10 @@ export default { if (self.$utilities.isString(data.result.token)) { self.$user.updateTokenAndUserInfo(data.result); + + if (self.$settings.isAutoUpdateExchangeRatesData()) { + self.$services.autoRefreshLatestExchangeRates(); + } } self.$toast('You have been successfully registered'); diff --git a/src/views/mobile/accounts/AccountEdit.vue b/src/views/mobile/accounts/AccountEdit.vue index 2c82dd92..ecfc59e6 100644 --- a/src/views/mobile/accounts/AccountEdit.vue +++ b/src/views/mobile/accounts/AccountEdit.vue @@ -339,7 +339,7 @@ export default { return ret; }, allCurrencies() { - return this.$getAllCurrencies(); + return this.$locale.getAllCurrencies(); } }, created() { diff --git a/src/views/mobile/users/UserProfile.vue b/src/views/mobile/users/UserProfile.vue index e84aa12e..9ef777b7 100644 --- a/src/views/mobile/users/UserProfile.vue +++ b/src/views/mobile/users/UserProfile.vue @@ -126,7 +126,7 @@ export default { }, computed: { allCurrencies() { - return this.$getAllCurrencies(); + return this.$locale.getAllCurrencies(); }, inputIsNotChanged() { return !!this.inputIsNotChangedProblemMessage;