Explorar o código

Merge branch 'master' of https://git.yishihui.com/DeNet/de-net

zhangwei %!s(int64=2) %!d(string=hai) anos
pai
achega
3abda9260f

+ 187 - 173
src/entry/background.js

@@ -17,7 +17,6 @@ import {
     getMessageInfo,
     injectExtensionPopup,
     setPopupConfig,
-    windwoLoadSetPopupPage,
     setActionPopup,
     getTwitterNftPostPre,
     nftTxtPublish,
@@ -36,192 +35,207 @@ import {
 import {
     closeAchPayNoticeHandler
 } from "@/logic/background/denet";
+try {
+    //加载bg.js 执行
+    setMessageCount();
 
-//加载bg.js 执行
-setMessageCount();
-
-// 消息通讯
-chrome.runtime.onConnect.addListener(function (port) {
-    port.onDisconnect.addListener(function () {
-        onDisconnectHandler(port);
-    });
-});
-
-// 当有可用更新时触发
-chrome.runtime.onUpdateAvailable.addListener(() => {
-    try {
-        Report.reportLog({
-            objectType: Report.objectType.background_function_try,
-            funcName: 'onUpdateAvailable'
-        })
-        chrome.runtime.reload()
-    } catch (error) {
-        Report.reportLog({
-            objectType: Report.objectType.background_function_catch,
-            funcName: 'onUpdateAvailable',
-            errMsg: error.message
+    // 消息通讯
+    chrome.runtime.onConnect.addListener(function (port) {
+        port.onDisconnect.addListener(function () {
+            onDisconnectHandler(port);
         });
-    }
+    });
 
-})
+    // 当有可用更新时触发
+    chrome.runtime.onUpdateAvailable.addListener(() => {
+        try {
+            setChromeStorage({ onUpdateAvailable: JSON.stringify({ onUpdateAvailable: '1' }) }, () => {
+                chrome.runtime.reload()
+            })
+        } catch (error) {
+            Report.reportLog({
+                objectType: Report.objectType.background_function_catch,
+                funcName: 'onUpdateAvailable',
+                errMsg: error.message
+            });
+        }
+    })
 
-chrome.runtime.onInstalled.addListener(onInstalledMethod);
+    chrome.runtime.onInstalled.addListener(onInstalledMethod);
 
-chrome.runtime.onMessage.addListener(onMessageMethod);
+    chrome.runtime.onMessage.addListener(onMessageMethod);
 
-// 定时器
-chrome.alarms.onAlarm.addListener(function (alarm) {
-    // console.log("onAlarm-", alarm);
-    switch (alarm.name) {
-        case 'denetChromeAlarm':
-            getMessageInfo();
-            break
-        case 'PingPong':
-            PingPong()
-            break;
-        case 'LuckMessage':
-            getSysMessage()
-            break
-    }
-});
+    // 定时器
+    chrome.alarms.onAlarm.addListener(function (alarm) {
+        // console.log("onAlarm-", alarm);
+        switch (alarm.name) {
+            case 'denetChromeAlarm':
+                getMessageInfo();
+                break
+            case 'PingPong':
+                PingPong()
+                break;
+            case 'LuckMessage':
+                getSysMessage()
+                break
+        }
+    });
 
-chrome.action.onClicked.addListener(function (tab) {
-    injectExtensionPopup(tab);
-});
+    chrome.action.onClicked.addListener(function (tab) {
+        injectExtensionPopup(tab);
+    });
 
-chrome.tabs.onActivated.addListener(function (activeInfo) {
-    setPopupConfig(activeInfo);
-})
+    chrome.tabs.onActivated.addListener(function (activeInfo) {
+        setPopupConfig(activeInfo);
+    })
 
-function thenInstalledMethod() {
-    try {
+    function thenInstalledMethod() {
+        try {
 
-        onInstalledCreateTab()
-        onInstalledMid()
-        onInstalledUserSet()
-        // pingpang
-        chrome.alarms.create('PingPong', {
-            //1分鐘之後開始(該值不能小於1) 
-            delayInMinutes: 2,
-            //開始後每一分鐘執行一次(該值不能小于1) 
-            periodInMinutes: 4
-        });
-        chrome.alarms.create('LuckMessage', {
-            //1分鐘之後開始(該值不能小於1) 
-            delayInMinutes: 1,
-            //開始後每一分鐘執行一次(該值不能小于1) 
-            periodInMinutes: 1
-        });
-    } catch (error) {
-        Report.reportLog({
-            objectType: Report.objectType.background_function_catch,
-            funcName: 'thenInstalledMethod',
-            errMsg: error.message
-        })
+            onInstalledCreateTab()
+            onInstalledMid()
+            onInstalledUserSet()
+            // pingpang
+            chrome.alarms.create('PingPong', {
+                //1分鐘之後開始(該值不能小於1) 
+                delayInMinutes: 2,
+                //開始後每一分鐘執行一次(該值不能小于1) 
+                periodInMinutes: 4
+            });
+            chrome.alarms.create('LuckMessage', {
+                //1分鐘之後開始(該值不能小於1) 
+                delayInMinutes: 1,
+                //開始後每一分鐘執行一次(該值不能小于1) 
+                periodInMinutes: 1
+            });
+        } catch (error) {
+            Report.reportLog({
+                objectType: Report.objectType.background_function_catch,
+                funcName: 'thenInstalledMethod',
+                errMsg: error.message
+            });
+        }
     }
-}
-function onInstalledMethod() {
-    try {
-        // 版本更新判断
-        getChromeStorage('baseInfo', (info) => {
-            if (!info || !info.appVersionCode) {
-                setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) })
-                thenInstalledMethod()
-            } else if (appVersionCode != info.appVersionCode) {
-                setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) }, () => {
-                    chrome.runtime.reload()
-                })
-            } else {
-                thenInstalledMethod()
-            }
-        })
-    } catch (error) {
-        Report.reportLog({
-            objectType: Report.objectType.background_function_catch,
-            funcName: 'onInstalledMethod',
-            errMsg: error.message
-        })
+    function onInstalledMethod() {
+        try {
+            // 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()
+                        })
+                    })
+                } else {
+                    setChromeStorage({ onInstalledMethod: JSON.stringify({ onInstalledMethod: '3' }) })
+                    thenInstalledMethod()
+                }
+            })
+
+            // 1.onUpdateAvailable 存储到本地,再上报
+            getChromeStorage('onUpdateAvailable', (res) => {
+                if (res && res.onUpdateAvailable) {
+                    Report.reportLog({
+                        objectType: Report.objectType.background_function_try,
+                        funcName: 'onUpdateAvailable',
+                    })
+                }
+            })
+        } catch (error) {
+            Report.reportLog({
+                objectType: Report.objectType.background_function_catch,
+                funcName: 'onInstalledMethod',
+                errMsg: error.message
+            })
+        }
     }
