A\An 2 سال پیش
والد
کامیت
b7e83aafb6

+ 5 - 1
src/entry/content.js

@@ -17,7 +17,8 @@ import {
     hideNoticeBindTweet,
     getTweetAuthorByDom,
     facebookReplyTweet,
-    doTaskTwitterAPI
+    doTaskTwitterAPI,
+    onTweetReplyClick
 } from "@/logic/content/twitter.js";
 import { duration } from "moment";
 
@@ -62,6 +63,9 @@ window.onmessage = (res) => {
             case "IFRAME_RED_PACKET_CHECK_FACEBOOK_REPLY":
                 facebookReplyTweet(res.data.data || {});
                 break;
+            case "IFRAME_RED_PACKET_ON_TWEET_REPLY_CLICK":
+                onTweetReplyClick(res.data.data || {});
+                break;
             // case 'IFRAME_TWITTER_API_DO_TASK':
             //     doTaskTwitterAPI(res.data)
             //     break

+ 1 - 1
src/http/configAPI.js

@@ -1,4 +1,4 @@
-export const appVersionCode = 5
+export const appVersionCode = 6
 
 const api = {
 	production: 'https://api.denetme.net',

+ 12 - 3
src/iframe/publish-tips.js

@@ -1,10 +1,19 @@
 import { createApp } from 'vue'
 import App from '@/view/iframe/publish-tips/publish-tips.vue'
-import ElementPlus from 'element-plus'
-import 'element-plus/dist/index.css'
+// import ElementPlus from 'element-plus'
+// import 'element-plus/dist/index.css'
 
+import "ant-design-vue/dist/antd.css"; // or 'ant-design-vue/dist/antd.less'
+import "@/assets/css/reset.css";
+
+import { message } from "ant-design-vue";
+message.config({
+    top: `20px`,
+    duration: 3,
+    maxCount: 1,
+});
 
 const app = createApp(App);
 
-app.use(ElementPlus);
+app.use(message);
 app.mount('#app');

+ 3 - 6
src/logic/content/facebook.js

@@ -43,17 +43,14 @@ function formatContentStr(content) {
  */
 async function setShareInputContent() {
     let shareData = await getChromeStorage('shareFacebookData') || {};
-    console.log(shareData);
     const contentStr = formatContentStr(shareData.contentStr);
 
     if (!tempData.isSetContent && contentStr) {
         tempData.isSetContent = true;
+        document.execCommand("insertText", false, contentStr);
         setTimeout(() => {
-            document.execCommand("insertText", false, contentStr);
-            setTimeout(() => {
-                tempData.isSetContent = false;
-            }, 800)
-        }, 600);
+            tempData.isSetContent = false;
+        }, 300)
     }
 }
 

+ 68 - 28
src/logic/content/twitter.js

@@ -180,7 +180,8 @@ function _publishTweetEvent(params, cb) {
 function checkIsShowReSend(dom, params) {
     let str = dom.querySelector('div[data-contents="true"]').innerHTML;
     if (str.indexOf('#DeNet') < 0 || str.indexOf(params.postId) < 0) {
-        noticeBindTweet({ postId: params.postId, taskLuckdropId: '' });
+        let taskLuckdropId = JSON.parse(params.postBizData).taskLuckdropId;
+        noticeBindTweet({ postId: params.postId, taskLuckdropId});
     }
 }
 
@@ -303,10 +304,12 @@ function addPublishTipsIframe({ srcContent }) {
         if (dialog) {
             let right = dialog.offsetLeft - 15 - 266, top = window.innerHeight * 0.05 + dialog.offsetHeight - 60 - 160;
 
+            top = top - 80 > 0 ? top - 80 : 0;
+
             let iframe = document.createElement('iframe');
             iframe.id = 'de-publish-tips'
             iframe.src = chrome.runtime.getURL('/iframe/publish-tips.html');
-            iframe.style.cssText = `border: medium none; width:266px;min-height:178px;position: fixed; right: ${right}px; top: ${top}px;`
+            iframe.style.cssText = `border: medium none; width:270px;height:500px;position: fixed; right: ${right}px; top: ${top}px;z-index: -1`
             let iframeContent = document.getElementById('de-publish-tips');
             if (!iframeContent) {
                 dialog.appendChild(iframe)
@@ -742,43 +745,80 @@ export function replyHandle(params) {
     if (replyBtn) {
         replyBtn.click();
     }
+    onReplyDialogOpen(params, iframe);
+
+    // 详情页推文底部评论处理
+    let pathNameArr = window.location.pathname.split('/');
+    if (pathNameArr.length >= 2 && pathNameArr[pathNameArr.length - 2] == 'status') {
+        let tweetReply = document.querySelector('div[data-testid="tweetButtonInline"]');
+        if(tweetReply) {
+            tweetReply.addEventListener('click', function() {
+                let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
+                reportReplyResult(eleList, params, () => {
+                    iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
+                });
+            })
+        }
+    }
+}
+
+export function onTweetReplyClick(params) {
+    let iframe = window.parent.document.getElementById(params.postId);
+    let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
+        iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
+    if (replyBtn) {
+        replyBtn.addEventListener('click', () => {
+            onReplyDialogOpen(params, iframe);
+        })
+    }
+}
 
+function onReplyDialogOpen(params, iframe) {
     setTimeout(() => {
         let dialog = document.querySelector('div[role="dialog"]');
         if (dialog) {
             let replyBtn = dialog.querySelector('div[data-testid="toolBar"]').querySelector('div[data-testid="tweetButton"]');
             replyBtn.addEventListener('click', function () {
                 let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
-                if (eleList && eleList.length) {
-                    let atList = [];
-                    for (let i = 0; i < eleList.length; i++) {
-                        let item = eleList[i];
-                        // 是否有中文
-                        let reg = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g;
-
-                        if (item && item.innerText.startsWith('@') && !reg.test(item.innerText)) {
-                            atList.push({
-                                text: item.innerText
-                            })
-                        }
-                    }
-
-                    if (atList.length >= 3) {
-                        fetchAddFinishEvent({
-                            eventType: params.type,
-                            luckdropId: params.taskLuckdropId
-                        }).then(res => {
-                            if (res.code == 0) {
-                                // 上報完成
-                                iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
-                            }
-                        })
-                    }
-                }
+                reportReplyResult(eleList, params, () => {
+                    // 上報完成
+                    iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
+                })
             });
         }
     }, 1000);
 }
+
+const reportReplyResult = throttle(function (eleList, params, cb) {
+    if (eleList && eleList.length) {
+        let atList = [];
+        for (let i = 0; i < eleList.length; i++) {
+            let item = eleList[i];
+            // 是否有中文
+            let reg = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g;
+
+            if (item && item.innerText.startsWith('@') && !reg.test(item.innerText)) {
+                atList.push(item.innerText);
+            }
+        }
+
+        atList = Array.from(new Set(atList));
+
+        if (atList.length >= 3) {
+            fetchAddFinishEvent({
+                eventType: params.type,
+                luckdropId: params.taskLuckdropId
+            }).then(res => {
+                if (res.code == 0) {
+                    cb && cb();
+                }
+            })
+        }
+    }
+}, 800);
+
+
+
 // 根据推特id找到dom,完成任务
 export function findTweetByIdDoTask({ tweet_Id = '', follow_names = [] }, task_type = 'like') {
     // 1.根据推特ID寻找推文,获取卡片

+ 12 - 21
src/view/iframe/publish-tips/publish-tips.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="tips-wrapper">
+    <div class="publish-tips-wrapper">
         <div class="top">
             <img src="@/assets/svg/icon-bells.svg" class="icon-bells">
             <div class="text-wrapper">
@@ -7,7 +7,7 @@
                     Do not delete the
                 </div>
                 <div>
-                    <span>#DeNet</span>and<span> Giveaway link</span>
+                    <span>#DeNet </span>and<span> Giveaway link</span>
                     otherwise the giveaway will not be available
                 </div>
             </div>
@@ -21,7 +21,7 @@
 <script setup>
 /* eslint-disable */
 import { onMounted, ref } from "vue";
-import { ElMessage } from 'element-plus'
+import { message } from 'ant-design-vue';
 import { getChromeStorage } from '@/uilts/chromeExtension.js'
 
 let ClipboardJS = require('clipboard');
@@ -30,17 +30,10 @@ let strContent = ref('');
 
 const copyToken = async () => {
     let publishData = await getChromeStorage('publishData');
-    strContent.value = publishData.srcContent;
+    strContent.value = publishData.copyContent;
     var clipboard = new ClipboardJS('.copy-btn');
     clipboard.on('success', function (e) {
-        // ElMessage({
-        //     message: 'copy success',
-        //     grouping: true,
-        //     type: 'success',
-        //     offset: -16,
-        //     appendTo: document.body
-
-        // })
+        message.success('copy success');
         console.info('Action:', e.action);
         console.info('Text:', e.text);
         console.info('Trigger:', e.trigger);
@@ -49,12 +42,6 @@ const copyToken = async () => {
     });
 
     clipboard.on('error', function (e) {
-        // ElMessage({
-        //     message: 'copy error',
-        //     grouping: true,
-        //     type: 'error',
-        //     offset: -16
-        // })
         console.error('Action:', e.action);
         console.error('Trigger:', e.trigger);
     });
@@ -66,14 +53,17 @@ onMounted(() => {
 
 </script>
 
-<style scoped lang="scss">
-.tips-wrapper {
+<style  lang="scss">
+body {
+    overflow-y: hidden;
+}
+.publish-tips-wrapper {
     width: 100%;
-    height: 100%;
     box-sizing: border-box;
     background: #FFFFFF;
     border-radius: 12px;
     padding: 15px;
+    margin-top: 88px;
     .top {
         display: flex;
 
@@ -86,6 +76,7 @@ onMounted(() => {
         .text-wrapper {
             font-weight: 500;
             font-size: 14px;
+            line-height: 17px;
 
             span {
                 color: red;

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

@@ -75,7 +75,7 @@
           <template v-if="item.type == 9">
             <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
             <div class="item-content">
-              <div class="item-title">Comment and tag 3 friends</div>
+              <div class="item-title">Comment and Tag 3 friends</div>
             </div>
             <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
               v-show="!state.done.reply && state.done.reply_red" />
@@ -580,6 +580,16 @@ async function clickRetweetBtn() {
   });
 }
 
+function onTweetReplyClick(params) {
+    let replyData = {
+      postId: state.postId,
+      type: params.type,
+      taskLuckdropId: state.detail.taskLuckdropId
+    }
+
+     window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_ON_TWEET_REPLY_CLICK",  data: replyData}, "*");
+}
+
 async function clickReply(params) {
     let _userInfo = await checkIsLogin()
     if (!_userInfo) {
@@ -1021,8 +1031,7 @@ function init(initParams) {
       }
       state.detail = JSON.parse(res.data.postBizData)
       state.detail.taskCondition = state.detail.taskCondition || []
-      console.log(state.detail)
-
+      checkFacebookReply();
       handleStatusPage()
     } else {
       handleErrorCode(res)
@@ -1061,6 +1070,9 @@ function initTaskDetail() {
                 break;
               case 9:
                 state.done.reply = res.data[i].finished;
+                if(!state.done.reply) {
+                  onTweetReplyClick({type: 9});
+                }
                 break;
             }
           }
@@ -1152,7 +1164,6 @@ onMounted(() => {
   state.window_origin = getQueryString('window_origin');
 
   getTweetAuthor();
-  checkFacebookReply();
 
   init()
   // state.loading_show = true
@@ -2167,8 +2178,10 @@ body {
       .item {
         display: flex;
         align-items: center;
-        min-height: 50px;
+        // min-height: 50px;
         border-bottom: 1px solid #f0f0f0;
+        padding: 12px 0;
+        box-sizing: border-box;
 
         img {
           width: 24px;