auth.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import styles from "./auth.module.scss";
  2. import { IconButton } from "./button";
  3. import { useNavigate } from "react-router-dom";
  4. import { Path } from "../constant";
  5. import { useAccessStore } from "../store";
  6. import Locale from "../locales";
  7. import BotIcon from "../icons/bot.svg";
  8. import { useEffect } from "react";
  9. import { getClientConfig } from "../config/client";
  10. export function AuthPage() {
  11. const navigate = useNavigate();
  12. const access = useAccessStore();
  13. const goHome = () => navigate(Path.Home);
  14. useEffect(() => {
  15. if (getClientConfig()?.isApp) {
  16. navigate(Path.Settings);
  17. }
  18. // eslint-disable-next-line react-hooks/exhaustive-deps
  19. }, []);
  20. return (
  21. <div className={styles["auth-page"]}>
  22. <div className={`no-dark ${styles["auth-logo"]}`}>
  23. <BotIcon />
  24. </div>
  25. <div className={styles["auth-title"]}>{Locale.Auth.Title}</div>
  26. <div className={styles["auth-tips"]}>{Locale.Auth.Tips}</div>
  27. <input
  28. className={styles["auth-input"]}
  29. type="password"
  30. placeholder={Locale.Auth.Input}
  31. value={access.accessCode}
  32. onChange={(e) => {
  33. access.updateCode(e.currentTarget.value);
  34. }}
  35. />
  36. <div className={styles["auth-actions"]}>
  37. <IconButton
  38. text={Locale.Auth.Confirm}
  39. type="primary"
  40. onClick={goHome}
  41. />
  42. <IconButton text={Locale.Auth.Later} onClick={goHome} />
  43. </div>
  44. </div>
  45. );
  46. }