From d09429922681f8ea5a6d913768c71bb827f3fda4 Mon Sep 17 00:00:00 2001 From: chaosBreaking Date: Fri, 4 Oct 2019 17:53:49 +0800 Subject: [PATCH] new --- src/router.js | 26 +++++++++++++------------- src/services/axios.js | 3 ++- src/store/modules/login.js | 16 +++++++++------- src/views/Chain.vue | 20 ++++++++++---------- src/views/Home.vue | 2 +- src/views/Login.vue | 29 +++++++++++++++++++++-------- 6 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/router.js b/src/router.js index 0999bf3..b860fad 100644 --- a/src/router.js +++ b/src/router.js @@ -51,18 +51,18 @@ const router = new Router({ ], }) -router.beforeEach((to, _, next) => { - const loginPage = to.path === '/login' - const signed = store.getters.isLogin - if (!loginPage && !signed) { - next('/login') - return - } - if (loginPage && signed) { - next('/owner') - return - } - next() -}) +// router.beforeEach((to, _, next) => { +// const loginPage = to.path === '/login' +// const signed = store.getters.isLogin +// if (!loginPage && !signed) { +// next('/login') +// return +// } +// if (loginPage && signed) { +// next('/home') +// return +// } +// next() +// }) export default router diff --git a/src/services/axios.js b/src/services/axios.js index 291303f..cb06430 100644 --- a/src/services/axios.js +++ b/src/services/axios.js @@ -1,7 +1,8 @@ import axios from 'axios' // import app from './app' // let baseURL = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/api/` -let baseURL = `${location.protocol}//${location.hostname}:60000/api/` +// let baseURL = `${location.protocol}//${location.hostname}:80/api/` +let baseURL = `http://server4test.vic.yuanjin.net/v1/` // 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者让用户在控制台启动时,自己设置一个节点主机。 axios.defaults.baseURL = baseURL diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 6b52cb5..f717d43 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -3,12 +3,14 @@ import router from '../../router' import { i18n } from '../../i18n' import _ from 'lodash' import ticCrypto from 'tic.crypto' +import axios from 'axios' export default { namespaced: true, state: { - mnemonic: '', + user: '', + passwd: '', errorMnemonic: '', signing: false, renewing: false, @@ -38,14 +40,14 @@ export default { actions: { async login({ state, commit }) { commit('updateSign', true) - const account = (await ticApi.secword2account(state.mnemonic)) || {} - account.mnemonic = state.mnemonic + let result = await axios.post('admin/in', { name: 'jojo', passwd: '941411d944c479af9a5e9d29d7430722d90a8e34d9585014e2f2c12b21db143d' }) commit('updateSign', false) - if (await ticApi.isAddress(account.address)) { - commit('updateAccount', _.omit(account, 'seckey'), { root: true }) - router.push('/owner') + console.log(result.data) + if (result.code === 0) { + commit('updateAccount', 'xxx', { root: true }) + router.push('/home') } else { - commit('updateError', i18n.t('login.errorMnemonic')) + commit('updateError', '用户名或密码错误') } }, async createSecword({ state, commit }) { diff --git a/src/views/Chain.vue b/src/views/Chain.vue index 244b904..4448b6a 100644 --- a/src/views/Chain.vue +++ b/src/views/Chain.vue @@ -94,7 +94,7 @@ import io from 'socket.io-client' const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('chain') const socketUrl = `ws://${location.hostname}:60000` -Vue.use(VueSocketio, io(socketUrl), store) +// Vue.use(VueSocketio, io(socketUrl), store) export default { name: 'Chain', @@ -110,14 +110,14 @@ export default { ]), ...mapGetters([]), }, - sockets: { - connect() { - console.log('socket connected') - }, - newBlock(msg) { - this.addNewBlock(msg) - }, - }, + // sockets: { + // connect() { + // console.log('socket connected') + // }, + // newBlock(msg) { + // this.addNewBlock(msg) + // }, + // }, methods: { ...mapActions([ @@ -133,7 +133,7 @@ export default { }, mounted() { - this.queryBlockList() + // this.queryBlockList() }, } diff --git a/src/views/Home.vue b/src/views/Home.vue index b30eed3..843ff38 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -3,7 +3,7 @@
- TIME IN CHAIN + VIC