code refactor

This commit is contained in:
MaysWind
2021-01-05 23:37:00 +08:00
parent 22d7b48355
commit 0deb522089
4 changed files with 10 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
const baseUrlPath = '/api';
export default {
baseUrlPath: baseUrlPath
}
+2 -7
View File
@@ -1,13 +1,12 @@
import axios from 'axios';
import api from "../consts/api.js";
import userState from "./userstate.js";
const baseUrlPath = '/api';
let needBlockRequest = false;
let blockedRequests = [];
axios.defaults.baseURL = baseUrlPath;
axios.defaults.baseURL = api.baseUrlPath;
axios.interceptors.request.use(config => {
const token = userState.getToken();
@@ -113,10 +112,6 @@ export default {
});
});
},
getDataExportUrl: () => {
const token = userState.getToken();
return `${baseUrlPath}/data/export.csv?token=${token}`;
},
getTokens: () => {
return axios.get('v1/tokens/list.json');
},
+2
View File
@@ -16,6 +16,7 @@ import 'framework7-icons';
import 'line-awesome/dist/line-awesome/css/line-awesome.css';
import { getAllLanguages, getLanguage, getDefaultLanguage, getI18nOptions, getLocalizedError, getLocalizedErrorParameters } from './lib/i18n.js';
import api from './consts/api.js';
import currency from './consts/currency.js';
import colors from './consts/color.js';
import icons from './consts/icon.js';
@@ -82,6 +83,7 @@ Vue.prototype.$buildTime = version.getBuildTime();
Vue.prototype.$licenses = licenses;
Vue.prototype.$constants = {
api: api,
currency: currency,
colors: colors,
icons: icons,
+1 -1
View File
@@ -5,7 +5,7 @@
<f7-card>
<f7-card-content class="no-safe-areas" :padding="false">
<f7-list>
<f7-list-button external no-chevron target="_blank" :link="$services.getDataExportUrl()">{{ $t('Export Data') }}</f7-list-button>
<f7-list-button external no-chevron target="_blank" :link="`${$constants.api.baseUrlPath}/data/export.csv?token=${$user.getToken()}`">{{ $t('Export Data') }}</f7-list-button>
</f7-list>
</f7-card-content>
</f7-card>