diff --git a/src/App.vue b/src/App.vue index 251e0231..5783889d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,14 +1,15 @@ @@ -36,7 +42,6 @@ export default { color: #2c3e50; } - main { margin: 0 auto; /* padding: 30px; */ @@ -58,5 +63,4 @@ ul { font-size: 22px; /* border-right: 1px solid #bbb; */ } - diff --git a/src/ftbot/TradeList.vue b/src/ftbot/TradeList.vue new file mode 100644 index 00000000..e4f22416 --- /dev/null +++ b/src/ftbot/TradeList.vue @@ -0,0 +1,40 @@ + + + diff --git a/src/ftbot/TradeView.vue b/src/ftbot/TradeView.vue index a7eb26a0..82b7cb56 100644 --- a/src/ftbot/TradeView.vue +++ b/src/ftbot/TradeView.vue @@ -1,15 +1,39 @@ - + diff --git a/src/store/index.js b/src/store/index.js index bd3ec8ef..c9627046 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,18 +1,33 @@ import Vue from 'vue' import Vuex from 'vuex' +import axios from 'axios'; import tradesModule from './modules/trades'; + +import { apiBase } from './modules/config'; + Vue.use(Vuex) export default new Vuex.Store({ state: { + ping: 'ddd', }, modules: { trades: tradesModule }, mutations: { + setPing(state, ping) { + console.log(ping); + const now = Date(Date.now()); + state.ping = `${ping.status} ${now.toString()}` ; + } }, actions: { - }, + ping({ commit }) { + axios.get(`${apiBase}/ping`) + .then((result) => commit('setPing', result.data)) + .catch(console.error); + } + } }) diff --git a/src/store/modules/config.js b/src/store/modules/config.js index 9429a03c..76ad2ccf 100644 --- a/src/store/modules/config.js +++ b/src/store/modules/config.js @@ -1,5 +1,11 @@ -const apiBase = '/api/v1/' - -export default { - apiBase, +const apiBase = '/api/v1' +const apiAuth = {auth: { + username: 'xxxx', + password: 'xxxx!', + } +} + +module.exports = { + + apiBase, apiAuth } diff --git a/src/store/modules/trades.js b/src/store/modules/trades.js index 30e5d327..1fe5f845 100644 --- a/src/store/modules/trades.js +++ b/src/store/modules/trades.js @@ -1,21 +1,25 @@ import axios from 'axios'; -const apiBase = require('./config.js') +import { apiBase, apiAuth } from './config'; export default { namespaced: true, state: { trades: [], + trade_count: 0, }, mutations: { updateTrades(state, trades) { - state.trades = trades; + state.trades = trades.trades; + state.trade_count = trades.trade_count; } }, actions: { getTrades({ commit }) { - axios.get(`${apiBase}/trades`) + axios.get(`${apiBase}/trades`, { + ...apiAuth + }) .then((result) => commit('updateTrades', result.data)) .catch(console.error); } diff --git a/vue.config.js b/vue.config.js index 9c7dd42d..da13aadf 100644 --- a/vue.config.js +++ b/vue.config.js @@ -2,7 +2,7 @@ module.exports = { devServer: { proxy: { '/api': { - target: 'http://localhost:8081', + target: 'http://127.0.0.1:8081', changeOrigin: true, }, },