|
|
@ -1,4 +1,3 @@
|
|
|
|
import { Option, Select } from "@mui/joy";
|
|
|
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { useNavigate } from "react-router-dom";
|
|
|
|
import { useNavigate } from "react-router-dom";
|
|
|
@ -9,6 +8,7 @@ import useLoading from "../hooks/useLoading";
|
|
|
|
import Icon from "../components/Icon";
|
|
|
|
import Icon from "../components/Icon";
|
|
|
|
import toastHelper from "../components/Toast";
|
|
|
|
import toastHelper from "../components/Toast";
|
|
|
|
import AppearanceSelect from "../components/AppearanceSelect";
|
|
|
|
import AppearanceSelect from "../components/AppearanceSelect";
|
|
|
|
|
|
|
|
import LocaleSelect from "../components/LocaleSelect";
|
|
|
|
import "../less/auth.less";
|
|
|
|
import "../less/auth.less";
|
|
|
|
|
|
|
|
|
|
|
|
const validateConfig: ValidatorConfig = {
|
|
|
|
const validateConfig: ValidatorConfig = {
|
|
|
@ -19,12 +19,12 @@ const validateConfig: ValidatorConfig = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const Auth = () => {
|
|
|
|
const Auth = () => {
|
|
|
|
const { t, i18n } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const globalStore = useGlobalStore();
|
|
|
|
const globalStore = useGlobalStore();
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const actionBtnLoadingState = useLoading(false);
|
|
|
|
const actionBtnLoadingState = useLoading(false);
|
|
|
|
const systemStatus = globalStore.state.systemStatus;
|
|
|
|
const { appearance, locale, systemStatus } = globalStore.state;
|
|
|
|
const mode = systemStatus.profile.mode;
|
|
|
|
const mode = systemStatus.profile.mode;
|
|
|
|
const [username, setUsername] = useState(mode === "dev" ? "demohero" : "");
|
|
|
|
const [username, setUsername] = useState(mode === "dev" ? "demohero" : "");
|
|
|
|
const [password, setPassword] = useState(mode === "dev" ? "secret" : "");
|
|
|
|
const [password, setPassword] = useState(mode === "dev" ? "secret" : "");
|
|
|
@ -43,6 +43,14 @@ const Auth = () => {
|
|
|
|
setPassword(text);
|
|
|
|
setPassword(text);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleLocaleSelectChange = (locale: Locale) => {
|
|
|
|
|
|
|
|
globalStore.setLocale(locale);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleAppearanceSelectChange = (appearance: Appearance) => {
|
|
|
|
|
|
|
|
globalStore.setAppearance(appearance);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSigninBtnsClick = async () => {
|
|
|
|
const handleSigninBtnsClick = async () => {
|
|
|
|
if (actionBtnLoadingState.isLoading) {
|
|
|
|
if (actionBtnLoadingState.isLoading) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -109,10 +117,6 @@ const Auth = () => {
|
|
|
|
actionBtnLoadingState.setFinish();
|
|
|
|
actionBtnLoadingState.setFinish();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleLocaleItemClick = (locale: Locale) => {
|
|
|
|
|
|
|
|
globalStore.setLocale(locale);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="page-wrapper auth">
|
|
|
|
<div className="page-wrapper auth">
|
|
|
|
<div className="page-container">
|
|
|
|
<div className="page-container">
|
|
|
@ -122,7 +126,7 @@ const Auth = () => {
|
|
|
|
<img className="logo-img" src={systemStatus.customizedProfile.iconUrl} alt="" />
|
|
|
|
<img className="logo-img" src={systemStatus.customizedProfile.iconUrl} alt="" />
|
|
|
|
<p className="logo-text">{systemStatus.customizedProfile.name}</p>
|
|
|
|
<p className="logo-text">{systemStatus.customizedProfile.name}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<p className="slogan-text">{t("slogan")}</p>
|
|
|
|
<p className="slogan-text">{systemStatus.customizedProfile.description || t("slogan")}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={`page-content-container ${actionBtnLoadingState.isLoading ? "requesting" : ""}`}>
|
|
|
|
<div className={`page-content-container ${actionBtnLoadingState.isLoading ? "requesting" : ""}`}>
|
|
|
|
<div className="form-item-container input-form-container">
|
|
|
|
<div className="form-item-container input-form-container">
|
|
|
@ -167,22 +171,8 @@ const Auth = () => {
|
|
|
|
{!systemStatus?.host && <p className="tip-text">{t("auth.host-tip")}</p>}
|
|
|
|
{!systemStatus?.host && <p className="tip-text">{t("auth.host-tip")}</p>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-row items-center justify-center w-full gap-2">
|
|
|
|
<div className="flex flex-row items-center justify-center w-full gap-2">
|
|
|
|
<Select
|
|
|
|
<LocaleSelect value={locale} onChange={handleLocaleSelectChange} />
|
|
|
|
className="!min-w-[9rem] w-auto whitespace-nowrap"
|
|
|
|
<AppearanceSelect value={appearance} onChange={handleAppearanceSelectChange} />
|
|
|
|
startDecorator={<Icon.Globe className="w-4 h-auto" />}
|
|
|
|
|
|
|
|
value={i18n.language}
|
|
|
|
|
|
|
|
onChange={(_, value) => handleLocaleItemClick(value as Locale)}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Option value="en">English</Option>
|
|
|
|
|
|
|
|
<Option value="zh">中文</Option>
|
|
|
|
|
|
|
|
<Option value="vi">Tiếng Việt</Option>
|
|
|
|
|
|
|
|
<Option value="fr">French</Option>
|
|
|
|
|
|
|
|
<Option value="nl">Nederlands</Option>
|
|
|
|
|
|
|
|
<Option value="sv">Svenska</Option>
|
|
|
|
|
|
|
|
<Option value="de">German</Option>
|
|
|
|
|
|
|
|
<Option value="es">Español</Option>
|
|
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
<AppearanceSelect />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|