Просмотр исходного кода

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

@dayan_hjm лет назад: 2
Родитель
Сommit
cc6b3229ac
3 измененных файлов с 28 добавлено и 9 удалено
  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
  * @Author: dayan_hjm  产供销价值链
2
  * @Author: dayan_hjm  产供销价值链
3
  * @Date: 2023-11-10 10:19:34 
3
  * @Date: 2023-11-10 10:19:34 
4
  * @Last Modified by: dayan_hjm
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
 import React, { useState, useEffect, Component } from "react";
8
 import React, { useState, useEffect, Component } from "react";
@@ -24,10 +24,11 @@ import {
24
 } from "./api";
24
 } from "./api";
25
 import MapViewTwo from "./component/mapView2.jsx";
25
 import MapViewTwo from "./component/mapView2.jsx";
26
 import mpVideoGvc from "@assets/imgs/dataVimg/videoGvc2.mp4";
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
 import 'animate.css';
29
 import 'animate.css';
30
 import { get } from "lodash";
30
 import { get } from "lodash";
31
+
31
 @withRouter
32
 @withRouter
32
 
33
 
33
 class Gvc extends Component {
34
 class Gvc extends Component {
@@ -384,12 +385,17 @@ class Gvc extends Component {
384
         {/* 右键切换大屏 */}
385
         {/* 右键切换大屏 */}
385
         <Tooltip placement="bottom" title={"数据运营中心"}>
386
         <Tooltip placement="bottom" title={"数据运营中心"}>
386
           <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {
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
         </Tooltip>
393
         </Tooltip>
390
         <Tooltip placement="bottom" title={"数据运营中心"}>
394
         <Tooltip placement="bottom" title={"数据运营中心"}>
391
           <img src={require("@assets/imgs/iconJpg/rightJL.png").default} alt="" className={"rightJ_png rightJ_png_L"} onClick={() => {
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
         </Tooltip>
400
         </Tooltip>
395
 
401
 

+ 8 - 5
src/pages/tqcDataVHome/view.jsx

@@ -2,7 +2,7 @@
2
  * @Author: dayan_hjm 
2
  * @Author: dayan_hjm 
3
  * @Date: 2023-10-25 10:32:44 
3
  * @Date: 2023-10-25 10:32:44 
4
  * @Last Modified by: dayan_hjm
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
  * @Author: dayan_hjm 
8
  * @Author: dayan_hjm 
@@ -30,11 +30,10 @@ import {
30
   checkToken,
30
   checkToken,
31
   updateTimeService
31
   updateTimeService
32
 } from "./api";
32
 } from "./api";
33
-import { getThousandNum } from "@utils/util";
33
+import { getThousandNum,deleteCacheAndChangeUrl } from "@utils/util";
34
 import {
34
 import {
35
   fullscreen,
35
   fullscreen,
36
 } from "@ant-design/icons";
36
 } from "@ant-design/icons";
37
-
38
 import 'animate.css';
37
 import 'animate.css';
39
 @withRouter
38
 @withRouter
40
 
39
 
@@ -249,12 +248,16 @@ class Home extends Component {
249
         {/* 右键切换大屏 */}
248
         {/* 右键切换大屏 */}
250
         <Tooltip placement="bottom" title={"产供销价值链"}>
249
         <Tooltip placement="bottom" title={"产供销价值链"}>
251
           <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {
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
         </Tooltip>
255
         </Tooltip>
255
         <Tooltip placement="bottom" title={"产供销价值链"}>
256
         <Tooltip placement="bottom" title={"产供销价值链"}>
256
           <img src={require("@assets/imgs/iconJpg/rightJL.png").default} alt="" className={"rightJ_png rightJ_png_L"} onClick={() => {
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
         </Tooltip>
262
         </Tooltip>
260
 
263
 

+ 10 - 0
src/utils/util.js

@@ -7,6 +7,7 @@ import { getSheetToken } from "@apis/common";
7
 import { switchPage, getUnionId } from "@apis/common.js";
7
 import { switchPage, getUnionId } from "@apis/common.js";
8
 import $store from "@store/";
8
 import $store from "@store/";
9
 import utils from "@utils/index";
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
   return text8_sum;
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
 export function findTreeAllNode(tree) {
1005
 export function findTreeAllNode(tree) {