(id, str, $element)
| 707 | return str.replace(replaceStr, newStr) |
| 708 | }, |
| 709 | addWaterMask(id, str, $element) { |
| 710 | // 增加水印 |
| 711 | |
| 712 | if (document.getElementById(id) !== null) { |
| 713 | try { |
| 714 | document.body.removeChild(document.getElementById(id)); |
| 715 | } catch (err) {} |
| 716 | } |
| 717 | if (!str) return; |
| 718 | const can = document.createElement('canvas'); |
| 719 | const strLength = str.length |
| 720 | can.width = 30 * strLength; |
| 721 | can.height = Math.min(200, 30 * strLength); |
| 722 | |
| 723 | const cans = can.getContext('2d'); |
| 724 | // 旋转角度 |
| 725 | cans.rotate(-15 * Math.PI / 180); |
| 726 | cans.font = '18px Vedana'; |
| 727 | // 设置填充绘画的颜色、渐变或者模式 |
| 728 | cans.fillStyle = 'rgba(200, 200, 200, 0.40)'; |
| 729 | // 设置文本内容的当前对齐方式 |
| 730 | cans.textAlign = 'left'; |
| 731 | // 设置在绘制文本时使用的当前文本基线 |
| 732 | cans.textBaseline = 'Middle'; |
| 733 | // 在画布上绘制填色的文本(输出的文本,开始绘制文本的X坐标位置,开始绘制文本的Y坐标位置) |
| 734 | cans.fillText(str, can.width / 8, can.height / 2); |
| 735 | |
| 736 | const div = document.createElement('div'); |
| 737 | div.id = id; |
| 738 | div.style.pointerEvents = 'none'; |
| 739 | div.style.top = '30px'; |
| 740 | div.style.left = '0px'; |
| 741 | div.style.position = 'absolute'; |
| 742 | div.style.zIndex = '1'; |
| 743 | div.style.width = `100%`; |
| 744 | div.style.height = `100%`; |
| 745 | div.style.background = `url(${can.toDataURL('image/png')}) left top repeat`; |
| 746 | $element && $element.appendChild(div); |
| 747 | return id; |
| 748 | }, |
| 749 | clearData(property) { |
| 750 | // 当组件是api或者SSE 删除组件的数据 |
| 751 | property.option.data.forEach(item => { |
nothing calls this directly
no outgoing calls
no test coverage detected