diff --git a/package.json b/package.json index 7f9d899..faddbf1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "league-explorer", + "license": "MIT", "version": "0.1.0", "private": true, "scripts": { @@ -12,6 +13,7 @@ "@33cn/chain33-rpc-api": "^1.5.29", "@element-plus/icons": "^0.0.11", "axios": "^0.21.4", + "clipboard": "^2.0.8", "element-plus": "^1.1.0-beta.16", "vue": "^3.2.11", "vue-router": "^4.0.11", diff --git a/src/api/index.ts b/src/api/index.ts index e77b76b..4ecd40d 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,8 +1,11 @@ import auth from './interfaces/auth' -import user from './interfaces/user' import block from './interfaces/block' +import esdb from './interfaces/esdb' +import user from './interfaces/user' + export { auth, - user, - block + block, + esdb, + user } diff --git a/src/api/interfaces/block.ts b/src/api/interfaces/block.ts index 0fa62f2..6bff532 100644 --- a/src/api/interfaces/block.ts +++ b/src/api/interfaces/block.ts @@ -1,3 +1,3 @@ import Chain33Rpc from '@33cn/chain33-rpc-api' -export default new Chain33Rpc(process.env.VUE_APP_BLOCK_URL, null) +export default new Chain33Rpc(process.env.VUE_APP_BLOCK_URL as string, null) diff --git a/src/api/interfaces/esdb.ts b/src/api/interfaces/esdb.ts new file mode 100644 index 0000000..9097986 --- /dev/null +++ b/src/api/interfaces/esdb.ts @@ -0,0 +1,46 @@ +import { AuthResponse } from '@/types/auth' +import axios, { AxiosRequestConfig } from 'axios' + +const request = axios.create({ + baseURL: process.env.VUE_APP_API_URL as string + process.env.VUE_APP_ESDB_URL as string, + timeout: 5000 +}) +const axiosConf = (config: AxiosRequestConfig) => { + config.headers.Accept = 'application/json' + return config +} +request.interceptors.response.use(async (response) => { + if (response.data?.error !== null) { + return Promise.reject(response.data.error) + } + return Promise.resolve(response.data?.result) +}, () => { + return Promise.reject('网络请求超时') +}) + +request.interceptors.request.use(axiosConf, err => { + return Promise.reject(err) +}) + +const txList = (size?: number): Promise => { + const body = { + id: 1, + method: 'Tx.TxList', + params: [{ + 'sort': [{ + 'key': 'height', + 'ascending': false + }], + 'page': { + 'number': 1, + 'size': size + } + }] + } + + return request.post('', body) +} + +export default { + txList +} diff --git a/src/components/Header.vue b/src/components/Header.vue index c820863..5f6ee20 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -2,7 +2,7 @@
@@ -34,6 +34,7 @@ const router = useRouter() } .logo { + font-size: 32px; align-items: center; display: flex; margin-right: 32px; diff --git a/src/components/Nav.vue b/src/components/Nav.vue index 8bb6342..f868ae8 100644 --- a/src/components/Nav.vue +++ b/src/components/Nav.vue @@ -32,10 +32,10 @@ const navList = ref([ title: 'Token', route: 'Token' }, - { - title: '节点', - route: 'Nodes' - }, + // { + // title: '节点', + // route: 'Nodes' + // }, { title: '解析数据', route: 'Analytical' diff --git a/src/main.ts b/src/main.ts index 9b5ad3b..1ee9d9b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,12 +5,14 @@ import App from './App.vue' import router from './router' import store, { key } from './store' import zhCn from 'element-plus/es/locale/lang/zh-cn' +import directives from '@/utils/directives' const app = createApp(App) app.use(ElementPlus, { locale: zhCn, }) +app.use(directives) app.use(store, key) app.use(router) app.mount('#app') diff --git a/src/utils/directives.ts b/src/utils/directives.ts new file mode 100644 index 0000000..d2b0b2b --- /dev/null +++ b/src/utils/directives.ts @@ -0,0 +1,22 @@ +import { App, DirectiveBinding } from '@vue/runtime-core' +import ClipboardJS from 'clipboard' +import { ElMessage } from 'element-plus' + +export default (Vue: App) => { + Vue.directive('copy', { + updated (el: Element, binding: DirectiveBinding) { + const clipboard = new ClipboardJS(el, { + text: () => { + return binding.value + } + }) + + clipboard.on('error', (): void => { + ElMessage.warning({ + message: '当前浏览器不支持复制' + }) + clipboard.destroy() + }) + } + }) +} diff --git a/src/views/Address/index.vue b/src/views/Address/index.vue index 523a2a9..ca43460 100644 --- a/src/views/Address/index.vue +++ b/src/views/Address/index.vue @@ -3,8 +3,12 @@
- 地址 + 地址: {{ address }} + 合约地址 + 普通地址 + + 复制
@@ -16,24 +20,24 @@
- {{ balance.balance.toFixed(2) }} {{ store.getters.symbol }} + {{ balance.balance.toFixed(2) }} {{ symbol }}
- {{ balance.reciver.toFixed(2) }} {{ store.getters.symbol }} + {{ balance.reciver.toFixed(2) }} {{ symbol }}
- {{ sended.toFixed(2) }} {{ store.getters.symbol }} + {{ sended.toFixed(2) }} {{ symbol }}
- {{ frozen.toFixed(2) }} {{ store.getters.symbol }} + {{ frozen.toFixed(2) }} {{ symbol }}
@@ -78,7 +82,7 @@ - + - + - + + @@ -113,28 +118,38 @@ - + - + - + - + + + + + + + @@ -156,6 +171,8 @@ const route = useRoute() const address = computed(() => route.params.address as string) const pageSize = Number(process.env.VUE_APP_BLOCK_DETAIL_LIST_SIZE) +const symbol = computed(() => store.getters.symbol) + const balance = ref({ balance: 0, reciver: 0, @@ -167,6 +184,7 @@ const records = ref([]) const token = ref('') const assets = ref([]) const loading = ref(false) +const isContract = ref(false) watch(route, (to) => { if (to.name == 'Address') { @@ -180,6 +198,15 @@ onMounted(() => { }) const initAddressData = () => { + block.callPromiseAPI('Query', { + execer: 'evm', + funcName: 'CheckAddrExists', + payload: { + addr: address.value + } + }).then(res => { + isContract.value = res.result.contract + }) /** * 获取地址的基本信息 */ @@ -259,6 +286,13 @@ const loadTradeList = () => { color: #516379; font-weight: 500; } + + .el-tag, + .el-button { + vertical-align: middle; + margin-left: 16px; + } + } .warning { diff --git a/src/views/Block/detail.vue b/src/views/Block/detail.vue index 1c06558..5c4c645 100644 --- a/src/views/Block/detail.vue +++ b/src/views/Block/detail.vue @@ -5,7 +5,7 @@

区块高度 {{ info.height }}

区块哈希 {{ info.hash }} - 复 制 + 复 制
@@ -28,7 +28,7 @@
- + {{ info.height - 1 }} @@ -42,7 +42,7 @@
- {{ info.blockTime }} +
@@ -76,35 +76,44 @@ - + - + - + - - - + + + + + - + + + + @@ -124,18 +133,20 @@ import { useRoute } from 'vue-router' const route = useRoute() const pageSize = Number(process.env.VUE_APP_BLOCK_DETAIL_LIST_SIZE) +const thisHash = ref('') onMounted(() => { + thisHash.value = route.params.hash as string loadBlockData() }) watch(route, (to) => { if (to.name === 'BlockDetail') { + thisHash.value = info.value.parentHash loadBlockData() } }) -const hash: string = route.params.hash as string const handleCurrentChange = (e: number) => { console.log(e) @@ -157,10 +168,7 @@ const next = ref({ const records = ref([]) const loadBlockData = () => { - console.log('jiazai shuju ') - - block.getBlockOverview(hash).then(res => { - console.log('更新INFO A ') + block.getBlockOverview(thisHash.value).then(res => { info.value = res.result.head block.getTxByHashes(res.result.txHashes).then(txs => { diff --git a/src/views/Home/index.vue b/src/views/Home/index.vue index 08ee561..64749ab 100644 --- a/src/views/Home/index.vue +++ b/src/views/Home/index.vue @@ -77,7 +77,7 @@ export default {