Ver Fonte

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

wenliming há 2 anos atrás
pai
commit
3aef0bc61c

+ 8 - 2
src/entry/background.js

@@ -154,14 +154,17 @@ function onInstalledMethod({ id, previousVersion, reason }) {
         // 3.onInstalledMethod 执行了那个
         // 版本更新判断
         getChromeStorage('baseInfo', (info) => {
+            // 第一次安装
             if (!info || !info.appVersionCode) {
                 setChromeStorage({ onInstalledMethod: JSON.stringify({ onInstalledMethod: '1' }) })
                 setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) })
                 thenInstalledMethod()
+
+                // 版本更新了
             } else if (appVersionCode != info.appVersionCode) {
                 setChromeStorage({ onInstalledMethod: JSON.stringify({ onInstalledMethod: '2' }) }, () => {
                     setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) }, () => {
-                        chrome.runtime.reload()
+                        // chrome.runtime.reload()
                         onInstalledUserSet()
                     })
                 })
@@ -169,8 +172,11 @@ function onInstalledMethod({ id, previousVersion, reason }) {
                 setChromeStorage({ onInstalledMethod: JSON.stringify({ onInstalledMethod: '3' }) })
                 thenInstalledMethod()
             }
+            console.log('1-appVersionCode', appVersionCode)
+            console.log('1-info.appVersionCode', info.appVersionCode)
+            console.log('1-info', info)
         })
-
+        console.log('2-appVersionCode', appVersionCode)
         // 1.onUpdateAvailable 存储到本地,再上报
         getChromeStorage('onUpdateAvailable', (res) => {
             if (res && res.onUpdateAvailable) {

+ 0 - 1
src/entry/content.js

@@ -164,7 +164,6 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
         // case 'IFREME_TAB_GROUP_CONTENT_GET_NAV_TOP':
         //     getTweetProfileNavTop(req.data);
         case 'IFRAME_PAGE_JUMP':
-
             pageJumpHandler(req.data);
             break;
         case 'BG_LOGIN_SET_USERINFO_CB':

+ 43 - 41
src/entry/content_help.js

@@ -5,50 +5,52 @@ import {
 import { createApp } from 'vue'
 import ViewMessage from '@/view/content/message/index.vue'
 import CoutomSentry from "@/uilts/sentry.js"
-
-const addDomMessage = (element) => {
-    const div = document.createElement('div')
-    div.id = 'denet_message'
-    document.body.appendChild(div)
-    let app = createApp(element)
-    app.mount('#denet_message')
-    CoutomSentry.initVue(app)
-}
-
-let timer = setInterval(() => {
-    if (document.body) {
-        init()
-        clearInterval(timer)
+try {
+    const addDomMessage = (element) => {
+        const div = document.createElement('div')
+        div.id = 'denet_message'
+        document.body.appendChild(div)
+        let app = createApp(element)
+        app.mount('#denet_message')
+        CoutomSentry.initVue(app)
     }
-}, 1000)
 
-const init = () => {
-    // appendPopupPage();
-    addDomMessage(ViewMessage)
+    let timer = setInterval(() => {
+        if (document.body) {
+            init()
+            clearInterval(timer)
+        }
+    }, 1000)
+
+    const init = () => {
+        // appendPopupPage();
+        addDomMessage(ViewMessage)
+
+        chrome.runtime.sendMessage({
+            actionType: "CONTENT_WINDOW_LOADED_SET_POPUP_PAGE",
+            data: {}
+        });
+    }
 
     chrome.runtime.sendMessage({
-        actionType: "CONTENT_WINDOW_LOADED_SET_POPUP_PAGE",
-        data: {}
+        actionType: "CONTENT_SET_POPUP_CONFIG",
+        data: {
+            popup: 'popup.html'
+        }
     });
-}
-
 
-chrome.runtime.sendMessage({
-    actionType: "CONTENT_SET_POPUP_CONFIG",
-    data: {
-        popup: 'popup.html'
-    }
-});
-
-chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
-
-    switch (req.actionType) {
-        case 'BACK_PING':
-            chrome.runtime.sendMessage({ actionType: "CONTENT_PONG", data: '1' }, (res) => { console.log(res) })
-            break
-        case 'BG_INJECT_EXTENSION_POPUP':
-            tiggerInjectPopupPage();
-            break
-    }
-    sendResponse && sendResponse()
-})
+    chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
+
+        switch (req.actionType) {
+            case 'BACK_PING':
+                chrome.runtime.sendMessage({ actionType: "CONTENT_PONG", data: '1' }, (res) => { console.log(res) })
+                break
+            case 'BG_INJECT_EXTENSION_POPUP':
+                tiggerInjectPopupPage();
+                break
+        }
+        sendResponse && sendResponse()
+    })
+} catch (error) {
+    console.log('catch', error)
+}

+ 6 - 4
src/logic/background/facebook.js

@@ -5,9 +5,9 @@ import Report from "@/log-center/log"
  * facebook分享成功逻辑
  */
 export function facebookShareSuccess(params, sender) {
-    try{
-        let {data} = params;
-        let {id} = sender.tab || {};
+    try {
+        let { data } = params;
+        let { id } = sender.tab || {};
         chrome.tabs.remove(id);
 
         fetchAddFinishEvent({
@@ -22,6 +22,8 @@ export function facebookShareSuccess(params, sender) {
                     });
                 })
             }
+        }).catch((error) => {
+            console.log('catch', error)
         })
     } catch (error) {
         Report.reportLog({
@@ -34,7 +36,7 @@ export function facebookShareSuccess(params, sender) {
 
 
 function sendActivetabMessage(message = {}) {
-    try{
+    try {
         chrome.tabs.query({
             active: true,
             currentWindow: true

+ 25 - 9
src/logic/background/twitter.js

@@ -111,6 +111,8 @@ export function twitterPinLoginCode(sender, code) {
                     setMessageCount()
                     chrome.cookies.remove(LANDING_PAGE)
                 }
+            }).catch((error) => {
+                console.log('catch', error)
             })
         })
     } catch (error) {
@@ -146,6 +148,8 @@ export function discordLoginCode({ code }, sender) {
                     });
                 })
             }
+        }).catch((error) => {
+            console.log('catch', error)
         })
     } catch (error) {
         Report.reportLog({
@@ -204,6 +208,8 @@ export function twitterShortUrl(sender, url) {
                 //     state: "BACK_TWITTER_SHORT_URL"
                 // });
             })
+        }).catch((error) => {
+            console.log('catch', error)
         })
     } catch (error) {
         Report.reportLog({
@@ -264,6 +270,8 @@ export function onInstalledUserSet() {
                     }
                 }
             })
