GoJs 去水印
此下方法主要是修改了go.js 2.2.9版本的Pa这个函数,通过下面的方式针对水印部分做特殊处理
注意:2.2.9版本是有效的,其他版本未测试,如果不行的话,请按照此方法针对性的做调整即可
在项目跟目录新建文件:removeWatermarkForGoJs.js
内容如下:
const fs = require("fs"); const path = require("path"); const filePaths = [ "./node_modules/gojs/release/go.js", "./node_modules/gojs/release/go-module.js", ] filePaths.map(filePath => { const file = path.join(__dirname, filePath); fs.readFile(file, "utf8", function (err, data) { if (err) throw err; let content = data.replace("String.fromCharCode(a.charCodeAt(g)^b[(b[c]+b[d])%256]);return f", `String.fromCharCode(a.charCodeAt(g)^b[(b[c]+b[d])%256]); if ( /GoJS \d\.\d evaluation/.test(f) || /? 1998-\d{4} Northwoods Software/.test(f) || "Not for distribution or production use" === f || "gojs.net" === f ) { return ""; } else { return f; } ` ); fs.writeFile(file, content, "utf8", (err) => { if (err) throw err; console.log('remove gojs watermark success done!!'); }); }); })
修改package.json文件,主要修改scripts部分,代码如下:
"scripts": { "serve": "node removeWatermarkForGoJs && vue-cli-service serve --copy --port 8088", "build": "node removeWatermarkForGoJs && vue-cli-service build", "test:unit": "vue-cli-service test:unit", "test:e2e": "vue-cli-service test:e2e", "lint": "vue-cli-service lint" }
重新启动项目,或者重新打包水印就没有了,效果如下: