Ver código fonte

添加复制功能

wkw 3 semanas atrás
pai
commit
34cc59c3dc

+ 3 - 1
src/views/me/index.vue

@@ -14,7 +14,7 @@
           <div class="user-info-name">{{ walletStore.username  }}</div>
           <div class="user-info-key-body">
             <span>{{ formatAddress(walletStore.account) }}</span>
-            <svg-icon style="width: 24px; height: 24px;" name="copy" />
+            <svg-icon class="im-copy-btn" style="width: 24px; height: 24px;" :data-clipboard-text="walletStore.account" name="copy" />
           </div>
         </div>
       </div>
@@ -68,6 +68,8 @@
 <script setup> 
 import { useSystemStore } from "@/stores/modules/systemStore"
 import { useWalletStore } from "@/stores/modules/walletStore";
+import { useCopy } from "@/hooks/use-copy.js";
+useCopy();
 const systemStore = useSystemStore();
 const walletStore = useWalletStore();
 const router = useRouter();

+ 4 - 2
src/views/me/personalInformation/index.vue

@@ -6,7 +6,7 @@
     <div class="username">{{ walletStore.username || "Angel Token" }}</div>
     <div class="useraddress">
       <span>{{formatAddress(walletStore.account)}}</span>
-      <svg-icon style="width: 18px; height: 18px" name="copy" />
+      <svg-icon class="im-copy-btn" style="width: 18px; height: 18px" name="copy" :data-clipboard-text="walletStore.account"/>
     </div>
     <van-list class="user-bar-list">
       <van-cell
@@ -54,7 +54,9 @@ import QrcodeVue from "qrcode.vue";
 import { useWalletStore } from "@/stores/modules/walletStore";
 import { uploadFile, userInfoEdit } from "@/api/path/im.api";
 import { updateUserInfo } from "@/common/login";
- 
+import { useCopy } from "@/hooks/use-copy.js";
+useCopy();
+
 const walletStore = useWalletStore();
 
 const show = ref(false);

+ 5 - 3
src/views/me/walletManagement/index.vue

@@ -24,8 +24,8 @@
                                 <div class="card-box-lf-text">
                                     <div>{{ element.name }}</div>
                                     <div class="address">
-                                    <span>{{ element.address }}</span>
-                                    <svg-icon name="copy" style="width:16px;height:16px;margin-left:2px" />
+                                    <span>{{ short(element.address) }}</span>
+                                    <svg-icon class="im-copy-btn" name="copy" style="width:16px;height:16px;margin-left:2px" :data-clipboard-text="element.address"/>
                                     </div>
                                 </div>
                             </div>
@@ -42,6 +42,8 @@
 import Draggable from 'vuedraggable';
 import { useWalletStore } from '@/stores/modules/walletStore';
 import { useRouter } from 'vue-router'
+import { useCopy } from "@/hooks/use-copy.js";
+useCopy();
 const walletStore = useWalletStore();
 const router = useRouter();
 
@@ -67,7 +69,7 @@ const items = computed({
         id: w.id,
         name: w.username,
         img: w.avatar,
-        address: short(w.account),
+        address: w.account,
         _raw: w,            // 保留原始对象引用,更新时用
       }));
   },

+ 34 - 27
src/views/wallet/index.vue

@@ -16,7 +16,7 @@
             </div>
             <div class="user-info-key-body">
               <span class="user-info-key-body-text">{{ formatAddress(walletStore.account) }}</span>
-              <svg-icon style="width: 16px; height: 16px;" name="copy" />
+              <svg-icon class="im-copy-btn" style="width: 16px; height: 16px;" name="copy" :data-clipboard-text="walletStore.account"/>
             </div>
           </div>
         </div>
@@ -108,7 +108,11 @@
                     <div class="tree-li-text">{{ item.username }}</div>
                     <div class="tree-li-address">
                       <span>{{ formatAddress(item.account) }}</span>
-                      <svg-icon style="width: 16px; height: 16px;margin-left: 2px;" name="copy" />
+                      <svg-icon 
+                        class="im-copy-btn" 
+                        style="width: 16px; height: 16px;margin-left: 2px;" 
+                        name="copy" :data-clipboard-text="item.account"
+                      />
                     </div>
                   </div>
                 </div>
