mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 16:24:25 +08:00
support exchange rate
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const exchangeRatesLocalStorageKey = 'lab_exchange_rates';
|
||||
|
||||
function getExchangeRates() {
|
||||
const storageData = localStorage.getItem(exchangeRatesLocalStorageKey) || '{}';
|
||||
return JSON.parse(storageData);
|
||||
}
|
||||
|
||||
function setExchangeRates(value) {
|
||||
const storageData = JSON.stringify(value);
|
||||
localStorage.setItem(exchangeRatesLocalStorageKey, storageData);
|
||||
}
|
||||
|
||||
function clearExchangeRates() {
|
||||
localStorage.removeItem(exchangeRatesLocalStorageKey);
|
||||
}
|
||||
|
||||
export default {
|
||||
getExchangeRates,
|
||||
setExchangeRates,
|
||||
clearExchangeRates,
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import userState from "./userstate.js";
|
||||
import exchangeRates from "./exchangeRates.js";
|
||||
|
||||
let needBlockRequest = false;
|
||||
let blockedRequests = [];
|
||||
@@ -209,4 +210,20 @@ export default {
|
||||
id
|
||||
});
|
||||
},
|
||||
getLatestExchangeRates: () => {
|
||||
return axios.get('v1/exchange_rates/latest.json');
|
||||
},
|
||||
refreshLatestExchangeRates: () => {
|
||||
return axios.get('v1/exchange_rates/latest.json', {
|
||||
ignoreError: true
|
||||
}).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
if (data && data.success && data.result && data.result.exchangeRates) {
|
||||
exchangeRates.setExchangeRates(data.result);
|
||||
}
|
||||
|
||||
return data.result;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ const serverSettingsCookieKey = 'ACP_SETTINGS';
|
||||
|
||||
const defaultSettings = {
|
||||
lang: 'en',
|
||||
autoUpdateExchangeRatesData: true,
|
||||
thousandsSeparator: true,
|
||||
currencyDisplayMode: 'code', // or 'none' or 'name'
|
||||
showAccountBalance: true,
|
||||
@@ -72,6 +73,8 @@ function clearSettings() {
|
||||
export default {
|
||||
getLanguage: () => getOriginalOption('lang'),
|
||||
setLanguage: value => setOption('lang', value),
|
||||
isAutoUpdateExchangeRatesData: () => getOption('autoUpdateExchangeRatesData'),
|
||||
setAutoUpdateExchangeRatesData: value => setOption('autoUpdateExchangeRatesData', value),
|
||||
isEnableThousandsSeparator: () => getOption('thousandsSeparator'),
|
||||
setEnableThousandsSeparator: value => setOption('thousandsSeparator', value),
|
||||
getCurrencyDisplayMode: () => getOption('currencyDisplayMode'),
|
||||
|
||||
Reference in New Issue
Block a user