wenliming 2 år sedan
förälder
incheckning
2efaaa1a01

+ 5 - 1
src/entry/background.js

@@ -21,7 +21,8 @@ import {
     setActionPopup,
     getTwitterNftPostPre,
     nftTxtPublish,
-    getLuckMessage
+    getLuckMessage,
+    checkShowPublishDialog
 } from "@/logic/background/twitter";
 import Report from "@/log-center/log"
 import { PingPong, httpNetWork } from "@/logic/background/help";
@@ -109,6 +110,9 @@ function onMessageMethod(req, sender, sendResponse) {
             case "POPUP_PUBLISH_TWITTER_RED_PACK":
                 popupRePublish(req);
                 break;
+            case "POPUP_SHOW_DENET_PUBLISH_DIALOG":
+                checkShowPublishDialog();
+                break;
             case 'CONTENT_GET_PINED':
                 checkPined();
                 break;

+ 5 - 1
src/entry/content.js

@@ -37,7 +37,8 @@ import {
     setGroupInfo,
     refreshTabGroup,
     groupTipsSelectGroupTab,
-    TwitterApiUserByScreenName
+    TwitterApiUserByScreenName,
+    showPublishDialog
 } from "@/logic/content/twitter.js";
 
 import { 
@@ -186,5 +187,8 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
         case 'IFRAME_API_GET_TWEET_USER_INFO_REQ':
             TwitterApiUserByScreenName(req.data)
             break;
+        case 'BG_SHOW_DENET_PUBLISH_DIALOG':
+            showPublishDialog();
+            break;
     }
 })

+ 34 - 0
src/logic/background/twitter.js

@@ -491,4 +491,38 @@ export const nftTxtPublish = (params, sender) => {
             chrome.tabs.sendMessage(sender.tab.id, { actionType: 'BACK_NFT_PUBLISH_DONE', data: res.data }, (res) => { console.log(res) });
         }
     })
+}
+
+export const checkShowPublishDialog = (params) => {
+    const twitterUrl = 'https://twitter.com';
+
+    chrome.tabs.query({
+        active: true,
+    }, (tabs) => {
+        if(tabs && tabs.length == 1) {
+            if(tabs[0].url.startsWith(twitterUrl)) {
+                chrome.tabs.sendMessage(tabs[0].id, { 
+                    actionType: 'BG_SHOW_DENET_PUBLISH_DIALOG', 
+                    data: {} 
+                }, (res) => { console.log(res) });
+            } else {
+                createTabShowGiveaway({
+                    url: twitterUrl
+                })
+            }
+        } else {
+            createTabShowGiveaway({
+                url: twitterUrl
+            })
+        }
+    })
+}
+
+const createTabShowGiveaway = (params) => {
+    setChromeStorage({showGiveawayData : JSON.stringify({
+        show: true
+    })});
+    chrome.tabs.create({
+        url: params.url,
+    });
 }

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

@@ -587,7 +587,7 @@ function _createBtnDom() {
     dom.loadingImg = loadingImg;
 }
 
-function addSliderNavDeBtn(isSmall = false) {
+async function addSliderNavDeBtn(isSmall = false) {
     if (!isSmall) {
         let bigDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
         let deBtn = document.getElementById('de-btn');
@@ -611,6 +611,11 @@ function addSliderNavDeBtn(isSmall = false) {
             });
         }
     }
+    let { show = false } = await getChromeStorage('showGiveawayData') || {};
+    if(show) {
+        chrome.storage.local.remove("showGiveawayData");
+        showPublishDialog()
+    }
 }
 
 function onWindowResize() {
@@ -2355,3 +2360,14 @@ export const loginSuccessHandle = () => {
         addJoinedGroupList();
     })
 }
+
+export const showPublishDialog = () => {
+    let bigBtn = document.getElementById('de-btn');
+    let smallBtn = document.getElementById('de-btn3');
+
+    if(bigBtn) {
+        bigBtn.click();
+    } else if(smallBtn) {
+        smallBtn.click();
+    }
+}

+ 65 - 2
src/view/popup/currency-detail.vue

@@ -33,10 +33,24 @@
       </div>
     </div>
     <div class="bottom">
-      <div class="btn deposit-btn"
+      <template v-if="showSendBtn">
+        <div class="btn send-btn" @click="showSendGiveawayDialog">
+          <img :src="require('@/assets/svg/icon-send-giveaway.svg')" /> 
+          Send Giveaway
+        </div>
+        <div class="btn-wrapper">
+          <div class="button "
+            v-if="currencyInfo.currencyCode != 'USD'"
+            @click="clickDeposit">Deposit</div>
+          <div class="button" @click="clickWithdraw">Withdrawal</div>
+        </div>
+      </template>
+      <template v-else>
+        <div class="btn deposit-btn"
           v-if="currencyInfo.currencyCode != 'USD'"
           @click="clickDeposit">Deposit</div>
-      <div class="btn withdrawal-btn" @click="clickWithdraw">Withdrawal</div>
+        <div class="btn withdrawal-btn" @click="clickWithdraw">Withdrawal</div>
+      </template>
     </div>
 
     <template v-if="showCurrencySelect">
@@ -73,6 +87,8 @@ let showCurrencySelect = ref(false);
 
 let currencyOpertionType = '';
 
+let showSendBtn = ref(true);
+
 
 
 const selectCurrency = (params) => {
@@ -172,6 +188,13 @@ const onRefresh = () => {
   })
 };
 
+const showSendGiveawayDialog = () => {
+  chrome.runtime.sendMessage({ 
+      actionType: "POPUP_SHOW_DENET_PUBLISH_DIALOG", 
+      data: { } 
+  }, () => { });
+};
+
 onMounted(() => {
     let {params = '{}'} = router.currentRoute.value.query;
 
@@ -186,6 +209,11 @@ onMounted(() => {
         totalUsdEstimateBalance
       };
       console.log(currencyInfo.value )
+    } 
+    if(window.location.pathname.indexOf('/home.html') > -1) {
+      showSendBtn.value = false;
+    } else {
+      showSendBtn.value = true;
     }
 })
 </script>
@@ -274,6 +302,41 @@ onMounted(() => {
       box-sizing: border-box;
       color: #1d9bf0;
     }
+
+    .send-btn {
+      font-weight: 700;
+      font-size: 18px;
+      margin-bottom: 18px;
+      background: #1d9bf0;
+      color: #fff;
+      img {
+        width: 19px;
+        height: 19px;
+        margin-right: 8px;
+      }
+    }
+
+    .btn-wrapper {
+      width: 100%;
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+
+      .button {
+        width: 163px;
+        height: 50px;
+        border: 1px solid #d7e8f4;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        font-weight: 600;
+        font-size: 16px;
+        border-radius: 100px;
+        box-sizing: border-box;
+        color: #1D9BF0;
+        cursor: pointer;
+      }
+    }
   }