فهرست منبع

自动的chain explorer

龚成明 2 سال پیش
والد
کامیت
eaa4a3076a
5فایلهای تغییر یافته به همراه27 افزوده شده و 20 حذف شده
  1. 2 2
      package.json
  2. 6 1
      src/App.vue
  3. 4 4
      src/components/viewer/Table.vue
  4. 8 8
      src/components/viewer/table/TradeInfoDetails.vue
  5. 7 5
      src/plugins/kit/HttpKit.js

+ 2 - 2
package.json

@@ -6,8 +6,8 @@
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
     "lint": "vue-cli-service lint",
-    "uploadFromMacOS": "sudo scp -i ~/Desktop/410.pem -r /Volumes/Code/Customer/410/ethereum_viewer_webapp/dist ec2-user@3.227.34.41:/webapp/frontend",
-    "uploadFromWindows": "scp -i 410.pem -r C:/Users/skyfffire/WebstormProjects/ethereum_viewer_webapp/dist ec2-user@3.227.34.41:/webapp/frontend"
+    "uploadFromMacOS": "sudo scp -i 410.pem -r /Volumes/Code/Customer/410/ethereum_viewer_webapp/dist ec2-user@3.227.34.41:/webapp/frontend-blockchain",
+    "uploadFromWindows": "scp -i 410.pem -r C:/Users/skyfffire/WebstormProjects/ethereum_viewer_webapp/dist ec2-user@3.227.34.41:/webapp/frontend-blockchain"
   },
   "dependencies": {
     "@mdi/font": "^5.6.55",

+ 6 - 1
src/App.vue

@@ -51,7 +51,7 @@
           <v-row align="center" v-if="chain.id !== ''">
             <v-col cols="3"></v-col>
             <v-col cols="6">
-              <v-btn tile large depressed color="primary" elevation="0" @click="selected = true">我选好了</v-btn>
+              <v-btn tile large depressed color="primary" elevation="0" @click="selectConfirm">我选好了</v-btn>
             </v-col>
           </v-row>
         </v-container>
@@ -72,6 +72,7 @@
 
 import History from '@/components/History'
 import Pending from '@/components/Pending'
+import HttpKit from "@/plugins/kit/HttpKit";
 import Chain from '@/plugins/model/Chain.js'
 import md5 from 'md5-node'
 
@@ -98,6 +99,10 @@ export default {
     },
     jump () {
       window.open('https://etherscan.io/address/' + this.pwd)
+    },
+    selectConfirm() {
+      this.selected = true
+      HttpKit.BASE_URL = this.chain.explorer
     }
   },
   async mounted() {

+ 4 - 4
src/components/viewer/Table.vue

@@ -54,7 +54,7 @@
         </template>
         <!-- Hash -->
         <template v-slot:item.hash="{ item }">
-          <v-btn v-if="item.hash.indexOf('0x') !== -1" outlined text target="_blank" :href="'https://www.oklink.com/en/ethw/tx/' + item.hash">
+          <v-btn v-if="item.hash.indexOf('0x') !== -1" outlined text target="_blank" @click="httpKit.jumpToExplorer(item.hash, 'tx')">
             {{ hashKit.head5(item.hash) + '..' }}
           </v-btn>
           <v-chip v-else label target="_blank">
@@ -63,16 +63,16 @@
         </template>
         <!-- From -->
         <template v-slot:item.from="{ item }">
-          <v-chip label color="green lighten-3" target="_blank" @click="httpKit.jumpToEthw(item.from)">
+          <v-chip label color="green lighten-3" target="_blank" @click="httpKit.jumpToExplorer(item.from)">
             {{ hashKit.headAndEnd2(item.from) }}
           </v-chip>
         </template>
         <!-- to -->
         <template v-slot:item.to="{ item }">
-          <v-chip v-if="!item.toName" label color="indigo lighten-4"  @click="httpKit.jumpToEthw(item.to)">
+          <v-chip v-if="!item.toName" label color="indigo lighten-4"  @click="httpKit.jumpToExplorer(item.to)">
             {{ hashKit.headAndEnd2(item.to) }}
           </v-chip>
-          <v-chip v-else label color="indigo lighten-4" @click="httpKit.jumpToEthw(item.to)">
+          <v-chip v-else label color="indigo lighten-4" @click="httpKit.jumpToExplorer(item.to)">
             {{ item.toName }}
           </v-chip>
         </template>

+ 8 - 8
src/components/viewer/table/TradeInfoDetails.vue

@@ -5,14 +5,14 @@
         <v-row>
           <!--token symbol-->
           <v-chip v-if="!trade.tokenSymbol"
-                  label class="ma-2 tradeLabel" @click="httpKit.jumpToEthw(trade.token, 'token')">
+                  label class="ma-2 tradeLabel" @click="httpKit.jumpToExplorer(trade.token, 'token')">
             <!-- 没有名字的 -->
             <div class="tokenName">{{ '**' + hashKit.headAndEnd2(trade.token) }}</div>
             <div class="tokenAmount">{{ numKit.getSubFloat(trade.amount, 4) }} </div>
           </v-chip>
           <v-chip v-else
                   label class="ma-2 tradeLabel" :color="hashKit.generateColorByHash(trade.token)"
-                  @click="httpKit.jumpToEthw(trade.token, 'token')">
+                  @click="httpKit.jumpToExplorer(trade.token, 'token')">
             <!-- 有名字的和Ethereum/EthereumPow -->
             <div class="tokenName">{{ trade.tokenSymbol === '' ? '[no name]' : trade.tokenSymbol }}</div>
             <div class="tokenAmount">{{ numKit.getSubFloat(trade.amount, 4) }}</div>
@@ -20,17 +20,17 @@
           <!--from-->
           <div>
             <v-chip v-if="trade.from === item.from"
-                    label class="ma-2" color="green lighten-3" @click="httpKit.jumpToEthw(trade.from)">
+                    label class="ma-2" color="green lighten-3" @click="httpKit.jumpToExplorer(trade.from)">
               {{ '[F] ' + hashKit.headAndEnd2(trade.from) }}
             </v-chip>
             <v-chip v-else-if="trade.from === item.to"
-                    label class="ma-2" color="indigo lighten-4" @click="httpKit.jumpToEthw(trade.from)">
+                    label class="ma-2" color="indigo lighten-4" @click="httpKit.jumpToExplorer(trade.from)">
               <div v-if="!trade.fromName">{{ '[T] ' + hashKit.headAndEnd2(trade.from) }}</div>
               <div v-else>{{ '[T] ' + trade.fromName }}</div>
             </v-chip>
             <v-chip v-else
                     label class="ma-2" :color="hashKit.generateColorByHash(trade.from)"
-                    @click="httpKit.jumpToEthw(trade.from)">
+                    @click="httpKit.jumpToExplorer(trade.from)">
               <div v-if="!trade.fromName">{{ hashKit.headAndEnd2(trade.from) }}</div>
               <div v-else>{{ trade.fromName }}</div>
             </v-chip>
@@ -39,16 +39,16 @@
           <!--to-->
           <div>
             <v-chip v-if="trade.to === item.from"
-                    label class="ma-2" color="green lighten-3" @click="httpKit.jumpToEthw(trade.to)">
+                    label class="ma-2" color="green lighten-3" @click="httpKit.jumpToExplorer(trade.to)">
               {{ '[F] ' + hashKit.headAndEnd2(trade.to) }}
             </v-chip>
             <v-chip v-else-if="trade.to === item.to"
-                    label class="ma-2" color="indigo lighten-4" @click="httpKit.jumpToEthw(trade.to)">
+                    label class="ma-2" color="indigo lighten-4" @click="httpKit.jumpToExplorer(trade.to)">
               <div v-if="!trade.toName">{{ '[T] ' + hashKit.headAndEnd2(trade.to) }}</div>
               <div v-else>{{'[T] ' +  trade.toName }}</div>
             </v-chip>
             <v-chip v-else
-                    label class="ma-2" :color="hashKit.generateColorByHash(trade.to)" @click="httpKit.jumpToEthw(trade.to)">
+                    label class="ma-2" :color="hashKit.generateColorByHash(trade.to)" @click="httpKit.jumpToExplorer(trade.to)">
               <div v-if="!trade.toName">{{ hashKit.headAndEnd2(trade.to) }}</div>
               <div v-else>{{ trade.toName }}</div>
             </v-chip>

+ 7 - 5
src/plugins/kit/HttpKit.js

@@ -1,9 +1,11 @@
 export default class HttpKit {
-  static jumpToEthw(pairAddress, type) {
-    if (type === 'token') {
-      window.open('https://www.oklink.com/en/ethw/token/' + pairAddress)
-    } else {
-      window.open('https://www.oklink.com/en/ethw/address/' + pairAddress)
+  static BASE_URL = undefined
+
+  static jumpToExplorer(hash, type='address') {
+    if (!HttpKit.BASE_URL) {
+      throw Error(`Chain explorer is not set!`)
     }
+
+    window.open(`${HttpKit.BASE_URL}/${type}/${hash}`)
   }
 }