feat: login with only name in widget
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ const styles = {
|
|||||||
Object.assign(wrapper.style, styles);
|
Object.assign(wrapper.style, styles);
|
||||||
wrapper.src = `${new URL(_src).origin}/widget.html?host=${hostId}&themeColor=${encodeURIComponent(
|
wrapper.src = `${new URL(_src).origin}/widget.html?host=${hostId}&themeColor=${encodeURIComponent(
|
||||||
themeColor
|
themeColor
|
||||||
)}&from=${encodeURIComponent(location.host)}`;
|
)}&from=${encodeURIComponent(location.hostname)}`;
|
||||||
wrapper.width = closeWidth;
|
wrapper.width = closeWidth;
|
||||||
wrapper.height = closeHeight;
|
wrapper.height = closeHeight;
|
||||||
wrapper.frameborder = 0;
|
wrapper.frameborder = 0;
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
const name = data.get("username") as string;
|
const name = data.get("username") as string;
|
||||||
const email = data.get("email") as string;
|
// const email = data.get("email") as string;
|
||||||
console.log("name,email", name, email);
|
console.log("name,email", name);
|
||||||
|
const randomEmail = `${name}-${(Math.random() + 1).toString(36).substring(7)}@${from}`;
|
||||||
register({
|
register({
|
||||||
name: `${name}-[${from}]`,
|
name,
|
||||||
email,
|
email: randomEmail,
|
||||||
password: email,
|
password: randomEmail,
|
||||||
});
|
});
|
||||||
// const content = new FormData(form).get("prompt") as string;
|
// const content = new FormData(form).get("prompt") as string;
|
||||||
};
|
};
|
||||||
@@ -61,10 +62,7 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
|
|
||||||
if (!loginConfigSuccess) return null;
|
if (!loginConfigSuccess) return null;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
github: enableGithubLogin,
|
github: enableGithubLogin,
|
||||||
google: enableGoogleLogin,
|
google: enableGoogleLogin,
|
||||||
@@ -76,7 +74,7 @@ const Login = () => {
|
|||||||
<div className="bg-white dark:bg-gray-700 border dark:border-gray-500 rounded-lg">
|
<div className="bg-white dark:bg-gray-700 border dark:border-gray-500 rounded-lg">
|
||||||
<form className="px-4 py-3 flex flex-col gap-2" onSubmit={handleSubmit}>
|
<form className="px-4 py-3 flex flex-col gap-2" onSubmit={handleSubmit}>
|
||||||
<Input required placeholder="Name" name='username' />
|
<Input required placeholder="Name" name='username' />
|
||||||
<Input required placeholder="Email" type="email" name='email' />
|
{/* <Input required placeholder="Email" type="email" name='email' /> */}
|
||||||
<StyledButton disabled={isLoading} type="submit" className={clsx("small", `bg-[${color}] text-[${fgColor}]`)}>Start Chat</StyledButton>
|
<StyledButton disabled={isLoading} type="submit" className={clsx("small", `bg-[${color}] text-[${fgColor}]`)}>Start Chat</StyledButton>
|
||||||
{hasSocialLogins && <Divider content='OR' />}
|
{hasSocialLogins && <Divider content='OR' />}
|
||||||
{googleLogin && <GoogleLoginButton clientId={clientId} />}
|
{googleLogin && <GoogleLoginButton clientId={clientId} />}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useAppSelector } from '../app/store';
|
|||||||
import { getContrastColor } from '../common/utils';
|
import { getContrastColor } from '../common/utils';
|
||||||
|
|
||||||
const color = decodeURIComponent(new URLSearchParams(location.search).get("themeColor") || "#1fe1f9");
|
const color = decodeURIComponent(new URLSearchParams(location.search).get("themeColor") || "#1fe1f9");
|
||||||
const from = decodeURIComponent(new URLSearchParams(location.search).get("from") || "widget");
|
const from = decodeURIComponent(new URLSearchParams(location.search).get("from") || "widget.link");
|
||||||
const fgColor = getContrastColor(color);
|
const fgColor = getContrastColor(color);
|
||||||
// 判断是否是iframe上下文
|
// 判断是否是iframe上下文
|
||||||
const embed = window.location !== window.parent.location;
|
const embed = window.location !== window.parent.location;
|
||||||
@@ -12,7 +12,7 @@ const WidgetContext = createContext({ color, fgColor, embed, from, loading: true
|
|||||||
|
|
||||||
|
|
||||||
function WidgetProvider({ children }: { children: ReactNode }) {
|
function WidgetProvider({ children }: { children: ReactNode }) {
|
||||||
const { isLoading: loadingServerData, isError } = useGetServerQuery();
|
const { isLoading: loadingServerData } = useGetServerQuery();
|
||||||
const { isLoading: loadingConfig, data: loginConfig } = useGetLoginConfigQuery();
|
const { isLoading: loadingConfig, data: loginConfig } = useGetLoginConfigQuery();
|
||||||
const serverData = useAppSelector(store => store.server);
|
const serverData = useAppSelector(store => store.server);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user