소스 검색

[bug] fix

wenliming 3 년 전
부모
커밋
f4400f5c17
6개의 변경된 파일41개의 추가작업 그리고 20개의 파일을 삭제
  1. 0 1
      library/paypal.html
  2. 23 14
      src/entry/background.js
  3. 2 2
      src/logic/twitter.js
  4. 7 0
      src/uilts/chromeExtension.js
  5. 6 2
      src/view/components/give-dialog.vue
  6. 3 1
      src/view/components/preview-card.vue

+ 0 - 1
library/paypal.html

@@ -140,7 +140,6 @@
                                     var transaction =
                                         orderData.purchase_units[0].payments
                                             .captures[0];
-                                    amount = 0;
                                     window.parent.postMessage(
                                         {
                                             actionType: "payCallBack",

+ 23 - 14
src/entry/background.js

@@ -5,7 +5,7 @@ import {
     backTwitterPinLoginCode,
 } from "../logic/twitter.js";
 
-import { setChromeStorage, getChromeCookie, LANDING_PAGE, setChromeCookie, LANDING_PAGE_MIND } from "../uilts/chromeExtension";
+import { setChromeStorage, getChromeCookie, LANDING_PAGE, setChromeCookie, removeChromeCookie, LANDING_PAGE_MIND } from "../uilts/chromeExtension";
 import { guid } from '../uilts/help.js'
 
 chrome.runtime.onInstalled.addListener(onInstalledMethod);
@@ -13,20 +13,24 @@ chrome.runtime.onInstalled.addListener(onInstalledMethod);
 chrome.runtime.onMessage.addListener(onMessageMethod);
 
 function onInstalledMethod() {
-    getChromeCookie({
-        name: 'pickup_info',
-        url: 'https://de-net-test.piaoquantv.com'
-    }, (res) => {
-        if(res) {
-            let {postNickName, srcContentId} = res;
-            if(postNickName && srcContentId) {
-                let url = `https://twitter.com/${postNickName}/status/${srcContentId}`
-                chrome.tabs.create({
-                    url
-                });
-            }
+    let cookiesParams = {
+        name: "pickup_info",
+        url: "https://de-net-test.piaoquantv.com",
+    };
+    getChromeCookie(cookiesParams, (res) => {
+        let { postNickName, srcContentId } = res;
+        if (res && postNickName && srcContentId) {
+            let url = `https://twitter.com/${postNickName}/status/${srcContentId}`;
+            chrome.tabs.create({
+                url,
+            });
+            removeChromeCookie(cookiesParams);
         } else {
-            backTwitterPinLoginToken();
+            chrome.tabs.create({
+                url: "https://twitter.com",
+            });
+            let { isOnToolbar } = checkIsPinned();
+            console.log(isOnToolbar);
         }
     })
     getChromeCookie(LANDING_PAGE_MIND, (res_arr) => {
@@ -43,6 +47,11 @@ function onInstalledMethod() {
     })
 }
 
+async function checkIsPinned(){
+    let userSettings = await chrome.action.getUserSettings();
+    console.log('userSettings', userSettings.isOnToolbar)
+}
+
 function onMessageMethod(req, sender, sendResponse) {
     if (req) {
         switch (req.method) {

+ 2 - 2
src/logic/twitter.js

@@ -376,12 +376,12 @@ function _createBtnDom(port) {
 
 function addSliderNavDeBtn(isSmall = false) {
     if (!isSmall) {
-        let bigDom = document.querySelector('header[role="banner"]').querySelector('.r-1habvwh');
+        let bigDom = document.querySelector('h1[role]').parentNode.parentNode;
         if (bigDom) {
             bigDom.appendChild(dom.deBtn);
         }
     } else {
-        let smallDom = document.querySelector('header[role="banner"]').querySelector('.r-1awozwy');
+        let smallDom = document.querySelector('h1[role]').parentNode.parentNode;
         if (smallDom) {
             smallDom.appendChild(dom.deBtn3);
         }

+ 7 - 0
src/uilts/chromeExtension.js

@@ -97,3 +97,10 @@ export function concatChromeCookie({ name, url }, value_obj) {
         }
     )
 }
+
+export function removeChromeCookie(params, cb) {
+    let {name, url} = params;
+    chrome.cookies.remove({name, url}, () => {
+        cb && cb
+    })
+}

+ 6 - 2
src/view/components/give-dialog.vue

@@ -211,6 +211,11 @@ watch(
     () => props.dialogVisible,
     (newVal) => {
         console.log("watch", newVal);
+        if(newVal) {
+            setTimeout(() => {
+                setDialogHeight();
+            }, 300)
+        }
         visible.value = newVal;
     }
 );
@@ -228,7 +233,7 @@ const close = () => {
 };
 
 const setDialogHeight = () => {
-    let clientHeight = document.documentElement.clientHeight;
+    let clientHeight = window.innerHeight;
     let gapSafe = 40;
 
     if(dialogHeight.value > clientHeight - gapSafe) {
@@ -484,7 +489,6 @@ const setFrontConfig = () => {
 
 onMounted(() => {
     setFrontConfig();
-    setDialogHeight();
     setPayConfig();
     document.onkeydown = function(e){    
         var keyNum=window.event ? e.keyCode :e.which;

+ 3 - 1
src/view/components/preview-card.vue

@@ -172,8 +172,10 @@ onMounted(() => {
 
             .article-wrapper {
                 display: flex;
-                .nickname, .name {
+                .nickname {
                     font-weight: 500;
+                }
+                .nickname, .name {
                     font-size: 15px;
                 }
                 .name {