diff --git a/public/api_address_config.js b/public/api_address_config.js index 4b57f53c..1d5a9abd 100644 --- a/public/api_address_config.js +++ b/public/api_address_config.js @@ -16,3 +16,8 @@ window._CONFIG.onlyOfficeUrl = 'http://127.0.0.1:8080' window._CONFIG.onlyOfficeDownloadFileUrl = 'http://localhost:8184/sys/common/download' // 管理员角色code,英文逗号拼接 window._CONFIG.adminRoleCode = 'admin,BZGLY' +// 水印配置 +window._CONFIG.watermarkConfig = { + color: 'rgba(180, 180, 180, 0.2)', + font: '13px Microsoft Yahei' +} diff --git a/src/App.vue b/src/App.vue index b5a9848e..f25550e6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,7 +2,7 @@
-
+
@@ -37,6 +37,9 @@ export default { return this.$store.getters.userInfo.username + this.$store.getters.userInfo.realname } return null + }, + watermarkConfig () { + return window._CONFIG.watermarkConfig } }, watch: { diff --git a/src/utils/kkFilePreview.js b/src/utils/kkFilePreview.js index c1a2f9b5..d4560b5e 100644 --- a/src/utils/kkFilePreview.js +++ b/src/utils/kkFilePreview.js @@ -1,8 +1,7 @@ import Vue from 'vue' import { USER_INFO } from '../store/mutation-types' import { Base64 } from 'js-base64' - -const md5 = require('md5') +import md5 from 'md5' /** * kkFile预览文件并添加水印 @@ -13,7 +12,7 @@ export const kkFilePreview = (fileUrl) => { // 水印内容 const watermarkTxt = `${userInfo.username} ${userInfo.realname}` // 客户环境预览需要加的加密参数 - const watermarkSign = md5(watermarkTxt, 'cnhtc') + const watermarkSign = md5(watermarkTxt + 'cnhtc') const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}` window.open(url) } \ No newline at end of file diff --git a/src/utils/warterMark.js b/src/utils/warterMark.js index e5b882ef..113b82b0 100644 --- a/src/utils/warterMark.js +++ b/src/utils/warterMark.js @@ -16,7 +16,7 @@ Vue.directive('watermark', { can.style.display = 'none' const cans = can.getContext('2d') cans.rotate(-20 * Math.PI / 180) - cans.font = font || '13px Microsoft Yahei' + cans.font = font || window._CONFIG.watermarkConfig.font cans.fillStyle = textColor || '#DDDDDD' cans.textAlign = 'left' cans.textBaseline = 'Middle' @@ -38,6 +38,7 @@ Vue.directive('watermark', { parentNode.appendChild(div) } } + if (binding.value.text) { addWaterMarker(binding.value.text, el, binding.value.width, binding.value.height, binding.value.font, binding.value.textColor, binding.value.fillTextX) }