Ver código fonte

fix: 修复因缓存导致的切换页面后渲染失败

@dayan_hjm 2 anos atrás
pai
commit
cc6b3229ac
3 arquivos alterados com 28 adições e 9 exclusões
  1. 10 4
      src/pages/gvc/view.jsx
  2. 8 5
      src/pages/tqcDataVHome/view.jsx
  3. 10 0
      src/utils/util.js

+ 10 - 4
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-19 15:27:45
5
+ * @Last Modified time: 2023-12-19 15:49:21
6 6
  */
7 7
 
8 8
 import React, { useState, useEffect, Component } from "react";
@@ -24,10 +24,11 @@ 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 } from "@utils/util";
27
+import { getThousandNum,deleteCacheAndChangeUrl } from "@utils/util";
28 28
 
29 29
 import 'animate.css';
30 30
 import { get } from "lodash";
31
+
31 32
 @withRouter
32 33
 
33 34
 class Gvc extends Component {
@@ -384,12 +385,17 @@ class Gvc extends Component {
384 385
         {/* 右键切换大屏 */}
385 386
         <Tooltip placement="bottom" title={"数据运营中心"}>
386 387
           <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {
387
-            this.props.history.replace("/home/operation");
388
+            deleteCacheAndChangeUrl("/home/operation",(url)=>{
389
+              this.props.history.replace(url);
390
+            })
391
+
388 392
           }} />
389 393
         </Tooltip>
390 394
         <Tooltip placement="bottom" title={"数据运营中心"}>
391 395
           <img src={require("@assets/imgs/iconJpg/rightJL.png").default} alt="" className={"rightJ_png rightJ_png_L"} onClick={() => {
392
-            this.props.history.replace("/home/operation");
396
+            deleteCacheAndChangeUrl("/home/operation",(url)=>{
397
+              this.props.history.replace(url);
398
+            })
393 399
           }} />
394 400
         </Tooltip>
395 401
 

+ 8 - 5
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: 2023-12-19 15:32:21
5
+ * @Last Modified time: 2023-12-19 15:47:39
6 6
  */
7 7
 /*
8 8
  * @Author: dayan_hjm 
@@ -30,11 +30,10 @@ import {
30 30
   checkToken,
31 31
   updateTimeService
32 32
 } from "./api";
33
-import { getThousandNum } from "@utils/util";
33
+import { getThousandNum,deleteCacheAndChangeUrl } from "@utils/util";
34 34
 import {
35 35
   fullscreen,
36 36
 } from "@ant-design/icons";
37
-
38 37
 import 'animate.css';
39 38
 @withRouter
40 39
 
@@ -249,12 +248,16 @@ class Home extends Component {
249 248
         {/* 右键切换大屏 */}
250 249
         <Tooltip placement="bottom" title={"产供销价值链"}>
251 250
           <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {
252
-            this.props.history.replace("/home/gvc");
251
+            deleteCacheAndChangeUrl("/home/gvc",(url)=>{
252
+              this.props.history.replace(url);
253
+            })
253 254
           }} />
254 255
         </Tooltip>
255 256
         <Tooltip placement="bottom" title={"产供销价值链"}>
256 257
           <img src={require("@assets/imgs/iconJpg/rightJL.png").default} alt="" className={"rightJ_png rightJ_png_L"} onClick={() => {
257
-            this.props.history.replace("/home/gvc");
258
+            deleteCacheAndChangeUrl("/home/gvc",(url)=>{
259
+              this.props.history.replace(url);
260
+            })
258 261
           }} />
259 262
         </Tooltip>
260 263
 

+ 10 - 0
src/utils/util.js

@@ -7,6 +7,7 @@ import { getSheetToken } from "@apis/common";
7 7
 import { switchPage, getUnionId } from "@apis/common.js";
8 8
 import $store from "@store/";
9 9
 import utils from "@utils/index";
10
+import RouterCache from '@utils/routerCache';
10 11
 
11 12
 /**
12 13
  * 公用事件封装文件
@@ -990,6 +991,15 @@ export function getThousandNum(num){
990 991
   return text8_sum;
991 992
 }
992 993
 
994
+//大屏转跳-去除缓存
995
+export function deleteCacheAndChangeUrl(url,callback){
996
+  RouterCache.deleteCache(url)
997
+  setTimeout(()=>{
998
+    callback && callback(url)
999
+  },300)
1000
+}
1001
+
1002
+
993 1003
 
994 1004
 // 格式化树结构
995 1005
 export function findTreeAllNode(tree) {