+        }).catch((error) => {
+            console.log('catch', error)
         })
     } catch (error) {
         Report.reportLog({
@@ -302,7 +310,7 @@ function sendActivetabMessage(message = {}) {
             active: true,
             currentWindow: true
         }, (tabs) => {
-            if(tabs && tabs.length) {
+            if (tabs && tabs.length) {
                 chrome.tabs.sendMessage(tabs[0].id, message)
             }
         })
@@ -404,14 +412,14 @@ export function onInstalledCreateTab() {
                     }
                     break
                 case 'treasure_info':
-                  if (res && res.postNickName && res.srcContentId) {
-                      created_detail = true
-                      url = `https://twitter.com/${res.postNickName}/status/${res.srcContentId}`
-                      chrome.tabs.create({
-                          url
-                      });
-                  }
-                  break;
+                    if (res && res.postNickName && res.srcContentId) {
+                        created_detail = true
+                        url = `https://twitter.com/${res.postNickName}/status/${res.srcContentId}`
+                        chrome.tabs.create({
+                            url
+                        });
+                    }
+                    break;
             }
 
             if (created_detail == false) {
@@ -532,6 +540,8 @@ export function getMessageInfo() {
                     hideBadge();
                 }
             }
+        }).catch((error) => {
+            console.log('catch', error)
         })
     } catch (error) {
         Report.reportLog({
@@ -627,6 +637,8 @@ export const getSysMessage = () => {
             .then((res) => {
                 // 向选中的content发送消息
                 setContentMessage({ actionType: 'BACK_UNREAD_MESSAGE', data: res })
+            }).catch((error) => {
+                console.log('catch', error)
             })
     } catch (error) {
         Report.reportLog({
@@ -686,6 +698,8 @@ export const getTwitterNftPostPre = (params, sender) => {
         if (res.code == 0) {
             chrome.tabs.sendMessage(sender.tab.id, { actionType: 'BACK_TWITTER_NFT_POST_PRE', data: res.data }, (res) => { console.log(res) });
         }
+    }).catch((error) => {
+        console.log('catch', error)
     })
 }
 
@@ -695,6 +709,8 @@ export const nftTxtPublish = (params, sender) => {
         if (res.code == 0) {
             chrome.tabs.sendMessage(sender.tab.id, { actionType: 'BACK_NFT_PUBLISH_DONE', data: res.data }, (res) => { console.log(res) });
         }
+    }).catch((error) => {
+        console.log('catch', error)
     })
 }
 

+ 27 - 15
src/uilts/chromeExtension.js

@@ -108,16 +108,24 @@ export function getChromeCookie({ name = '', url = '', return_type = '' }, callb
 }
 
 export function removeChromeCookie(params, cb) {
-    let { name, url } = params;
-    chrome.cookies.remove({ name, url }, () => {
-        cb && cb
-    })
+    try {
+        let { name, url } = params;
+        chrome.cookies.remove({ name, url }, () => {
+            cb && cb
+        })
+    } catch (error) {
+        console.log('catch', error)
+    }
 }
 
 export function sendChromeTabMessage(params, callback) {
-    chrome.tabs.getCurrent((tab) => {
-        chrome.tabs.sendMessage(tab.id, params, callback);
-    })
+    try {
+        chrome.tabs.getCurrent((tab) => {
+            chrome.tabs.sendMessage(tab.id, params, callback);
+        })
+    } catch (error) {
+        console.log('catch', error)
+    }
 }
 
 export function checkIsLogin(callback) {
@@ -156,19 +164,23 @@ export function httpContentToBack(data, callback) {
             }
         })
     } catch (error) {
-
+        console.error('catch', error)
     }
 }
 
 // 再找到它执行
 export function httpBackToContentCallBack(req) {
-    for (let i in callback_arr) {
-        if (callback_arr[i].callback_id == req.callback_id) {
-            // 执行
-            callback_arr[i].callback(req.data)
-            // 删除
-            callback_arr.splice(i, 1)
-            break
+    try {
+        for (let i in callback_arr) {
+            if (callback_arr[i].callback_id == req.callback_id) {
+                // 执行
+                callback_arr[i].callback(req.data)
+                // 删除
+                callback_arr.splice(i, 1)
+                break
+            }
         }
+    } catch (error) {
+        console.error('catch', error)
     }
 }

+ 10 - 5
src/view/iframe/tool-box/buy-nft.vue

@@ -1,9 +1,5 @@
 <template>
-    <div
-        class="nft-layer"
-        v-show-log="{
-            pageSource: Report.pageSource.buy_posteditor_nft_dialog,
-        }">
+    <div class="nft-layer">
         <div class="title">
             <img @click="close" :src=" require('@/assets/svg/icon-close.svg') " />
             <span class="text">Unlock by Ruomeng NFT</span>
@@ -22,6 +18,8 @@
                 v-click-log="{
                     pageSource: Report.pageSource.buy_posteditor_nft_dialog,
                     objectType: Report.objectType.buy_button,
+                    nftProjectId: nftAuthINfo.certNftProjectId || '',
+                    postId: postId,
                 }">
                 <span>Buy NFT to Participate</span>
             </div>
