Browse Source

水印优化

李文 4 years ago
parent
commit
aa23d815ac
1 changed files with 14 additions and 2 deletions
  1. 14 2
      src/utils/shuiyin.js

+ 14 - 2
src/utils/shuiyin.js

@@ -1,9 +1,11 @@
 // 添加水印方法
-export default function (strArr) {
+let syAttr = []
+function setShuiyin (strArr) {
   // let cpyName = str
   // if (str.length > 16) {
   //   cpyName = str.substring(0, 16)
   // }
+  syAttr = strArr
   if (window.$('.shuiyincanvas')[0]) {
     window.$('.shuiyincanvas')[0].remove()
   }
@@ -15,8 +17,16 @@ export default function (strArr) {
   let boxWL = Math.ceil(winW / boxW)
   let boxHL = Math.ceil(winH / boxH)
   let canvas = window.$('<canvas class="shuiyincanvas"></canvas>')
-  let report = window.$('body')
+  let report = window.$('.navbar-logo')
   report.append(canvas)
+  // window.$('.navbar-logo').on('DOMNodeRemoved', function (e) {
+  //   let className = window.$('.shuiyincanvas').attr('class')
+  //   console.log(className)
+  //   if (className === 'shuiyincanvas') {
+  //     setShuiyin(syAttr, 1)
+  //     window.$('.navbar-logo').off('DOMNodeRemoved')
+  //   }
+  // })
   canvas.css({
     zIndex: '999',
     position: 'fixed',
@@ -52,3 +62,5 @@ function setName (arr, ctx) {
     ctx.fillText(e, 0, i * h)
   })
 }
+
+export default setShuiyin