mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 00:34:28 +08:00
code refactor
This commit is contained in:
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
-12
@@ -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)
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
+10
-6
@@ -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;
|
||||
|
||||
+19
-17
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
+8
-4
@@ -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}`;
|
||||
|
||||
+153
-83
@@ -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
|
||||
};
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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();
|
||||
|
||||
+16
-13
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user