Commit 69368f13 by xue_wengang

水印

parent ec753e31
......@@ -14,7 +14,6 @@ import store from "./store";
import "./plugins/element.js";
import Util from "./utils/util";
import VueWechatTitle from "vue-wechat-title";
import Watermark from "./utils/watermark.js"
import Driver from 'driver.js'
import 'driver.js/dist/driver.min.css'
import './assets/iconfont/iconfont.css'
......@@ -54,14 +53,6 @@ Vue.prototype.$bus = new Vue()
window.util = Util;
Vue.use(VueWechatTitle);
let userInfo = window.sessionStorage.getItem("userInfo") || "";
if (userInfo) {
userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"))
let info = `${userInfo.realname} ${userInfo.identitycard}`
let zjhm = userInfo.identitycard.replace(/^(.{10})(?:\d+)(.{4})$/, "$1****$2")
Watermark.set(userInfo.realname, zjhm, userInfo.ip)
}
Vue.directive("nsLoading", {
bind(el, binding) {
const instance = new LoadingCons({
......
......@@ -54,7 +54,8 @@ import xsspPtRoutes from "./modules/xsspPt";
import pgypbgglRoutes from "./modules/pgypbggl";
import commonServerRoutes from "./modules/commonServer";
import aiModuleRoutes from "./modules/aiModule";
import Watermark from "../utils/watermark.js"
import moment from '../utils/util'
import rwddRoutes from "./modules/rwddzx";
import zcxwRoutes from "./modules/zcxw";
......@@ -153,15 +154,26 @@ const router = createRouter()
// });
router.beforeEach((to, from, next) => {
if (to.meta.isAdd) {
if (!to.meta.langTile) {
to.meta.langTile = to.meta.title;
}
let str = `新增${to.meta.langTile}`;
if (to.query.xxzjbh) {
str = `修改${to.meta.langTile}`;
if (to.path != '/login' && to.path != '/jump') {
if (to.meta.isAdd) {
if (!to.meta.langTile) {
to.meta.langTile = to.meta.title;
}
let str = `新增${to.meta.langTile}`;
if (to.query.xxzjbh) {
str = `修改${to.meta.langTile}`;
}
to.meta.title = str;
}
to.meta.title = str;
let userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"))
let name = userInfo.realname.substring(0, userInfo.realname.length - 1)
let names = userInfo.realname.replace(name, '***')
let zjhm = userInfo.identitycard.replace(/^(.{10})(?:\d+)(.{4})$/, "$1****$2")
let one = `${zjhm} ${names}`
let xmmc = '西藏刑侦综合应用系统'
let two = `${userInfo.ip} ${xmmc}`
let time = moment.timeStampTurnTime(new Date().getTime())
Watermark.set(one, time, two, userInfo.unitname)
}
next()
})
......
let watermark = {}
let setWatermark = (str,str3,str4,str5) => {
let id = '1.23452384164.123412415'
if (document.getElementById(id) !== null) {
document.body.removeChild(document.getElementById(id))
}
let can = document.createElement('canvas')
can.width = 300
can.height = 230
let cans = can.getContext('2d')
cans.rotate(-20 * Math.PI / 180)
cans.font = '13px Vedana'
cans.fillStyle = 'rgba(0, 0, 0, 0.1)'
cans.textAlign = 'left'
cans.textBaseline = 'Middle'
cans.fillText(str, can.width / 3, can.height / 2)
cans.fillText(str3, can.width / 3, can.height / 1.73)
cans.fillText(str4, can.width / 3, can.height / 1.55)
// cans.fillText(str5, can.width / 3, can.height / 1.38)
let div = document.createElement('div')
div.id = id
div.style.pointerEvents = 'none'
div.style.top = '70px'
div.style.left = '50px'
div.style.position = 'fixed'
div.style.zIndex = '100000'
div.style.width = document.documentElement.clientWidth - 125 + 'px'
div.style.height = document.documentElement.clientHeight - 125 + 'px'
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
document.body.appendChild(div)
return id
let setWatermark = (str1,str2,str3,str4) => {
let id = '1.23452384164.123412415'
if (document.getElementById(id) !== null) {
document.body.removeChild(document.getElementById(id))
}
let can = document.createElement('canvas')
can.width = 600
can.height = 400
let cans = can.getContext('2d')
cans.rotate(-20 * Math.PI / 180)
cans.font = '16px Vedana'
cans.fillStyle = 'rgba(0, 0, 0, 0.35)'
cans.textAlign = 'left'
cans.textBaseline = 'Middle'
cans.fillText(str1, can.width / 3, can.height / 2)
cans.fillText(str2, can.width / 3, can.height / 1.7)
cans.fillText(str3, can.width / 3, can.height / 1.5)
cans.fillText(str4, can.width / 3, can.height / 1.35)
let div = document.createElement('div')
div.id = id
div.style.pointerEvents = 'none'
div.style.top = '10px'
div.style.left = '0px'
div.style.position = 'fixed'
div.style.zIndex = '100000'
div.style.width = document.documentElement.clientWidth - 10 + 'px'
div.style.height = document.documentElement.clientHeight - 10 + 'px'
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
document.body.appendChild(div)
return id
}
// 该方法只允许调用一次
watermark.set = (str,str3,str4) => {
let id = setWatermark(str,str3,str4)
setInterval(() => {
if (document.getElementById(id) === null) {
id = setWatermark(str,str3,str4)
watermark.set = (str1,str2,str3,str4) => {
let id = setWatermark(str1,str2,str3,str4)
setInterval(() => {
if (document.getElementById(id) === null) {
id = setWatermark(str1,str2,str3,str4)
}
}, 500)
window.onresize = () => {
setWatermark(str1,str2,str3,str4)
}
}, 500)
window.onresize = () => {
setWatermark(str,str3,str4)
}
}
export default watermark
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment