update 增加水印
This commit is contained in:
parent
814b3084de
commit
d15ee19390
@ -5,7 +5,7 @@
|
||||
<meta base="/management/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>数字化管理系统</title>
|
||||
<title>企业数字化管理系统</title>
|
||||
<script src="https://f.ldxinyong.com/h5/echarts.min.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import { isAuth } from '@/utils'
|
||||
import echarts from 'echarts'
|
||||
import '@/assets/scss/index.scss'
|
||||
import '@/element-ui-theme'
|
||||
import watermark from '@/utils/watermark'
|
||||
|
||||
import VCharts from 'v-charts'
|
||||
Vue.use(VCharts)
|
||||
@ -17,6 +18,7 @@ Vue.use(VueCookie)
|
||||
Vue.config.productionTip = false
|
||||
|
||||
// 挂载全局
|
||||
Vue.prototype.$watermark = watermark // 水印
|
||||
Vue.prototype.$echarts = echarts // echarts画图
|
||||
Vue.prototype.isAuth = isAuth // 权限方法
|
||||
|
||||
|
||||
52
src/utils/watermark.js
Normal file
52
src/utils/watermark.js
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 水印画布
|
||||
*/
|
||||
const watermark = {}
|
||||
|
||||
const setWatermark = (str) => {
|
||||
const id = '1.23452384164.123412415'
|
||||
|
||||
if (document.getElementById(id) !== null) {
|
||||
document.body.removeChild(document.getElementById(id))
|
||||
}
|
||||
|
||||
const can = document.createElement('canvas')
|
||||
can.width = 150
|
||||
can.height = 120
|
||||
|
||||
const cans = can.getContext('2d')
|
||||
cans.rotate(-20 * Math.PI / 180)
|
||||
cans.font = '15px Vedana'
|
||||
cans.fillStyle = 'rgba(0, 0, 0, 0.05)'
|
||||
cans.textAlign = 'left'
|
||||
cans.textBaseline = 'Middle'
|
||||
cans.fillText(str, can.width / 20, can.height)
|
||||
|
||||
const div = document.createElement('div')
|
||||
div.id = id
|
||||
div.style.pointerEvents = 'none'
|
||||
div.style.top = '3px'
|
||||
div.style.left = '0px'
|
||||
div.style.position = 'fixed'
|
||||
div.style.zIndex = '100000'
|
||||
div.style.width = document.documentElement.clientWidth + 'px'
|
||||
div.style.height = document.documentElement.clientHeight + 'px'
|
||||
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
|
||||
document.body.appendChild(div)
|
||||
return id
|
||||
}
|
||||
|
||||
// 该方法只允许调用一次
|
||||
watermark.set = (str) => {
|
||||
let id = setWatermark(str)
|
||||
setInterval(() => {
|
||||
if (document.getElementById(id) === null) {
|
||||
id = setWatermark(str)
|
||||
}
|
||||
}, 2000)
|
||||
window.onresize = () => {
|
||||
setWatermark(str)
|
||||
}
|
||||
}
|
||||
|
||||
export default watermark
|
||||
@ -3,7 +3,7 @@
|
||||
<div class="site-content__wrapper">
|
||||
<div class="site-content">
|
||||
<div class="brand-info">
|
||||
<h2 class="brand-info__text">数字化管理系统</h2>
|
||||
<h2 class="brand-info__text">企业数字化管理系统</h2>
|
||||
</div>
|
||||
<div class="login-main">
|
||||
<h3 class="login-title">用户登录</h3>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType">
|
||||
<div class="site-navbar__header">
|
||||
<h1 class="site-navbar__brand" @click="$router.push({ name: 'home' })">
|
||||
<a class="site-navbar__brand-lg" href="javascript:;">数字化管理系统</a>
|
||||
<a class="site-navbar__brand-lg" href="javascript:;">企业数字化管理系统</a>
|
||||
<a class="site-navbar__brand-mini" href="javascript:;">系统</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@ -80,6 +80,8 @@
|
||||
this.loading = false
|
||||
this.userId = res.user.userId
|
||||
this.userName = res.user.username
|
||||
this.mobile = res.user.mobile
|
||||
this.$watermark.set(this.userName + ' ' + this.mobile.substr(0, 4))
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user