Quellcode durchsuchen

feat: 用 privateConfig.js SHOW_WATERMARK字段控制是否显示水印

@dayan_hjm vor 2 Jahren
Ursprung
Commit
7b0e3d0bde
5 geänderte Dateien mit 34 neuen und 13 gelöschten Zeilen
  1. 1 0
      public/index.html
  2. 1 0
      src/assets/js/privateConfig.js
  3. 14 6
      src/pages/gvc/view.jsx
  4. 14 3
      src/pages/tqcDataVHome/view.jsx
  5. 4 4
      src/utils/util.js

+ 1 - 0
public/index.html

@@ -194,6 +194,7 @@
194 194
   <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script> -->
195 195
   <script type="text/javascript" src="<%=htmlWebpackPlugin.options.publicPath%>static/privateConfig.js"></script>
196 196
   <script type="text/javascript" src="../src/assets/js/crypto-js.js"></script>
197
+  <script type="text/javascript" src="../src/assets/js/privateConfig.js"></script>
197 198
   <script type="text/javascript" src="<%=htmlWebpackPlugin.options.publicPath%>static/crypto-js.js"></script>
198 199
 
199 200
   <script type="text/javascript" src="<%=htmlWebpackPlugin.options.publicPath%>static/jquery-1.11.0.min.js"></script>

+ 1 - 0
src/assets/js/privateConfig.js

@@ -3,5 +3,6 @@ window.privateConfig = {
3 3
   publicPath: '',
4 4
   mock: false,
5 5
   CDN_BASE: '',
6
+  SHOW_WATERMARK:false,//是否显示水印
6 7
   IS_SSO_LOGIN: false //是否是采用单点登录方式
7 8
 }

+ 14 - 6
src/pages/gvc/view.jsx

@@ -2,7 +2,7 @@
2 2
  * @Author: dayan_hjm  产供销价值链
3 3
  * @Date: 2023-11-10 10:19:34 
4 4
  * @Last Modified by: dayan_hjm
5
- * @Last Modified time: 2023-12-27 14:18:06
5
+ * @Last Modified time: 2024-01-22 14:26:38
6 6
  */
7 7
 
8 8
 import React, { useState, useEffect, Component } from "react";
@@ -24,10 +24,10 @@ import {
24 24
 } from "./api";
25 25
 import MapViewTwo from "./component/mapView2.jsx";
26 26
 import mpVideoGvc from "@assets/imgs/dataVimg/videoGvc2.mp4";
27
-import { getThousandNum,deleteCacheAndChangeUrl } from "@utils/util";
28
-
27
+import { getThousandNum,deleteCacheAndChangeUrl,timestampToTime,setWaterMark } from "@utils/util";
29 28
 import 'animate.css';
30 29
 import { get } from "lodash";
30
+import $store from "@store/";
31 31
 
32 32
 @withRouter
33 33
 
@@ -62,11 +62,15 @@ class Gvc extends Component {
62 62
     } else {
63 63
       await checkToken(sessionStorage.getItem("tqcVToken")).then(({ data, resultCode }) => {
64 64
         if (data?.userId) {
65
-          // this.props.history.push('/')
65
+          sessionStorage.setItem("tqcUserName", data?.userId);
66
+          $store.app.setMarkSrc(
67
+            setWaterMark({
68
+              toDataURL: true,
69
+              waterMarkText: [data?.userId || sessionStorage.getItem("tqcUserName"),timestampToTime()],
70
+            })
71
+          );
66 72
         } else {
67 73
           window.location = window.location.origin + '/transfer.html#/login';
68
-
69
-          // this.props.history.replace("/home/index");
70 74
         }
71 75
       });
72 76
     }
