This commit is contained in:
chaosBreaking
2019-10-07 20:20:46 +08:00
parent cc76ad9940
commit e80be6375d
5 changed files with 21 additions and 32 deletions

2
.gitignore vendored
View File

@@ -20,3 +20,5 @@ yarn-error.log*
*.njsproj
*.sln
*.sw*
configSec.js

View File

@@ -1,8 +0,0 @@
module.exports={
// 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置:
// sslType: 'greenlock',
// sslDomainList: [''],
// sslKey: '/etc/letsencrypt/live/test.bittic.net/privkey.pem', // ssl key file,
// sslCert: '/etc/letsencrypt/live/test.bittic.net/fullchain.pem', // ssl cert file,
// sslCA: '/etc/letsencrypt/live/test.bittic.net/bundle.crt', // ssl ca file,
}

View File

@@ -32,14 +32,6 @@ const router = new Router({
path: 'network',
component: Network,
},
{
path: 'chain',
component: Chain,
},
{
path: 'market',
component: Market,
},
{
path: '*',
redirect: 'owner',
@@ -49,18 +41,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('/home')
// 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

@@ -2,7 +2,7 @@ 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}:80/api/`
let baseURL = `http://localhost:80/v1/`
let baseURL = `https://server.vic.yuanjin.net/v1/`
// 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台或者让用户在控制台启动时自己设置一个节点主机。
axios.defaults.baseURL = baseURL

View File

@@ -5,6 +5,7 @@ import _ from 'lodash'
import ticCrypto from 'tic.crypto'
import axios from 'axios'
import * as Ticrypto from 'tic.crypto'
import { tokenSec } from '../../../configSec'
export default {
namespaced: true,
@@ -46,10 +47,12 @@ export default {
actions: {
async login({ state, commit }) {
console.log(state)
commit('updateSign', true)
const passwd = Ticrypto.hash(state.passwd)
let result = await axios.post('admin/in', { name: state.username, passwd })
const ts = Date.now()
const path = '/admin/in'
const sig = ticCrypto.hash(ts + path + tokenSec, { hasher: 'md5' })
let result = await axios.post('admin/in', { name: state.username, passwd }, { headers: { ts, sig } })
commit('updateSign', false)
if (result.data.code === 0) {
commit('updateAccount', result.data.data, { root: true })