소스 검색

[edit][如果推特api失效,走打开标签页]

zhangwei 2 년 전
부모
커밋
19ac493365
2개의 변경된 파일18개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 1
      src/logic/content/twitter.js
  2. 12 5
      src/view/iframe/red-packet/red-packet.vue

+ 6 - 1
src/logic/content/twitter.js

@@ -787,8 +787,9 @@ const TwitterFollowAPI = (item, tweet_Id) => {
         let task_data = {
             follow_name: item.name
         }
-
         chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'follow', task_data, task_done: true }, () => { })
+    }).catch(()=>{
+        chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'follow', task_data, task_done: false }, () => { })
     })
 }
 
@@ -819,6 +820,8 @@ const TwitterRetweetAPI = (tweet_Id) => {
         "credentials": "include"
     }).then(() => {
         chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'retweet', task_data: '', task_done: true }, () => { })
+    }).catch(()=>{
+        chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'retweet', task_data: '', task_done: false }, () => { })
     })
 }
 
@@ -848,5 +851,7 @@ const TwitterLikeAPI = (tweet_Id) => {
         "credentials": "include"
     }).then(() => {
         chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: true }, () => { })
+    }).catch(()=>{
+        chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: false }, () => { })
     })
 }

+ 12 - 5
src/view/iframe/red-packet/red-packet.vue

@@ -350,7 +350,6 @@ import { srcPublishSuccess } from '@/http/publishApi'
 import { discordAuthUrl, checkGuildJoined } from '@/http/discordApi'
 import { discordAuthRedirectUri } from '@/http/configAPI'
 import GlobalTip from '@/view/components/global-tip.vue'
-import { ITEM_RENDER_EVT } from "element-plus/es/components/virtual-list/src/defaults";
 
 var moment = require('moment');
 
@@ -415,6 +414,7 @@ async function clickLikeBtn() {
       window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
       break
     case '3':
+      state.loading_show = true
       chrome.tabs.getCurrent((tab) => {
         chrome.tabs.sendMessage(tab.id, {
           actionType: "IFRAME_TWITTER_API_DO_TASK", task_data: {
@@ -515,6 +515,7 @@ async function clickRetweetBtn() {
       window.open(`https://twitter.com/intent/retweet?tweet_id=${state.tweetId}`)
       break
     case '3':
+      state.loading_show = true
       chrome.tabs.getCurrent((tab) => {
         chrome.tabs.sendMessage(tab.id, {
           actionType: "IFRAME_TWITTER_API_DO_TASK", task_data: {
@@ -633,6 +634,7 @@ async function clickFollowAll(item, is_all) {
       arr_name.forEach((item) => {
         follow_data.push(item)
       })
+      state.loading_show = true
       chrome.tabs.getCurrent((tab) => {
         chrome.tabs.sendMessage(tab.id, {
           actionType: "IFRAME_TWITTER_API_DO_TASK",
@@ -683,10 +685,6 @@ const reSetBindTwtterId = (_params) => {
   })
 }
 
-function showLastTwoPlace(n) {
-  return n
-}
-
 const showCloseEndTimePage = () => {
   state.status = 'close'
   state.close_status = '红包过期了'
@@ -909,6 +907,7 @@ function initTaskDetail() {
 
 let tab_index = 0
 const doTaskReport = (req, sender) => {
+  state.loading_show = false
   let follow_name = req.task_data.follow_name || ''
   // 1 Twitter follow Twitter ScreenName
   // 2 Tweet like
@@ -918,10 +917,17 @@ const doTaskReport = (req, sender) => {
     case 'retweet':
       event_type = 3
       state.done.retweet = req.task_done
+      if (!req.task_done && req.do_type == 'api') {
+        window.open(`https://twitter.com/intent/retweet?tweet_id=${state.tweetId}`)
+      }
       break;
     case 'like':
       event_type = 2
       state.done.like = req.task_done
+      // 
+      if (!req.task_done && req.do_type == 'api') {
+        window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
+      }
       break
     case 'follow':
       event_type = 1
@@ -953,6 +959,7 @@ const doTaskReport = (req, sender) => {
       if (!has_no_finished) {
         state.done.follow = true
         state.done.follow_red = false
+        openFollowTabs(state.detail.taskCondition[0].relatedUsers)
       }
       break
   }