فهرست منبع

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

wenliming 2 سال پیش
والد
کامیت
8dc46787e4

+ 20 - 0
src/logic/content/help/twitter.js

@@ -0,0 +1,20 @@
+
+// 根据提示dom 跳转到推文详情页面
+export const jumpTwitterDetailByAlert = () => {
+    let num = 10
+    let timer = setInterval(() => {
+        if (num <= 0) {
+            clearInterval(timer)
+            return
+        }
+        let alert = document.querySelector('div[role=alert]')
+        if (alert) {
+            let a = alert.querySelector('a')
+            if (a) {
+                clearInterval(timer)
+                a.click()
+            }
+        }
+        num--
+    }, 500)
+}

+ 14 - 8
src/logic/content/nft.js

@@ -36,6 +36,9 @@ export const showNFTGroupIcon = () => {
 export const showNFTGroupList = (e) => {
     let { top, left } = getOffsetRect(e.target);
     let oTop = top + e.target.offsetHeight + 10;
+    // 居底判断
+    let wHeight = document.body.offsetHeight || document.body.clientHeight;
+    if ((top + e.target.offsetHeight + 290) > wHeight) oTop = top - 290;
     let iframe = document.createElement('iframe');
         iframe.src = chrome.runtime.getURL(`/iframe/nft-group.html`)
         iframe.style.cssText = 'border:medium none; width:315px; height:260px;';
@@ -72,8 +75,8 @@ export const checkUserJoinGroup = (fn) => {
                     pageSize: 1
                 }
             }).then(res => {
-                let { data } = res;
-                if (data !== null) {
+                let { data = [] } = res;
+                if (data !== null && data.length > 0) {
                     ifShowNftGroup = true;
                     if (fn) fn()
                 }
@@ -115,12 +118,15 @@ export const setPostContent = (res) => {
 export const setNFTGroupContent = (res) => {
     tempNftGroupPost = res;
 
-    let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
-    if (bigBtn) {
-        bigBtn.click();
-    } else {
-        let smallBtn = document.querySelector('a[href="/compose/tweet"]')
-        smallBtn && smallBtn.click();
+    let dialogDiv = document.querySelectorAll('div[role="dialog"]');
+    if (dialogDiv.length === 0) {
+        let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
+        if (bigBtn) {
+            bigBtn.click();
+        } else {
+            let smallBtn = document.querySelector('a[href="/compose/tweet"]')
+            smallBtn && smallBtn.click();
+        }
     }
 
     let edit = document.querySelector('div[contenteditable="true"]')

+ 21 - 11
src/logic/content/twitter.js

@@ -1,11 +1,12 @@
 import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
-import { throttle, getQueryString, getCookie, nextTick ,getQueryStringByUrl} from '@/uilts/help'
+import { throttle, getQueryString, getCookie, nextTick, getQueryStringByUrl } from '@/uilts/help'
 import { discordAuthRedirectUri } from '@/http/configAPI'
 import { reportSrcPublishEvent } from '@/http/publishApi'
 import Report from "@/log-center/log"
 import { fetchAddFinishEvent } from '@/logic/background/fetch/facebook';
 import { showNFTGroupIcon, hideNFTGroupList, checkUserJoinGroup, elemAddEventListener, addJoinedGroupList } from '@/logic/content/nft';
 import { getTwitterNftGroupInfo } from '@/http/nft'
+import { jumpTwitterDetailByAlert } from '@/logic/content/help/twitter.js'
 
 let dom = {};
 
@@ -658,6 +659,7 @@ function bindTwitterArtMethod() {
 
 import parseCard from './ParseCard'
 import { renderThumbStyle } from 'element-plus'
+import { defaultNavigator } from '_@vueuse_core@8.7.4@@vueuse/core'
 
 // 检测dom改变 
 // 获取短链接 
@@ -1288,7 +1290,15 @@ const TwitterLikeAPI = (tweet_Id) => {
     })
 }
 
+
+
+let click_old_time = new Date().getTime()
 export const showTwitterPost = (data) => {
+    let click_new_time = new Date().getTime()
+    if ((click_new_time - click_old_time) < 3000) {
+        return
+    }
+    click_old_time = click_new_time
     let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
     if (bigBtn) {
         bigBtn.click();
@@ -1353,9 +1363,8 @@ export function publishNFTTweetEvent({ groupId, postId, srcContent }) {
                 actionType: "CONTENT_NFT_TXT_PUBLISH",
                 data: params
             }, () => { });
-
+            jumpTwitterDetailByAlert()
             setTimeout(() => {
-                document.querySelector('a[data-testid="AppTabBar_Profile_Link"]').click();
                 setGroupTabSelfStyle({
                     groupColor: 'rgb(83, 100, 113)',
                     groupFontWeight: '500',
@@ -1384,12 +1393,13 @@ export const setTwitterTextarea = (params) => {
     if (inputEle) {
         inputEle.focus();
         document.execCommand("insertText", false, '');
-    }
-    setTimeout(() => {
-        document.execCommand("insertText", false, params.srcContent);
-    }, 1000);
 
-    publishNFTTweetEvent(params)
+        setTimeout(() => {
+            document.execCommand("insertText", false, params.srcContent);
+        }, 1000);
+
+        publishNFTTweetEvent(params)
+    }
 }
 
 
@@ -1788,9 +1798,9 @@ const addGroupTab = () => {
 const hiddenMaskWeb3Tab = (count) => {
     setTimeout(() => {
         count++;
-        if(count < 6) {
+        if (count < 6) {
             let tab = getMaskWeb3Tab();
-            if(tab) {
+            if (tab) {
                 tab.style.display = 'none'
             } else {
                 hiddenMaskWeb3Tab(count);
@@ -1852,7 +1862,7 @@ const addGroupTabEventListener = () => {
         window.addEventListener('scroll', addPageScrollEvent);
 
         let tipsDom = document.querySelector('#denet_group_tip');
-        if(tipsDom) {
+        if (tipsDom) {
             chrome.runtime.sendMessage({
                 actionType: "SWITCH_GROUP_BANNER_STATUS",
                 data: { type: 'btn' }

+ 16 - 2
src/view/iframe/buy-nft/group/tip.vue

@@ -51,10 +51,11 @@
 import { reactive, onMounted } from 'vue'
 import { useRouter } from 'vue-router'
 import { setGroupJoin } from '@/http/group.js'
+import { ElMessage } from 'element-plus'
 import { sendChromeTabMessage } from '@/uilts/chromeExtension.js';
 let state = reactive({
     show: 'tip',
-    params:{}
+    params: {}
 })
 const router = useRouter()
 
@@ -69,6 +70,20 @@ const clickJoin = () => {
             state.show = 'success'
             state.params.type = 'buy'
             sendChromeTabMessage({ actionType: "FINISH_GROUP_BANNNER" }, () => { })
+        } else {
+            let msg = ''
+            switch(res.code.toSrting()){
+                case '':
+                    break
+                default:
+                    msg = res.msg
+            }
+            ElMessage({
+                message: msg,
+                grouping: true,
+                type: 'warning',
+                appendTo: document.body
+            })
         }
     })
 }
@@ -91,7 +106,6 @@ const clickFinish = () => {
 
 onMounted(() => {
     let params = router.currentRoute.value.query.params || {}
-    debugger
     state.params = JSON.parse(params)
 })
 

+ 1 - 0
src/view/iframe/group-card/card.vue

@@ -93,6 +93,7 @@ const init = (callback) => {
                 } else if (res.data.joinStatus == 1) {
                     state.show2 = 'post'
                 }
+                // state.show2 = 'join'
                 callback && callback()
             }
         }