1234567891011121314151617181920212223242526272829303132333435363738 |
- import React from "react";
- import { View } from "@tarojs/components";
- import { useModel } from "@/store";
-
- export default (props) => {
- const { roles = [] } = props;
-
- const { duty } = useModel("user");
-
-
-
- const hasRights = roles.includes(duty);
-
-
-
-
-
-
-
- const filteredChildren = React.Children.toArray(props.children).filter(
- child => React.isValidElement(child)
- );
-
- return !roles.length || hasRights ? (
- <div>{filteredChildren}</div>
- ) : (
- <View
- style={{
- width: "100%",
- height: "100%",
- display: "grid",
- placeItems: "center",
- }}
- >
- <View>暂无权限</View>
- </View>
- );
- };
|