Jelajahi Sumber

fix-嵌套页面的返回按钮问题

shaogen1995 1 tahun lalu
induk
melakukan
e3f8513c93

+ 1 - 6
pc/src/pages/App/MainM/Tab1/Scene/index.tsx

@@ -9,12 +9,7 @@ type Props = {
   code: string;
 };
 
-// 为 window 添加属性ts类型
-declare global {
-  interface Window {
-    sceneBackIconStatus: (flag: boolean) => void;
-  }
-}
+
 
 function Scene({ closeFu, code }: Props) {
   // 给嵌套的场景页面调用,打开热点的时候 关闭返回按钮

+ 1 - 1
pc/src/pages/App/MainM/Tab4/index.module.scss

@@ -7,7 +7,7 @@
       padding-top: 6px;
       margin-top: 10px;
       width: 100%;
-      height: calc(100% - 50px);
+      height: 100%;
       overflow-y: auto;
       padding-right: 20px;
 

+ 13 - 0
pc/src/pages/App/MainM/Tab5/Info/index.tsx

@@ -25,10 +25,23 @@ type Props = {
   isGoodsRu?: boolean;
 };
 
+
 function Info({ sId, closeFu, isOpen, title, isGoodsRu }: Props) {
   // 顶部的标题
   const [titleTxt, setTitleTxt] = useState("");
 
+  // 子敏的大场景调用 我的 这个页面=》通过文物 地址包含 goods 。并且从文物里面点击知识
+  // 需要 操作 子敏 的页面的 返回按钮
+  useEffect(() => {
+    if (window.location.href.includes("goods?id=") && window.parent) {
+      window.parent.incoBackSonFu(false);
+
+      return () => {
+        window.parent.incoBackSonFu(true);
+      };
+    }
+  }, []);
+
   const [data, setData] = useState([] as PcTab5ListType[]);
 
   const getInfoFu = useCallback(async () => {

+ 2 - 1
pc/src/types/declaration.d.ts

@@ -4,4 +4,5 @@ declare module "*.png";
 declare module "*.jpg";
 declare module "*.gif";
 declare module "*.mp4";
-declare module "*.xmp";
+declare module "*.xmp";
+

+ 9 - 1
pc/src/utils/http.ts

@@ -11,6 +11,14 @@ export const baseURL =
   //   : "";
   process.env.NODE_ENV === "development" ? "https://ypbwg.4dage.com" : "";
 
+// 为 window 添加属性ts类型
+declare global {
+  interface Window {
+    sceneBackIconStatus: (flag: boolean) => void;
+    incoBackSonFu: (flag: boolean) => void;
+  }
+}
+
 // 处理  类型“AxiosResponse<any, any>”上不存在属性“code”
 declare module "axios" {
   interface AxiosResponse {
@@ -58,7 +66,7 @@ http.interceptors.response.use(
     if (response.data.code === 0) {
       // MessageFu.success(response.data.msg);
     } else {
-      isMobiileFu()&&response.data.msg
+      isMobiileFu() && response.data.msg
         ? Toast.show({
             icon: "fail",
             content: response.data.msg,