Browse Source

Merge branch 'dev_1.1.5-1' into dev_1.1.5.2

zhangwei 2 years ago
parent
commit
14ead71fbb

+ 0 - 7
src/entry/background.js

@@ -112,13 +112,6 @@ function thenInstalledMethod() {
             //開始後每一分鐘執行一次(該值不能小于1) 
             periodInMinutes: 1
         });
-        setTimeout(() => {
-            // 安装成功埋点
-            Report.reportLog({
-                objectType: Report.objectType.background_function_try,
-                funcName: 'onInstalledMethod'
-            });
-        }, 5000);
     } catch (error) {
         Report.reportLog({
             objectType: Report.objectType.background_function_catch,

+ 24 - 0
src/http/help.js

@@ -0,0 +1,24 @@
+import { getChromeStorage } from '@/uilts/chromeExtension.js'
+import { srcPublishSuccess } from '@/http/publishApi'
+
+// 重新绑定推文id
+export const reSetBindTwtterId = ({
+    postId = '',
+    tweetId = ''
+}, callback) => {
+    getChromeStorage('userInfo', (_userInfo = {}) => {
+        // if (_userInfo && _userInfo.uid == _params.uid) {
+        if (_userInfo.uid) {
+            srcPublishSuccess({
+                params: {
+                    postId,
+                    srcContentId: tweetId
+                }
+            }).then((res) => {
+                if (res.code == 0 || res.code == 3003) {
+                    callback && callback()
+                }
+            })
+        }
+    })
+}

+ 8 - 0
src/http/toolBoxApi.js

@@ -22,4 +22,12 @@ export function screenshotWebsite(params) {
         method: 'post',
         data: params
     })
+}
+
+export function checkInputUrlInBlacklist(params) {
+    return service({
+        url: `/post/editor/checkInputUrlInBlacklist`,
+        method: 'post',
+        data: params
+    })
 }

+ 6 - 0
src/iframe/tool-box-guide.js

@@ -1,7 +1,13 @@
 import { createApp } from 'vue'
 import App from '@/view/iframe/publish/tool-box/child/guide.vue'
 
+import "ant-design-vue/dist/antd.css"; // or 'ant-design-vue/dist/antd.less'
+
+import {message} from "ant-design-vue";
+
 const app = createApp(App);
+
+app.use(message);
 app.mount('#app');
 
 window.onload= () => {

+ 14 - 12
src/logic/background/denet.js

@@ -1,18 +1,20 @@
 import { getChromeStorage } from '@/uilts/chromeExtension.js'
+import { payAchNoticeUrl } from '@/http/configAPI'
 
 export const closeAchPayNoticeHandler = async () => {
-    let {id} = await getCurrentTab();
-
-    chrome.tabs.remove(
-        id, () => {
-            getChromeStorage('achPayInfo', (res) => {
-                chrome.storage.local.remove("achPayInfo");
-                if(res && res.tab) {
-                    chrome.tabs.highlight({ windowId: res.tab.windowId, tabs: res.tab.index })
-                }
-            })
-        }
-    )
+    let res = await getCurrentTab();
+    if(res.url.startsWith(payAchNoticeUrl)) {
+        chrome.tabs.remove(
+            res.id, () => {
+                getChromeStorage('achPayInfo', (res) => {
+                    chrome.storage.local.remove("achPayInfo");
+                    if(res && res.tab) {
+                        chrome.tabs.highlight({ windowId: res.tab.windowId, tabs: res.tab.index })
+                    }
+                })
+            }
+        )
+    }
 }
 
 const getCurrentTab = async () => {

+ 11 - 2
src/logic/background/twitter.js

@@ -3,7 +3,7 @@ import { LANDING_PAGE, LANDING_PAGE_MID, setChromeStorage, setChromeCookie, getC
 import { guid } from '@/uilts/help.js'
 import { discordAuthRedirectUri } from '@/http/configAPI'
 import { setContentMessage } from '@/logic/background/help.js'
-
+import Report from "@/log-center/log"
 let authToken = ''
 let consumerKey = ''
 let tab_flag = true
@@ -250,7 +250,16 @@ function sendActivetabMessage(message = {}) {
  */
 
 export function onInstalledCreateTab() {
-    getChromeCookie(LANDING_PAGE_JUMP_INFO, (res) => {
+    getChromeCookie(LANDING_PAGE_JUMP_INFO, (res = {}) => {
+        setTimeout(() => {
+            // 安装成功埋点
+            Report.reportLog({
+                objectType: Report.objectType.chrome_extension_installed,
+                funcName: 'onInstalledCreateTab',
+                postId: res.postId || ''
+            })
+        }, 5000)
+
         // jump_info
         if (!res || !res.jump_type) {
             chrome.tabs.create({

+ 1 - 2
src/logic/content/twitter.js

@@ -879,7 +879,6 @@ function initParseCard() {
                 if (queue_num <= 0) {
                     return
                 }
-                console.log('queue_num', queue_num)
                 initGroupTip()
                 setIframeRedPacket()
                 checkHasDeBtn()
@@ -2414,7 +2413,7 @@ export const loginSuccessHandle = () => {
 
 export const showPublishDialog = () => {
     let smallBtn = document.getElementById('de-btn1');
-    if(smallBtn) {
+    if (smallBtn) {
         smallBtn.click();
     }
 }

+ 0 - 1
src/manifest.json

@@ -82,7 +82,6 @@
         "tabs",
         "action",
         "cookies",
-        "webNavigation",
         "declarativeNetRequest",
         "activeTab",
         "scripting",

+ 1 - 1
src/view/components/input-action-sheet.vue

@@ -166,7 +166,7 @@ const confirm = () => {
             font-weight: 500;
             font-size: 13px;
             color: #888888;
-            height: 40px;
+            min-height: 40px;
         }
         .btn-wrapper {
             display: flex;

+ 19 - 20
src/view/components/popup-withdraw.vue

@@ -21,19 +21,17 @@
                     <div class="form-item">
                         <div class="label">PayPal account</div>
                         <div class="input-wrapper">
-                            <input type="text" 
-                                v-model="requestWithdrawParams.withdrawReceiveAccount" placeholder="Enter PayPal account"/>
+                            <input type="text" v-model="requestWithdrawParams.withdrawReceiveAccount"
+                                placeholder="Enter PayPal account" />
                         </div>
                     </div>
                     <div class="form-item">
-                        <div class="label">Withdrawal amount<span
-                                class="msg">(${{ walletWithdrawConfig.withdrawPerMinAmount }} minimum)</span></div>
+                        <div class="label">Withdrawal amount<span class="msg">(${{
+                                walletWithdrawConfig.withdrawPerMinAmount
+                        }} minimum)</span></div>
                         <div class="input-wrapper amount-wrapper">
-                            <input type="text" 
-                                v-model="requestWithdrawParams.amountValue" 
-                                placeholder="$0"
-                                style="width: 220px"
-                                @input="onAmountInput"  />
+                            <input type="text" v-model="requestWithdrawParams.amountValue" placeholder="$0"
+                                style="width: 220px" @input="onAmountInput" />
                             <div @click="withdrawalAll" class="withdrawal-all-btn">
                                 Withdrawal All
                             </div>
@@ -79,8 +77,9 @@
                 <div>
                     <div class="title">Submitted successfully</div>
                     <div class="desc">
-                        Please wait for a while,<br />
-                        then check the balance with paypal
+                        <!-- Please wait for a while,<br />
+                        then check the balance with paypal -->
+                        Estimate in 24 hours
                     </div>
                 </div>
             </div>
@@ -122,10 +121,10 @@ let isSubmit = ref(false);
 let withdrawIng = ref(false);
 
 let walletWithdrawConfig = ref({
-        withdrawPerMinAmount: 1,
-        withdrawUSDSwitch: "",
-        withdrawFeeDesc: ''
-    });
+    withdrawPerMinAmount: 1,
+    withdrawUSDSwitch: "",
+    withdrawFeeDesc: ''
+});
 
 let finalWithdrawalAmount = ref('');
 let calcReq = ref(false);
@@ -146,7 +145,7 @@ const queryWithdrawConfig = () => {
         if (res.code == 0) {
             walletWithdrawConfig.value = res.data;
         }
-        console.log('queryWithdrawConfig',walletWithdrawConfig.value);
+        console.log('queryWithdrawConfig', walletWithdrawConfig.value);
     });
 };
 
@@ -213,7 +212,7 @@ const withdraw = () => {
     }
     params.withdrawReceiveAccount = params.withdrawReceiveAccount.replace(/\s*/g, "");
     params.amountValue = params.amountValue;
-    if (parseInt(params.amountValue) > parseInt(canWithdrawBalance.value)) {
+    if (+params.amountValue > +canWithdrawBalance.value) {
         return;
     }
     withdrawIng.value = true;
@@ -259,7 +258,7 @@ const onAmountInput = () => {
     setWithdrawIptStatus(value);
 
     // 输入金额大于可提现金额
-    if (parseInt(value) > parseInt(canWithdrawBalance.value)) {
+    if (+value > +canWithdrawBalance.value) {
         if (!showWithdrawError.value) {
             showWithdrawIptError.value = true;
         }
@@ -275,8 +274,8 @@ const onAmountInput = () => {
 const setWithdrawIptStatus = (amount) => {
     //显示tips
     if (
-        amount > 0 &&
-        amount < walletWithdrawConfig.value.withdrawPerMinAmount
+        +amount > 0 &&
+        +amount < +walletWithdrawConfig.value.withdrawPerMinAmount
     ) {
         showWithdrawError.value = true;
     } else {

+ 2 - 2
src/view/iframe/publish/components/pay-button.vue

@@ -7,7 +7,7 @@
                 v-show="currentCurrencyInfo.currencyCode == 'USD'">
                 <div class="token-pay" 
                     @click="clickPayUSD">
-                    Pay {{finalAmountData.rechargeAmountValue > 0 && USDepositStatus != 'SUCCESS' ? finalAmountData.rechargeAmountValue : finalAmountData.orderAmountValue}} {{currentCurrencyInfo.tokenSymbol}}
+                    Pay ${{finalAmountData.rechargeAmountValue > 0 && USDepositStatus != 'SUCCESS' ? finalAmountData.rechargeAmountValue : finalAmountData.orderAmountValue}}
                 </div>
 
                 <!-- <iframe
@@ -113,7 +113,7 @@ const balancePay = () => {
 }
 
 const clickPayUSD = () => {
-    if(props.finalAmountData.rechargeAmountValue > 0) {
+    if(props.finalAmountData.rechargeAmountValue > 0 && props.USDepositStatus != 'SUCCESS') {
         setTimeout(() => {
             emits("showDepositMask", {});
         }, 1000)

+ 55 - 10
src/view/iframe/publish/give-dialog.vue

@@ -316,11 +316,19 @@
                                 @showDepositMask="showDepositMessageBox = true"
                                 @payFinish="payFinish">
                                 <template v-slot:balance>
-                                    <div class="balance" v-if="Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance)">
+                                    <div class="balance" v-if="Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance) || currentCurrencyInfo.currencyCode == 'USD' ">
                                         <img class="icon" src="@/assets/subject/icon-balance.png" />
                                         <div class="con">
                                             <div class="desc">Balance</div>
-                                            <div class="price">{{currentCurrencyInfo.balance}} {{currentCurrencyInfo.tokenSymbol}}</div>
+                                            <div class="price">
+                                                <template v-if="currentCurrencyInfo.currencyCode == 'USD'">
+                                                    $
+                                                </template>
+                                                {{currentCurrencyInfo.balance}} 
+                                                <template v-if="currentCurrencyInfo.currencyCode != 'USD'">
+                                                    {{currentCurrencyInfo.tokenSymbol}}
+                                                </template>
+                                            </div>
                                         </div>
                                         <img class="refresh"
                                             :class="{ 'icon-refresh-rotate': refreshRotate }"
@@ -721,6 +729,7 @@ watch(
     () => props.dialogData,
     (newVal) => {
         visible.value = newVal.visible;
+        USDepositStatus.value = "DEFAULT"
 
         if (newVal.visible) {
             publishType.value = newVal.type;
@@ -750,6 +759,7 @@ watch(
 const emits = defineEmits(["close", "confirm", "postPublishFinish"]);
 
 const close = () => {
+    USDepositStatus.value = "DEFAULT"
     if(publishType.value == 'TOOL_BOX') {
         closeToolBoxPage()
     } else {
@@ -994,21 +1004,29 @@ const topUpDone = () => {
 /**
  * 更新货币余额
  */
-const updateCurrencyBanlce = () => {
+const updateCurrencyBanlce = async () => {
     if(!refreshRotate.value) {
         refreshRotate.value = true;
         setTimeout(() => {
             refreshRotate.value = false;
         }, 1000)
     }
-    asyncTokenRechRecord((res) => {
-        if(res.code == 0 && res.data && res.data.length) {
-            let currencyInfo = res.data[0];
-            if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
-                currentCurrencyInfo.value.balance = currencyInfo.balance;
-            }
+    if(currentCurrencyInfo.value.currencyCode == 'USD') {
+        let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
+
+        if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
+            currentCurrencyInfo.value = currencyInfoRes.data;
         }
-    })
+    } else {
+        asyncTokenRechRecord((res) => {
+            if(res.code == 0 && res.data && res.data.length) {
+                let currencyInfo = res.data[0];
+                if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
+                    currentCurrencyInfo.value.balance = currencyInfo.balance;
+                }
+            }
+        })
+    }
 }
 
 /**
@@ -1851,6 +1869,21 @@ const submitReward = (reward) => {
     onIptSetErrorTxt();
 }
 
+const updateUSDeposit = async () => {
+    if(showDepositMessageBox.value) {
+        let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
+
+        if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
+            currentCurrencyInfo.value = currencyInfoRes.data;
+            let {balance} = currencyInfoRes.data;
+            if(balance >= finalAmountData.value.orderAmountValue) {
+                USDepositStatus.value = 'SUCCESS';
+            }
+        }
+    }
+};
+
+
 const depositAchCancel = async () => {
     showDepositMessageBox.value = false;
     let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
@@ -1864,6 +1897,7 @@ const depositAchCancel = async () => {
     }
 }
 
+
 const depositAchConfirm = async () => {
     let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
 
@@ -1874,16 +1908,27 @@ const depositAchConfirm = async () => {
         let {balance} = currencyInfoRes.data;
         if(balance >= finalAmountData.value.orderAmountValue) {
             USDepositStatus.value = 'SUCCESS';
+            payButtonDom.value && payButtonDom.value.balancePay();
         } else {
             message.info('Deposit failed, please try again later');
         }
     }
 }
 
+const onPageVisbile = () => {
+    document.addEventListener('visibilitychange', function () {
+        let isHidden = document.hidden;
+        if (!isHidden) {
+            updateUSDeposit();
+        }
+    });
+}
+
 onMounted(() => {
     setFrontConfig();
     setPayConfig();
     getLocalCurrencyInfoByCode();
+    onPageVisbile();
     window.addEventListener('resize', function () {
         setDialogStyle(true);
     })

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

@@ -53,7 +53,7 @@
 import { ref, defineProps, defineEmits, onMounted } from "vue";
 import axios from 'axios';
 import { message } from "ant-design-vue";
-import { convertUrl, getAllPostEditorAppData } from "@/http/toolBoxApi";
+import { convertUrl, getAllPostEditorAppData, checkInputUrlInBlacklist } from "@/http/toolBoxApi";
 import { setChromeStorage, getChromeStorage } from "@/uilts/chromeExtension"
 import { checkURL, debounce } from "@/uilts/help"
 
@@ -98,6 +98,23 @@ const searchHandler = async (_params) => {
     message.error('Page loading failed');
   }, 1000 * 15);
 
+  if(!_params) {
+    let blackListRes = await checkInputUrlInBlacklist({
+      params: {
+        url: siteUrl.value
+      }
+    })
+
+    if(blackListRes.code == 0) {
+      if(blackListRes.data) {
+        loadingHide();
+        clearTimeout(timer);
+        message.info('This site is not supported');
+        return;
+      }
+    }
+  }
+
   let siteRes = await axios.get(siteUrl.value);
 
   let currentApp = {

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

@@ -28,6 +28,9 @@
 import { ref, reactive, onMounted } from "vue";
 import { checkURL } from "@/uilts/help"
 import { setChromeStorage, getChromeStorage } from "@/uilts/chromeExtension"
+import { message } from "ant-design-vue";
+
+import { checkInputUrlInBlacklist } from "@/http/toolBoxApi";
 
 let siteUrl = ref('');
 
@@ -40,9 +43,23 @@ const confirm = async () => {
     siteUrl.value = siteUrl.value.trim();
 
     if (!checkURL(siteUrl.value)) {
+        message.info('Incorrect URL entered');
         return;
     }
 
+    let blackListRes = await checkInputUrlInBlacklist({
+        params: {
+            url: siteUrl.value
+        }
+    })
+
+    if(blackListRes.code == 0) {
+        if(blackListRes.data) {
+            message.info('This site is not supported');
+            return;
+        }
+    }
+
     let {list: windowList = []} = await getChromeStorage('guideAppWindowList') || {list: []};
 
     chrome.runtime.sendMessage({

+ 8 - 25
src/view/iframe/tool-box/card.vue

@@ -70,7 +70,8 @@ import { getChromeStorage, setChromeStorage, defineProps, sendChromeTabMessage }
 import { getPostDetail } from '@/http/redPacket.js'
 import { guid, getQueryString } from "@/uilts/help";
 import { onMounted, reactive, ref } from "vue";
-let dom_area_iframe = ref(null)
+import { reSetBindTwtterId } from '@/http/help.js'
+let dom_iframe = ref(null)
 let state = reactive({
     status: '', //
     show_alert: false,
@@ -143,30 +144,6 @@ onMounted(() => {
     })
 
 })
-let area_iframe
-
-const createIframe = () => {
-    area_iframe = dom_area_iframe.value
-    if (area_iframe.querySelector('iframe')) {
-        return
-    }
-    let iframe = document.createElement('iframe')
-    iframe.onerror = () => {
-        state.status = '网页错误'
-    }
-    iframe.onload = () => {
-        if (state.status == '加载' || state.status == 'iframe') {
-            state.show_btn = true
-            state.status = 'iframe'
-        }
-    }
-    // if (state.detail.urlInBlacklist) {
-    //     iframe.sandbox = "allow-same-origin allow-scripts allow-popups allow-top-navigation allow-forms allow-modals allow-popups-to-escape-sandbox allow-presentation"
-    // }
-    // state.detail.convertUrl
-    iframe.src = 'https://www.twitter.com'
-    area_iframe.appendChild(iframe)
-}
 
 // detail函数
 const getDetail = () => {
@@ -177,6 +154,12 @@ const getDetail = () => {
     }).then((res) => {
         if (res && res.code == 0) {
             state.detail = JSON.parse(res.data.postBizData)
+            if (!res.data.srcContentId) {
+                reSetBindTwtterId({
+                    postId: state.postId,
+                    tweetId: state.tweetId
+                })
+            }
             console.log('postBizData', state.detail)
             // 加载iframe
             if (state.detail.viewBgImagePath) {

+ 24 - 2
src/view/popup/currency-detail.vue

@@ -186,6 +186,7 @@ const clickDeposit = () => {
       if(currencyInfo.currencyCode == 'USD') {
         // 法币充值
         showDepositInput.value = true;
+        setDepositDesc();
           
       } else {
         depositHandle(currencyInfo);
@@ -193,6 +194,20 @@ const clickDeposit = () => {
     }
 }
 
+const setDepositDesc = async () => {
+  let res = await payCalcFee({
+      params: {
+          amountValue: 0,
+          currencyCode: currencyInfo.value.currencyCode,
+          payChannel: 'ach',
+      },
+  });
+  if(res.code == 0) {
+    let {feeDesc} = res.data;
+    depositDesc.value = `${feeDesc}`;
+  }
+}
+
 const depositHandle = (_params) => {
   top_up_info.token = _params.currencyName || ''
   top_up_info.token_chain = _params.tokenChain 
@@ -281,13 +296,16 @@ const confirmDeposit = (params) => {
   setChromeStorage({ achPayInfo : JSON.stringify(achPayInfo)});
 
   chrome.tabs.create({
-      url: guideUrl
+    url: guideUrl
   });
 }
 
 const onDepositAmountInput = async (params = {}) => {
   let {inputVal} = params;
   reqCalcIng = true;
+  if(inputVal === '') {
+    inputVal = 0;
+  }
   let res = await payCalcFee({
       params: {
           amountValue: inputVal,
@@ -299,7 +317,11 @@ const onDepositAmountInput = async (params = {}) => {
   if(res.code == 0) {
     let {feeAmountValue, feeDesc} = res.data;
     finalAmountData.value = res.data;
-    depositDesc.value = `Charge Fee:${feeAmountValue} USD(${feeDesc})`;
+    if(inputVal === 0) {
+      depositDesc.value = `${feeDesc}`;
+    } else {
+      depositDesc.value = `Charge Fee:${feeAmountValue} USD(${feeDesc})`;
+    }
   }
 }
 

+ 1 - 1
src/view/popup/withdraw/confirm.vue

@@ -101,7 +101,7 @@ const clickBtn = () => {
     })
 
 }
-onMounted(()=>{
+onMounted(() => {
     Report.reportLog({
         pageSource: Report.pageSource.denetWithdrawConfirm,
         businessType: Report.businessType.pageView,