diff --git a/app/components/auth.module.scss b/app/components/auth.module.scss
new file mode 100644
index 00000000000..6630c0613c7
--- /dev/null
+++ b/app/components/auth.module.scss
@@ -0,0 +1,36 @@
+.auth-page {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100%;
+ width: 100%;
+ flex-direction: column;
+
+ .auth-logo {
+ transform: scale(1.4);
+ }
+
+ .auth-title {
+ font-size: 24px;
+ font-weight: bold;
+ line-height: 2;
+ }
+
+ .auth-tips {
+ font-size: 14px;
+ }
+
+ .auth-input {
+ margin: 3vh 0;
+ }
+
+ .auth-actions {
+ display: flex;
+ justify-content: center;
+ flex-direction: column;
+
+ button:not(:last-child) {
+ margin-bottom: 10px;
+ }
+ }
+}
diff --git a/app/components/auth.tsx b/app/components/auth.tsx
new file mode 100644
index 00000000000..93df35b90b3
--- /dev/null
+++ b/app/components/auth.tsx
@@ -0,0 +1,46 @@
+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";
+
+export function AuthPage() {
+ const navigate = useNavigate();
+ const access = useAccessStore();
+
+ const goHome = () => navigate(Path.Home);
+
+ return (
+
+
+
+
+
+
{Locale.Auth.Title}
+
{Locale.Auth.Tips}
+
+
{
+ access.updateCode(e.currentTarget.value);
+ }}
+ />
+
+
+
+
+
+
+ );
+}
diff --git a/app/components/home.tsx b/app/components/home.tsx
index 810c9fa12c8..96bcd28820c 100644
--- a/app/components/home.tsx
+++ b/app/components/home.tsx
@@ -23,6 +23,7 @@ import {
} from "react-router-dom";
import { SideBar } from "./sidebar";
import { useAppConfig } from "../store/config";
+import { AuthPage } from "./auth";
export function Loading(props: { noLogo?: boolean }) {
return (
@@ -102,6 +103,7 @@ function Screen() {
const config = useAppConfig();
const location = useLocation();
const isHome = location.pathname === Path.Home;
+ const isAuth = location.pathname === Path.Auth;
const isMobileScreen = useMobileScreen();
useEffect(() => {
@@ -119,17 +121,25 @@ function Screen() {
}`
}
>
-
-
-
-
- } />
- } />
- } />
- } />
- } />
-
-
+ {isAuth ? (
+ <>
+
+ >
+ ) : (
+ <>
+
+
+
+
+ } />
+ } />
+ } />
+ } />
+ } />
+
+
+ >
+ )}
);
}
diff --git a/app/constant.ts b/app/constant.ts
index 0fb18c2fb31..b640919e500 100644
--- a/app/constant.ts
+++ b/app/constant.ts
@@ -13,6 +13,7 @@ export enum Path {
Settings = "/settings",
NewChat = "/new-chat",
Masks = "/masks",
+ Auth = "/auth",
}
export enum SlotID {
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index 48134e38360..c3cd8f4577f 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -4,7 +4,14 @@ const cn = {
WIP: "该功能仍在开发中……",
Error: {
Unauthorized:
- "访问密码不正确或为空,请前往[设置](/#/settings)页输入正确的访问密码,或者填入你自己的 OpenAI API Key。",
+ "访问密码不正确或为空,请前往[登录](/#/auth)页输入正确的访问密码,或者在[设置](/#/settings)页填入你自己的 OpenAI API Key。",
+ },
+ Auth: {
+ Title: "需要密码",
+ Tips: "管理员开启了密码验证,请在下方填入访问码",
+ Input: "在此处填写访问码",
+ Confirm: "确认",
+ Later: "稍后再说",
},
ChatItem: {
ChatItemCount: (count: number) => `${count} 条对话`,
diff --git a/app/locales/en.ts b/app/locales/en.ts
index 1ff665581cb..068b2e58314 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -5,7 +5,14 @@ const en: RequiredLocaleType = {
WIP: "Coming Soon...",
Error: {
Unauthorized:
- "Unauthorized access, please enter access code in settings page.",
+ "Unauthorized access, please enter access code in [auth](/#/auth) page.",
+ },
+ Auth: {
+ Title: "Need Access Code",
+ Tips: "Please enter access code below",
+ Input: "access code",
+ Confirm: "Confirm",
+ Later: "Later",
},
ChatItem: {
ChatItemCount: (count: number) => `${count} messages`,