浏览代码

Merge branch 'test' of https://git.yishihui.com/DeNet/de-net into test

A\An 3 年之前
父节点
当前提交
01d901e052
共有 3 个文件被更改,包括 27 次插入27 次删除
  1. 6 7
      src/entry/background.js
  2. 15 15
      src/entry/content.js
  3. 6 5
      src/logic/twitter.js

+ 6 - 7
src/entry/background.js

@@ -107,13 +107,12 @@ chrome.runtime.onConnect.addListener(function (port) {
                 backTwitterPinLoginToken();
                 break;
             case "CONTENT_TWITTER_SHORT_LINK":
-                
-                backHttpTwitterShortUrl(res.url,res.tweet_id).then((item) => {
-                    // port.postMessage({
-                    //     state: "BACK_TWITTER_SHORT_LINK",
-                    //     post_id: item.post_id,
-                    //     tweet_id: res.tweet_id
-                    // });
+                backHttpTwitterShortUrl(res.url).then((item) => {
+                    port.postMessage({
+                        state: "BACK_TWITTER_SHORT_LINK",
+                        post_id: item.post_id,
+                        tweet_id: res.tweet_id
+                    });
                 })
                 break
         }

+ 15 - 15
src/entry/content.js

@@ -23,13 +23,13 @@ port.onMessage.addListener(function (res) {
         case "BACK_TWITTER_LOGIN_SUCCESS":
             showGiveDialogHandler();
             break;
-        // case "BACK_TWITTER_SHORT_LINK":
-            // console.log('BACK_TWITTER_SHORT_LINK', res)
-            // console.log('needBind', bindTwitterArt.needBind)
-            // if (bindTwitterArt.needBind) {
-            //     bindTwitterArtMethod({ postId: res.post_id, twitterId: res.tweet_id });
-            // }
-            // break
+        case "BACK_TWITTER_SHORT_LINK":
+            console.log('BACK_TWITTER_SHORT_LINK', res)
+            console.log('needBind', bindTwitterArt.needBind)
+            if (bindTwitterArt.needBind) {
+                bindTwitterArtMethod({ postId: res.post_id, twitterId: res.tweet_id });
+            }
+            break
     }
 });
 
@@ -40,14 +40,14 @@ chrome.storage.onChanged.addListener(changes => {
             init()
         }
     }
-    if (bindTwitterArt.needBind) {
-        let item = JSON.parse(changes.sortLink.newValue)
-        for (let i in item) {
-            if (item[i].tweet_id) {
-                bindTwitterArtMethod({ postId: item[i].post_id, twitterId: item[i].tweet_id });
-            }
-        }
-    }
+    // if (bindTwitterArt.needBind) {
+    //     let item = JSON.parse(changes.sortLink.newValue)
+    //     for (let i in item) {
+    //         if (item[i].tweet_id) {
+    //             bindTwitterArtMethod({ postId: item[i].post_id, twitterId: item[i].tweet_id });
+    //         }
+    //     }
+    // }
 })
 
 window.onload = () => {

+ 6 - 5
src/logic/twitter.js

@@ -67,7 +67,7 @@ export function backTwitterPinLoginCode(code) {
 
 }
 
-export function backHttpTwitterShortUrl(url,tweet_id) {
+export function backHttpTwitterShortUrl(url) {
     return new Promise(function (resolve, reject) {
         console.log('请求一次短链接')
         httpTwitterShortUrl(url).then(res => {
@@ -79,17 +79,18 @@ export function backHttpTwitterShortUrl(url,tweet_id) {
             // 解析
             let _obj = {
                 url,
-                post_id: _post_id,
-                tweet_id
+                post_id: _post_id
+                // tweet_id
             }
             getChromeStorage('sortLink', item => {
                 if (item) {
                     for (let i in item) {
                         if (item[i].url == _obj.url) {
                             item[i] = _obj
-                        }else{
-                            delete item[i].tweet_id
                         }
+                        // else{
+                        //     delete item[i].tweet_id
+                        // }
                     }
                     setChromeStorage({ sortLink: JSON.stringify(item) })
                 } else {