|
@@ -37,6 +37,7 @@ type EChartsOption = echarts.EChartsOption;
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
checkWalletAddress()
|
|
checkWalletAddress()
|
|
|
|
+ listeningDisconnect()
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -98,6 +99,17 @@ let chainId = '0x144'
|
|
const MMSDK = new MetaMaskSDK()
|
|
const MMSDK = new MetaMaskSDK()
|
|
MM.value = MMSDK.getProvider()
|
|
MM.value = MMSDK.getProvider()
|
|
|
|
|
|
|
|
+//监听连接断开(通过监听账号的变化判断是否断开连接)
|
|
|
|
+const listeningDisconnect = () => {
|
|
|
|
+ MM.value.on('accountsChanged', (accounts: string[]) => {
|
|
|
|
+ if (accounts.length >= 1) {
|
|
|
|
+ address.value = accounts[0]
|
|
|
|
+ connectWallet()
|
|
|
|
+ } else {
|
|
|
|
+ address.value = ''
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
//查询钱包地址
|
|
//查询钱包地址
|
|
const checkWalletAddress = async () => {
|
|
const checkWalletAddress = async () => {
|
|
let accounts: string[] = await MM.value.request({method: 'eth_accounts'});//不弹窗
|
|
let accounts: string[] = await MM.value.request({method: 'eth_accounts'});//不弹窗
|