@@ -165,11 +169,15 @@
                 </div>
                 <div class="pop-list-li">
                   <div>收款地址</div>
-                  <div>{{formatAddress(item.to?.hash)}}<svg-icon style="width: 16px; height: 16px;" name="copy" /></div>
+                  <div>{{formatAddress(item.to?.hash)}}
+                    <svg-icon class="im-copy-btn" style="width: 16px; height: 16px;" name="copy" :data-clipboard-text="item.to?.hash"/>
+                  </div>
                 </div>
                 <div class="pop-list-li">
                   <div>hash</div>
-                  <div>{{formatAddress(item.hash)}}<svg-icon style="width: 16px; height: 16px;" name="copy" /></div>
+                  <div>{{formatAddress(item.hash)}}
+                    <svg-icon class="im-copy-btn" style="width: 16px; height: 16px;" name="copy" :data-clipboard-text="item.hash"/>
+                  </div>
                 </div>
                 <div class="pop-list-li" v-if="selectUrl.name == 'ACC'">
                   <div>矿工费</div>
@@ -189,6 +197,8 @@
   import { useWalletStore } from "@/stores/modules/walletStore";
   import { useSystemStore } from "@/stores/modules/systemStore";
   import {  transactions, tokenTransfers } from "@/api/path/backend.api";
+  import { useCopy } from "@/hooks/use-copy.js";
+  useCopy();
 
   const router = useRouter();
   const walletStore = useWalletStore();
@@ -233,19 +243,17 @@
     showHistory.value = true;
   }
   const getList = async () => {
-    const res = await transactions(walletStore.account) 
-    if (res.status === 200) {
-      const items = res.data.items || []
-      if (items.length > 0) {
-        items.forEach(val => {
-          val.timestamp = getDateTime(val.timestamp)
-          val.gas_price = getPrice(val.fee.value).toFixed(9)
-          if (val.value !== '0') {
-            val.value = getPrice(val.value).toFixed(6)
-          }
-        })
-        historyList.value = items
-      }
+    const res = await transactions(walletStore.account);
+    const items = res.items || []
+    if (items.length > 0) {
+      items.forEach(val => {
+        val.timestamp = getDateTime(val.timestamp)
+        val.gas_price = getPrice(val.fee.value).toFixed(9)
+        if (val.value !== '0') {
+          val.value = getPrice(val.value).toFixed(6)
+        }
+      })
+      historyList.value = items
     }
   }
   const getDBList = async (DBaddress) => {
@@ -256,16 +264,14 @@
         token: DBaddress
       }
     })
-    if (res.status === 200) {
-      const items = res.data.items || []
-      if (items.length > 0) {
-        items.forEach(val => {
-          val.timestamp = getDateTime(val.timestamp)
-          val.value = getPrice(val.total.value).toFixed(6)
-          val.hash = val.transaction_hash
-        })
-        historyList.value = items
-      }
+    const items = res.items || []
+    if (items.length > 0) {
+      items.forEach(val => {
+        val.timestamp = getDateTime(val.timestamp)
+        val.value = getPrice(val.total.value).toFixed(6)
+        val.hash = val.transaction_hash
+      })
+      historyList.value = items
     }
   }
   // 计算总和
@@ -373,6 +379,7 @@
             color: #FFFFFF;
             display: flex;
             align-items: center;
+            margin-bottom: 2px;
           }
           .user-info-key-body{
             font-weight: 400;

+ 3 - 1
src/views/wallet/walletDetail/index.vue

@@ -11,7 +11,7 @@
         <div class="username">{{ currentWallet.username }}</div>
         <div class="useraddress">
             <span>{{ formatAddress(currentWallet.account) }}</span>
-            <svg-icon style="width: 18px; height: 18px" name="copy" />
+            <svg-icon class="im-copy-btn" style="width: 18px; height: 18px" name="copy" :data-clipboard-text="currentWallet.account"/>
         </div>
 
         <van-list class="user-bar-list">
@@ -77,6 +77,8 @@ import QrcodeVue from 'qrcode.vue';
 import { useWalletStore } from '@/stores/modules/walletStore';
 import { showNotify } from 'vant';
 import { useRoute } from 'vue-router';
+import { useCopy } from "@/hooks/use-copy.js";
+useCopy();
 
 const walletStore = useWalletStore();
 const route = useRoute();