Explorar o código

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

nieyuge %!s(int64=2) %!d(string=hai) anos
pai
achega
c8846243a1
Modificáronse 3 ficheiros con 37 adicións e 10 borrados
  1. 3 2
      src/iframe/home.js
  2. 19 2
      src/logic/content/twitter.js
  3. 15 6
      src/view/iframe/publish/give-dialog.vue

+ 3 - 2
src/iframe/home.js

@@ -6,7 +6,7 @@ const app = createApp(App)
 // 引入路由对象实例
 import router from '@/router/popup.js'
 import "ant-design-vue/dist/antd.css"; // or 'ant-design-vue/dist/antd.less'
-import { Button, message, Tooltip } from "ant-design-vue";
+import { Button, message, Tooltip, Switch } from "ant-design-vue";
 
 message.config({
     top: `10px`,
@@ -15,10 +15,11 @@ message.config({
 });
 app.use(Tooltip);
 app.use(Button);
+app.use(Switch)
 app.use(message);
 app.use(router)
 app.mount('#app')
 
-window.onload= () => {
+window.onload = () => {
     document.title = 'DeNet'
 }

+ 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;