update 水印颜色、字体提出配置项

This commit is contained in:
赵霄
2024-01-02 14:50:02 +08:00
parent 64a66bad91
commit 74e6cdba16
3 changed files with 11 additions and 2 deletions
+5
View File
@@ -16,3 +16,8 @@ window._CONFIG.onlyOfficeUrl = 'http://127.0.0.1:8080'
window._CONFIG.onlyOfficeDownloadFileUrl = 'http://localhost:8184/sys/common/download' window._CONFIG.onlyOfficeDownloadFileUrl = 'http://localhost:8184/sys/common/download'
// 管理员角色code,英文逗号拼接 // 管理员角色code,英文逗号拼接
window._CONFIG.adminRoleCode = 'admin' window._CONFIG.adminRoleCode = 'admin'
// 水印配置
window._CONFIG.watermarkConfig = {
color: 'rgba(180, 180, 180, 0.2)',
font: '13px Microsoft Yahei'
}
+4 -1
View File
@@ -2,7 +2,7 @@
<a-config-provider :locale="locale"> <a-config-provider :locale="locale">
<div id="app"> <div id="app">
<router-view v-if="isRouterAlive" /> <router-view v-if="isRouterAlive" />
<div class="watermark" v-if="show" v-watermark="{text: watermark, textColor: 'rgba(180, 180, 180, 0.2)'}"></div> <div class="watermark" v-if="show" v-watermark="{text: watermark, textColor: watermarkConfig.color}"></div>
</div> </div>
</a-config-provider> </a-config-provider>
</template> </template>
@@ -37,6 +37,9 @@ export default {
return this.$store.getters.userInfo.username + this.$store.getters.userInfo.realname return this.$store.getters.userInfo.username + this.$store.getters.userInfo.realname
} }
return null return null
},
watermarkConfig () {
return window._CONFIG.watermarkConfig
} }
}, },
watch: { watch: {
+2 -1
View File
@@ -16,7 +16,7 @@ Vue.directive('watermark', {
can.style.display = 'none' can.style.display = 'none'
const cans = can.getContext('2d') const cans = can.getContext('2d')
cans.rotate(-20 * Math.PI / 180) cans.rotate(-20 * Math.PI / 180)
cans.font = font || '13px Microsoft Yahei' cans.font = font || window._CONFIG.watermarkConfig.font
cans.fillStyle = textColor || '#DDDDDD' cans.fillStyle = textColor || '#DDDDDD'
cans.textAlign = 'left' cans.textAlign = 'left'
cans.textBaseline = 'Middle' cans.textBaseline = 'Middle'
@@ -38,6 +38,7 @@ Vue.directive('watermark', {
parentNode.appendChild(div) parentNode.appendChild(div)
} }
} }
if (binding.value.text) { if (binding.value.text) {
addWaterMarker(binding.value.text, el, binding.value.width, binding.value.height, binding.value.font, binding.value.textColor, binding.value.fillTextX) addWaterMarker(binding.value.text, el, binding.value.width, binding.value.height, binding.value.font, binding.value.textColor, binding.value.fillTextX)
} }