Browse Source

添加 导入钱包逻辑

wkw 3 weeks ago
parent
commit
cc683beb19
2 changed files with 10 additions and 4 deletions
  1. 1 1
      src/stores/modules/walletStore.js
  2. 9 3
      src/views/wallet/index.vue

+ 1 - 1
src/stores/modules/walletStore.js

@@ -112,7 +112,7 @@ export const useWalletStore = defineStore("useWalletStore", {
     addWallet() { 
       const data = cloneDeep(this.$state)
       Reflect.deleteProperty(data, "walletList");
-      if(this.walletList.length = 0) {
+      if(this.walletList.length == 0) {
         this.walletList.push(data)
         return 
       } 

+ 9 - 3
src/views/wallet/index.vue

@@ -93,7 +93,7 @@
             <div class="tree-ri">
               <div class="tree-ri-title">{{networkList[netWorkIndex].name}}</div>
               <div class="tree-ul">
-                <div class="tree-li" v-for="(item,i) in 10" :class="i == 0?'tree-active':''">
+                <div class="tree-li" v-for="(item,i) in currentWallets" :class="i == 0?'tree-active':''">
                   <van-image
                     width="37px"
                     height="37px"
@@ -101,9 +101,9 @@
                     src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
                   />
                   <div class="tree-li-cont">
-                    <div class="tree-li-text">名字</div>
+                    <div class="tree-li-text">{{ item.username }}</div>
                     <div class="tree-li-address">
-                      <span>0xF3fefE…EcaB</span>
+                      <span>{{ formatAddress(item.account) }}</span>
                       <svg-icon style="width: 16px; height: 16px;margin-left: 2px;" name="copy" />
                     </div>
                   </div>
@@ -219,6 +219,12 @@
     const { data } = await getNetwork({})
     networkList.value = data
   }
+  const currentChainName = computed(() => networkList.value[netWorkIndex.value]?.name)
+
+  // 当前链对应的钱包数组
+  const currentWallets = computed(() => {
+    return walletStore.walletList.filter(w => w.accountName === currentChainName.value)
+  })
   // 切换网络
   const changeNetwork = (i) => {
     netWorkIndex.value = i;