瀏覽代碼

[bug][固定右上角]

zhangwei 2 年之前
父節點
當前提交
9d4b6deb85

+ 7 - 0
src/assets/svg/icon-iframe-pinned.svg

@@ -0,0 +1,7 @@
+<svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
+<mask id="path-1-inside-1_22953_197808" fill="white">
+<rect x="4" y="8" width="72" height="64" rx="4"/>
+</mask>
+<rect x="4" y="8" width="72" height="64" rx="4" fill="#D9D9D9" fill-opacity="0.01" stroke="#8E8E8E" stroke-width="12" mask="url(#path-1-inside-1_22953_197808)"/>
+<rect x="36" y="20" width="28" height="20" fill="#8E8E8E"/>
+</svg>

+ 2 - 1
src/entry/background.js

@@ -141,7 +141,7 @@ function onInstalledMethod() {
 
 function onMessageMethod(req, sender, sendResponse) {
     try {
-        sendResponse(req.actionType || 'ok')
+
         if (req) {
             switch (req.actionType) {
                 case "POPUP_LOGIN":
@@ -201,6 +201,7 @@ function onMessageMethod(req, sender, sendResponse) {
                     httpContentToBack(req, sender)
                     break
                 case 'CONTENT_TWITTER_SHORT_LINK':
+                    sendResponse('ok')
                     req.arr_url.forEach(item => {
                         if (item) {
                             twitterShortUrl(sender, item)

+ 4 - 20
src/entry/content.js

@@ -106,11 +106,6 @@ window.onmessage = (res) => {
 
 
 chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-    if (req.actionType == 'Get_ToolBox_Fixed_TweetId') {
-        sendResponse(toolbox_fixed_tweetId)
-        return
-    }
-    sendResponse(req.actionType || 'ok')
     switch (req.actionType) {
         case 'BG_SHOW_PIN_TIPS':
             showPinTips()
@@ -119,7 +114,6 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             showGiveDialogHandler();
             break
         case 'BACK_TWITTER_SHORT_URL':
-            console.log('BACK_TWITTER_SHORT_URL')
             changeQueueNum(1)
             break
         case 'IFRAME_TWITTER_API_DO_TASK':
@@ -129,40 +123,31 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             showNFTSale()
             break
         case 'IFRAME_NFT_GROUP_LIST_HIDE':
-
             hideNFTGroupList()
             break;
         case 'IFRAME_NFT_GROUP_SET_CONTENT':
-
             setNFTGroupContent(req.publishRes);
             break;
         case "IFRAME_TWITTER_PUBLISH":
-
             twitterPublishHandler(req.publishRes);
             break;
         case 'IFRAME_TWITTER_SHOW_POPUP_PAGE':
-
             let { from = '', showJoinGroupFinish } = req.data || {};
             showPopupPage({ path: '/NFT', from, showJoinGroupFinish });
             break
         case "IFRAME_TWITTER_SHOW_BUY_NFT":
-
             showBuyNFT(req.data)
             break
         case 'IFRAME_TWITTER_HIDE_BUY_NFT':
-
             hideBuyNFT()
             break
         case 'BG_SET_POPUP_CONFIG':
-
             setPopupConfByPopupPage();
             break
         case 'IFREME_TAB_GROUP_SET_IFRAME_HEIGHT':
-
             setTabGroupIframeStyle(req.data);
             break
         case 'IFREME_TAB_GROUP_CONTENT_GET_NAV_TOP':
-
             getTweetProfileNavTop(req.data);
         case 'IFRAME_PAGE_JUMP':
 
@@ -185,11 +170,10 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             showTwitterPost(req.data)
             break
         case 'BACK_TWITTER_NFT_POST_PRE':
-
             setTwitterTextarea(req.data)
             break
         case 'SWITCH_GROUP_STATUS':
-
+            sendResponse('ok')
             groupTipsSelectGroupTab(req.data);
             break
         case 'IFRAME_GROUP_BANNER_GROUP_INFO':
@@ -210,14 +194,14 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             break;
         // 回掉参数
         case 'HTTP_BACK_TO_CONTENT':
-
             httpBackToContentCallBack(req)
             break
         case 'BG_SHOW_DENET_PUBLISH_DIALOG':
-
             showPublishDialog();
             break;
-
+        case 'Get_ToolBox_Fixed_TweetId':
+            sendResponse(toolbox_fixed_tweetId)
+            break
         case 'Set_ToolBox_Fixed':
             toolBox.switchStatus(req)
             break

+ 1 - 1
src/entry/content_help.js

@@ -41,7 +41,7 @@ chrome.runtime.sendMessage({
 }, () => { });
 
 chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-    sendResponse(req.actionType || 'ok')
+
     switch (req.actionType) {
         case 'BACK_PING':
             chrome.runtime.sendMessage({ actionType: "CONTENT_PONG", data: '1' }, (res) => { console.log(res) })

+ 0 - 1
src/logic/content/ToolBox.js

@@ -25,7 +25,6 @@ export const toolBox = new class ToolBox {
     switchStatus(req) {
         toolbox_fixed_tweetId = req.data.tweetId
         let dom_fixed = $('#denet-tool-box-fixed')
-        debugger
         switch (req.data.type) {
             case '全屏':
                 dom_fixed.style.cssText = `

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

@@ -130,7 +130,6 @@ const init = (callback) => {
 }
 
 chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-    sendResponse(req.actionType || '')
     switch (req.actionType) {
         case 'FINISH_GROUP_BANNNER':
             init()

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

@@ -107,7 +107,7 @@ onMounted(() => {
 
     // 登录回调
     chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-        sendResponse(req.actionType || 'ok')
+
         switch (req.actionType) {
             case 'BG_LOGIN_SET_USERINFO_CB':
                 getDetail();

+ 1 - 1
src/view/iframe/publish/tool-box/child/editor.vue

@@ -233,7 +233,7 @@ const getAppList = () => {
 
 const onRuntimeMsg = () => {
   chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-    sendResponse(req.actionType || 'ok')
+
     switch (req.actionType) {
       case 'CONTENT_GET_GUIDE_DATA':
         chrome.runtime.sendMessage({

+ 1 - 1
src/view/iframe/publish/tool-box/child/guide.vue

@@ -62,7 +62,7 @@ const confirm = () => {
 
 const onRuntimeMsg = () => {
     chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-        sendResponse(req.actionType || 'ok')
+
         switch (req.actionType) {
             case 'CONTENT_EDIT_SEND_GUIDE_DATA':
                 let { guideData, windowData } = req.data;

+ 1 - 1
src/view/iframe/red-packet/luck-draw.vue

@@ -1980,7 +1980,7 @@ function onPageVisbile() {
 
 function onRuntimeMsg() {
     chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-        sendResponse(req.actionType || 'ok');
+        ;
         switch (req.actionType) {
             case 'BACK_DISCORD_LOGIN_SUCCESS':
                 discordLoginSuccess();

+ 1 - 1
src/view/iframe/red-packet/red-packet.vue

@@ -1775,7 +1775,7 @@ function onPageVisbile() {
 
 function onRuntimeMsg() {
   chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-    sendResponse(req.actionType || 'ok');
+    ;
     switch (req.actionType) {
       case 'BACK_DISCORD_LOGIN_SUCCESS':
         discordLoginSuccess();

+ 1 - 1
src/view/iframe/tab-group/tab-group.vue

@@ -104,7 +104,7 @@ const clickItem = (data, index) => {
 
 function onRuntimeMsg() {
     chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-        sendResponse(req.actionType || 'ok')
+
         switch (req.actionType) {
             case 'CONTENT_REFRESH_TAB_GROUP_LIST':
                 listReqParams.params.preTimestamp = ''

+ 23 - 14
src/view/iframe/tool-box/card.vue

@@ -34,8 +34,8 @@
             <!-- 固定右上角 -->
             <div class="state" v-show="state.status == '固定右上角'">
                 <div class="info">
-                    <img :src="require('@/assets/img/icon-fixed-gray.png')" alt />
-                    <div>Pinned to the top right</div>
+                    <img :src="require('@/assets/svg/icon-iframe-pinned.svg')" alt />
+                    <div class="pinned">Pinned to the top right</div>
                 </div>
             </div>
         </div>
@@ -94,7 +94,7 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
     switch (req.actionType) {
         // 事件传输
         case 'Set_ToolBox_Fixed':
-            sendResponse(req.actionType || 'ok')
+
             if (req.data.tweetId == state.tweetId && req.data.type == '关闭') {
                 state.show_btn = true
                 state.status = ''
@@ -127,18 +127,22 @@ onMounted(() => {
     sendChromeTabMessage({
         actionType: 'Get_ToolBox_Fixed_TweetId'
     }, (res) => {
-        console.log('Get_ToolBox_Fixed_TweetId', res)
         if (res == state.tweetId) {
             state.status = '固定右上角'
-            return
+        } else {
+            getDetail()
         }
     })
-    getDetail()
+
 })
 
 // detail函数
 const getDetail = () => {
     state.status = '加载'
+    let iframe = dom_iframe.value
+    iframe.onerror = () => {
+        state.status = '网页错误'
+    }
     getPostDetail({
         params: {
             postId: state.postId
@@ -148,12 +152,7 @@ const getDetail = () => {
             state.detail = JSON.parse(res.data.postBizData)
             console.log('postBizData', state.detail)
             // 加载iframe
-            let iframe = dom_iframe.value
-            iframe.onerror = () => {
-                state.status = '网页错误'
-            }
             state.cover_url = state.detail.linkImagePath
-
             setTimeout(() => {
                 state.iframe_url = state.detail.convertUrl
                 state.status = ''
@@ -394,7 +393,12 @@ body,
 
         .state {
             text-align: center;
+            width: 100%;
+            height: 100%;
             position: relative;
+            display: flex;
+            justify-content: center;
+            align-items: center;
 
             .cover {
                 width: 100%;
@@ -402,6 +406,10 @@ body,
                 opacity: 0.6;
             }
 
+            .icon-loading {
+                animation: loading 1s infinite linear;
+            }
+
             .info {
                 position: absolute;
                 width: 100%;
@@ -418,9 +426,6 @@ body,
                 }
 
 
-                .icon-loading {
-                    animation: loading 1s infinite linear;
-                }
 
                 div {
                     margin-bottom: 40px;
@@ -429,6 +434,10 @@ body,
                     font-weight: 500;
                     font-size: 22px;
                 }
+
+                .pinned {
+                    color: #8E8E8E;
+                }
             }
 
         }

+ 4 - 28
src/view/iframe/tool-box/full.vue

@@ -22,37 +22,13 @@ import { sendChromeTabMessage } from "@/uilts/chromeExtension";
 import IconSvg from '@/view/components/icon-svg.vue'
 
 let state = reactive({
-    status: '固定', // 全屏
+    status: '固定右上角', // 全屏
     iframe_url: '',
     tweetId: ''
 })
-let dom_fixed = null
-
-window.addEventListener("onEvent", e => {
-    let info = e.detail
-    switch (info.event_type) {
-        // 固定
-        case 'ToolBox_To_Fixed':
-            // 替换
-            if (state.iframe_url || state.tweetId) {
-                sendClose()
-            }
-            state.iframe_url = info.data.iframe_url
-            state.tweetId = info.data.tweetId
-            break
-        case 'ToolBox_To_Full':
-            if (state.iframe_url || state.tweetId) {
-                sendClose()
-            }
-            state.status = '全屏'
-            state.iframe_url = info.data.iframe_url
-            state.tweetId = info.data.tweetId
-            break
-    }
-});
 
 chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-    sendResponse(req.actionType || 'ok')
+
     switch (req.actionType) {
         // 事件传输
         case 'Set_ToolBox_Fixed':
@@ -72,11 +48,11 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
 
 
 const clickFull = () => {
-    if (state.status == '固定') {
+    if (state.status == '固定右上角') {
         state.status = '全屏'
         changeFull()
     } else {
-        state.status = '固定'
+        state.status = '固定右上角'
         changeFixed()
     }
 }

+ 1 - 1
src/view/popup/components/tabbar.vue

@@ -160,7 +160,7 @@ const onMessage = () => {
 }
 
 const msgListener = (req, sender, sendResponse) => {
-    sendResponse(req.actionType || 'ok');
+    ;
     switch (req.actionType) {
         case 'CONTENT_POPUP_PAGE_SHOW':
             init();

+ 1 - 1
src/view/popup/tabbar-page/index.vue

@@ -111,7 +111,7 @@ const onRuntimeMsg = () => {
 }
 
 const msgListener = (req, sender, sendResponse) => {
-  sendResponse(req.actionType || 'ok');
+  ;
   switch (req.actionType) {
     case 'BG_LOGIN_SET_USERINFO_CB':
       if (!userInfo.value.accessToken) {

+ 1 - 1
src/view/popup/tabbar-page/message/index.vue

@@ -481,7 +481,7 @@ const onMessage = () => {
 }
 
 const msgListener = (req, sender, sendResponse) => {
-  sendResponse(req.actionType || 'ok');
+  ;
   switch (req.actionType) {
     case 'CONTENT_POPUP_PAGE_SHOW':
       init();

+ 1 - 1
src/view/popup/tabbar-page/nft/index.vue

@@ -84,7 +84,7 @@ const onMessage = () => {
 }
 
 const msgListener = (req, sender, sendResponse) => {
-  sendResponse(req.actionType || 'ok');
+  ;
   switch (req.actionType) {
     case 'CONTENT_POPUP_PAGE_SHOW':
       getNFTListMine();

+ 1 - 1
src/view/popup/tabbar-page/wallter/popup.vue

@@ -200,7 +200,7 @@ const onMessage = () => {
 }
 
 const msgListener = (req, sender, sendResponse) => {
-    sendResponse(req.actionType || 'ok');
+    ;
     switch (req.actionType) {
         case 'CONTENT_POPUP_PAGE_SHOW':
             init();