@@ -390,6 +394,10 @@ class Gvc extends Component {
390 394
     let { LeftHtml, updateTime, changGif } = this.state;
391 395
     return (
392 396
       <div className={[styles.gvc_home + ' home_box ']}>
397
+        {/* 水印 */}
398
+        {
399
+          window.privateConfig && window.privateConfig.SHOW_WATERMARK && <div className={"shuiYin"} style={{ backgroundImage: `url(${$store.app.markSrc})`, backgroundRepeat: 'repeat' }}></div>
400
+        }
393 401
         {/* 右键切换大屏 */}
394 402
         <Tooltip placement="bottom" title={"数据运营中心"}>
395 403
           <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {

+ 14 - 3
src/pages/tqcDataVHome/view.jsx

@@ -2,7 +2,7 @@
2 2
  * @Author: dayan_hjm 
3 3
  * @Date: 2023-10-25 10:32:44 
4 4
  * @Last Modified by: dayan_hjm
5
- * @Last Modified time: 2024-01-02 10:42:01
5
+ * @Last Modified time: 2024-01-22 14:26:36
6 6
  */
7 7
 /*
8 8
  * @Author: dayan_hjm 
@@ -24,13 +24,14 @@ import LeftMenoyView from "./component/leftMenoyView.jsx";
24 24
 import RightBottomView from "./component/rightBottomView.jsx";
25 25
 import OneQualified from "./component/oneQualified.jsx";
26 26
 import MapView from "./component/mapView.jsx";
27
+import $store from "@store/";
27 28
 import {
28 29
   timeService,
29 30
   numberService,
30 31
   checkToken,
31 32
   updateTimeService
32 33
 } from "./api";
33
-import { getThousandNum, deleteCacheAndChangeUrl } from "@utils/util";
34
+import { getThousandNum, deleteCacheAndChangeUrl,timestampToTime,setWaterMark  } from "@utils/util";
34 35
 import {
35 36
   fullscreen,
36 37
 } from "@ant-design/icons";
@@ -67,7 +68,13 @@ class Home extends Component {
67 68
     } else {
68 69
       await checkToken(sessionStorage.getItem("tqcVToken")).then(({ data, resultCode }) => {
69 70
         if (data?.userId) {
70
-          // this.props.history.push('/')
71
+          sessionStorage.setItem("tqcUserName", data?.userId);
72
+          $store.app.setMarkSrc(
73
+            setWaterMark({
74
+              toDataURL: true,
75
+              waterMarkText: [data?.userId || sessionStorage.getItem("tqcUserName"),timestampToTime()],
76
+            })
77
+          );
71 78
         } else {
72 79
           window.location = window.location.origin + '/transfer.html#/login';
73 80
           // this.props.history.replace("/home/index");
@@ -248,6 +255,10 @@ class Home extends Component {
248 255
     let { changGif, updateTime, changNun } = this.state;
249 256
     return (
250 257
       <div className={"home_box"}>
258
+        {/* 水印 */}
259
+        {
260
+          window.privateConfig && window.privateConfig.SHOW_WATERMARK && <div className={"shuiYin"} style={{ backgroundImage: `url(${$store.app.markSrc})`, backgroundRepeat: 'repeat' }}></div>
261
+        }
251 262
         {/* 右键切换大屏 */}
252 263
         <Tooltip placement="bottom" title={"产供销价值链"}>
253 264
           <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {

+ 4 - 4
src/utils/util.js

@@ -220,7 +220,7 @@ export function setWaterMark(option = {}) {
220 220
     eleId = "",
221 221
     toImg = false,
222 222
     toDataURL = false,
223
-    rotate = 45,
223
+    rotate = 30,
224 224
     color = "rgba(180, 180, 180, 0.2)",
225 225
     // color='red',
226 226
     fontSize = 12,
@@ -248,8 +248,8 @@ export function setWaterMark(option = {}) {
248 248
   //   Math.sqrt((horizontalWidth * horizontalWidth) / 2) + fontSize;
249 249
   // horizontalWidth = horizontalWidth;
250 250
 
251
-  canvas.width = horizontalWidth * 1 + 20;
252
-  canvas.height = horizontalWidth * 1 + 20;
251
+  canvas.width = horizontalWidth * 1 + 50;
252
+  canvas.height = horizontalWidth * 1 + 50;
253 253
   ctx.textAlign = "center";
254 254
   ctx.textBaseline = "middle";
255 255
   ctx.fillStyle = color;
@@ -266,7 +266,7 @@ export function setWaterMark(option = {}) {
266 266
 
267 267
   arr.map((item, index) => {
268 268
     ctx.beginPath();
269
-    draw(item, horizontalWidth / 2 - 20, index * 20 + horizontalWidth / 2 - 20);
269
+    draw(item, horizontalWidth / 2 - 30, index * 30 + horizontalWidth / 2 - 30);
270 270
 
271 271
     // ctx.fillText(item, index * 100, index * 100);
272 272
     ctx.closePath();