|
@@ -1,12 +1,13 @@
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
import LeftBar from "@/components/LeftBar";
|
|
import LeftBar from "@/components/LeftBar";
|
|
-import React, { useEffect, useRef } from "react";
|
|
|
|
|
|
+import React, { useEffect, useState } from "react";
|
|
import SpinLoding from "@/components/SpinLoding";
|
|
import SpinLoding from "@/components/SpinLoding";
|
|
import { Route, Switch } from "react-router-dom";
|
|
import { Route, Switch } from "react-router-dom";
|
|
import AuthRoute from "@/components/AuthRoute";
|
|
import AuthRoute from "@/components/AuthRoute";
|
|
import NotFound from "@/components/NotFound";
|
|
import NotFound from "@/components/NotFound";
|
|
import history from "@/utils/history";
|
|
import history from "@/utils/history";
|
|
-import { getPowerInfo } from "@/utils/storage";
|
|
|
|
|
|
+import { useSelector } from "react-redux";
|
|
|
|
+import { RootState } from "@/store";
|
|
|
|
|
|
const LookObject1 = React.lazy(
|
|
const LookObject1 = React.lazy(
|
|
() => import("../ObjectSon/Object1/LookObject1")
|
|
() => import("../ObjectSon/Object1/LookObject1")
|
|
@@ -140,12 +141,14 @@ const dataInTemp = [
|
|
];
|
|
];
|
|
|
|
|
|
export default function Object() {
|
|
export default function Object() {
|
|
- const data = useRef<any>([]);
|
|
|
|
- const dataIn = useRef<any>([]);
|
|
|
|
|
|
+ const powerInfo = useSelector(
|
|
|
|
+ (state: RootState) => state.loginStore.authPageArr
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const [data, setData] = useState(dataTemp);
|
|
|
|
+ const [dataIn, setDadaIn] = useState(dataInTemp);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- // 根据权限来判断
|
|
|
|
- const powerInfo = getPowerInfo();
|
|
|
|
powerInfo.forEach((v: any) => {
|
|
powerInfo.forEach((v: any) => {
|
|
if (v.id === 100) {
|
|
if (v.id === 100) {
|
|
dataTemp[0].done = true;
|
|
dataTemp[0].done = true;
|
|
@@ -183,15 +186,17 @@ export default function Object() {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- data.current = dataTemp.filter((v) => v.done);
|
|
|
|
- console.log(1231231,data.current);
|
|
|
|
-
|
|
|
|
- dataIn.current = dataInTemp.filter((v) => v.done);
|
|
|
|
|
|
+ setData(dataTemp.filter((v) => v.done));
|
|
|
|
+ setDadaIn(dataInTemp.filter((v) => v.done));
|
|
|
|
+
|
|
|
|
+ }, [powerInfo]);
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
// 没有藏品登记页面的权限 跳到有权限的页面
|
|
// 没有藏品登记页面的权限 跳到有权限的页面
|
|
- if (data.current[0].id !== 1) {
|
|
|
|
- history.replace(data.current[0].path);
|
|
|
|
|
|
+ if (data[0].id !== 1) {
|
|
|
|
+ history.replace(data[0].path);
|
|
}
|
|
}
|
|
- }, []);
|
|
|
|
|
|
+ }, [data]);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.Object}>
|
|
<div className={styles.Object}>
|
|
@@ -202,7 +207,7 @@ export default function Object() {
|
|
<div className="rightMain">
|
|
<div className="rightMain">
|
|
<React.Suspense fallback={<SpinLoding />}>
|
|
<React.Suspense fallback={<SpinLoding />}>
|
|
<Switch>
|
|
<Switch>
|
|
- {data.current.map((v: any, i: number) => (
|
|
|
|
|
|
+ {data.map((v: any, i: number) => (
|
|
<AuthRoute
|
|
<AuthRoute
|
|
exact
|
|
exact
|
|
// exact={i === 0 ? true : false}
|
|
// exact={i === 0 ? true : false}
|
|
@@ -220,7 +225,7 @@ export default function Object() {
|
|
<AuthRoute path="/object/6/look" component={LookObject6} />
|
|
<AuthRoute path="/object/6/look" component={LookObject6} />
|
|
|
|
|
|
{/* 新增 */}
|
|
{/* 新增 */}
|
|
- {dataIn.current.map((v: any) => (
|
|
|
|
|
|
+ {dataIn.map((v: any) => (
|
|
<AuthRoute key={v.id} path={v.path} component={v.Com} />
|
|
<AuthRoute key={v.id} path={v.path} component={v.Com} />
|
|
))}
|
|
))}
|
|
|
|
|