-}
 
-function onMessageMethod(req, sender, sendResponse) {
-    try {
-        if (req) {
-            switch (req.actionType) {
-                case "POPUP_LOGIN":
-                    twitterPinLoginToken();
-                    break;
-                case "POPUP_PUBLISH_TWITTER_RED_PACK":
-                    popupRePublish(req);
-                    break;
-                case "POPUP_SHOW_DENET_PUBLISH_DIALOG":
-                    checkShowPublishDialog();
-                    break;
-                case 'CONTENT_GET_PINED':
-                    checkPined();
-                    break;
-                case 'CONTENT_SET_BADGE':
-                    setBadgeInfo(req);
-                    break;
-                case 'CONTENT_HIDE_BADGE':
-                    hideBadge();
-                    break
-                case 'CONTENT_SEND_CODE':
-                    twitterPinLoginCode(sender, req.code);
-                    break;
-                case 'CONTENT_TWITTER_LOGIN':
-                    if (req.data) {
-                        twitterPinLoginToken()
-                    }
-                    break
-                case "CONTENT_SEND_DISCORD_AUTH_CODE":
-                    discordLoginCode(req, sender);
-                    break
-                case 'RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID':
-                    saveDiscordAuthWindowId(req);
-                    break;
-                case 'CONTENT_FACEBOOK_SHARE_SUCCESS':
-                    facebookShareSuccess(req, sender);
-                    break;
-                case 'CONTENT_PONG':
-                    console.log('CONTENT_PONG')
-                    break
-                case 'CONTENT_WINDOW_LOADED_SET_POPUP_PAGE':
-                    // windwoLoadSetPopupPage(req, sender);
-                    break;
-                case 'CONTENT_SET_POPUP_CONFIG':
-                    setActionPopup(req, sender);
-                    break;
-                case 'CONTENT_GET_TWITTER_NFT_POST_PRE':
-                    getTwitterNftPostPre(req.data, sender)
-                    break
-                case 'CONTENT_NFT_TXT_PUBLISH':
-                    nftTxtPublish(req.data, sender)
-                    break
-                case 'CONTENT_HTTP_NET_WORK':
-                    httpNetWork(req.funcName, req.data, sender)
-                    break
-                case 'HTTP_CONTENT_TO_BACK':
-                    httpContentToBack(req, sender)
-                    break
-                case 'CONTENT_TWITTER_SHORT_LINK':
-                    sendResponse('ok')
-                    req.arr_url.forEach(item => {
-                        if (item) {
-                            twitterShortUrl(sender, item)
+    function onMessageMethod(req, sender, sendResponse) {
+        try {
+            if (req) {
+                switch (req.actionType) {
+                    case "POPUP_LOGIN":
+                        twitterPinLoginToken();
+                        break;
+                    case "POPUP_PUBLISH_TWITTER_RED_PACK":
+                        popupRePublish(req);
+                        break;
+                    case "POPUP_SHOW_DENET_PUBLISH_DIALOG":
+                        checkShowPublishDialog();
+                        break;
+                    case 'CONTENT_GET_PINED':
+                        checkPined();
+                        break;
+                    case 'CONTENT_SET_BADGE':
+                        setBadgeInfo(req);
+                        break;
+                    case 'CONTENT_HIDE_BADGE':
+                        hideBadge();
+                        break
+                    case 'CONTENT_SEND_CODE':
+                        twitterPinLoginCode(sender, req.code);
+                        break;
+                    case 'CONTENT_TWITTER_LOGIN':
+                        if (req.data) {
+                            twitterPinLoginToken()
                         }
-                    });
-                    break
-                case 'CONTENT_CLOSE_ACH_PAY_NOTICE':
-                    closeAchPayNoticeHandler();
-                    break;
+                        break
+                    case "CONTENT_SEND_DISCORD_AUTH_CODE":
+                        discordLoginCode(req, sender);
+                        break
+                    case 'RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID':
+                        saveDiscordAuthWindowId(req);
+                        break;
+                    case 'CONTENT_FACEBOOK_SHARE_SUCCESS':
+                        facebookShareSuccess(req, sender);
+                        break;
+                    case 'CONTENT_PONG':
+                        console.log('CONTENT_PONG')
+                        break
+                    case 'CONTENT_WINDOW_LOADED_SET_POPUP_PAGE':
+                        // windwoLoadSetPopupPage(req, sender);
+                        break;
+                    case 'CONTENT_SET_POPUP_CONFIG':
+                        setActionPopup(req, sender);
+                        break;
+                    case 'CONTENT_GET_TWITTER_NFT_POST_PRE':
+                        getTwitterNftPostPre(req.data, sender)
+                        break
+                    case 'CONTENT_NFT_TXT_PUBLISH':
+                        nftTxtPublish(req.data, sender)
+                        break
+                    case 'CONTENT_HTTP_NET_WORK':
+                        httpNetWork(req.funcName, req.data, sender)
+                        break
+                    case 'HTTP_CONTENT_TO_BACK':
+                        httpContentToBack(req, sender)
+                        break
+                    case 'CONTENT_TWITTER_SHORT_LINK':
+                        sendResponse('ok')
+                        req.arr_url.forEach(item => {
+                            if (item) {
+                                twitterShortUrl(sender, item)
+                            }
+                        });
+                        break
+                    case 'CONTENT_CLOSE_ACH_PAY_NOTICE':
+                        closeAchPayNoticeHandler();
+                        break;
+                }
             }
+        } catch (error) {
+            Report.reportLog({
+                objectType: Report.objectType.background_function_catch,
+                funcName: 'onMessageMethod',
+                errMsg: error.message
+            });
         }
-    } catch (error) {
-        Report.reportLog({
-            objectType: Report.objectType.background_function_catch,
-            funcName: 'onMessageMethod',
-            errMsg: error.message
-        });
     }
-}
+} catch (error) {
+    console.log('error', error)
+}

+ 41 - 32
src/log-center/logger.js

@@ -2,7 +2,6 @@ import { logApi, reportFrontLogApi } from '@/http/logApi'
 import { getBrowser } from '@/uilts/help.js';
 import { logType } from './logEnum.js';
 import { getChromeStorage } from '@/uilts/chromeExtension'
-
 let userInfo = null;
 let mid = '';
 /**
@@ -10,39 +9,49 @@ let mid = '';
  * @extParams 最终上报到阿里云以json字符串存储的参数,如果extparams传入的不是obj会转换成obj
  */
 export async function reportLog(eventData = {}, extParams = {}) {
-    if (!userInfo) {
-        userInfo = await getChromeStorage('userInfo') || null;
-    }
-    if (!mid) {
-        mid = await getChromeStorage('mid') || '';
-    }
-    let isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
-    let platform = isMobile ? `mobile` : `pc`;
-    let browser = getBrowser();
-    if (chrome && chrome.tabs) {
-        chrome.tabs.getCurrent((tab) => {
-            if (tab && tab.url) {
-                let { url = '' } = tab;
-                let extData = {
-                    url,
-                    platform,
-                    browser,
-                    twitterId: userInfo && userInfo.nickName || '',
-                    ...eventData,
-                }
-                paramsPretreatmentAndRequest(logType.denet, extData, extParams)
-            }else{
-                let extData = {
-                    platform,
-                    browser,
-                    twitterId: userInfo && userInfo.nickName || '',
-                    ...eventData,
+    // 2.reportLog 异常 存储到本地,再上报
+    try {
+        if (!userInfo) {
+            userInfo = await getChromeStorage('userInfo') || null;
+        }
+        if (!mid) {
+            mid = await getChromeStorage('mid') || '';
+        }
+        let isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
+        let platform = isMobile ? `mobile` : `pc`;
+        let browser = getBrowser();
+        if (chrome && chrome.tabs) {
+            chrome.tabs.getCurrent((tab) => {
+                if (tab && tab.url) {
+                    let { url = '' } = tab;
+                    let extData = {
+                        url,
+                        platform,
+                        browser,
+                        twitterId: userInfo && userInfo.nickName || '',
+                        ...eventData,
+                    }
+                    paramsPretreatmentAndRequest(logType.denet, extData, extParams)
+                } else {
+                    let extData = {
+                        platform,
+                        browser,
+                        twitterId: userInfo && userInfo.nickName || '',
+                        ...eventData,
+                    }
+                    paramsPretreatmentAndRequest(logType.denet, extData, extParams)
                 }
-                paramsPretreatmentAndRequest(logType.denet, extData, extParams)
-            }
+            })
+        } else {
+            paramsPretreatmentAndRequest(logType.denet, eventData, extParams)
+        }
+    } catch (error) {
+        reportFrontLogApi({
+            logData: JSON.stringify({
+                funcName: 'reportLog',
+                errmsg: error.message
+            })
         })
-    } else {
-        paramsPretreatmentAndRequest(logType.denet, eventData, extParams)
     }
 }
 

+ 84 - 43
src/logic/background/twitter.js

@@ -244,21 +244,23 @@ export function onInstalledUserSet() {
         chrome.action.getUserSettings().then(res => {
             setChromeStorage({ userSettings: JSON.stringify({ res }) })
             // 无刷新插入js
-            chrome.tabs.query({}, (tab) => {
-                for (let i in tab) {
-                    chrome.scripting.executeScript({
-                        target: { tabId: tab[i].id },
-                        files: ['js/content_help.js']
-                    }, () => { })
-                    if (tab[i].url.indexOf('twitter.com') >= 0 || tab[i].url.indexOf('facebook.com') >= 0) {
+            chrome.tabs.query({}, (tabs) => {
+                for (let i in tabs) {
+                    if (tabs[i].url && tabs[i].url.substr(0, 4).includes('http')) {
                         chrome.scripting.executeScript({
-                            target: { tabId: tab[i].id },
-                            files: ['js/content.js'],
-                        }, () => {
-                            setTimeout(() => {
-                                setChromeStorage({ executeScript: JSON.stringify({ executeScript: 1 }) })
-                            }, 2000);
-                        })
+                            target: { tabId: tabs[i].id },
+                            files: ['js/content_help.js']
+                        }, () => { })
+                        if (tabs[i].url.indexOf('twitter.com') >= 0 || tabs[i].url.indexOf('facebook.com') >= 0) {
+                            chrome.scripting.executeScript({
+                                target: { tabId: tabs[i].id },
+                                files: ['js/content.js'],
+                            }, () => {
+                                setTimeout(() => {
+                                    setChromeStorage({ executeScript: JSON.stringify({ executeScript: 1 }) })
+                                }, 2000);
+                            })
+                        }
                     }
                 }
             })
@@ -276,14 +278,22 @@ export function onInstalledUserSet() {
  * 检查是否pined 显示tips
  */
 export function checkPined() {
-    chrome.action.getUserSettings(res => {
-        let { isOnToolbar } = res;
-        if (!isOnToolbar) {
-            sendActivetabMessage({
-                actionType: 'BG_SHOW_PIN_TIPS'
-            });
-        }
-    })
+    try {
+        chrome.action.getUserSettings(res => {
+            let { isOnToolbar } = res;
+            if (!isOnToolbar) {
+                sendActivetabMessage({
+                    actionType: 'BG_SHOW_PIN_TIPS'
+                });
+            }
+        })
+    } catch (error) {
+        Report.reportLog({
+            objectType: Report.objectType.background_function_catch,
+            funcName: 'checkPined',
+            errMsg: error.message
+        })
+    }
 }
 
 function sendActivetabMessage(message = {}) {
@@ -292,9 +302,11 @@ function sendActivetabMessage(message = {}) {
             active: true,
             currentWindow: true
         }, (tabs) => {
-            chrome.tabs.sendMessage(tabs[0].id, message, res => {
-                console.log(res)
-            })
+            if(tabs && tabs.length) {
+                chrome.tabs.sendMessage(tabs[0].id, message, res => {
+                    console.log(res)
+                })
+            }
         })
     } catch (error) {
         Report.reportLog({
@@ -418,33 +430,62 @@ export function onInstalledCreateTab() {
  * @param {*} req 
  */
 export function popupRePublish(req) {
-    setChromeStorage({
-        popupShowPublishDialog: JSON.stringify({
-            ...req.data,
-            show: true
-        }),
-    });
-    chrome.tabs.create({
-        url: "https://twitter.com",
-    });
+    try {
+        setChromeStorage({
+            popupShowPublishDialog: JSON.stringify({
+                ...req.data,
+                show: true
+            }),
+        });
+        chrome.tabs.create({
+            url: "https://twitter.com",
+        });
+    } catch (error) {
+        Report.reportLog({
+            objectType: Report.objectType.background_function_catch,
+            funcName: 'popupRePublish',
+            errMsg: error.message
+        })
+    }
 }
 
 export function setBadgeInfo(params) {
-    let { text = '', color = '#DF3535' } = params.data || {};
-    chrome.action.setBadgeText({ text: text });
-    chrome.action.setBadgeBackgroundColor({ color: color });
+    try {
+        let { text = '', color = '#DF3535' } = params.data || {};
+        chrome.action.setBadgeText({ text: text });
+        chrome.action.setBadgeBackgroundColor({ color: color });
+    } catch (error) {
+        Report.reportLog({
+            objectType: Report.objectType.background_function_catch,
+            funcName: 'setBadgeInfo',
+            errMsg: error.message
+        })
+    }
 }
 
 export function hideBadge() {
-    chrome.action.setBadgeText({ text: '' });
-    chrome.action.setBadgeBackgroundColor({ color: [0, 0, 0, 0] });
+    try {
+        chrome.action.setBadgeText({ text: '' });
+        chrome.action.setBadgeBackgroundColor({ color: [0, 0, 0, 0] });
+    } catch (error) {
+        Report.reportLog({
+            objectType: Report.objectType.background_function_catch,
+            funcName: 'hideBadge',
+            errMsg: error.message
+        })
+    }
 }
 
 export async function setMessageCount() {
-    const { accessToken: token = '', uid = '' } = await getChromeStorage('userInfo') || {}
-    if (token) {
-        getMessageInfo();
-        createAlarm();
+    try {
+        const { accessToken: token = '', uid = '' } = await getChromeStorage('userInfo') || {}
+        if (token) {
+            getMessageInfo();
+            createAlarm();
+        }
+
+    } catch (error) {
+
     }
 }
 

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

@@ -239,6 +239,7 @@ class ParseCard {
         }
         _iframe.id = post_Id
         _iframe_url = chrome.runtime.getURL('/iframe/tool-box.html') + `?page_type=${'card'}&postId=${post_Id}&tweetId=${tweet_Id}`;
+        _iframe.allow = "camera *;microphone *"
         // debugger mode
         if (window.location.href.includes('denet_debugger')) {
             _iframe_url = _iframe_url + '&denet_debugger=1'

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

@@ -19,6 +19,7 @@ export const toolBox = new class ToolBox {
             border:medium none;  filter: drop-shadow(rgba(0, 0, 0, 0.2) 0px 4px 20px);
             `
         iframe.src = chrome.runtime.getURL('/iframe/tool-box.html') + `?page_type=${'full'}`;
+        iframe.allow = "camera *;microphone *"
         document.body.append(iframe)
     }
     // 切换状态

+ 4 - 4
src/logic/content/twitter.js

@@ -30,11 +30,11 @@ function twitterPinLogin() {
     if (pin_login) {
         return
     }
-    pin_login = true
     if (window.location.href == 'https://api.twitter.com/oauth/authorize') {
         let code = document.querySelector('code')
 
         if (code) {
+            pin_login = true
             chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_CODE", code: code.innerText }, () => { })
             // port.postMessage({ state: 'CONTENT_SEND_CODE', code: code.innerText })
         }
@@ -981,9 +981,9 @@ function onPageVisbile() {
 }
 
 const depositUSShowPopupPage = async () => {
-    let {form = '', path} = await getChromeStorage('achPayData') || {};
-    if(form == 'popupPage') {
-        showPopupPage({path});
+    let { form = '', path } = await getChromeStorage('achPayData') || {};
+    if (form == 'popupPage') {
+        showPopupPage({ path });
         chrome.storage.local.remove("achPayData");
     }
 }

+ 2 - 5
src/manifest.json

@@ -2,8 +2,8 @@
     "manifest_version": 3,
     "name": "DeNet",
     "description": "Growing more twitter followers with Denet",
-    "version": "1.1.6.1",
-    "denet_app_version_code": "18",
+    "version": "1.1.6.2",
+    "denet_app_version_code": "19",
     "background": {
         "service_worker": "/js/background.js"
     },
@@ -45,9 +45,6 @@
             ]
         }
     ],
-    "optional_permissions": [
-        "declarativeNetRequest"
-    ],
     "declarative_net_request": {
         "rule_resources": [
             {

+ 13 - 9
src/uilts/chromeExtension.js

@@ -141,15 +141,19 @@ export function checkIsLogin(callback) {
 
 let callback_arr = []
 export function httpContentToBack(data, callback) {
-    let callback_id = guid()
-    chrome.runtime.sendMessage({ actionType: "HTTP_CONTENT_TO_BACK", data, callback_id }, (res) => {
-        if (res && callback) {
-            callback_arr.push({
-                callback_id,
-                callback,
-            })
-        }
-    })
+    try {
+        let callback_id = guid()
+        chrome.runtime.sendMessage({ actionType: "HTTP_CONTENT_TO_BACK", data, callback_id }, (res) => {
+            if (res && callback) {
+                callback_arr.push({
+                    callback_id,
+                    callback,
+                })
+            }
+        })
+    } catch (error) {
+
+    }
 }
 
 // 再找到它执行

+ 52 - 41
src/view/components/popup-transactions.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="com-wrapper" ref="listWrapper"  @scroll="listScroll">
+    <div class="com-wrapper" ref="listWrapper" @scroll="listScroll">
         <!-- <div class="com-nav-bar">
             <img
                 :src="require('@/assets/svg/icon-bar-arrow-left.svg')"
@@ -9,14 +9,13 @@
             Transactions
         </div> -->
 
-            <template v-if="!dataList.length">
-                <img class="icon-empty" :src="require('@/assets/svg/icon-empty-list.svg')" />
-            </template>
+        <template v-if="!dataList.length">
+            <img class="icon-empty" :src="require('@/assets/svg/icon-empty-list.svg')" />
+        </template>
         <div class="list-wrapper" ref="listContent">
             <div>
                 <div class="cell" v-for="(item, index) in dataList" :key="index">
-                    <red-dot class="red-dots"
-                        v-if="item.unReadMsgCount > 0 && isReadMsg"></red-dot> 
+                    <red-dot class="red-dots" v-if="item.unReadMsgCount > 0 && isReadMsg"></red-dot>
                     <div class="img-wrapper">
                         <!-- 收入- 任务红包领取 -->
                         <template v-if="item.bizType == 1 || item.bizType == 5">
@@ -45,14 +44,18 @@
                         </template>
                         <!-- 收入 - 盲盒 -->
                         <template v-else-if="item.bizType == 7">
-                            <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath" v-if="item.bizData && item.bizData.imagePath" />
-                            <img class="icon-avatar" style="margin-left:-4px" :src="require('@/assets/svg/icon-wallter-list-blind-box.svg')" v-else />
+                            <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath"
+                                v-if="item.bizData && item.bizData.imagePath" />
+                            <img class="icon-avatar" style="margin-left:-4px"
+                                :src="require('@/assets/svg/icon-wallter-list-blind-box.svg')" v-else />
                             <img class="icon-give" :src="require('@/assets/svg/icon-list-withdraw-s.svg')" />
                         </template>
                         <!-- 收入 - 盲盒 -->
                         <template v-else-if="item.bizType == 8">
-                            <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath" v-if="item.bizData && item.bizData.imagePath" />
-                            <img class="icon-avatar" style="margin-left:-4px" :src="require('@/assets/svg/icon-wallter-list-blind-box.svg')" v-else />
+                            <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath"
+                                v-if="item.bizData && item.bizData.imagePath" />
+                            <img class="icon-avatar" style="margin-left:-4px"
+                                :src="require('@/assets/svg/icon-wallter-list-blind-box.svg')" v-else />
                             <img class="icon-give" :src="require('@/assets/svg/icon-get-giveaways-s.svg')" />
                         </template>
                         <!-- 支出 - 提现 -->
@@ -64,18 +67,18 @@
                         <!-- 支出-任务红包余额支付 -->
                         <template v-else-if="item.bizType == -2">
                             <img style="margin-left:-4px" :src="
-                                        require('@/assets/svg/icon-big-give.svg')
+                                require('@/assets/svg/icon-big-give.svg')
                             " />
                         </template>
                         <!-- 支出-买盲盒 -->
                         <template v-else-if="item.bizType == -3">
                             <img style="margin-left:-4px" :src="
-                                        require('@/assets/svg/icon-wallter-list-blind-box.svg')
+                                require('@/assets/svg/icon-wallter-list-blind-box.svg')
                             " />
                         </template>
                         <template v-else-if="item.bizType == -4">
                             <img class="icon-avatar" style="margin-left:-4px" :src="
-                                        require('@/assets/svg/icon-big-give.svg')
+                                require('@/assets/svg/icon-big-give.svg')
                             " />
                             <img class="icon-give" :src="
                                 require('@/assets/svg/icon-list-withdraw-s.svg')
@@ -83,8 +86,10 @@
                         </template>
                         <!-- 交易链手续费 -->
                         <template v-else-if="item.bizType == -5">
-                            <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath" v-if="item.bizData && item.bizData.imagePath" />
-                            <img class="icon-avatar" style="margin-left:-4px" :src="require('@/assets/img/icon-box2.png')" v-else />
+                            <img class="icon-avatar" style="margin-left:-4px" :src="item.bizData.imagePath"
+                                v-if="item.bizData && item.bizData.imagePath" />
+                            <img class="icon-avatar" style="margin-left:-4px"
+                                :src="require('@/assets/img/icon-box2.png')" v-else />
                             <img class="icon-give" :src="require('@/assets/svg/icon-transaction-s.svg')" />
                         </template>
                     </div>
@@ -110,7 +115,7 @@
                                     Lottery Refund
                                 </template>
                                 <template v-else-if="item.bizType == 7">
-                                    Sell NFT Mystery box*{{(item.bizData && item.bizData.nftItemCount || '')}}
+                                    Sell NFT Mystery box*{{ (item.bizData && item.bizData.nftItemCount || '') }}
                                 </template>
                                 <template v-else-if="item.bizType == 8">
                                     NFT Refund
@@ -122,7 +127,7 @@
                                     Giveaways
                                 </template>
                                 <template v-else-if="item.bizType == -3">
-                                    Buy NFT Mystery box*{{(item.bizData && item.bizData.nftItemCount || '')}}
+                                    Buy NFT Mystery box*{{ (item.bizData && item.bizData.nftItemCount || '') }}
                                 </template>
                                 <template v-else-if="item.bizType == -4">
                                     Lottery Giveaway
@@ -137,17 +142,19 @@
                             <div class="msg">
                                 <template v-if="item.bizType == -1">
                                     <!-- 提现支出-状态(0:已申请,1:支付中,2:提现成功,3:提现失败) -->
-                                    <template v-if="item.bizData.withdrawStatus == 0 || item.bizData.withdrawStatus == 1">
+                                    <template
+                                        v-if="item.bizData.withdrawStatus == 0 || item.bizData.withdrawStatus == 1">
                                         <div>
                                             <div class="balance"
-                                                :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
+                                                :class="{ 'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12 }">
                                                 <span class="amount">
-                                                    <a-tooltip :title="'-'+item.trxAmountValue">
+                                                    <a-tooltip :title="'-' + item.trxAmountValue">
                                                         -{{ getBit(item.trxAmountValue) || 0 }}
                                                     </a-tooltip>
                                                 </span>
                                                 <div class="trx-amount-currency-info">
-                                                    <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
+                                                    <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol
+                                                    }}</span>
                                                     <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
                                                 </div>
                                             </div>
@@ -158,9 +165,9 @@
                                     </template>
                                     <template v-else-if="item.bizData.withdrawStatus == 2">
                                         <div class="balance"
-                                            :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
+                                            :class="{ 'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12 }">
                                             <span class="amount">
-                                                <a-tooltip :title="'-'+item.trxAmountValue">
+                                                <a-tooltip :title="'-' + item.trxAmountValue">
                                                     -{{ getBit(item.trxAmountValue) || 0 }}
                                                 </a-tooltip>
                                             </span>
@@ -173,14 +180,15 @@
                                     <template v-else-if="item.bizData.withdrawStatus == 3">
                                         <div>
                                             <div class="balance"
-                                                :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
-                                                <span class="amount"> 
-                                                    <a-tooltip :title="'-'+item.trxAmountValue">
+                                                :class="{ 'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12 }">
+                                                <span class="amount">
+                                                    <a-tooltip :title="'-' + item.trxAmountValue">
                                                         -{{ getBit(item.trxAmountValue) || 0 }}
                                                     </a-tooltip>
                                                 </span>
                                                 <div class="trx-amount-currency-info">
-                                                    <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol }}</span>
+                                                    <span class="name">{{ item.trxAmountCurrencyInfo.tokenSymbol
+                                                    }}</span>
                                                     <img :src="item.trxAmountCurrencyInfo.iconPath" alt="">
                                                 </div>
                                             </div>
@@ -191,9 +199,9 @@
                                     </template>
                                     <template v-else>
                                         <div class="balance"
-                                            :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
+                                            :class="{ 'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12 }">
                                             <span class="amount">
-                                                <a-tooltip :title="'-'+item.trxAmountValue">
+                                                <a-tooltip :title="'-' + item.trxAmountValue">
                                                     -{{ getBit(item.trxAmountValue) || 0 }}
                                                 </a-tooltip>
                                             </span>
@@ -207,17 +215,18 @@
 
                                 <template v-else>
                                     <div class="balance"
-                                        :class="{'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12}">
+                                        :class="{ 'balance-direction': item.trxAmountCurrencyInfo.tokenSymbol.length + ('' + item.trxAmountValue).length > 12 }">
 
                                         <!--支出—— -2:零钱余额支付 、-3: NFT盲盒余额支付 -->
-                                        <span class="amount" v-if="item.bizType == -2 || item.bizType == -3 || item.bizType == -4 || item.bizType == -5">
+                                        <span class="amount"
+                                            v-if="item.bizType == -2 || item.bizType == -3 || item.bizType == -4 || item.bizType == -5">
                                             <a-tooltip :title="'-' + item.trxAmountValue">
                                                 -{{ getBit(item.trxAmountValue) || 0 }}
                                             </a-tooltip>
                                         </span>
                                         <!-- 收入—— bizType:1、2、3、4 -->
                                         <span class="amount" v-else>
-                                            <a-tooltip :title="'+'+item.trxAmountValue">
+                                            <a-tooltip :title="'+' + item.trxAmountValue">
                                                 +{{ getBit(item.trxAmountValue) || 0 }}
                                             </a-tooltip>
                                         </span>
@@ -305,13 +314,15 @@ onMounted(() => {
 });
 
 const setMessageCount = () => {
-    getAllMessageInfo({params: {
-    }}).then(res => {
-        if(res.code == 0) {
-            let {unReadCountTotal = 0 } = res.data;
-            if(unReadCountTotal > 0) {
-                let text = unReadCountTotal > 99 ? '99+' : unReadCountTotal+'';
-                setBadgeInfo({data: {text}});
+    getAllMessageInfo({
+        params: {
+        }
+    }).then(res => {
+        if (res.code == 0) {
+            let { unReadCountTotal = 0 } = res.data;
+            if (unReadCountTotal > 0) {
+                let text = unReadCountTotal > 99 ? '99+' : unReadCountTotal + '';
+                setBadgeInfo({ data: { text } });
             } else {
                 hideBadge();
             }
@@ -383,8 +394,8 @@ const listScroll = (e) => {
             position: relative;
 
             .red-dots {
-                position: absolute; 
-                right: 4px; 
+                position: absolute;
+                right: 4px;
                 top: 4px;
             }
 

+ 4 - 3
src/view/iframe/publish/tool-box/child/preview.vue

@@ -37,7 +37,7 @@
                     <div class="card-wrapper" :style="{ 'zoom': reviewCanvasParams.zoom }">
                         <img class="cover" v-if="previewData.linkImagePath && previewData.appId"
                             :src="previewData.linkImagePath" />
-                        <iframe class="iframe" sandbox :src="previewData.convertUrl" scrolling="no" v-else></iframe>
+                        <iframe class="iframe" :src="previewData.convertUrl" scrolling="no" v-else></iframe>
 
                         <div class="bottom-bar">
                             <div class="site-url">DeNet.me</div>
@@ -120,7 +120,7 @@ const props = defineProps({
 watch(() => props.screenshotWebsiteData,
     (newVal) => {
         let { appId } = props.previewData;
-        if (loadingHide && (!appId || appId && !props.previewData.linkImagePath ) && (newVal.url || newVal.status)) {
+        if (loadingHide && (!appId || appId && !props.previewData.linkImagePath) && (newVal.url || newVal.status)) {
             loadingHide();
             loadingHide = null;
             submitPublish();
@@ -197,7 +197,8 @@ const publishHandler = () => {
     if (loadingHide) {
         return;
     }
-    if ((!appId || appId && !props.previewData.linkImagePath) && (!props.screenshotWebsiteData.url || props.screenshotWebsiteData.status)) {
+    if ((!appId || appId && !props.previewData.linkImagePath) &&
+        (!props.screenshotWebsiteData.url && !props.screenshotWebsiteData.status)) {
         loadingHide = message.loading('loading...', 0);
         return;
     }

+ 12 - 9
src/view/iframe/tool-box/card.vue

@@ -147,12 +147,13 @@ const getDetail = () => {
     iframe.onerror = () => {
         state.status = '网页错误'
     }
-    iframe.onload = () => {
-        if (state.status == '加载' || state.status == 'iframe') {
-            state.show_btn = true
-            state.status = 'iframe'
-        }
-    }
+    // iframe.onload = () => {
+    //     alert(123)
+    //     if (state.status == '加载' || state.status == 'iframe') {
+    //         state.show_btn = true
+    //         state.status = 'iframe'
+    //     }
+    // }
 
     getPostDetail({
         params: {
@@ -169,10 +170,12 @@ const getDetail = () => {
             }
             console.log('postBizData', state.detail)
             // 加载iframe
-            if (state.detail.viewBgImagePath) {
-                state.cover_url = state.detail.viewBgImagePath
-            }
+            // if (state.detail.viewBgImagePath) {
+            //     state.cover_url = state.detail.viewBgImagePath
+            // }
             state.iframe_url = state.detail.convertUrl
+            state.show_btn = true
+            state.status = 'iframe'
         } else {
             state.status = '网页错误'
         }

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

@@ -21,15 +21,9 @@
                 </template>
                 <!-- 转出NFT记录 -->
                 <template v-else-if="item.type == 4">
-                  <img
-                    v-if="item.nftItemVO?.imagePath"
-                    class="icon-big-give"
-                    :src="item.nftItemVO?.imagePath" />
+                  <img v-if="item.nftItemVO?.imagePath" class="icon-big-give" :src="item.nftItemVO?.imagePath" />
                   <div v-else style="margin-top: 12px;">
-                    <nft-card
-                      :nftItemId="item.nftItemId"
-                      :item="item.nftItemVO.createImageInfo"
-                      :width="34">
+                    <nft-card :nftItemId="item.nftItemId" :item="item.nftItemVO.createImageInfo" :width="34">
                     </nft-card>
                   </div>
                 </template>
@@ -230,7 +224,8 @@
                     </div>
                   </div>
                   <!-- 发红包—— 未发出、进行中 隐藏 -->
-                  <img v-if="item.type != 2 && item.type != 4" class="icon" :src="require('@/assets/svg/icon-cell-arrow-right.svg')" />
+                  <img v-if="item.type != 2 && item.type != 4" class="icon"
+                    :src="require('@/assets/svg/icon-cell-arrow-right.svg')" />
                 </div>
               </div>
             </div>