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

用 isGuest ===true 判断是否时访客模式

visuddhinanda 1 год назад
Родитель
Сommit
c482e6bc4b
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      dashboard/src/components/auth/LoginAlert.tsx

+ 5 - 5
dashboard/src/components/auth/LoginAlert.tsx

@@ -3,15 +3,13 @@ import { Link } from "react-router-dom";
 import { Alert } from "antd";
 
 import { useAppSelector } from "../../hooks";
-import { currentUser as _currentUser } from "../../reducers/current-user";
+import { isGuest } from "../../reducers/current-user";
 
 const LoginAlertWidget = () => {
   const intl = useIntl();
+  const guest = useAppSelector(isGuest);
 
-  const user = useAppSelector(_currentUser);
-  return user ? (
-    <></>
-  ) : (
+  return guest === true ? (
     <Alert
       message={intl.formatMessage({
         id: "message.auth.guest.alert",
@@ -26,6 +24,8 @@ const LoginAlertWidget = () => {
         </Link>
       }
     />
+  ) : (
+    <></>
   );
 };