mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-08 19:16:37 +08:00
commite6b72ac1ff
Author: Yifei Zhang <yidadaa@qq.com> Date: Fri Nov 10 02:59:47 2023 +0800 Update README.md commit8032e6d68d
Author: Yifei Zhang <yidadaa@qq.com> Date: Fri Nov 10 02:59:30 2023 +0800 Update README.md commitc7e0a6f37f
Author: Yidadaa <yidadaa@qq.com> Date: Fri Nov 10 02:57:40 2023 +0800 doc: update azure env vars commit1141cd2e6e
Merge:fd2f441
c9dd953
Author: Yifei Zhang <yidadaa@qq.com> Date: Fri Nov 10 02:55:12 2023 +0800 Merge pull request #3206 from Yidadaa/azure commitc9dd953817
Author: Yidadaa <yidadaa@qq.com> Date: Fri Nov 10 02:50:50 2023 +0800 fixup commitb7ffca031e
Author: Yidadaa <yidadaa@qq.com> Date: Fri Nov 10 02:43:30 2023 +0800 feat: close #935 add azure support commitfd2f441e02
Author: Yifei Zhang <yidadaa@qq.com> Date: Thu Nov 9 20:45:25 2023 +0800 feat: wont send max_tokens
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
import styles from "./auth.module.scss";
|
|
import { IconButton } from "./button";
|
|
|
|
import { useNavigate } from "react-router-dom";
|
|
import { Path } from "../constant";
|
|
import { useAccessStore } from "../store";
|
|
import Locale from "../locales";
|
|
|
|
import BotIcon from "../icons/bot.svg";
|
|
import { useEffect } from "react";
|
|
import { getClientConfig } from "../config/client";
|
|
|
|
export function AuthPage() {
|
|
const navigate = useNavigate();
|
|
const accessStore = useAccessStore();
|
|
|
|
const goHome = () => navigate(Path.Home);
|
|
const goChat = () => navigate(Path.Chat);
|
|
const resetAccessCode = () => {
|
|
accessStore.update((access) => {
|
|
access.openaiApiKey = "";
|
|
access.accessCode = "";
|
|
});
|
|
}; // Reset access code to empty string
|
|
|
|
useEffect(() => {
|
|
if (getClientConfig()?.isApp) {
|
|
navigate(Path.Settings);
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []);
|
|
|
|
return (
|
|
<div className={styles["auth-page"]}>
|
|
<div className={`no-dark ${styles["auth-logo"]}`}>
|
|
<BotIcon />
|
|
</div>
|
|
|
|
<div className={styles["auth-title"]}>{Locale.Auth.Title}</div>
|
|
<div className={styles["auth-tips"]}>{Locale.Auth.Tips}</div>
|
|
|
|
<input
|
|
className={styles["auth-input"]}
|
|
type="password"
|
|
placeholder={Locale.Auth.Input}
|
|
value={accessStore.accessCode}
|
|
onChange={(e) => {
|
|
accessStore.update(
|
|
(access) => (access.accessCode = e.currentTarget.value),
|
|
);
|
|
}}
|
|
/>
|
|
{!accessStore.hideUserApiKey ? (
|
|
<>
|
|
<div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>
|
|
<input
|
|
className={styles["auth-input"]}
|
|
type="password"
|
|
placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}
|
|
value={accessStore.openaiApiKey}
|
|
onChange={(e) => {
|
|
accessStore.update(
|
|
(access) => (access.openaiApiKey = e.currentTarget.value),
|
|
);
|
|
}}
|
|
/>
|
|
</>
|
|
) : null}
|
|
|
|
<div className={styles["auth-actions"]}>
|
|
<IconButton
|
|
text={Locale.Auth.Confirm}
|
|
type="primary"
|
|
onClick={goChat}
|
|
/>
|
|
<IconButton
|
|
text={Locale.Auth.Later}
|
|
onClick={() => {
|
|
resetAccessCode();
|
|
goHome();
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|