瀏覽代碼

[fix] publish bug

wenliming 2 年之前
父節點
當前提交
808633ff7a
共有 2 個文件被更改,包括 34 次插入8 次删除
  1. 19 2
      src/logic/content/twitter.js
  2. 15 6
      src/view/iframe/publish/give-dialog.vue

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

@@ -114,7 +114,8 @@ export function showTwitterPublishDialogHandler(publishRes) {
     addPublishTipsIframe({
         srcContent: publishRes.copyContent
     })
-    _setPublishContent(publishRes.srcContent);
+    // _setPublishContent(publishRes.srcContent);
+    setDialogPublishContent(publishRes.srcContent);
     _publishTweetEvent(publishRes, bindTwitterArtMethod);
 }
 
@@ -480,6 +481,22 @@ export const _setPublishContent = throttle(function (content, time = 1000) {
     }
 }, 800);
 
+
+const setDialogPublishContent =  throttle(function (content) {
+    setTimeout(() => {
+        let inputEle = document.querySelector('div[role="dialog"]').querySelector('div[contenteditable="true"]');
+        const dataTransfer = new DataTransfer();
+        dataTransfer.setData('text', content);
+        const event = new ClipboardEvent('paste', {
+            clipboardData: dataTransfer,
+            bubbles: true
+        });
+        if(inputEle) {
+            inputEle.dispatchEvent(event);
+        }
+    }, 300)
+}, 600);
+
 /**
  * 创建deNet按钮 添加到页面
  * @returns {{deBtn2: HTMLDivElement, deBtn1: HTMLDivElement, deBtn: HTMLSpanElement}}
@@ -1571,7 +1588,7 @@ export const appendPopupPage = (params = {}) => {
     let iframe = document.createElement('iframe');
     iframe.id = 'de-popup-page';
     iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
-    iframe.style.cssText = `border: medium none; width: 375px;
+    iframe.style.cssText = `border: medium none; width: 375px !important;
         height: 650px;position: fixed; right: 16px; top: 16px;background: #FFFFFF;border: 0.5px solid #919191;box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);box-sizing: border-box;z-index: 90000;
         animation-duration: 0.5s !important;
         animation-timing-function: ease-in-out !important;

+ 15 - 6
src/view/iframe/publish/give-dialog.vue

@@ -762,18 +762,21 @@ const selectCurrencyAfter = (params, openWindow = true) => {
         setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
         showCurrencyPop.value = false;
         finalAmountData.value.currencyCode = currentCurrencyInfo.value.currencyCode;
-        resetFormIpt();
+        resetFormIpt(false);
         onIptSetErrorTxt();
     }
 }
 
-const resetFormIpt = () => {
+const resetFormIpt = (clearMode = true) => {
     baseFormData.amountValue = "";
     baseFormData.totalCount = "";
     baseFormData.validityDuration = "";
-    selectModeInfo.index = 0;
-    selectModeInfo.type = publishModeList[selectModeInfo.index]['type'];
-    baseFormData.type = selectModeInfo.type;
+
+    if(clearMode) {
+        selectModeInfo.index = 0;
+        selectModeInfo.type = publishModeList[selectModeInfo.index]['type'];
+        baseFormData.type = selectModeInfo.type;
+    }
 }
 
 const setLocalSelectCurrencyInfo = (params = {}) => {
@@ -815,7 +818,7 @@ const messageBoxCancel = () => {
     showMessageBox.value = false;
     showCurrencyPop.value = false;
     showCurrencySelect.value = false;
-    resetFormIpt();
+    resetFormIpt(false);
     onIptSetErrorTxt();
 };
 
@@ -1114,11 +1117,17 @@ const onAmountInput = () => {
 
 const onCountInput = () => {
     let val = baseFormData.totalCount;
+    const maxCount = 100000000;
+
     if (val == 0) {
         val = "";
     }
     val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
 
+    if(val > maxCount) {
+        val = maxCount
+    } 
+
     baseFormData.totalCount = val;
     setInputErrorMsg({from: 'count', type:'input'});
     return val;