From fb7790ba4a3429640e7a875d1d956e2918c759e9 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 24 Jun 2023 17:02:57 +0800 Subject: [PATCH] code refactor --- src/DesktopApp.vue | 17 +- src/MobileApp.vue | 32 +-- src/desktop-main.js | 8 +- src/lib/common.js | 4 +- src/lib/i18n.js | 20 +- src/lib/logger.js | 4 +- src/lib/map/amap.js | 16 +- src/lib/map/index.js | 36 +-- src/lib/map/leaflet.js | 6 +- src/lib/server_settings.js | 74 ++++++ src/lib/services.js | 12 +- src/lib/settings.js | 236 ++++++++++++------ src/lib/ui.mobile.js | 6 +- src/lib/userstate.js | 8 +- src/lib/version.js | 29 ++- src/mobile-main.js | 8 +- src/stores/index.js | 26 +- src/stores/setting.js | 116 ++++++++- src/views/desktop/LoginPage.vue | 12 +- src/views/desktop/MainLayout.vue | 20 +- .../settings/UserDataManagementSettingTab.vue | 5 +- src/views/mobile/ApplicationLockPage.vue | 43 ++-- src/views/mobile/HomePage.vue | 36 +-- src/views/mobile/LoginPage.vue | 7 +- src/views/mobile/SettingsPage.vue | 77 +++--- src/views/mobile/SignupPage.vue | 14 +- src/views/mobile/UnlockPage.vue | 12 +- src/views/mobile/accounts/ListPage.vue | 18 +- .../mobile/settings/TextSizeSettingsPage.vue | 11 +- .../statistics/AccountFilterSettingsPage.vue | 7 +- .../statistics/CategoryFilterSettingsPage.vue | 7 +- src/views/mobile/statistics/SettingsPage.vue | 20 +- .../mobile/statistics/TransactionPage.vue | 21 +- src/views/mobile/transactions/EditPage.vue | 18 +- src/views/mobile/transactions/ListPage.vue | 9 +- src/views/mobile/users/DataManagementPage.vue | 3 +- 36 files changed, 644 insertions(+), 354 deletions(-) create mode 100644 src/lib/server_settings.js diff --git a/src/DesktopApp.vue b/src/DesktopApp.vue index 852bbdf7..f249eaa0 100644 --- a/src/DesktopApp.vue +++ b/src/DesktopApp.vue @@ -14,6 +14,7 @@ import { useUserStore } from '@/stores/user.js'; import { useTokensStore } from '@/stores/token.js'; import { useExchangeRatesStore } from '@/stores/exchangeRates.js'; +import { isProduction } from '@/lib/version.js'; import { loadMapAssets } from '@/lib/map/index.js'; import { getSystemTheme } from '@/lib/ui.js'; @@ -22,8 +23,8 @@ export default { const self = this; return { - isProduction: self.$settings.isProduction(), - devCookiePath: self.$settings.isProduction() ? '' : '/dev/cookies' + isProduction: isProduction(), + devCookiePath: isProduction() ? '' : '/dev/cookies' } }, computed: { @@ -33,16 +34,16 @@ export default { const self = this; const theme = useTheme(); - if (self.$settings.getTheme() === 'light') { + if (self.settingsStore.appSettings.theme === 'light') { theme.global.name.value = 'light'; - } else if (self.$settings.getTheme() === 'dark') { + } else if (self.settingsStore.appSettings.theme === 'dark') { theme.global.name.value = 'dark'; } else { theme.global.name.value = getSystemTheme(); } window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function (e) { - if (self.$settings.getTheme() === 'auto') { + if (self.settingsStore.appSettings.theme === 'auto') { if (e.matches) { theme.global.name.value = 'dark'; } else { @@ -51,11 +52,11 @@ export default { } }); - let localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage); + let localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage, self.settingsStore.appSettings.timeZone); self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings); if (self.$user.isUserLogined()) { - if (!self.$settings.isEnableApplicationLock()) { + if (!self.settingsStore.appSettings.applicationLock) { // refresh token if user is logined self.tokensStore.refreshTokenAndRevokeOldToken().then(response => { if (response.user && response.user.language) { @@ -65,7 +66,7 @@ export default { }); // auto refresh exchange rates data - if (self.$settings.isAutoUpdateExchangeRatesData()) { + if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) { self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false }); } } diff --git a/src/MobileApp.vue b/src/MobileApp.vue index 7a3338fb..3f690109 100644 --- a/src/MobileApp.vue +++ b/src/MobileApp.vue @@ -15,6 +15,8 @@ import { useUserStore } from '@/stores/user.js'; import { useTokensStore } from '@/stores/token.js'; import { useExchangeRatesStore } from '@/stores/exchangeRates.js'; +import { isProduction } from '@/lib/version.js'; +import { getTheme, isEnableAnimate } from '@/lib/settings.js'; import { loadMapAssets } from '@/lib/map/index.js'; import { isModalShowing, setAppFontSize } from '@/lib/ui.mobile.js'; @@ -23,15 +25,15 @@ export default { const self = this; let darkMode = 'auto'; - if (self.$settings.getTheme() === 'light') { + if (getTheme() === 'light') { darkMode = false; - } else if (self.$settings.getTheme() === 'dark') { + } else if (getTheme() === 'dark') { darkMode = true; } return { - isProduction: self.$settings.isProduction(), - devCookiePath: self.$settings.isProduction() ? '' : '/dev/cookies', + isProduction: isProduction(), + devCookiePath: isProduction() ? '' : '/dev/cookies', f7params: { name: 'ezBookkeeping', theme: 'ios', @@ -45,31 +47,31 @@ export default { tapHold: true }, serviceWorker: { - path: self.$settings.isProduction() ? './sw.js' : undefined, + path: isProduction() ? './sw.js' : undefined, scope: './', }, actions: { - animate: self.$settings.isEnableAnimate(), + animate: isEnableAnimate(), backdrop: true, closeOnEscape: true }, dialog: { - animate: self.$settings.isEnableAnimate(), + animate: isEnableAnimate(), backdrop: true }, popover: { - animate: self.$settings.isEnableAnimate(), + animate: isEnableAnimate(), backdrop: true, closeOnEscape: true }, popup: { - animate: self.$settings.isEnableAnimate(), + animate: isEnableAnimate(), backdrop: true, closeOnEscape: true, swipeToClose: true }, sheet: { - animate: self.$settings.isEnableAnimate(), + animate: isEnableAnimate(), backdrop: true, closeOnEscape: true }, @@ -77,7 +79,7 @@ export default { routableModals: false }, view: { - animate: self.$settings.isEnableAnimate(), + animate: isEnableAnimate(), browserHistory: !self.isiOSHomeScreenMode(), browserHistoryInitialMatch: true, browserHistoryAnimate: false, @@ -96,11 +98,11 @@ export default { created() { const self = this; - let localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage); + let localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage, self.settingsStore.appSettings.timeZone); self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings); if (self.$user.isUserLogined()) { - if (!self.$settings.isEnableApplicationLock()) { + if (!self.settingsStore.appSettings.applicationLock) { // refresh token if user is logined self.tokensStore.refreshTokenAndRevokeOldToken().then(response => { if (response.user && response.user.language) { @@ -110,14 +112,14 @@ export default { }); // auto refresh exchange rates data - if (self.$settings.isAutoUpdateExchangeRatesData()) { + if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) { self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false }); } } } }, mounted() { - setAppFontSize(this.$settings.getFontSize()); + setAppFontSize(this.settingsStore.appSettings.fontSize); f7ready((f7) => { this.isDarkMode = f7.darkMode; diff --git a/src/desktop-main.js b/src/desktop-main.js index 2c8310b9..2d6418ff 100644 --- a/src/desktop-main.js +++ b/src/desktop-main.js @@ -44,8 +44,7 @@ import '@vuepic/vue-datepicker/dist/main.css'; import router from '@/router/desktop.js'; -import version from '@/lib/version.js'; -import settings from '@/lib/settings.js'; +import { getVersion, getBuildTime } from '@/lib/version.js'; import userstate from '@/lib/userstate.js'; import { getI18nOptions, @@ -324,10 +323,9 @@ app.component('VueDatePicker', VueDatePicker); app.component('AmountInput', AmountInput); app.component('ConfirmDialog', ConfirmDialog); -app.config.globalProperties.$version = version.getVersion(); -app.config.globalProperties.$buildTime = version.getBuildTime(); +app.config.globalProperties.$version = getVersion(); +app.config.globalProperties.$buildTime = getBuildTime(); -app.config.globalProperties.$settings = settings; app.config.globalProperties.$locale = i18nFunctions(i18n.global); app.config.globalProperties.$tIf = (text, isTranslate) => translateIf(text, isTranslate, i18n.global.t); app.config.globalProperties.$tError = (message) => translateError(message, i18n.global.t); diff --git a/src/lib/common.js b/src/lib/common.js index abae61bc..311e76d2 100644 --- a/src/lib/common.js +++ b/src/lib/common.js @@ -1,4 +1,4 @@ -import settings from './settings.js'; +import { isEnableThousandsSeparator } from './settings.js'; export function isFunction(val) { return typeof(val) === 'function'; @@ -80,7 +80,7 @@ export function isEquals(obj1, obj2) { } export function appendThousandsSeparator(value) { - if (!settings.isEnableThousandsSeparator() || value.length <= 3) { + if (!isEnableThousandsSeparator() || value.length <= 3) { return value; } diff --git a/src/lib/i18n.js b/src/lib/i18n.js index f1d11304..b478706b 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -24,7 +24,7 @@ import { } from './currency.js'; import logger from './logger.js'; -import settings from './settings.js'; +import { getCurrencyDisplayMode } from './settings.js'; import services from './services.js'; const apiNotFoundErrorCode = 100001; @@ -530,7 +530,7 @@ function getDisplayCurrency(value, currencyCode, notConvertValue, translateFn) { } } - const currencyDisplayMode = settings.getCurrencyDisplayMode(); + const currencyDisplayMode = getCurrencyDisplayMode(); if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Symbol) { const currencyInfo = currency.all[currencyCode]; @@ -660,17 +660,15 @@ function setLanguage(i18nGlobal, locale, force) { }; } -function setTimezone(timezone) { +function setTimeZone(timezone) { if (timezone) { - settings.setTimezone(timezone); moment.tz.setDefault(timezone); } else { - settings.setTimezone(''); moment.tz.setDefault(); } } -function initLocale(i18nGlobal, lastUserLanguage) { +function initLocale(i18nGlobal, lastUserLanguage, timezone) { let localeDefaultSettings = null; if (lastUserLanguage && getLanguageInfo(lastUserLanguage)) { @@ -680,9 +678,9 @@ function initLocale(i18nGlobal, lastUserLanguage) { localeDefaultSettings = setLanguage(i18nGlobal, null, true); } - if (settings.getTimezone()) { - logger.info(`Current timezone is ${settings.getTimezone()}`); - setTimezone(settings.getTimezone()); + if (timezone) { + logger.info(`Current timezone is ${timezone}`); + setTimeZone(timezone); } else { logger.info(`No timezone is set, use browser default ${getTimezoneOffset()} (maybe ${moment.tz.guess(true)})`); } @@ -771,8 +769,6 @@ export function i18nFunctions(i18nGlobal) { getAllWeekDays: () => getAllWeekDays(i18nGlobal.t), getDisplayCurrency: (value, currencyCode, notConvertValue) => getDisplayCurrency(value, currencyCode, notConvertValue, i18nGlobal.t), setLanguage: (locale, force) => setLanguage(i18nGlobal, locale, force), - getTimezone: settings.getTimezone, - setTimezone: setTimezone, - initLocale: (lastUserLanguage) => initLocale(i18nGlobal, lastUserLanguage) + initLocale: (lastUserLanguage, timezone) => initLocale(i18nGlobal, lastUserLanguage, timezone) }; } diff --git a/src/lib/logger.js b/src/lib/logger.js index 0467e38c..96dc05e9 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -1,7 +1,7 @@ -import settings from './settings.js'; +import { isEnableDebug } from './settings.js'; function logDebug(msg, obj) { - if (settings.isEnableDebug()) { + if (isEnableDebug()) { if (obj) { console.debug('[ezBookkeeping Debug] ' + msg, obj); } else { diff --git a/src/lib/map/amap.js b/src/lib/map/amap.js index 7823359b..8b9083de 100644 --- a/src/lib/map/amap.js +++ b/src/lib/map/amap.js @@ -1,6 +1,10 @@ import { asyncLoadAssets } from '@/lib/misc.js'; import services from '@/lib/services.js'; -import settings from '@/lib/settings.js'; +import { + getAmapSecurityVerificationMethod, + getAmapApiExternalProxyUrl, + getAmapApplicationSecret +} from '@/lib/server_settings.js'; import logger from '@/lib/logger.js'; const amapHolder = { @@ -15,12 +19,12 @@ export function loadAmapAssets() { if (!window._AMapSecurityConfig) { const amapSecurityConfig = {}; - if (settings.getAmapSecurityVerificationMethod() === 'internalproxy') { + if (getAmapSecurityVerificationMethod() === 'internalproxy') { amapSecurityConfig.serviceHost = services.generateAmapApiInternalProxyUrl(); - } else if (settings.getAmapSecurityVerificationMethod() === 'externalproxy') { - amapSecurityConfig.serviceHost = settings.getAmapApiExternalProxyUrl(); - } else if (settings.getAmapSecurityVerificationMethod() === 'plaintext') { - amapSecurityConfig.securityJsCode = settings.getAmapApplicationSecret(); + } else if (getAmapSecurityVerificationMethod() === 'externalproxy') { + amapSecurityConfig.serviceHost = getAmapApiExternalProxyUrl(); + } else if (getAmapSecurityVerificationMethod() === 'plaintext') { + amapSecurityConfig.securityJsCode = getAmapApplicationSecret(); } window._AMapSecurityConfig = amapSecurityConfig; diff --git a/src/lib/map/index.js b/src/lib/map/index.js index 19b031f6..e1b70272 100644 --- a/src/lib/map/index.js +++ b/src/lib/map/index.js @@ -1,5 +1,7 @@ import mapConstants from '@/consts/map.js'; -import settings from '@/lib/settings.js'; +import { + getMapProvider +} from '@/lib/server_settings.js'; import { loadLeafletMapAssets, @@ -38,26 +40,26 @@ import { } from './amap.js'; export function loadMapAssets(language) { - if (mapConstants.leafletTileSources[settings.getMapProvider()]) { + if (mapConstants.leafletTileSources[getMapProvider()]) { return loadLeafletMapAssets(language); - } else if (settings.getMapProvider() === 'googlemap') { + } else if (getMapProvider() === 'googlemap') { return loadGoogleMapAssets(language); - } else if (settings.getMapProvider() === 'baidumap') { + } else if (getMapProvider() === 'baidumap') { return loadBaiduMapAssets(language); - } else if (settings.getMapProvider() === 'amap') { + } else if (getMapProvider() === 'amap') { return loadAmapAssets(language); } } export function createMapHolder() { - if (mapConstants.leafletTileSources[settings.getMapProvider()]) { - return createLeafletMapHolder(settings.getMapProvider()); - } else if (settings.getMapProvider() === 'googlemap') { - return createGoogleMapHolder(settings.getMapProvider()); - } else if (settings.getMapProvider() === 'baidumap') { - return createBaiduMapHolder(settings.getMapProvider()); - } else if (settings.getMapProvider() === 'amap') { - return createAmapHolder(settings.getMapProvider()); + if (mapConstants.leafletTileSources[getMapProvider()]) { + return createLeafletMapHolder(getMapProvider()); + } else if (getMapProvider() === 'googlemap') { + return createGoogleMapHolder(getMapProvider()); + } else if (getMapProvider() === 'baidumap') { + return createBaiduMapHolder(getMapProvider()); + } else if (getMapProvider() === 'amap') { + return createAmapHolder(getMapProvider()); } else { return null; } @@ -68,7 +70,7 @@ export function initMapInstance(mapHolder, mapContainer, options) { return; } - if (mapConstants.leafletTileSources[settings.getMapProvider()]) { + if (mapConstants.leafletTileSources[getMapProvider()]) { createLeafletMapInstance(mapHolder, mapContainer, options); } else if (mapHolder.mapProvider === 'googlemap') { createGoogleMapInstance(mapHolder, mapContainer, options); @@ -84,7 +86,7 @@ export function setMapCenterTo(mapHolder, center, zoomLevel) { return; } - if (mapConstants.leafletTileSources[settings.getMapProvider()]) { + if (mapConstants.leafletTileSources[getMapProvider()]) { setLeafletMapCenterTo(mapHolder, center, zoomLevel); } else if (mapHolder.mapProvider === 'googlemap') { setGoogleMapCenterTo(mapHolder, center, zoomLevel); @@ -100,7 +102,7 @@ export function setMapCenterMarker(mapHolder, position) { return; } - if (mapConstants.leafletTileSources[settings.getMapProvider()]) { + if (mapConstants.leafletTileSources[getMapProvider()]) { setLeafletMapCenterMaker(mapHolder, position); } else if (mapHolder.mapProvider === 'googlemap') { setGoogleMapCenterMaker(mapHolder, position); @@ -116,7 +118,7 @@ export function removeMapCenterMarker(mapHolder) { return; } - if (mapConstants.leafletTileSources[settings.getMapProvider()]) { + if (mapConstants.leafletTileSources[getMapProvider()]) { removeLeafletMapCenterMaker(mapHolder); } else if (mapHolder.mapProvider === 'googlemap') { removeGoogleMapCenterMaker(mapHolder); diff --git a/src/lib/map/leaflet.js b/src/lib/map/leaflet.js index 8c99420d..580e5735 100644 --- a/src/lib/map/leaflet.js +++ b/src/lib/map/leaflet.js @@ -1,5 +1,5 @@ import mapConstants from '@/consts/map.js'; -import settings from '@/lib/settings.js'; +import { isMapDataFetchProxyEnabled, getTomTomMapAPIKey } from '@/lib/server_settings.js'; import services from '@/lib/services.js'; const leafletHolder = { @@ -48,7 +48,7 @@ export function createLeafletMapInstance(mapHolder, mapContainer, options) { }); let mapTileSource = Object.assign({}, mapConstants.leafletTileSources[mapHolder.mapProvider]); - if (settings.isMapDataFetchProxyEnabled()) { + if (isMapDataFetchProxyEnabled()) { mapTileSource.tileUrlFormat = services.generateMapProxyTileImageUrl(mapHolder.mapProvider, options.language); mapTileSource.tileUrlSubDomains = ''; } else if (mapTileSource.tileUrlExtraParams) { @@ -58,7 +58,7 @@ export function createLeafletMapInstance(mapHolder, mapContainer, options) { const param = mapTileSource.tileUrlExtraParams[i]; if (param.paramValueType === 'tomtom_key') { - params.push('key=' + settings.getTomTomMapAPIKey()); + params.push('key=' + getTomTomMapAPIKey()); } else if (param.paramValueType === 'language' && options.language) { params.push('language=' + options.language); } diff --git a/src/lib/server_settings.js b/src/lib/server_settings.js new file mode 100644 index 00000000..28152753 --- /dev/null +++ b/src/lib/server_settings.js @@ -0,0 +1,74 @@ +import Cookies from 'js-cookie'; + +import { base64decode } from '@/lib/common.js'; + +const serverSettingsCookieKey = 'ebk_server_settings'; + +function getServerSetting(key) { + const settings = Cookies.get(serverSettingsCookieKey) || ''; + const settingsArr = settings.split('_'); + + for (let i = 0; i < settingsArr.length; i++) { + const pairs = settingsArr[i].split('.'); + + if (pairs[0] === key) { + return pairs[1]; + } + } + + return undefined; +} + +function getServerDecodedSetting(key) { + const value = getServerSetting(key); + + if (!value) { + return value; + } + + return decodeURIComponent(base64decode(value)); +} + +export function isUserRegistrationEnabled() { + return getServerSetting('r') === '1'; +} + +export function isDataExportingEnabled() { + return getServerSetting('e') === '1'; +} + +export function getMapProvider() { + return getServerSetting('m'); +} + +export function isMapDataFetchProxyEnabled() { + return getServerSetting('mp') === '1'; +} + +export function getTomTomMapAPIKey() { + return getServerDecodedSetting('tmak'); +} + +export function getGoogleMapAPIKey() { + return getServerDecodedSetting('gmak'); +} + +export function getBaiduMapAK() { + return getServerDecodedSetting('bmak'); +} + +export function getAmapApplicationKey() { + return getServerDecodedSetting('amak'); +} + +export function getAmapSecurityVerificationMethod() { + return getServerSetting('amsv'); +} + +export function getAmapApiExternalProxyUrl() { + return getServerDecodedSetting('amep'); +} + +export function getAmapApplicationSecret() { + return getServerDecodedSetting('amas'); +} diff --git a/src/lib/services.js b/src/lib/services.js index 92edee1c..ac4d4ff4 100644 --- a/src/lib/services.js +++ b/src/lib/services.js @@ -2,7 +2,11 @@ import axios from 'axios'; import api from '@/consts/api.js'; import userState from './userstate.js'; -import settings from './settings.js'; +import { + getGoogleMapAPIKey, + getBaiduMapAK, + getAmapApplicationKey +} from './server_settings.js'; import { getTimezoneOffsetMinutes } from './datetime.js'; let needBlockRequest = false; @@ -407,7 +411,7 @@ export default { return url; }, generateGoogleMapJavascriptUrl: (language, callbackFnName) => { - let url = `${api.googleMapJavascriptUrl}?key=${settings.getGoogleMapAPIKey()}&libraries=core,marker&callback=${callbackFnName}`; + let url = `${api.googleMapJavascriptUrl}?key=${getGoogleMapAPIKey()}&libraries=core,marker&callback=${callbackFnName}`; if (language) { url = url + `&language=${language}`; @@ -416,10 +420,10 @@ export default { return url; }, generateBaiduMapJavascriptUrl: (callbackFnName) => { - return `${api.baiduMapJavascriptUrl}&ak=${settings.getBaiduMapAK()}&callback=${callbackFnName}`; + return `${api.baiduMapJavascriptUrl}&ak=${getBaiduMapAK()}&callback=${callbackFnName}`; }, generateAmapJavascriptUrl: (callbackFnName) => { - return `${api.amapJavascriptUrl}&key=${settings.getAmapApplicationKey()}&plugin=AMap.ToolBar&callback=${callbackFnName}`; + return `${api.amapJavascriptUrl}&key=${getAmapApplicationKey()}&plugin=AMap.ToolBar&callback=${callbackFnName}`; }, generateAmapApiInternalProxyUrl: () => { return `${window.location.origin}${api.baseAmapApiProxyUrlPath}`; diff --git a/src/lib/settings.js b/src/lib/settings.js index f3aa89b5..5308328f 100644 --- a/src/lib/settings.js +++ b/src/lib/settings.js @@ -1,12 +1,7 @@ -import Cookies from 'js-cookie'; - import currencyConstants from '@/consts/currency.js'; import statisticsConstants from '@/consts/statistics.js'; -import { base64decode } from '@/lib/common.js'; - const settingsLocalStorageKey = 'ebk_app_settings'; -const serverSettingsCookieKey = 'ebk_server_settings'; const defaultSettings = { theme: 'auto', @@ -106,87 +101,162 @@ function setSubOption(key, subKey, value) { return setSettings(settings); } -function getServerSetting(key) { - const settings = Cookies.get(serverSettingsCookieKey) || ''; - const settingsArr = settings.split('_'); - - for (let i = 0; i < settingsArr.length; i++) { - const pairs = settingsArr[i].split('.'); - - if (pairs[0] === key) { - return pairs[1]; - } - } - - return undefined; +export function isEnableDebug() { + return getOption('debug'); } -function getServerDecodedSetting(key) { - const value = getServerSetting(key); - - if (!value) { - return value; - } - - return decodeURIComponent(base64decode(value)); +export function getTheme() { + return getOption('theme'); } -function clearSettings() { +export function setTheme(value) { + return setOption('theme', value); +} + +export function getFontSize() { + return getOption('fontSize'); +} + +export function setFontSize(value) { + return setOption('fontSize', value); +} + +export function getTimeZone() { + return getOption('timeZone'); +} + +export function setTimeZone(value) { + return setOption('timeZone', value); +} + +export function isEnableApplicationLock() { + return getOption('applicationLock'); +} + +export function setEnableApplicationLock(value) { + return setOption('applicationLock', value); +} + +export function isEnableApplicationLockWebAuthn() { + return getOption('applicationLockWebAuthn'); +} + +export function setEnableApplicationLockWebAuthn(value) { + return setOption('applicationLockWebAuthn', value); +} + +export function isAutoUpdateExchangeRatesData() { + return getOption('autoUpdateExchangeRatesData'); +} + +export function setAutoUpdateExchangeRatesData(value) { + setOption('autoUpdateExchangeRatesData', value); +} + +export function isAutoGetCurrentGeoLocation() { + return getOption('autoGetCurrentGeoLocation'); +} + +export function setAutoGetCurrentGeoLocation(value) { + setOption('autoGetCurrentGeoLocation', value); +} + +export function isEnableThousandsSeparator() { + return getOption('thousandsSeparator'); +} + +export function setEnableThousandsSeparator(value) { + setOption('thousandsSeparator', value); +} + +export function getCurrencyDisplayMode() { + return getOption('currencyDisplayMode'); +} + +export function setCurrencyDisplayMode(value) { + setOption('currencyDisplayMode', value); +} + +export function isShowAmountInHomePage() { + return getOption('showAmountInHomePage'); +} + +export function setShowAmountInHomePage(value) { + setOption('showAmountInHomePage', value); +} + +export function isShowTotalAmountInTransactionListPage() { + return getOption('showTotalAmountInTransactionListPage'); +} + +export function setShowTotalAmountInTransactionListPage(value) { + setOption('showTotalAmountInTransactionListPage', value); +} + +export function isShowAccountBalance() { + return getOption('showAccountBalance'); +} + +export function setShowAccountBalance(value) { + setOption('showAccountBalance', value); +} + +export function getStatisticsDefaultChartType() { + return getSubOption('statistics', 'defaultChartType'); +} + +export function setStatisticsDefaultChartType(value) { + setSubOption('statistics', 'defaultChartType', value); +} + +export function getStatisticsDefaultChartDataType() { + return getSubOption('statistics', 'defaultChartDataType'); +} + +export function setStatisticsDefaultChartDataType(value) { + setSubOption('statistics', 'defaultChartDataType', value); +} + +export function getStatisticsDefaultDateRange() { + return getSubOption('statistics', 'defaultDataRangeType'); +} + +export function setStatisticsDefaultDateRange(value) { + setSubOption('statistics', 'defaultDataRangeType', value); +} + +export function getStatisticsDefaultAccountFilter() { + return getSubOption('statistics', 'defaultAccountFilter'); +} + +export function setStatisticsDefaultAccountFilter(value) { + setSubOption('statistics', 'defaultAccountFilter', value); +} + +export function getStatisticsDefaultTransactionCategoryFilter() { + return getSubOption('statistics', 'defaultTransactionCategoryFilter'); +} + +export function setStatisticsDefaultTransactionCategoryFilter(value) { + setSubOption('statistics', 'defaultTransactionCategoryFilter', value); +} + +export function getStatisticsSortingType() { + return getSubOption('statistics', 'defaultSortingType'); +} + +export function setStatisticsSortingType(value) { + setSubOption('statistics', 'defaultSortingType', value); +} + +export function isEnableAnimate() { + return getOption('animate'); +} + +export function setEnableAnimate(value) { + return setOption('animate', value); +} + +export function clearSettings() { localStorage.removeItem(settingsLocalStorageKey); } - -export default { - isProduction: () => process.env.NODE_ENV === 'production', - getTheme: () => getOption('theme'), - setTheme: value => setOption('theme', value), - getFontSize: () => getOption('fontSize'), - setFontSize: value => setOption('fontSize', value), - getTimezone: () => getOption('timeZone'), - setTimezone: value => setOption('timeZone', value), - isEnableDebug: () => getOption('debug'), - setEnableDebug: value => setOption('debug', value), - isEnableApplicationLock: () => getOption('applicationLock'), - setEnableApplicationLock: value => setOption('applicationLock', value), - isEnableApplicationLockWebAuthn: () => getOption('applicationLockWebAuthn'), - setEnableApplicationLockWebAuthn: value => setOption('applicationLockWebAuthn', value), - isAutoUpdateExchangeRatesData: () => getOption('autoUpdateExchangeRatesData'), - setAutoUpdateExchangeRatesData: value => setOption('autoUpdateExchangeRatesData', value), - isAutoGetCurrentGeoLocation: () => getOption('autoGetCurrentGeoLocation'), - setAutoGetCurrentGeoLocation: value => setOption('autoGetCurrentGeoLocation', value), - isEnableThousandsSeparator: () => getOption('thousandsSeparator'), - setEnableThousandsSeparator: value => setOption('thousandsSeparator', value), - getCurrencyDisplayMode: () => getOption('currencyDisplayMode'), - setCurrencyDisplayMode: value => setOption('currencyDisplayMode', value), - isShowAmountInHomePage: () => getOption('showAmountInHomePage'), - setShowAmountInHomePage: value => setOption('showAmountInHomePage', value), - isShowTotalAmountInTransactionListPage: () => getOption('showTotalAmountInTransactionListPage'), - setShowTotalAmountInTransactionListPage: value => setOption('showTotalAmountInTransactionListPage', value), - isShowAccountBalance: () => getOption('showAccountBalance'), - setShowAccountBalance: value => setOption('showAccountBalance', value), - getStatisticsDefaultChartType: () => getSubOption('statistics', 'defaultChartType'), - setStatisticsDefaultChartType: value => setSubOption('statistics', 'defaultChartType', value), - getStatisticsDefaultChartDataType: () => getSubOption('statistics', 'defaultChartDataType'), - setStatisticsDefaultChartDataType: value => setSubOption('statistics', 'defaultChartDataType', value), - getStatisticsDefaultDateRange: () => getSubOption('statistics', 'defaultDataRangeType'), - setStatisticsDefaultDateRange: value => setSubOption('statistics', 'defaultDataRangeType', value), - getStatisticsDefaultAccountFilter: () => getSubOption('statistics', 'defaultAccountFilter'), - setStatisticsDefaultAccountFilter: value => setSubOption('statistics', 'defaultAccountFilter', value), - getStatisticsDefaultTransactionCategoryFilter: () => getSubOption('statistics', 'defaultTransactionCategoryFilter'), - setStatisticsDefaultTransactionCategoryFilter: value => setSubOption('statistics', 'defaultTransactionCategoryFilter', value), - getStatisticsSortingType: () => getSubOption('statistics', 'defaultSortingType'), - setStatisticsSortingType: value => setSubOption('statistics', 'defaultSortingType', value), - isEnableAnimate: () => getOption('animate'), - setEnableAnimate: value => setOption('animate', value), - isUserRegistrationEnabled: () => getServerSetting('r') === '1', - isDataExportingEnabled: () => getServerSetting('e') === '1', - getMapProvider: () => getServerSetting('m'), - isMapDataFetchProxyEnabled: () => getServerSetting('mp') === '1', - getTomTomMapAPIKey: () => getServerDecodedSetting('tmak'), - getGoogleMapAPIKey: () => getServerDecodedSetting('gmak'), - getBaiduMapAK: () => getServerDecodedSetting('bmak'), - getAmapApplicationKey: () => getServerDecodedSetting('amak'), - getAmapSecurityVerificationMethod: () => getServerSetting('amsv'), - getAmapApiExternalProxyUrl: () => getServerDecodedSetting('amep'), - getAmapApplicationSecret: () => getServerDecodedSetting('amas'), - clearSettings: clearSettings -}; diff --git a/src/lib/ui.mobile.js b/src/lib/ui.mobile.js index c16b81a4..6fe60900 100644 --- a/src/lib/ui.mobile.js +++ b/src/lib/ui.mobile.js @@ -1,7 +1,7 @@ import { f7, f7ready } from 'framework7-vue'; import fontConstants from '@/consts/font.js'; -import settings from './settings.js'; +import { isEnableAnimate } from './settings.js'; import { translateError } from './i18n.js'; export function showAlert(message, confirmCallback, translateFn) { @@ -9,7 +9,7 @@ export function showAlert(message, confirmCallback, translateFn) { f7.dialog.create({ title: translateFn('global.app.title'), text: translateError(message, translateFn), - animate: settings.isEnableAnimate(), + animate: isEnableAnimate(), buttons: [ { text: translateFn('OK'), @@ -25,7 +25,7 @@ export function showConfirm(message, confirmCallback, cancelCallback, translateF f7.dialog.create({ title: translateFn('global.app.title'), text: translateFn(message), - animate: settings.isEnableAnimate(), + animate: isEnableAnimate(), buttons: [ { text: translateFn('Cancel'), diff --git a/src/lib/userstate.js b/src/lib/userstate.js index f70d9e4f..a41a3242 100644 --- a/src/lib/userstate.js +++ b/src/lib/userstate.js @@ -1,7 +1,7 @@ import CryptoJS from 'crypto-js'; -import settings from './settings.js'; import { isString, isObject } from './common.js'; +import { isEnableApplicationLock } from './settings.js'; const appLockSecretBaseStringPrefix = 'EBK_LOCK_SECRET_'; @@ -29,7 +29,7 @@ function getDecryptedToken(encryptedToken, appLockState) { } function getToken() { - if (settings.isEnableApplicationLock()) { + if (isEnableApplicationLock()) { return sessionStorage.getItem(tokenSessionStorageKey); } else { return localStorage.getItem(tokenLocalStorageKey); @@ -55,7 +55,7 @@ function isUserUnlocked() { return false; } - if (!settings.isEnableApplicationLock()) { + if (!isEnableApplicationLock()) { return true; } @@ -142,7 +142,7 @@ function isCorrectPinCode(pinCode) { function updateToken(token) { if (isString(token)) { - if (settings.isEnableApplicationLock()) { + if (isEnableApplicationLock()) { sessionStorage.setItem(tokenSessionStorageKey, token); const appLockState = getUserAppLockState(); diff --git a/src/lib/version.js b/src/lib/version.js index 810231c0..38af68b0 100644 --- a/src/lib/version.js +++ b/src/lib/version.js @@ -1,15 +1,18 @@ -export default { - getVersion: () => { - let version = __EZBOOKKEEPING_VERSION__ || 'unknown'; // eslint-disable-line - let commitHash = __EZBOOKKEEPING_BUILD_COMMIT_HASH__; // eslint-disable-line +export function isProduction() { + return process.env.NODE_ENV === 'production'; +} - if (commitHash) { - return `${version} (${commitHash.substring(0, Math.min(7, commitHash.length))})` - } else { - return version; - } - }, - getBuildTime: () => { - return __EZBOOKKEEPING_BUILD_UNIX_TIME__; // eslint-disable-line +export function getVersion() { + let version = __EZBOOKKEEPING_VERSION__ || 'unknown'; // eslint-disable-line + let commitHash = __EZBOOKKEEPING_BUILD_COMMIT_HASH__; // eslint-disable-line + + if (commitHash) { + return `${version} (${commitHash.substring(0, Math.min(7, commitHash.length))})` + } else { + return version; } -}; +} + +export function getBuildTime() { + return __EZBOOKKEEPING_BUILD_UNIX_TIME__; // eslint-disable-line +} diff --git a/src/mobile-main.js b/src/mobile-main.js index 88977ade..0a701a36 100644 --- a/src/mobile-main.js +++ b/src/mobile-main.js @@ -73,8 +73,7 @@ import 'line-awesome/dist/line-awesome/css/line-awesome.css'; import VueDatePicker from '@vuepic/vue-datepicker'; import '@vuepic/vue-datepicker/dist/main.css'; -import version from '@/lib/version.js'; -import settings from '@/lib/settings.js'; +import { getVersion, getBuildTime } from '@/lib/version.js'; import userstate from '@/lib/userstate.js'; import { getI18nOptions, @@ -183,10 +182,9 @@ app.component('TransactionTagSelectionSheet', TransactionTagSelectionSheet); app.directive('TextareaAutoSize', TextareaAutoSize); -app.config.globalProperties.$version = version.getVersion(); -app.config.globalProperties.$buildTime = version.getBuildTime(); +app.config.globalProperties.$version = getVersion(); +app.config.globalProperties.$buildTime = getBuildTime(); -app.config.globalProperties.$settings = settings; app.config.globalProperties.$locale = i18nFunctions(i18n.global); app.config.globalProperties.$tIf = (text, isTranslate) => translateIf(text, isTranslate, i18n.global.t); diff --git a/src/stores/index.js b/src/stores/index.js index 55d537da..6bdb9527 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -1,5 +1,6 @@ import { defineStore } from 'pinia'; +import { useSettingsStore } from './setting.js'; import { useUserStore } from './user.js'; import { useAccountsStore } from './account.js'; import { useTransactionCategoriesStore } from './transactionCategory.js'; @@ -11,7 +12,6 @@ import { useExchangeRatesStore } from './exchangeRates.js'; import userState from '@/lib/userstate.js'; import services from '@/lib/services.js'; -import settings from '@/lib/settings.js'; import logger from '@/lib/logger.js'; import { isObject, isString } from '@/lib/common.js'; @@ -43,6 +43,8 @@ export const useRootStore = defineStore('root', { userStore.resetUserInfo(); }, authorize({ loginName, password }) { + const settingsStore = useSettingsStore(); + return new Promise((resolve, reject) => { services.authorize({ loginName: loginName, @@ -60,13 +62,13 @@ export const useRootStore = defineStore('root', { return; } - if (settings.isEnableApplicationLock() || userState.getUserAppLockState()) { + if (settingsStore.appSettings.applicationLock || userState.getUserAppLockState()) { const appLockState = userState.getUserAppLockState(); if (!appLockState || appLockState.username !== data.result.user.username) { userState.clearTokenAndUserInfo(true); - settings.setEnableApplicationLock(false); - settings.setEnableApplicationLockWebAuthn(false); + settingsStore.setEnableApplicationLock(false); + settingsStore.setEnableApplicationLockWebAuthn(false); userState.clearWebAuthnConfig(); } } @@ -93,6 +95,8 @@ export const useRootStore = defineStore('root', { }); }, authorize2FA({ token, passcode, recoveryCode }) { + const settingsStore = useSettingsStore(); + return new Promise((resolve, reject) => { let promise = null; @@ -119,13 +123,13 @@ export const useRootStore = defineStore('root', { return; } - if (settings.isEnableApplicationLock() || userState.getUserAppLockState()) { + if (settingsStore.appSettings.applicationLock || userState.getUserAppLockState()) { const appLockState = userState.getUserAppLockState(); if (!appLockState || appLockState.username !== data.result.user.username) { userState.clearTokenAndUserInfo(true); - settings.setEnableApplicationLock(false); - settings.setEnableApplicationLockWebAuthn(false); + settingsStore.setEnableApplicationLock(false); + settingsStore.setEnableApplicationLockWebAuthn(false); userState.clearWebAuthnConfig(); } } @@ -152,6 +156,8 @@ export const useRootStore = defineStore('root', { }); }, register({ user }) { + const settingsStore = useSettingsStore(); + return new Promise((resolve, reject) => { services.register({ username: user.username, @@ -169,9 +175,9 @@ export const useRootStore = defineStore('root', { return; } - if (settings.isEnableApplicationLock()) { - settings.setEnableApplicationLock(false); - settings.setEnableApplicationLockWebAuthn(false); + if (settingsStore.appSettings.applicationLock) { + settingsStore.setEnableApplicationLock(false); + settingsStore.setEnableApplicationLockWebAuthn(false); userState.clearWebAuthnConfig(); } diff --git a/src/stores/setting.js b/src/stores/setting.js index 772f323c..7f4bf5f9 100644 --- a/src/stores/setting.js +++ b/src/stores/setting.js @@ -2,27 +2,125 @@ import { defineStore } from 'pinia'; import currencyConstants from '@/consts/currency.js'; import datetimeConstants from '@/consts/datetime.js'; +import * as settings from '@/lib/settings.js'; export const useSettingsStore = defineStore('settings', { state: () => ({ - defaultSetting: { - language: '', + appSettings: { + theme: settings.getTheme(), + fontSize: settings.getFontSize(), + timeZone: settings.getTimeZone(), + applicationLock: settings.isEnableApplicationLock(), + applicationLockWebAuthn: settings.isEnableApplicationLockWebAuthn(), + autoUpdateExchangeRatesData: settings.isAutoUpdateExchangeRatesData(), + autoGetCurrentGeoLocation: settings.isAutoGetCurrentGeoLocation(), + thousandsSeparator: settings.isEnableThousandsSeparator(), + currencyDisplayMode: settings.getCurrencyDisplayMode(), + showAmountInHomePage: settings.isShowAmountInHomePage(), + showTotalAmountInTransactionListPage: settings.isShowTotalAmountInTransactionListPage(), + showAccountBalance: settings.isShowAccountBalance(), + statistics: { + defaultChartType: settings.getStatisticsDefaultChartType(), + defaultChartDataType: settings.getStatisticsDefaultChartDataType(), + defaultDataRangeType: settings.getStatisticsDefaultDateRange(), + defaultAccountFilter: settings.getStatisticsDefaultAccountFilter(), + defaultTransactionCategoryFilter: settings.getStatisticsDefaultTransactionCategoryFilter(), + defaultSortingType: settings.getStatisticsSortingType() + }, + animate: settings.isEnableAnimate() + }, + localeDefaultSettings: { currency: currencyConstants.defaultCurrency, - firstDayOfWeek: datetimeConstants.defaultFirstDayOfWeek, - longDateFormat: 0, - shortDateFormat: 0, - longTimeFormat: 0, - shortTimeFormat: 0 + firstDayOfWeek: datetimeConstants.defaultFirstDayOfWeek } }), actions: { + setTheme(value) { + settings.setTheme(value); + this.appSettings.theme = value; + }, + setFontSize(value) { + settings.setFontSize(value); + this.appSettings.fontSize = value; + }, + setTimeZone(value) { + settings.setTimeZone(value); + this.appSettings.timeZone = value; + }, + setEnableApplicationLock(value) { + settings.setEnableApplicationLock(value); + this.appSettings.applicationLock = value; + }, + setEnableApplicationLockWebAuthn(value) { + settings.setEnableApplicationLockWebAuthn(value); + this.appSettings.applicationLockWebAuthn = value; + }, + setAutoUpdateExchangeRatesData(value) { + settings.setAutoUpdateExchangeRatesData(value); + this.appSettings.autoUpdateExchangeRatesData = value; + }, + setAutoGetCurrentGeoLocation(value) { + settings.setAutoGetCurrentGeoLocation(value); + this.appSettings.autoGetCurrentGeoLocation = value; + }, + setEnableThousandsSeparator(value) { + settings.setEnableThousandsSeparator(value); + this.appSettings.thousandsSeparator = value; + }, + setCurrencyDisplayMode(value) { + settings.setCurrencyDisplayMode(value); + this.appSettings.currencyDisplayMode = value; + }, + setShowAmountInHomePage(value) { + settings.setShowAmountInHomePage(value); + this.appSettings.showAmountInHomePage = value; + }, + setShowTotalAmountInTransactionListPage(value) { + settings.setShowTotalAmountInTransactionListPage(value); + this.appSettings.showTotalAmountInTransactionListPage = value; + }, + setShowAccountBalance(value) { + settings.setShowAccountBalance(value); + this.appSettings.showAccountBalance = value; + }, + setStatisticsDefaultChartType(value) { + settings.setStatisticsDefaultChartType(value); + this.appSettings.statistics.defaultChartType = value; + }, + setStatisticsDefaultChartDataType(value) { + settings.setStatisticsDefaultChartDataType(value); + this.appSettings.statistics.defaultChartDataType = value; + }, + setStatisticsDefaultDateRange(value) { + settings.setStatisticsDefaultDateRange(value); + this.appSettings.statistics.defaultDataRangeType = value; + }, + setStatisticsDefaultAccountFilter(value) { + settings.setStatisticsDefaultAccountFilter(value); + this.appSettings.statistics.defaultAccountFilter = value; + }, + setStatisticsDefaultTransactionCategoryFilter(value) { + settings.setStatisticsDefaultTransactionCategoryFilter(value); + this.appSettings.statistics.defaultTransactionCategoryFilter = value; + }, + setStatisticsSortingType(value) { + settings.setStatisticsSortingType(value); + this.appSettings.statistics.defaultSortingType = value; + }, + setEnableAnimate(value) { + settings.setEnableAnimate(value); + this.appSettings.animate = value; + }, + clearAppSettings() { + settings.clearSettings(); + }, updateLocalizedDefaultSettings(localeDefaultSettings) { if (!localeDefaultSettings) { return; } - this.defaultSetting.currency = localeDefaultSettings.defaultCurrency; - this.defaultSetting.firstDayOfWeek = localeDefaultSettings.defaultFirstDayOfWeek; + this.localeDefaultSettings.currency = localeDefaultSettings.defaultCurrency; + this.localeDefaultSettings.firstDayOfWeek = localeDefaultSettings.defaultFirstDayOfWeek; } } }); diff --git a/src/views/desktop/LoginPage.vue b/src/views/desktop/LoginPage.vue index f201c850..cded0737 100644 --- a/src/views/desktop/LoginPage.vue +++ b/src/views/desktop/LoginPage.vue @@ -80,7 +80,7 @@ - + {{ $t('Don\'t have an account?') }}  {{ $t('Create an account') }} @@ -141,6 +141,8 @@ import { useRootStore } from '@/stores/index.js'; import { useSettingsStore } from '@/stores/setting.js'; import { useExchangeRatesStore } from '@/stores/exchangeRates.js'; +import { isUserRegistrationEnabled } from '@/lib/server_settings.js'; + import { mdiEyeOutline, mdiEyeOffOutline, @@ -181,7 +183,7 @@ export default { return this.$locale.getAllLanguageInfos(); }, isUserRegistrationEnabled() { - return this.$settings.isUserRegistrationEnabled(); + return isUserRegistrationEnabled(); }, inputIsEmpty() { return !this.username || !this.password; @@ -255,8 +257,8 @@ export default { self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings); } - if (self.$settings.isAutoUpdateExchangeRatesData()) { - self.exchangeRatesStore.getLatestExchangeRates({silent: true, force: false}); + if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) { + self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false }); } this.$router.replace('/'); @@ -297,7 +299,7 @@ export default { self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings); } - if (self.$settings.isAutoUpdateExchangeRatesData()) { + if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) { self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false }); } diff --git a/src/views/desktop/MainLayout.vue b/src/views/desktop/MainLayout.vue index 649d6539..6170b7b7 100644 --- a/src/views/desktop/MainLayout.vue +++ b/src/views/desktop/MainLayout.vue @@ -97,8 +97,8 @@ - + :icon="true" @click="(theme === 'light' ? theme = 'dark' : (theme === 'dark' ? theme = 'auto' : theme = 'light'))"> + @@ -197,10 +197,7 @@ import { export default { data() { - const self = this; - return { - theme: self.$settings.getTheme(), logouting: false, isVerticalNavScrolled: false, showVerticalOverlayMenu: false, @@ -236,14 +233,13 @@ export default { currentNickName() { return this.userStore.currentUserNickname || this.$t('User'); }, - currentTheme: { + theme: { get: function () { - return this.theme; + return this.settingsStore.appSettings.theme; }, set: function (value) { - if (value !== this.$settings.getTheme()) { - this.theme = value; - this.$settings.setTheme(value); + if (value !== this.settingsStore.appSettings.theme) { + this.settingsStore.setTheme(value); if (value === 'light' || value === 'dark') { this.globalTheme.global.name.value = value; @@ -275,9 +271,9 @@ export default { self.logouting = false; self.showLoading = false; - self.$settings.clearSettings(); + self.settingsStore.clearAppSettings(); - const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage); + const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage, self.settingsStore.appSettings.timeZone); self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings); this.$router.replace('/login'); diff --git a/src/views/desktop/user/settings/UserDataManagementSettingTab.vue b/src/views/desktop/user/settings/UserDataManagementSettingTab.vue index a9b86c08..475eabb1 100644 --- a/src/views/desktop/user/settings/UserDataManagementSettingTab.vue +++ b/src/views/desktop/user/settings/UserDataManagementSettingTab.vue @@ -76,7 +76,7 @@ - + {{ $t('Export all data to csv file.') }} {{ $t('It may take a long time, please wait for a few minutes.') }} @@ -153,6 +153,7 @@ import { useRootStore } from '@/stores/index.js'; import { useUserStore } from '@/stores/user.js'; import { appendThousandsSeparator } from '@/lib/common.js'; +import { isDataExportingEnabled } from '@/lib/server_settings.js'; import { startDownloadFile } from '@/lib/ui.js'; import { @@ -206,7 +207,7 @@ export default { }; }, isDataExportingEnabled() { - return this.$settings.isDataExportingEnabled(); + return isDataExportingEnabled(); }, exportFileName() { const nickname = this.userStore.currentUserNickname; diff --git a/src/views/mobile/ApplicationLockPage.vue b/src/views/mobile/ApplicationLockPage.vue index 43be4caf..80be6ff6 100644 --- a/src/views/mobile/ApplicationLockPage.vue +++ b/src/views/mobile/ApplicationLockPage.vue @@ -37,6 +37,7 @@