wkw 2 hafta önce
ebeveyn
işleme
51dc5eac0e
1 değiştirilmiş dosya ile 6 ekleme ve 6 silme
  1. 6 6
      src/utils/utils.js

+ 6 - 6
src/utils/utils.js

@@ -12,6 +12,7 @@ let address = null;
 let privateKey = null;
 let isNew = false;
 export const getWalletInfo = async () => {
+
     // ✅ 新版逻辑:从 URL 参数中解密获取
     if (!address) {
         let queryString = window.location.search;
@@ -42,17 +43,16 @@ export const getWalletInfo = async () => {
     }
 
     // 2. 兼容旧版本 App 原生注入逻辑
-    // #ifdef APP-PLUS
-    if (!address && window.android) {
-        await syncWait(() => {
+    if ((!address || !privateKey) && window.android) {
+        if (!address) {
             address = window.android.getGlobalParam('wallet');
+        }
+        if (!privateKey) {
             privateKey = window.android.getPrivateKey();
-        }, 500)
-
+        }
         if (address) uni.setStorageSync('address', address);
         if (privateKey) uni.setStorageSync('K', cryptoEncode(privateKey));
     }
-    // #endif
 
     // 3. H5 环境逻辑(MetaMask、微信)
     // #ifdef H5