Selaa lähdekoodia

[edit] fix merge code

wenliming 2 vuotta sitten
vanhempi
commit
a7fe22b5eb

+ 6 - 0
src/entry/background.js

@@ -74,6 +74,12 @@ function onMessageMethod(req, sender, sendResponse) {
                     }
                 });
                 break
+            case "CONTENT_SEND_DISCORD_AUTH_CODE":
+                discordLoginCode(req);
+                break
+            case 'RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID':
+                saveDiscordAuthWindowId(req);
+                break;
         }
     }
 }

+ 3 - 2
src/logic/content/twitter.js

@@ -18,12 +18,12 @@ function twitterPinLogin() {
     }
 }
 
-function getDiscordAuthCode(port) {
+function getDiscordAuthCode() {
     if (window.location.href.indexOf(discordAuthRedirectUri) > -1) {
         const urlParams = new URLSearchParams(window.location.search);
         const code = urlParams.get('code');
         if (code) {
-            port.postMessage({ state: 'CONTENT_SEND_DISCORD_AUTH_CODE', code })
+            chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_DISCORD_AUTH_CODE", code}, () => { })
         }
     }
 };
@@ -576,6 +576,7 @@ export function initExecuteScript(changes) {
 }
 // 初始化
 export function init() {
+    getDiscordAuthCode();
     if (window.location.href.indexOf('twitter.com') < 0) {
         return
     }

+ 7 - 7
src/view/iframe/publish/give-dialog.vue

@@ -1092,12 +1092,7 @@ const setDiscordErrTxt = (params = {showPop: false}) => {
                             onIptSetErrorTxt();
                         }
                     }
-                }).catch((err) => {
-                    if(iptErrMsgTxt.value) {
-                        iptErrMsgTxt.value = '';
-                        iptErrType = '';
-                    }
-                });
+                })
             } else {
                 iptErrMsgTxt.value = discordIptErrTxt;
                 iptErrType = 'discord';
@@ -1163,7 +1158,12 @@ const getDiscordInviteInfo = (inviteUrl, cb) => {
         if(res.code == 0) {
             discordInviteInfo.value = res.data;
         }
-    })
+    }).catch((err) => {
+        if(iptErrMsgTxt.value && iptErrType == 'discord') {
+            iptErrMsgTxt.value = '';
+            iptErrType = '';
+        }
+    });
 }
 
 /**