@@ -94,6 +92,13 @@ onBeforeMount(() => {
         if ( code === 0 ) {
             btnStatus.value = true;
             nftAuthINfo.value = data;
+            // report
+            Report.reportLog({
+                businessType: Report.businessType.pageView,
+                pageSource: Report.pageSource.buy_posteditor_nft_dialog,
+                nftProjectId: data.certNftProjectId || '',
+                postId: postId.value || '',
+            })
         }
     })
 })

+ 3 - 0
src/view/iframe/treasure-hunt/invite.vue

@@ -153,15 +153,18 @@ state.inviteInit = () => {
 let line_width = 0
 const setLineFull = (box_num = 0, finishNeedInviteCount = 0, successInviteCount = 0) => {
     if (box_num == 0) {
+        // 第一个宝箱起点是0,终点是55
         line_width = (successInviteCount / finishNeedInviteCount) * 55
     } else if (box_num == 1) {
         if (line_width == 55) {
+            // 第二个宝箱起点是92,终点是155
             line_width = 92
             line_width = (successInviteCount / finishNeedInviteCount) * (155 - line_width) + line_width
         }
     } else if (box_num == 2) {
         if (line_width == 155) {
             line_width = 192
+            // 第二个宝箱起点是192,终点是260
             line_width = (successInviteCount / finishNeedInviteCount) * (260 - line_width) + line_width
         }
     }