This commit is contained in:
ann 2021-07-30 17:47:15 +08:00
parent 4b592f8173
commit 4a13575980
6 changed files with 92 additions and 49 deletions

View File

@ -32,6 +32,7 @@
"jsonlint": "1.6.3",
"jszip": "3.2.1",
"levenary": "^1.1.1",
"moment": "^2.29.1",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",
@ -44,7 +45,6 @@
"vue-codemirror": "^4.0.6",
"vue-count-to": "1.0.13",
"vue-json-editor": "^1.4.3",
"vue-json-viewer": "^2.2.19",
"vue-router": "3.0.2",
"vue-splitpane": "1.0.4",
"vuedraggable": "2.20.0",

View File

@ -165,10 +165,11 @@ export default {
})
},
// 块链列表
getBlockList(hash) {
getBlockList(hash, query) {
return request({
url: `/apiLedger/blockAndTxList/${hash}/0`,
method: 'get'
method: 'get',
params: query
})
},
// 交易列表

View File

@ -2,7 +2,6 @@ import { login, harvesterLogin, blockChainLogin } from '@/api/user'
import { getToken, setToken, removeToken } from '@/utils/auth'
import router, { resetRouter } from '@/router'
import Cookies from 'js-cookie'
const state = {
token: getToken(),
name: '',
@ -33,9 +32,6 @@ const actions = {
// user login
login({ commit }, userInfo) {
const { username, password } = userInfo
// Cookies.set('R_SESS', 'token-pvwtg:wzqksvsmk6564dqnd2fd7cqlww59t9kp9hbgh7f42mbc7hp47j6gm9')
return Promise.all([
login({ 'grant_type': 'password', 'username': username.trim(), 'password': password }),
harvesterLogin({ 'username': 'admin', 'password': 'Nudt@112!', 'description': 'UI Session', 'responseType': 'cookie', 'ttl': 57600000 }),
@ -44,13 +40,9 @@ const actions = {
'password': 'exploreradminpw',
'network': 'agridepart-network'
})]).then(response => {
// commit('SET_TOKEN', response[1].token)
// setToken(response[1].token)
commit('SET_TOKEN', response[0].access_token)
setToken(response[0].access_token)
console.log(response[1])
console.log(response[2])
// Cookies.set('jweToken', response[1].jweToken)
Cookies.set('htoken', response[2].token)
Promise.resolve()
}).catch(error => {
Promise.reject(error)

View File

@ -18,13 +18,16 @@ const service = axios.create({
service.interceptors.request.use(
config => {
// do something before request is sent
if (store.getters.token && config.url.indexOf('/v1/') !== 0) {
if (store.getters.token && config.url.indexOf('/v1/') !== 0 && config.url.indexOf('apiLedger') === -1) {
config.headers['Authorization'] = 'Bearer ' + getToken()
}
if (config.url.indexOf('v3-public') !== -1){
const csrf = Cookies.get('CSRF');
if ( csrf ) {
config.headers['x-api-csrf'] = csrf;
if (config.url.indexOf('apiLedger') !== -1) {
config.headers['Authorization'] = 'bearer ' + Cookies.get('htoken')
}
if (config.url.indexOf('v3-public') !== -1) {
const csrf = Cookies.get('CSRF')
if (csrf) {
config.headers['x-api-csrf'] = csrf
}
}
if (config.url === '/oauth/token') {

View File

@ -62,15 +62,14 @@
<span>区块</span>
<el-button style="float: right; padding: 3px 0" type="text" @click="toBlockList">更多</el-button>
</div>
<div class="">
<div class="" v-if="tradeList.length>0">
<div v-for="i in 5" :key="i" class="blockInfo">
<div class="blockInfoIcon"><i class="el-icon-connection" /></div>
<span class="time">2021-07-23T08:36:03.777Z</span>
<span class="title">区块18</span>
<span class="tradeNum">1TXNS</span>
<span class="info">18630ebb131f58725006d03d6991130f9d620c84e8cb5ba76b15d96e55f96fe4</span>
<span class="time" v-if="blockList.length>=i">{{blockList[i].createdt}}</span>
<span class="title" v-if="blockList.length>=i">区块{{blockList[i].blocknum}}</span>
<span class="tradeNum" v-if="blockList.length>=i">{{blockList[i].txcount}}TXNS</span>
<span class="info" v-if="blockList.length>=i">{{blockList[i].blockhash}}</span>
</div>
</div>
</el-card>
</el-col>
@ -79,45 +78,90 @@
<div slot="header" class="clearfix">
<span>交易</span>
</div>
<div class="">
<div v-for="i in 5" :key="i" class="blockInfo">
<div class="" v-if="tradeList.length>0">
<div v-for="i in 5" :key="i" class="blockInfo" @click="getTradeDetail(tradeList[i])">
<div class="blockInfoIcon"><svg-icon icon-class="money" /></div>
<span class="time">2021-07-23T08:36:03.777Z</span>
<span class="time">{{tradeList[i].createdt}}</span>
<span class="title">交易ID</span>
<span class="info">18630ebb131f58725006d03d6991130f9d620c84e8cb5ba76b15d96e55f96fe4</span>
<span class="info">{{tradeList[i].txhash}}</span>
</div>
</div>
</el-card>
</el-col>
</el-row>
<el-dialog width="80%" title="交易详情" :visible.sync="dialogDetailVisible">
<FormData :column="1" :data="detailData" :data-map="dataMap" />
</el-dialog>
</div>
</template>
<script>
import { FormData } from '@/components/FormData'
import TradeLineChart from '@/components/blockChain/tradeLineChart'
import moment from 'moment'
export default {
components: {
TradeLineChart
TradeLineChart,
FormData
},
data() {
return {
status: {
chaincodeCount: '1',
txCount: '40',
latestBlock: '40',
peerCount: '6',
userCount: '10',
tradeCount: '22'
}
chaincodeCount: '0',
txCount: '0',
latestBlock: '0',
peerCount: '0',
userCount: '0',
tradeCount: '0'
},
currentChannel: '',
blockList: [],
tradeList: [],
dialogDetailVisible: false,
detailData: {},
dataMap: {
transid: '交易ID',
ledgername: '数据标题',
txhash: '交易哈希',
createdt: '交易时间',
blockhash: '区块哈希',
blockNum: '区块高度',
},
}
},
mounted() {
this.$Api.getCurrentChannel().then(res=>{
this.currentChannel = res.currentChannel
this.getBlockList()
this.getTradeList()
this.getStatisticsCount()
})
},
methods: {
getTradeDetail(row) {
this.$Api.getTradeDetail(this.currentChannel, row.txhash).then(res=>{
this.detailData = res.row;
this.dialogDetailVisible = true
})
},
getStatisticsCount() {
this.$Api.getStatisticsCount(this.currentChannel).then(res => {
this.status = res
})
},
toBlockList() {
this.$router.push({ path: `/blockChain/blockList` })
},
getBlockList() {
this.$Api.getBlockList(this.currentChannel, {from: moment().subtract(1, 'months').format('YYYY-MM-DD HH:mm:ss.SSS'), to: moment().add(1, 'days').format('YYYY-MM-DD HH:mm:ss.SSS')}).then(res => {
this.blockList = res.rows
})
},
getTradeList() {
this.$Api.getTradeList(this.currentChannel).then(res => {
this.tradeList = res.rows
})
}
}
@ -153,6 +197,7 @@ export default {
.el-card__body {
padding: 0;
}
cursor: pointer;
.blockInfo{
display: block;
height: 70px;

View File

@ -39,10 +39,7 @@ module.exports = {
proxy: {
'/oauth': {
ws: false,
// target: 'http://124.71.196.205:30881/' /* EduCoder */
// target: 'http://119.3.157.144:30881/', /* KubeX */
target: 'http://119.45.100.73:30881/', /* Host */
// target: 'http://39.103.233.49:30881/', /* BJ-Member2 */
},
'^/v1': {
ws: false,
@ -71,20 +68,25 @@ module.exports = {
'^/prom': ''
}
},
'^/api': {
'^/apiLedger': {
ws: false,
target: 'http://124.71.195.158:8080/',
changeOrigin: true,
},
'^/api/': {
ws: false,
target: 'http://119.45.100.73:30881/', /* Host */
// changeOrigin: true,
},
'^/apis/': {
ws: false,
target: 'http://119.45.100.73:30881/', /* Host */
// changeOrigin: true,
},
'^/authLedger': {
ws: false,
// target: 'http://119.45.100.73:30881/', /* Host */
target: 'http://124.71.195.158:8080/',
},
'^/apiLedger': {
ws: false,
// target: 'http://119.45.100.73:30881/', /* Host */
target: 'http://124.71.195.158:8080/',
changeOrigin: true,
},
'/kapis/terminal.kubesphere.io': {
ws: true,