Skip to content

Commit

Permalink
<feat>:optimization of xaTransactionList (#182)
Browse files Browse the repository at this point in the history
* <feat>:optimization of xaTransactionList

* <feat>:optimization of xaTransactionList

* fix:parameter modifications

* Update xaTransactionList.vue

---------

Co-authored-by: Kyon <[email protected]>
  • Loading branch information
ranran99 and kyonRay authored Jan 3, 2024
1 parent 262ebf7 commit f41af0e
Show file tree
Hide file tree
Showing 3 changed files with 482 additions and 218 deletions.
143 changes: 112 additions & 31 deletions src/components/TransactionListExplorer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
<el-popover
width="600"
trigger="click"
@show="handleReceiptDetails(item.row)"
>
<div class="el-popover__title">
交易回执详情
Expand Down Expand Up @@ -215,8 +214,49 @@ export default {
this.buttonState.disablePreClick = true
this.buttonState.disableNextClick = false
},
handleReceiptDetails(val) {
this.txReceipt = val
async handleReceiptDetails(val) {
if (typeof val.properties.byProxy !== 'undefined') {
this.txReceipt = val
return
}
const response = await getTransaction({
path: this.chainValue,
txHash: val.txHash,
blockNumber: val.blockNumber
}).catch(
(error) => {
this.$message({
message: '网络异常:' + error,
type: 'error',
duration: 5000
})
}
)
if (
typeof response.errorCode === 'undefined' ||
response.errorCode !== 0
) {
throw new Error(
'查询交易失败,交易哈希: ' +
val.txHash +
',详情: ' +
JSON.stringify(response)
)
}
if (
typeof response.errorCode === 'undefined' ||
response.errorCode !== 0
) {
throw new Error(
'查询交易失败,交易哈希: ' +
val.txHash +
',详情: ' +
JSON.stringify(response)
)
}
var tx = response.data
this.txReceipt = response.data
this.txHash = tx.txHash
},
handlePrevClick() {
if (this.currentStep <= 0) {
Expand Down Expand Up @@ -366,36 +406,77 @@ export default {
this.buttonState.loading = false
return
}
this.fetchAllTx(chainValue, resp.data.transactions)
.then((response) => {
this.buttonState.loading = false
this.nextBlockNumber = resp.data.nextBlockNumber
this.nextOffset = resp.data.nextOffset
if (response.length === 0) {
this.$message({
type: 'info',
message: '交易列表为空,已查询至数据末尾'
})
this.updateButtonStatus()
return
if (resp.data.transactions.length === 0 && resp.data.transactionWithDetails === 0) {
this.$message({
type: 'info',
message: '交易列表为空,已查询至数据末尾'
})
this.updateButtonStatus()
return
}
if (resp.data.transactionWithDetails.length !== 0) {
this.buttonState.loading = false
this.nextBlockNumber = resp.data.nextBlockNumber
this.nextOffset = resp.data.nextOffset
var txs = []
if (resp.data.transactionWithDetails.length === 0) {
return txs
}
const defaultValue = (value, defaultValue) => {
if (value === 0) {
return value
}
if (this.controlVersion !== version) {
return
if (!value) {
return defaultValue
}
this.transactionList = response
this.historyData[this.currentStep] = response
this.currentStep += 1
this.updateButtonStatus()
})
.catch((err) => {
this.buttonState.loading = false
this.$message({ type: 'error', message: err.toString() })
})
return value
}
if (this.controlVersion !== version) {
return
}
for (const tx of resp.data.transactionWithDetails) {
var newTx = {}
newTx.txHash = defaultValue(tx.txHash, 'unknown')
newTx.username = defaultValue(tx.username, 'unknown')
newTx.txID = defaultValue(tx.xaTransactionID, 'unknown')
newTx.blockNumber = defaultValue(tx.blockNumber, 'unknown')
newTx.path = defaultValue(tx.path, 'unknown')
newTx.method = defaultValue(tx.method, 'unknown')
newTx.properties = defaultValue(tx.properties, 'unknown')
txs[txs.length] = newTx
}
this.transactionList = txs
this.historyData[this.currentStep] = txs
this.currentStep += 1
this.updateButtonStatus()
}
if (resp.data.transactions.length !== 0) {
this.fetchAllTx(chainValue, resp.data.transactions)
.then((response) => {
this.buttonState.loading = false
this.nextBlockNumber = resp.data.nextBlockNumber
this.nextOffset = resp.data.nextOffset
if (response.length === 0) {
this.$message({
type: 'info',
message: '交易列表为空,已查询至数据末尾'
})
this.updateButtonStatus()
return
}
if (this.controlVersion !== version) {
return
}
this.transactionList = response
this.historyData[this.currentStep] = response
this.currentStep += 1
this.updateButtonStatus()
})
.catch((err) => {
this.buttonState.loading = false
this.$message({ type: 'error', message: err.toString() })
})
}
})
.catch((error) => {
this.buttonState.loading = false
Expand Down
21 changes: 21 additions & 0 deletions src/views/transaction/transactionSteps/xaTransactionStep.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
export const xaTransactionManagerSteps = [
{
element: '#ChainExplorer',
title: '1. 导航选择',
intro: '第一步:从zone-chain导航中选择对应的链',
position: 'right'
},
{
element: '#xaTransactionListExplorer',
title: '2. 事务列表展示',
intro: '第二步:选择好对应的链之后,就会在资源列表中展示这条链中所有事务',
position: 'left'
},
{
element: '#sendxaTransaction',
title: '发起交易',
intro: '若需要发起事务,请点击"发起事务"按钮',
position: 'left'
}
]

export const startXASteps = [
{
element: '#XAID',
Expand Down
Loading

0 comments on commit f41af0e

Please sign in to comment.