Ver Fonte

使用 LoginButton 组件

visuddhinanda há 1 ano atrás
pai
commit
ac42175d84

+ 6 - 8
dashboard-v4/dashboard/src/components/auth/Avatar.tsx

@@ -16,6 +16,7 @@ import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { TooltipPlacement } from "antd/lib/tooltip";
 import SettingModal from "./setting/SettingModal";
+import LoginButton from "./LoginButton";
 
 const { Title } = Typography;
 
@@ -82,16 +83,13 @@ const AvatarWidget = ({ style, placement = "bottomRight" }: IWidget) => {
       </ProCard>
     );
   };
-  const Login = () => (
-    <Link to="/anonymous/users/sign-in">
-      {intl.formatMessage({
-        id: "nut.users.sign-in-up.title",
-      })}
-    </Link>
-  );
+
   return (
     <>
-      <Popover content={user ? <UserCard /> : <Login />} placement={placement}>
+      <Popover
+        content={user ? <UserCard /> : <LoginButton />}
+        placement={placement}
+      >
         <span style={style}>
           <Avatar
             style={{ backgroundColor: user ? "#87d068" : "gray" }}

+ 2 - 7
dashboard-v4/dashboard/src/components/auth/LoginAlert.tsx

@@ -4,6 +4,7 @@ import { Alert } from "antd";
 
 import { useAppSelector } from "../../hooks";
 import { isGuest } from "../../reducers/current-user";
+import LoginButton from "./LoginButton";
 
 const LoginAlertWidget = () => {
   const intl = useIntl();
@@ -16,13 +17,7 @@ const LoginAlertWidget = () => {
       })}
       type="warning"
       closable
-      action={
-        <Link to="/anonymous/users/sign-in">
-          {intl.formatMessage({
-            id: "buttons.sign-in",
-          })}
-        </Link>
-      }
+      action={<LoginButton />}
     />
   ) : (
     <></>

+ 2 - 7
dashboard-v4/dashboard/src/components/auth/SignInAvatar.tsx

@@ -23,6 +23,7 @@ import { AdminIcon } from "../../assets/icon";
 import User from "./User";
 import { fullUrl } from "../../utils";
 import Studio from "./Studio";
+import LoginButton from "./LoginButton";
 
 const { Title, Paragraph, Text } = Typography;
 
@@ -45,13 +46,7 @@ const SignInAvatarWidget = ({ style, placement = "bottomRight" }: IWidget) => {
     user?.roles?.includes("root") || user?.roles?.includes("administrator");
 
   if (typeof user === "undefined") {
-    return (
-      <Link to="/anonymous/users/sign-in">
-        {intl.formatMessage({
-          id: "nut.users.sign-in-up.title",
-        })}
-      </Link>
-    );
+    return <LoginButton />;
   } else {
     const welcome = (
       <Paragraph>

+ 2 - 5
dashboard-v4/dashboard/src/components/course/Status.tsx

@@ -20,6 +20,7 @@ import { useAppSelector } from "../../hooks";
 import { currentUser } from "../../reducers/current-user";
 import UserAction from "./UserAction";
 import { getStatusColor, getStudentActionsByStatus } from "./RolePower";
+import LoginButton from "../auth/LoginButton";
 
 const { Paragraph, Text } = Typography;
 
@@ -113,11 +114,7 @@ const StatusWidget = ({ data }: IWidget) => {
   } else {
     //未登录
     labelStatus = "未登录";
-    operation = (
-      <Link to="/anonymous/users/sign-in" target="_blank">
-        {"登录"}
-      </Link>
-    );
+    operation = <LoginButton target="_blank" />;
   }
 
   return data?.id ? (

+ 1 - 1
dashboard-v4/dashboard/src/components/nut/users/NonSignInSharedLinks.tsx

@@ -9,7 +9,7 @@ const Widget = () => {
         <FormattedMessage id="nut.users.sign-in.title" />
       </Link>
       <Divider type="vertical" />
-      <Link to="/users/sign-up">
+      <Link to="/anonymous/users/sign-up">
         <FormattedMessage id="nut.users.sign-up.title" />
       </Link>
       <Divider type="vertical" />

+ 2 - 9
dashboard-v4/dashboard/src/components/nut/users/ResetPassword.tsx

@@ -12,6 +12,7 @@ import { useRef, useState } from "react";
 import { Link } from "react-router-dom";
 import { RuleObject } from "antd/lib/form";
 import { StoreValue } from "antd/lib/form/interface";
+import LoginButton from "../../auth/LoginButton";
 
 interface IFormData {
   username: string;
@@ -58,15 +59,7 @@ const Widget = ({ token }: IWidget) => {
           message={notify}
           type={type}
           showIcon
-          action={
-            ok ? (
-              <Link to={"/anonymous/users/sign-in"}>
-                {intl.formatMessage({
-                  id: "buttons.sign-in",
-                })}
-              </Link>
-            ) : undefined
-          }
+          action={ok ? <LoginButton /> : undefined}
         />
       ) : (
         <></>