Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
founder_vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
founder_vue
Commits
67b35959
Commit
67b35959
authored
Jul 12, 2022
by
gao_yingdong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
水印
parent
b314c267
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
23 deletions
+105
-23
src/main.js
+6
-6
src/router/index.js
+23
-0
src/utils/watermark.js
+21
-17
src/utils/watermark1.js
+55
-0
No files found.
src/main.js
View file @
67b35959
...
@@ -43,12 +43,12 @@ const LoadingCons = Vue.extend(Nsloading);
...
@@ -43,12 +43,12 @@ const LoadingCons = Vue.extend(Nsloading);
Vue
.
prototype
.
$util
=
Util
;
Vue
.
prototype
.
$util
=
Util
;
window
.
util
=
Util
;
window
.
util
=
Util
;
Vue
.
use
(
VueWechatTitle
);
Vue
.
use
(
VueWechatTitle
);
let
userInfo
=
window
.
sessionStorage
.
getItem
(
"userInfo"
)
||
""
;
//
let userInfo = window.sessionStorage.getItem("userInfo") || "";
if
(
userInfo
)
{
//
if (userInfo) {
userInfo
=
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"userInfo"
))
//
userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"))
let
info
=
`
${
userInfo
.
realname
}
${
userInfo
.
identitycard
}
`
//
let info = `${userInfo.realname} ${userInfo.identitycard}`
Watermark
.
set
(
userInfo
.
realname
,
userInfo
.
userName
,
userInfo
.
identitycard
,
userInfo
.
ip
)
//
Watermark.set(userInfo.realname, userInfo.userName, userInfo.identitycard, userInfo.ip)
}
//
}
Vue
.
directive
(
"nsLoading"
,
{
Vue
.
directive
(
"nsLoading"
,
{
bind
(
el
,
binding
)
{
bind
(
el
,
binding
)
{
...
...
src/router/index.js
View file @
67b35959
...
@@ -7,6 +7,9 @@ import indexRoutes from "./modules/index";
...
@@ -7,6 +7,9 @@ import indexRoutes from "./modules/index";
import
rightContentRoutes
from
"./modules/rightContent"
;
import
rightContentRoutes
from
"./modules/rightContent"
;
import
zdryglRoutes
from
"./modules/zdrygl"
;
import
zdryglRoutes
from
"./modules/zdrygl"
;
import
specialRoutes
from
"./modules/specialData"
;
import
specialRoutes
from
"./modules/specialData"
;
import
moment
from
'moment'
import
Watermark
from
'@/utils/watermark'
;
import
Watermark1
from
'@/utils/watermark1'
;
const
originalPush
=
VueRouter
.
prototype
.
push
;
const
originalPush
=
VueRouter
.
prototype
.
push
;
VueRouter
.
prototype
.
push
=
function
push
(
location
)
{
VueRouter
.
prototype
.
push
=
function
push
(
location
)
{
...
@@ -62,5 +65,25 @@ const router = new VueRouter({
...
@@ -62,5 +65,25 @@ const router = new VueRouter({
// }
// }
// next();
// next();
// });
// });
router
.
afterEach
((
to
)
=>
{
var
userInfo
=
JSON
.
parse
(
sessionStorage
.
userInfo
);
// 身份证 和 姓名
let
one
=
userInfo
.
identitycard
.
replace
(
/^
(
.
{10})(?:\d
+
)(
.
{4})
$/
,
"$1****$2"
)
+
' '
+
userInfo
.
realname
// 当前登录时间
let
two
=
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
)
// 1p 和 系统名
let
three
=
(
userInfo
.
ip
==
undefined
||
userInfo
.
ip
==
null
)
?
''
:
userInfo
.
ip
+
' '
+
'全国刑侦类案标注子系统'
// 公安厅名称
if
(
to
.
path
!=
'/login'
&&
to
.
path
!=
'/home'
&&
to
.
path
!=
'/kshData'
)
{
Watermark
.
set
(
one
,
two
,
three
,
userInfo
.
unitname
==
null
?
''
:
userInfo
.
unitname
,
""
)
}
else
if
(
to
.
path
==
'/home'
||
to
.
path
==
'/kshData'
)
{
Watermark1
.
set
(
one
,
two
,
three
,
userInfo
.
unitname
==
null
?
''
:
userInfo
.
unitname
,
""
)
}
else
{
Watermark
.
set
(
''
,
''
,
''
,
''
,
""
)
}
});
export
default
router
;
export
default
router
;
src/utils/watermark.js
View file @
67b35959
let
watermark
=
{}
let
watermark
=
{}
let
setWatermark
=
(
str
,
str3
,
str4
,
str5
)
=>
{
let
setWatermark
=
(
str
1
,
str2
,
str3
,
str4
,
str5
)
=>
{
let
id
=
'1.23452384164.123412415'
let
id
=
'1.23452384164.123412415'
if
(
document
.
getElementById
(
id
)
!==
null
)
{
if
(
document
.
getElementById
(
id
)
!==
null
)
{
...
@@ -8,44 +10,46 @@ let setWatermark = (str,str3,str4,str5) => {
...
@@ -8,44 +10,46 @@ let setWatermark = (str,str3,str4,str5) => {
}
}
let
can
=
document
.
createElement
(
'canvas'
)
let
can
=
document
.
createElement
(
'canvas'
)
can
.
width
=
3
00
can
.
width
=
6
00
can
.
height
=
23
0
can
.
height
=
40
0
let
cans
=
can
.
getContext
(
'2d'
)
let
cans
=
can
.
getContext
(
'2d'
)
cans
.
rotate
(
-
20
*
Math
.
PI
/
180
)
cans
.
rotate
(
-
20
*
Math
.
PI
/
180
)
cans
.
font
=
'13px Vedana'
cans
.
font
=
'16px Vedana'
cans
.
fillStyle
=
'rgba(0, 0, 0, 0.1)'
cans
.
fillStyle
=
'rgba(0, 0, 0, 0.3)'
// cans.fillStyle = 'red'
cans
.
textAlign
=
'left'
cans
.
textAlign
=
'left'
cans
.
textBaseline
=
'Middle'
cans
.
textBaseline
=
'Middle'
cans
.
fillText
(
str
,
can
.
width
/
3
,
can
.
height
/
2
)
cans
.
fillText
(
str1
,
can
.
width
/
5
,
can
.
height
/
2
)
cans
.
fillText
(
str3
,
can
.
width
/
3
,
can
.
height
/
1.73
)
cans
.
fillText
(
str2
,
can
.
width
/
5
,
can
.
height
/
1.7
)
cans
.
fillText
(
str4
,
can
.
width
/
3
,
can
.
height
/
1.55
)
cans
.
fillText
(
str3
,
can
.
width
/
5
,
can
.
height
/
1.5
)
cans
.
fillText
(
str5
,
can
.
width
/
3
,
can
.
height
/
1.38
)
cans
.
fillText
(
str4
,
can
.
width
/
5
,
can
.
height
/
1.35
)
cans
.
fillText
(
str5
,
can
.
width
/
5
,
can
.
height
/
1.23
)
let
div
=
document
.
createElement
(
'div'
)
let
div
=
document
.
createElement
(
'div'
)
div
.
id
=
id
div
.
id
=
id
div
.
style
.
pointerEvents
=
'none'
div
.
style
.
pointerEvents
=
'none'
div
.
style
.
top
=
'
7
0px'
div
.
style
.
top
=
'
1
0px'
div
.
style
.
left
=
'
5
0px'
div
.
style
.
left
=
'
1
0px'
div
.
style
.
position
=
'fixed'
div
.
style
.
position
=
'fixed'
div
.
style
.
zIndex
=
'100000'
div
.
style
.
zIndex
=
'100000'
div
.
style
.
width
=
document
.
documentElement
.
clientWidth
-
1
25
+
'px'
div
.
style
.
width
=
document
.
documentElement
.
clientWidth
-
1
0
+
'px'
div
.
style
.
height
=
document
.
documentElement
.
clientHeight
-
1
25
+
'px'
div
.
style
.
height
=
document
.
documentElement
.
clientHeight
-
1
0
+
'px'
div
.
style
.
background
=
'url('
+
can
.
toDataURL
(
'image/png'
)
+
') left top repeat'
div
.
style
.
background
=
'url('
+
can
.
toDataURL
(
'image/png'
)
+
') left top repeat'
document
.
body
.
appendChild
(
div
)
document
.
body
.
appendChild
(
div
)
return
id
return
id
}
}
// 该方法只允许调用一次
// 该方法只允许调用一次
watermark
.
set
=
(
str
,
str3
,
str4
,
str5
)
=>
{
watermark
.
set
=
(
str
1
,
str2
,
str3
,
str4
,
str5
)
=>
{
let
id
=
setWatermark
(
str
,
str3
,
str4
,
str5
)
let
id
=
setWatermark
(
str
1
,
str2
,
str3
,
str4
,
str5
)
setInterval
(()
=>
{
setInterval
(()
=>
{
if
(
document
.
getElementById
(
id
)
===
null
)
{
if
(
document
.
getElementById
(
id
)
===
null
)
{
id
=
setWatermark
(
str
,
str3
,
str4
,
str5
)
id
=
setWatermark
(
str
1
,
str2
,
str3
,
str4
,
str5
)
}
}
},
500
)
},
500
)
window
.
onresize
=
()
=>
{
window
.
onresize
=
()
=>
{
setWatermark
(
str
,
str3
,
str4
,
str5
)
setWatermark
(
str
1
,
str2
,
str3
,
str4
,
str5
)
}
}
}
}
export
default
watermark
export
default
watermark
src/utils/watermark1.js
0 → 100644
View file @
67b35959
let
watermark
=
{}
let
setWatermark
=
(
str1
,
str2
,
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
=
600
can
.
height
=
400
let
cans
=
can
.
getContext
(
'2d'
)
cans
.
rotate
(
-
20
*
Math
.
PI
/
180
)
cans
.
font
=
'16px Vedana'
cans
.
fillStyle
=
'rgba(255, 255, 255, 0.3)'
// cans.fillStyle = 'red'
cans
.
textAlign
=
'left'
cans
.
textBaseline
=
'Middle'
cans
.
fillText
(
str1
,
can
.
width
/
5
,
can
.
height
/
2
)
cans
.
fillText
(
str2
,
can
.
width
/
5
,
can
.
height
/
1.7
)
cans
.
fillText
(
str3
,
can
.
width
/
5
,
can
.
height
/
1.5
)
cans
.
fillText
(
str4
,
can
.
width
/
5
,
can
.
height
/
1.35
)
cans
.
fillText
(
str5
,
can
.
width
/
5
,
can
.
height
/
1.23
)
let
div
=
document
.
createElement
(
'div'
)
div
.
id
=
id
div
.
style
.
pointerEvents
=
'none'
div
.
style
.
top
=
'10px'
div
.
style
.
left
=
'10px'
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
=
(
str1
,
str2
,
str3
,
str4
,
str5
)
=>
{
let
id
=
setWatermark
(
str1
,
str2
,
str3
,
str4
,
str5
)
setInterval
(()
=>
{
if
(
document
.
getElementById
(
id
)
===
null
)
{
id
=
setWatermark
(
str1
,
str2
,
str3
,
str4
,
str5
)
}
},
500
)
window
.
onresize
=
()
=>
{
setWatermark
(
str1
,
str2
,
str3
,
str4
,
str5
)
}
}
export
default
watermark
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment