shaogen1995 1 年之前
父節點
當前提交
9e2fe899a1

+ 54 - 10
houtai/src/pages/B1Scene/index.tsx

@@ -1,17 +1,40 @@
-import React, { useMemo } from "react";
+import React, { useCallback, useMemo } from "react";
 import styles from "./index.module.scss";
 import demoImg from "@/assets/img/demo.jpg";
 import { Button } from "antd";
 import ImageLazy from "@/components/ImageLazy";
+import { isTokenFlagAPI } from "@/store/action/login";
+import { MessageFu } from "@/utils/message";
+import { removeTokenInfo } from "@/utils/storage";
+import history from "@/utils/history";
+import { baseURL } from "@/utils/http";
+
+const isTokenFlagFu = (val: boolean, url: string) => {
+  if (val) {
+    // token 有效
+    window.open(url);
+  } else {
+    // token 失效
+    MessageFu.warning("登录失效,请重新登录!");
+    removeTokenInfo();
+    history.push("/login");
+  }
+};
+
 function Scene() {
   const list1 = useMemo(() => {
     return [
-      { id: 1, name: "鸦片战争博物馆", img: demoImg },
-      { id: 2, name: "海战博物馆A厅", img: demoImg },
-      { id: 3, name: "海战博物馆B厅", img: demoImg },
-      { id: 4, name: "海战博物馆C厅海战博物馆C厅海战博物馆C厅", img: demoImg },
-      { id: 5, name: "海战博物馆D厅", img: demoImg },
-      { id: 6, name: "虎门故事展厅", img: demoImg },
+      { id: 1, sceneCode: "1194", name: "鸦片战争博物馆", img: demoImg },
+      { id: 2, sceneCode: "1194", name: "海战博物馆A厅", img: demoImg },
+      { id: 3, sceneCode: "1194", name: "海战博物馆B厅", img: demoImg },
+      {
+        id: 4,
+        sceneCode: "1194",
+        name: "海战博物馆C厅海战博物馆C厅海战博物馆C厅",
+        img: demoImg,
+      },
+      { id: 5, sceneCode: "1194", name: "海战博物馆D厅", img: demoImg },
+      { id: 6, sceneCode: "1194", name: "虎门故事展厅", img: demoImg },
     ];
   }, []);
 
@@ -21,11 +44,29 @@ function Scene() {
       { id: 2, name: "靖远炮台1", img: demoImg },
       { id: 3, name: "靖远炮台2", img: demoImg },
       { id: 4, name: "靖远炮台3", img: demoImg },
-      { id: 5, name: "靖远炮台2靖远炮台2靖远炮台2靖远炮台2靖远炮台2靖远炮台2靖远炮台2", img: demoImg },
+      {
+        id: 5,
+        name: "靖远炮台2靖远炮台2靖远炮台2靖远炮台2靖远炮台2靖远炮台2靖远炮台2",
+        img: demoImg,
+      },
       { id: 6, name: "靖远炮台A", img: demoImg },
     ];
   }, []);
 
+  const lookFu = useCallback(async (code: string) => {
+    const res = await isTokenFlagAPI();
+    if (res.code === 0) {
+      isTokenFlagFu(res.data, baseURL + `/scene/index.html?m=${code}`);
+    }
+  }, []);
+
+  const editFu = useCallback(async (code: string) => {
+    const res = await isTokenFlagAPI();
+    if (res.code === 0) {
+      isTokenFlagFu(res.data, baseURL + `/scene/edit.html?m=${code}`);
+    }
+  }, []);
+
   return (
     <div className={styles.Scene}>
       <div className="pageTitlt">场景管理</div>
@@ -38,8 +79,11 @@ function Scene() {
               <ImageLazy src={v.img} width="100%" height={180} offline={true} />
               <div className="txt">{v.name}</div>
               <div className="button">
-                <Button type="primary">预览</Button>&emsp;
-                <Button>编辑</Button>
+                <Button type="primary" onClick={() => lookFu(v.sceneCode)}>
+                  预览
+                </Button>
+                &emsp;
+                <Button onClick={() => editFu(v.sceneCode)}>编辑</Button>
               </div>
             </div>
           ))}

+ 1 - 1
houtai/src/pages/C2Role/RoleAdd/index.tsx

@@ -40,7 +40,7 @@ function RoleAdd({ id, closePage, upTableList, addTableList }: Props) {
         { id: 240, name: "万物墙管理", authority: true },
         { id: 250, name: "弹幕管理", authority: true },
         { id: 260, name: "题库管理", authority: true },
-        { id: 270, name: "智能导览管理", authority: true },
+        // { id: 270, name: "智能导览管理", authority: true },
       ],
     },
   ]);

+ 7 - 7
houtai/src/pages/Layout/index.tsx

@@ -109,13 +109,13 @@ function Layout() {
             done: false,
             Com: React.lazy(() => import("../B5Topic")),
           },
-          {
-            id: 270,
-            name: "智能导览管理",
-            path: "/smart",
-            done: false,
-            Com: React.lazy(() => import("../B6Smart")),
-          },
+          // {
+          //   id: 270,
+          //   name: "智能导览管理",
+          //   path: "/smart",
+          //   done: false,
+          //   Com: React.lazy(() => import("../B6Smart")),
+          // },
         ],
       },
     ];

+ 8 - 0
houtai/src/store/action/login.ts

@@ -42,3 +42,11 @@ export const getDictListAPI = () => {
     }
   };
 };
+
+
+/**
+ * 检查登录状态
+ */
+export const isTokenFlagAPI = () => {
+  return http.get("/admin/checkLogin");
+};