migrate setting.js and logger.js to ts
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import { isProduction } from '@/lib/version.ts';
|
||||
import { getTheme, isEnableAnimate } from '@/lib/settings.js';
|
||||
import { getTheme, isEnableAnimate } from '@/lib/settings.ts';
|
||||
import { loadMapAssets } from '@/lib/map/index.js';
|
||||
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
||||
import { isModalShowing, setAppFontSize } from '@/lib/ui/mobile.js';
|
||||
|
||||
@@ -36,7 +36,7 @@ import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
|
||||
import { removeAll } from '@/lib/common.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ import {
|
||||
getAllFilteredAccountsBalance
|
||||
} from './account.js';
|
||||
|
||||
import logger from './logger.js';
|
||||
import logger from './logger.ts';
|
||||
import services from './services.js';
|
||||
|
||||
function getLanguageDisplayName(translateFn, languageName) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isEnableDebug } from './settings.js';
|
||||
import { isEnableDebug } from './settings.ts';
|
||||
|
||||
function logDebug(msg, obj) {
|
||||
function logDebug(msg: string, obj?: unknown): void {
|
||||
if (isEnableDebug()) {
|
||||
if (obj) {
|
||||
console.debug('[ezBookkeeping Debug] ' + msg, obj);
|
||||
@@ -10,7 +10,7 @@ function logDebug(msg, obj) {
|
||||
}
|
||||
}
|
||||
|
||||
function logInfo(msg, obj) {
|
||||
function logInfo(msg: string, obj?: unknown): void {
|
||||
if (obj) {
|
||||
console.info('[ezBookkeeping Info] ' + msg, obj);
|
||||
} else {
|
||||
@@ -18,7 +18,7 @@ function logInfo(msg, obj) {
|
||||
}
|
||||
}
|
||||
|
||||
function logWarn(msg, obj) {
|
||||
function logWarn(msg: string, obj?: unknown): void {
|
||||
if (obj) {
|
||||
console.warn('[ezBookkeeping Warn] ' + msg, obj);
|
||||
} else {
|
||||
@@ -26,7 +26,7 @@ function logWarn(msg, obj) {
|
||||
}
|
||||
}
|
||||
|
||||
function logError(msg, obj) {
|
||||
function logError(msg: string, obj?: unknown): void {
|
||||
if (obj) {
|
||||
console.error('[ezBookkeeping Error] ' + msg, obj);
|
||||
} else {
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
getAmapApiExternalProxyUrl,
|
||||
getAmapApplicationSecret
|
||||
} from '@/lib/server_settings.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
const amapHolder = {
|
||||
AMap: null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { asyncLoadAssets } from '@/lib/misc.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
const baiduMapHolder = {
|
||||
BMap: null,
|
||||
|
||||
@@ -1,324 +0,0 @@
|
||||
import { TimezoneTypeForStatistics } from '@/core/timezone.ts';
|
||||
import { CurrencySortingType } from '@/core/currency.ts';
|
||||
import {
|
||||
CategoricalChartType,
|
||||
TrendChartType,
|
||||
ChartDataType,
|
||||
ChartSortingType,
|
||||
DEFAULT_CATEGORICAL_CHART_DATA_RANGE,
|
||||
DEFAULT_TREND_CHART_DATA_RANGE
|
||||
} from '@/core/statistics.ts';
|
||||
|
||||
const settingsLocalStorageKey = 'ebk_app_settings';
|
||||
|
||||
const defaultSettings = {
|
||||
theme: 'auto',
|
||||
fontSize: 1,
|
||||
timeZone: '',
|
||||
debug: false,
|
||||
applicationLock: false,
|
||||
applicationLockWebAuthn: false,
|
||||
autoUpdateExchangeRatesData: true,
|
||||
autoSaveTransactionDraft: 'disabled',
|
||||
autoGetCurrentGeoLocation: false,
|
||||
showAmountInHomePage: true,
|
||||
timezoneUsedForStatisticsInHomePage: TimezoneTypeForStatistics.Default.type,
|
||||
itemsCountInTransactionListPage: 15,
|
||||
showTotalAmountInTransactionListPage: true,
|
||||
showTagInTransactionListPage: true,
|
||||
showAccountBalance: true,
|
||||
currencySortByInExchangeRatesPage: CurrencySortingType.Default.type,
|
||||
statistics: {
|
||||
defaultChartDataType: ChartDataType.Default.type,
|
||||
defaultTimezoneType: TimezoneTypeForStatistics.Default.type,
|
||||
defaultAccountFilter: {},
|
||||
defaultTransactionCategoryFilter: {},
|
||||
defaultSortingType: ChartSortingType.Default.type,
|
||||
defaultCategoricalChartType: CategoricalChartType.Default.type,
|
||||
defaultCategoricalChartDataRangeType: DEFAULT_CATEGORICAL_CHART_DATA_RANGE.type,
|
||||
defaultTrendChartType: TrendChartType.Default.type,
|
||||
defaultTrendChartDataRangeType: DEFAULT_TREND_CHART_DATA_RANGE,
|
||||
},
|
||||
animate: true
|
||||
};
|
||||
|
||||
function getOriginalSettings() {
|
||||
try {
|
||||
const storageData = localStorage.getItem(settingsLocalStorageKey) || '{}';
|
||||
return JSON.parse(storageData);
|
||||
} catch (ex) {
|
||||
console.warn('settings in local storage is invalid', ex);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function getFinalSettings() {
|
||||
const originalSettings = getOriginalSettings();
|
||||
|
||||
for (let key in originalSettings) {
|
||||
if (!Object.prototype.hasOwnProperty.call(originalSettings, key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof(defaultSettings[key]) === 'object') {
|
||||
originalSettings[key] = Object.assign({}, defaultSettings[key], originalSettings[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return Object.assign({}, defaultSettings, originalSettings);
|
||||
}
|
||||
|
||||
function setSettings(settings) {
|
||||
const storageData = JSON.stringify(settings);
|
||||
return localStorage.setItem(settingsLocalStorageKey, storageData);
|
||||
}
|
||||
|
||||
function getOption(key) {
|
||||
return getFinalSettings()[key];
|
||||
}
|
||||
|
||||
function getSubOption(key, subKey) {
|
||||
const options = getFinalSettings()[key] || {};
|
||||
return options[subKey];
|
||||
}
|
||||
|
||||
function setOption(key, value) {
|
||||
if (!Object.prototype.hasOwnProperty.call(defaultSettings, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = getFinalSettings();
|
||||
settings[key] = value;
|
||||
|
||||
return setSettings(settings);
|
||||
}
|
||||
|
||||
function setSubOption(key, subKey, value) {
|
||||
if (!Object.prototype.hasOwnProperty.call(defaultSettings, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(defaultSettings[key], subKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = getFinalSettings();
|
||||
let options = settings[key];
|
||||
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
options[subKey] = value;
|
||||
settings[key] = options;
|
||||
|
||||
return setSettings(settings);
|
||||
}
|
||||
|
||||
export function isEnableDebug() {
|
||||
return getOption('debug');
|
||||
}
|
||||
|
||||
export function getTheme() {
|
||||
return getOption('theme');
|
||||
}
|
||||
|
||||
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 getAutoSaveTransactionDraft() {
|
||||
return getOption('autoSaveTransactionDraft');
|
||||
}
|
||||
|
||||
export function setAutoSaveTransactionDraft(value) {
|
||||
setOption('autoSaveTransactionDraft', value);
|
||||
}
|
||||
|
||||
export function isAutoGetCurrentGeoLocation() {
|
||||
return getOption('autoGetCurrentGeoLocation');
|
||||
}
|
||||
|
||||
export function setAutoGetCurrentGeoLocation(value) {
|
||||
setOption('autoGetCurrentGeoLocation', value);
|
||||
}
|
||||
|
||||
export function isShowAmountInHomePage() {
|
||||
return getOption('showAmountInHomePage');
|
||||
}
|
||||
|
||||
export function setShowAmountInHomePage(value) {
|
||||
setOption('showAmountInHomePage', value);
|
||||
}
|
||||
|
||||
export function getTimezoneUsedForStatisticsInHomePage() {
|
||||
return getOption('timezoneUsedForStatisticsInHomePage');
|
||||
}
|
||||
|
||||
export function setTimezoneUsedForStatisticsInHomePage(value) {
|
||||
setOption('timezoneUsedForStatisticsInHomePage', value);
|
||||
}
|
||||
|
||||
export function getItemsCountInTransactionListPage() {
|
||||
return getOption('itemsCountInTransactionListPage');
|
||||
}
|
||||
|
||||
export function setItemsCountInTransactionListPage(value) {
|
||||
setOption('itemsCountInTransactionListPage', value);
|
||||
}
|
||||
|
||||
export function isShowTotalAmountInTransactionListPage() {
|
||||
return getOption('showTotalAmountInTransactionListPage');
|
||||
}
|
||||
|
||||
export function setShowTotalAmountInTransactionListPage(value) {
|
||||
setOption('showTotalAmountInTransactionListPage', value);
|
||||
}
|
||||
|
||||
export function isShowTagInTransactionListPage() {
|
||||
return getOption('showTagInTransactionListPage');
|
||||
}
|
||||
|
||||
export function setShowTagInTransactionListPage(value) {
|
||||
setOption('showTagInTransactionListPage', value);
|
||||
}
|
||||
|
||||
export function isShowAccountBalance() {
|
||||
return getOption('showAccountBalance');
|
||||
}
|
||||
|
||||
export function setShowAccountBalance(value) {
|
||||
setOption('showAccountBalance', value);
|
||||
}
|
||||
|
||||
export function getCurrencySortByInExchangeRatesPage() {
|
||||
return getOption('currencySortByInExchangeRatesPage');
|
||||
}
|
||||
|
||||
export function setCurrencySortByInExchangeRatesPage(value) {
|
||||
setOption('currencySortByInExchangeRatesPage', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultChartDataType() {
|
||||
return getSubOption('statistics', 'defaultChartDataType');
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultChartDataType(value) {
|
||||
setSubOption('statistics', 'defaultChartDataType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTimezoneType() {
|
||||
return getSubOption('statistics', 'defaultTimezoneType');
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTimezoneType(value) {
|
||||
setSubOption('statistics', 'defaultTimezoneType', 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 getStatisticsDefaultCategoricalChartType() {
|
||||
return getSubOption('statistics', 'defaultCategoricalChartType');
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultCategoricalChartType(value) {
|
||||
setSubOption('statistics', 'defaultCategoricalChartType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultCategoricalChartDataRange() {
|
||||
return getSubOption('statistics', 'defaultCategoricalChartDataRangeType');
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultCategoricalChartDataRange(value) {
|
||||
setSubOption('statistics', 'defaultCategoricalChartDataRangeType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTrendChartType() {
|
||||
return getSubOption('statistics', 'defaultTrendChartType');
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTrendChartType(value) {
|
||||
setSubOption('statistics', 'defaultTrendChartType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTrendChartDataRange() {
|
||||
return getSubOption('statistics', 'defaultTrendChartDataRangeType');
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTrendChartDataRange(value) {
|
||||
setSubOption('statistics', 'defaultTrendChartDataRangeType', value);
|
||||
}
|
||||
|
||||
export function isEnableAnimate() {
|
||||
return getOption('animate');
|
||||
}
|
||||
|
||||
export function setEnableAnimate(value) {
|
||||
return setOption('animate', value);
|
||||
}
|
||||
|
||||
export function clearSettings() {
|
||||
localStorage.removeItem(settingsLocalStorageKey);
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
import { TimezoneTypeForStatistics } from '@/core/timezone.ts';
|
||||
import { CurrencySortingType } from '@/core/currency.ts';
|
||||
import {
|
||||
CategoricalChartType,
|
||||
TrendChartType,
|
||||
ChartDataType,
|
||||
ChartSortingType,
|
||||
DEFAULT_CATEGORICAL_CHART_DATA_RANGE,
|
||||
DEFAULT_TREND_CHART_DATA_RANGE
|
||||
} from '@/core/statistics.ts';
|
||||
import { isObject } from './common.ts';
|
||||
|
||||
const settingsLocalStorageKey: string = 'ebk_app_settings';
|
||||
|
||||
export type ApplicationSettingKey = string;
|
||||
export type ApplicationSettingValue = string | number | boolean | Record<string, ApplicationSettingSubValue>;
|
||||
export type ApplicationSettingSubValue = string | number | boolean | Record<string, boolean> | Record<string, number>;
|
||||
|
||||
export interface ApplicationSettings {
|
||||
[key: ApplicationSettingKey]: ApplicationSettingValue;
|
||||
}
|
||||
|
||||
const defaultSettings: ApplicationSettings = {
|
||||
theme: 'auto',
|
||||
fontSize: 1,
|
||||
timeZone: '',
|
||||
debug: false,
|
||||
applicationLock: false,
|
||||
applicationLockWebAuthn: false,
|
||||
autoUpdateExchangeRatesData: true,
|
||||
autoSaveTransactionDraft: 'disabled',
|
||||
autoGetCurrentGeoLocation: false,
|
||||
showAmountInHomePage: true,
|
||||
timezoneUsedForStatisticsInHomePage: TimezoneTypeForStatistics.Default.type,
|
||||
itemsCountInTransactionListPage: 15,
|
||||
showTotalAmountInTransactionListPage: true,
|
||||
showTagInTransactionListPage: true,
|
||||
showAccountBalance: true,
|
||||
currencySortByInExchangeRatesPage: CurrencySortingType.Default.type,
|
||||
statistics: {
|
||||
defaultChartDataType: ChartDataType.Default.type,
|
||||
defaultTimezoneType: TimezoneTypeForStatistics.Default.type,
|
||||
defaultAccountFilter: {},
|
||||
defaultTransactionCategoryFilter: {},
|
||||
defaultSortingType: ChartSortingType.Default.type,
|
||||
defaultCategoricalChartType: CategoricalChartType.Default.type,
|
||||
defaultCategoricalChartDataRangeType: DEFAULT_CATEGORICAL_CHART_DATA_RANGE.type,
|
||||
defaultTrendChartType: TrendChartType.Default.type,
|
||||
defaultTrendChartDataRangeType: DEFAULT_TREND_CHART_DATA_RANGE.type,
|
||||
},
|
||||
animate: true
|
||||
};
|
||||
|
||||
function getOriginalSettings(): ApplicationSettings {
|
||||
try {
|
||||
const storageData = localStorage.getItem(settingsLocalStorageKey) || '{}';
|
||||
return JSON.parse(storageData);
|
||||
} catch (ex) {
|
||||
console.warn('settings in local storage is invalid', ex);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function getFinalSettings(): ApplicationSettings {
|
||||
const originalSettings = getOriginalSettings();
|
||||
|
||||
for (const key in originalSettings) {
|
||||
if (!Object.prototype.hasOwnProperty.call(originalSettings, key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof(defaultSettings[key]) === 'object') {
|
||||
originalSettings[key] = Object.assign({}, defaultSettings[key], originalSettings[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return Object.assign({}, defaultSettings, originalSettings);
|
||||
}
|
||||
|
||||
function setSettings(settings: ApplicationSettings): void {
|
||||
const storageData = JSON.stringify(settings);
|
||||
return localStorage.setItem(settingsLocalStorageKey, storageData);
|
||||
}
|
||||
|
||||
function getOption(key: ApplicationSettingKey): ApplicationSettingValue | undefined {
|
||||
return getFinalSettings()[key];
|
||||
}
|
||||
|
||||
function getSubOption(key: ApplicationSettingKey, subKey: ApplicationSettingKey): ApplicationSettingSubValue | undefined {
|
||||
const options = getFinalSettings()[key];
|
||||
|
||||
if (!isObject(options)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return (options as Record<string, ApplicationSettingSubValue>)[subKey];
|
||||
}
|
||||
|
||||
function setOption(key: ApplicationSettingKey, value: ApplicationSettingValue): void {
|
||||
if (!Object.prototype.hasOwnProperty.call(defaultSettings, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = getFinalSettings();
|
||||
settings[key] = value;
|
||||
|
||||
return setSettings(settings);
|
||||
}
|
||||
|
||||
function setSubOption(key: ApplicationSettingKey, subKey: ApplicationSettingKey, value: ApplicationSettingSubValue): void {
|
||||
if (!Object.prototype.hasOwnProperty.call(defaultSettings, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(defaultSettings[key], subKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = getFinalSettings();
|
||||
let options = settings[key];
|
||||
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
(options as Record<string, ApplicationSettingSubValue>)[subKey] = value;
|
||||
settings[key] = options;
|
||||
|
||||
return setSettings(settings);
|
||||
}
|
||||
|
||||
export function isEnableDebug(): boolean {
|
||||
return getOption('debug') as boolean;
|
||||
}
|
||||
|
||||
export function getTheme(): string {
|
||||
return getOption('theme') as string;
|
||||
}
|
||||
|
||||
export function setTheme(value: string): void {
|
||||
return setOption('theme', value);
|
||||
}
|
||||
|
||||
export function getFontSize(): number {
|
||||
return getOption('fontSize') as number;
|
||||
}
|
||||
|
||||
export function setFontSize(value: number): void {
|
||||
return setOption('fontSize', value);
|
||||
}
|
||||
|
||||
export function getTimeZone(): string {
|
||||
return getOption('timeZone') as string;
|
||||
}
|
||||
|
||||
export function setTimeZone(value: string): void {
|
||||
return setOption('timeZone', value);
|
||||
}
|
||||
|
||||
export function isEnableApplicationLock(): boolean {
|
||||
return getOption('applicationLock') as boolean;
|
||||
}
|
||||
|
||||
export function setEnableApplicationLock(value: boolean): void {
|
||||
return setOption('applicationLock', value);
|
||||
}
|
||||
|
||||
export function isEnableApplicationLockWebAuthn(): boolean {
|
||||
return getOption('applicationLockWebAuthn') as boolean;
|
||||
}
|
||||
|
||||
export function setEnableApplicationLockWebAuthn(value: boolean): void {
|
||||
return setOption('applicationLockWebAuthn', value);
|
||||
}
|
||||
|
||||
export function isAutoUpdateExchangeRatesData(): boolean {
|
||||
return getOption('autoUpdateExchangeRatesData') as boolean;
|
||||
}
|
||||
|
||||
export function setAutoUpdateExchangeRatesData(value: boolean): void {
|
||||
setOption('autoUpdateExchangeRatesData', value);
|
||||
}
|
||||
|
||||
export function getAutoSaveTransactionDraft(): boolean {
|
||||
return getOption('autoSaveTransactionDraft') as boolean;
|
||||
}
|
||||
|
||||
export function setAutoSaveTransactionDraft(value: boolean): void {
|
||||
setOption('autoSaveTransactionDraft', value);
|
||||
}
|
||||
|
||||
export function isAutoGetCurrentGeoLocation(): boolean {
|
||||
return getOption('autoGetCurrentGeoLocation') as boolean;
|
||||
}
|
||||
|
||||
export function setAutoGetCurrentGeoLocation(value: boolean): void {
|
||||
setOption('autoGetCurrentGeoLocation', value);
|
||||
}
|
||||
|
||||
export function isShowAmountInHomePage(): boolean {
|
||||
return getOption('showAmountInHomePage') as boolean;
|
||||
}
|
||||
|
||||
export function setShowAmountInHomePage(value: boolean): void {
|
||||
setOption('showAmountInHomePage', value);
|
||||
}
|
||||
|
||||
export function getTimezoneUsedForStatisticsInHomePage(): number {
|
||||
return getOption('timezoneUsedForStatisticsInHomePage') as number;
|
||||
}
|
||||
|
||||
export function setTimezoneUsedForStatisticsInHomePage(value: number): void {
|
||||
setOption('timezoneUsedForStatisticsInHomePage', value);
|
||||
}
|
||||
|
||||
export function getItemsCountInTransactionListPage(): number {
|
||||
return getOption('itemsCountInTransactionListPage') as number;
|
||||
}
|
||||
|
||||
export function setItemsCountInTransactionListPage(value: number): void {
|
||||
setOption('itemsCountInTransactionListPage', value);
|
||||
}
|
||||
|
||||
export function isShowTotalAmountInTransactionListPage(): boolean {
|
||||
return getOption('showTotalAmountInTransactionListPage') as boolean;
|
||||
}
|
||||
|
||||
export function setShowTotalAmountInTransactionListPage(value: boolean): void {
|
||||
setOption('showTotalAmountInTransactionListPage', value);
|
||||
}
|
||||
|
||||
export function isShowTagInTransactionListPage(): boolean {
|
||||
return getOption('showTagInTransactionListPage') as boolean;
|
||||
}
|
||||
|
||||
export function setShowTagInTransactionListPage(value: boolean): void {
|
||||
setOption('showTagInTransactionListPage', value);
|
||||
}
|
||||
|
||||
export function isShowAccountBalance(): boolean {
|
||||
return getOption('showAccountBalance') as boolean;
|
||||
}
|
||||
|
||||
export function setShowAccountBalance(value: boolean): void {
|
||||
setOption('showAccountBalance', value);
|
||||
}
|
||||
|
||||
export function getCurrencySortByInExchangeRatesPage(): number {
|
||||
return getOption('currencySortByInExchangeRatesPage') as number;
|
||||
}
|
||||
|
||||
export function setCurrencySortByInExchangeRatesPage(value: number): void {
|
||||
setOption('currencySortByInExchangeRatesPage', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultChartDataType(): number {
|
||||
return getSubOption('statistics', 'defaultChartDataType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultChartDataType(value: number): void {
|
||||
setSubOption('statistics', 'defaultChartDataType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTimezoneType(): number {
|
||||
return getSubOption('statistics', 'defaultTimezoneType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTimezoneType(value: number): void {
|
||||
setSubOption('statistics', 'defaultTimezoneType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultAccountFilter(): Record<string, boolean> {
|
||||
return getSubOption('statistics', 'defaultAccountFilter') as Record<string, boolean>;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultAccountFilter(value: Record<string, boolean>): void {
|
||||
setSubOption('statistics', 'defaultAccountFilter', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTransactionCategoryFilter(): Record<string, boolean> {
|
||||
return getSubOption('statistics', 'defaultTransactionCategoryFilter') as Record<string, boolean>;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTransactionCategoryFilter(value: Record<string, boolean>): void {
|
||||
setSubOption('statistics', 'defaultTransactionCategoryFilter', value);
|
||||
}
|
||||
|
||||
export function getStatisticsSortingType(): number {
|
||||
return getSubOption('statistics', 'defaultSortingType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsSortingType(value: number): void {
|
||||
setSubOption('statistics', 'defaultSortingType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultCategoricalChartType(): number {
|
||||
return getSubOption('statistics', 'defaultCategoricalChartType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultCategoricalChartType(value: number): void {
|
||||
setSubOption('statistics', 'defaultCategoricalChartType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultCategoricalChartDataRange(): number {
|
||||
return getSubOption('statistics', 'defaultCategoricalChartDataRangeType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultCategoricalChartDataRange(value: number): void {
|
||||
setSubOption('statistics', 'defaultCategoricalChartDataRangeType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTrendChartType(): number {
|
||||
return getSubOption('statistics', 'defaultTrendChartType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTrendChartType(value: number): void {
|
||||
setSubOption('statistics', 'defaultTrendChartType', value);
|
||||
}
|
||||
|
||||
export function getStatisticsDefaultTrendChartDataRange(): number {
|
||||
return getSubOption('statistics', 'defaultTrendChartDataRangeType') as number;
|
||||
}
|
||||
|
||||
export function setStatisticsDefaultTrendChartDataRange(value: number): void {
|
||||
setSubOption('statistics', 'defaultTrendChartDataRangeType', value);
|
||||
}
|
||||
|
||||
export function isEnableAnimate(): boolean {
|
||||
return getOption('animate') as boolean;
|
||||
}
|
||||
|
||||
export function setEnableAnimate(value: boolean) {
|
||||
return setOption('animate', value);
|
||||
}
|
||||
|
||||
export function clearSettings(): void {
|
||||
localStorage.removeItem(settingsLocalStorageKey);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { f7, f7ready } from 'framework7-vue';
|
||||
|
||||
import { FontSize, FONT_SIZE_PREVIEW_CLASSNAME_PREFIX } from '@/core/font.ts';
|
||||
import { isEnableAnimate } from '../settings.js';
|
||||
import { isEnableAnimate } from '../settings.ts';
|
||||
import { translateError } from '../i18n.js';
|
||||
|
||||
export function showAlert(message, confirmCallback, translateFn) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
import { isString, isObject } from './common.ts';
|
||||
import { isEnableApplicationLock } from './settings.js';
|
||||
import logger from './logger.js';
|
||||
import { isEnableApplicationLock } from './settings.ts';
|
||||
import logger from './logger.ts';
|
||||
|
||||
const appLockSecretBaseStringPrefix = 'EBK_LOCK_SECRET_';
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import CBOR from 'cbor-js';
|
||||
import logger from './logger.js';
|
||||
import logger from './logger.ts';
|
||||
import {
|
||||
isFunction,
|
||||
stringToArrayBuffer,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { PARENT_ACCOUNT_CURRENCY_PLACEHOLDER } from '@/consts/currency.ts';
|
||||
import { DEFAULT_ACCOUNT_ICON_ID } from '@/consts/icon.ts';
|
||||
import { DEFAULT_ACCOUNT_COLOR } from '@/consts/color.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import { isNumber, isEquals } from '@/lib/common.ts';
|
||||
import { getCurrentUnixTime } from '@/lib/datetime.ts';
|
||||
import { getCategorizedAccountsMap, getAllFilteredAccountsBalance } from '@/lib/account.js';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import { isEquals } from '@/lib/common.ts';
|
||||
import { getCurrentUnixTime, formatUnixTime } from '@/lib/datetime.ts';
|
||||
import { getExchangedAmount } from '@/lib/numeral.ts';
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import { useExchangeRatesStore } from './exchangeRates.js';
|
||||
|
||||
import userState from '@/lib/userstate.js';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import { isObject, isString } from '@/lib/common.ts';
|
||||
|
||||
export const useRootStore = defineStore('root', {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
getThisYearLastUnixTime
|
||||
} from '@/lib/datetime.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
function updateTransactionDateRange(state) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
||||
|
||||
import { WeekDay } from '@/core/datetime.ts';
|
||||
import { DEFAULT_CURRENCY_CODE } from '@/consts/currency.ts';
|
||||
import * as settings from '@/lib/settings.js';
|
||||
import * as settings from '@/lib/settings.ts';
|
||||
|
||||
export const useSettingsStore = defineStore('settings', {
|
||||
state: () => ({
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
import { DEFAULT_ACCOUNT_ICON, DEFAULT_CATEGORY_ICON } from '@/consts/icon.ts';
|
||||
import { DEFAULT_ACCOUNT_COLOR, DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
isEquals,
|
||||
isNumber,
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { useUserStore } from './user.js';
|
||||
|
||||
import userState from '@/lib/userstate.js';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import { isObject } from '@/lib/common.ts';
|
||||
|
||||
export const useTokensStore = defineStore('tokens', {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { TransactionType, TransactionTagFilterType } from '@/core/transaction.ts
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
|
||||
import userState from '@/lib/userstate.js';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
isDefined,
|
||||
isNumber,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { DEFAULT_CATEGORY_ICON_ID } from '@/consts/icon.ts';
|
||||
import { DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
||||
import { isEquals } from '@/lib/common.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
function loadTransactionCategoryList(state, allCategories) {
|
||||
state.allTransactionCategories = allCategories;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
||||
|
||||
import { isEquals } from '@/lib/common.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
function loadTransactionTagList(state, tags) {
|
||||
state.allTransactionTags = tags;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { TransactionType } from '@/core/transaction.ts';
|
||||
import { TemplateType } from '@/core/template.ts';
|
||||
import { isDefined, isObject, isArray, isEquals } from '@/lib/common.ts';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
function loadTransactionTemplateList(state, templateType, templates) {
|
||||
state.allTransactionTemplates[templateType] = templates;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
||||
|
||||
import userState from '@/lib/userstate.js';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import { isBoolean } from '@/lib/common.ts';
|
||||
|
||||
export const useTwoFactorAuthStore = defineStore('twoFactorAuth', {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { useSettingsStore } from './setting.js';
|
||||
|
||||
import userState from '@/lib/userstate.js';
|
||||
import services from '@/lib/services.js';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
isObject,
|
||||
isNumber
|
||||
|
||||
@@ -141,7 +141,7 @@ import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import { getConvertedAmount } from '@/lib/numeral.ts';
|
||||
|
||||
import {
|
||||
|
||||
@@ -119,7 +119,7 @@ import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
|
||||
export default {
|
||||
|
||||
@@ -601,7 +601,7 @@ import { AccountType } from '@/core/account.ts';
|
||||
import { TransactionType, TransactionTagFilterType } from '@/core/transaction.ts';
|
||||
import { TemplateType } from '@/core/template.ts';
|
||||
import { isString, isNumber, getNameByKeyValue } from '@/lib/common.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
getCurrentUnixTime,
|
||||
parseDateFromUnixTime,
|
||||
|
||||
@@ -406,7 +406,7 @@ import { TemplateType, ScheduledTemplateFrequencyType } from '@/core/template.ts
|
||||
import { TRANSACTION_MAX_PICTURE_COUNT } from '@/consts/transaction.ts';
|
||||
import { KnownErrorCode } from '@/consts/api.ts';
|
||||
import { SUPPORTED_IMAGE_EXTENSIONS } from '@/consts/file.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
isArray,
|
||||
getNameByKeyValue
|
||||
|
||||
@@ -616,7 +616,7 @@ import {
|
||||
} from '@/lib/common.ts';
|
||||
import { isFileExtensionSupported } from '@/lib/file.ts';
|
||||
import { generateRandomUUID } from '@/lib/misc.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
parseDateFromUnixTime,
|
||||
getUnixTime,
|
||||
|
||||
@@ -41,7 +41,7 @@ import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
|
||||
export default {
|
||||
|
||||
@@ -74,7 +74,7 @@ import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
||||
import { isModalShowing } from '@/lib/ui/mobile.js';
|
||||
|
||||
@@ -60,7 +60,7 @@ import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
import { AmountFilterType } from '@/core/numeral.ts';
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
|
||||
import { isString } from '@/lib/common.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -445,7 +445,7 @@ import { TemplateType, ScheduledTemplateFrequencyType } from '@/core/template.ts
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT, TRANSACTION_MAX_PICTURE_COUNT } from '@/consts/transaction.ts';
|
||||
import { KnownErrorCode } from '@/consts/api.ts';
|
||||
import { SUPPORTED_IMAGE_EXTENSIONS } from '@/consts/file.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import {
|
||||
isArray,
|
||||
getNameByKeyValue
|
||||
|
||||
Reference in New Issue
Block a user