Procházet zdrojové kódy

fix:复制文本多了换行符

Karsa před 11 měsíci
rodič
revize
92946940a6

+ 9 - 2
src/utils/svgToblob.js

@@ -38,7 +38,7 @@
 
 /* 转base64 */
 export const svgToBase64 = (svg) => {
-  const base64img = `data:image/svg+xml;base64,${window.btoa(
+  const base64img = `data:image/svgxmbase64,${window.btoa(
     unescape(encodeURI(svg))
   )}`;
   return base64img;
@@ -50,7 +50,14 @@ export function copyFit(value) {
     navigator.clipboard.writeText(value)
   }else {
     setTimeout(() => {
-      bus.$copyText(value)
+      const input = document.createElement('input')
+      input.setAttribute('readonly','readonly')
+      input.setAttribute('id',new Date().getTime())
+      input.value = value
+      document.body.appendChild(input)
+      input.select();
+      document.execCommand('copy');
+      document.body.removeChild(input);
     })
   }
 

+ 2 - 2
src/views/datasheet_manage/components/SheetExcel.vue

@@ -56,12 +56,12 @@ export default {
     copyData() {
       let rangeArr = luckysheet.getRangeArray('twoDimensional');
       let str = ''
-      rangeArr.forEach(item => {
+      rangeArr.forEach((item,r_index) => {
         let row = ''
         item.forEach((cell,index) => {
           row+= `${index!==0?'\t':''}${cell||''}`
         })
-        str+=`${row}\n`
+        str+= r_index===rangeArr.length-1 ? row : `${row}\n`
       });
       
       copyFit(str)