This commit is contained in:
chaosBreaking
2019-10-04 17:53:49 +08:00
parent 49942c99bc
commit d094299226
6 changed files with 56 additions and 40 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 }) {

View File

@@ -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()
},
}

View File

@@ -3,7 +3,7 @@
<div class="side-menus" :class="{ collapsed: sideCollapsed || !isLogin }">
<div class="side-title">
<img src="../assets/images/logo.png" />
<span class="white--text">TIME IN CHAIN</span>
<span class="white--text">VIC</span>
</div>
<div

View File

@@ -2,7 +2,7 @@
<div class="login-page">
<img src="../assets/images/logo.png">
<h1 class="white--text">{{ $t('login.title') }}</h1>
<h1 class="white--text"> VIC后台 </h1>
<v-text-field
color="secondary"
@@ -10,14 +10,26 @@
single-line
:error="inputError"
:error-messages="errorMnemonic"
:value="mnemonic"
:value="user"
:loading="signing"
:renewing="renewing"
@input="updateMnemonic"
label="用户名" />
<v-text-field
color="secondary"
dark autofocus
single-line
:error="inputError"
:error-messages="errorMnemonic"
:value="passwd"
:loading="signing"
:renewing="renewing"
@input="updateMnemonic"
@keyup.13="login"
:label="$t('login.inputLabel')" />
label="密码" />
<v-select
<!-- <v-select
color="secondary" dark
prepend-icon="language"
:value="currentLang"
@@ -25,7 +37,7 @@
:items="supportLangs"
item-value="code"
item-text="label"
/>
/> -->
<div class="loginSecword">
<v-btn :loading="signing" dark large color="transparent" @click="login">
@@ -35,9 +47,9 @@
<!-- <v-btn :renewing="renewing" dark large color="transparent" @click="createSecword">
{{ $t('login.secwordBtn') }}
</v-btn> -->
<v-btn :renewing="renewing" dark large color="transparent" @click="createSecword">
<!-- <v-btn :renewing="renewing" dark large color="transparent" @click="createSecword">
{{ $t('login.secwordBtn') }}
</v-btn>
</v-btn> -->
</div>
@@ -58,7 +70,8 @@ export default {
computed: {
...mapState([
'mnemonic',
'user',
'passwd',
'errorMnemonic',
'signing',
'renewing',