liming 3 týždňov pred
rodič
commit
80a5a8dd21
2 zmenil súbory, kde vykonal 17 pridanie a 3 odobranie
  1. 1 0
      src/i18n/zhHk/global.js
  2. 16 3
      src/stores/modules/walletStore.js

+ 1 - 0
src/i18n/zhHk/global.js

@@ -2,6 +2,7 @@
 export default {
   "logOut": "退出登录",
   "newMenu": "新增菜单",
+  "WalletDoesNotExist": "錢包不存在",
   common: {
     search: '搜索',
     reset: '重置',

+ 16 - 3
src/stores/modules/walletStore.js

@@ -1,7 +1,7 @@
 import { defineStore } from "pinia";
 import Web3 from "web3";
 import CryptoJS from "crypto-js";
-import { cloneDeep } from "lodash";
+import { cloneDeep, forEach } from "lodash";
 import { sysLogin } from "@/common/login.js";
 
 
@@ -123,9 +123,22 @@ export const useWalletStore = defineStore("useWalletStore", {
         this.walletList.push(data)
       }
     },
-
+    // 删除钱包
+    deleteWallet(id) {
+      const list = this.walletList.filter(item =>  item.id != id);
+      this.walletList = list
+    },
     // 切换钱包
-    switchWallet(account) { 
+    switchWallet(id) { 
+      const item = this.walletList.find(item =>  item.id === id);
+      if(!item){
+        $msg($t("global.WalletDoesNotExist"))
+      }
+      forEach(this.$state, (_, key) => {
+        if (key !== "walletList") {
+          this.$state[key] = item[key];
+        }
+      })
     },
   },
 });