MCPcopy
hub / github.com/yinxin630/fiora / Register

Function Register

packages/web/src/modules/LoginAndRegister/Register.tsx:15–80  ·  view source on GitHub ↗

登录框

()

Source from the content-addressed store, hash-verified

13
14/** 登录框 */
15function Register() {
16 const action = useAction();
17 const dispatch = useDispatch();
18 const [username, setUsername] = useState('');
19 const [password, setPassword] = useState('');
20
21 async function handleRegister() {
22 const user = await register(
23 username,
24 password,
25 platform.os?.family,
26 platform.name,
27 platform.description,
28 );
29 if (user) {
30 action.setUser(user);
31 action.toggleLoginRegisterDialog(false);
32 window.localStorage.setItem('token', user.token);
33
34 const linkmanIds = [
35 ...user.groups.map((group: any) => group._id),
36 ...user.friends.map((friend: any) =>
37 getFriendId(friend.from, friend.to._id),
38 ),
39 ];
40 const linkmanMessages = await getLinkmansLastMessagesV2(linkmanIds);
41 Object.values(linkmanMessages).forEach(
42 // @ts-ignore
43 ({ messages }: { messages: Message[] }) => {
44 messages.forEach(convertMessage);
45 },
46 );
47 dispatch({
48 type: ActionTypes.SetLinkmansLastMessages,
49 payload: linkmanMessages,
50 });
51 }
52 }
53
54 return (
55 <div className={Style.loginRegister}>
56 <h3 className={Style.title}>用户名</h3>
57 <Input
58 className={Style.input}
59 value={username}
60 onChange={setUsername}
61 onEnter={handleRegister}
62 />
63 <h3 className={Style.title}>密码</h3>
64 <Input
65 className={Style.input}
66 type="password"
67 value={password}
68 onChange={setPassword}
69 onEnter={handleRegister}
70 />
71 <button
72 className={Style.button}

Callers

nothing calls this directly

Calls 1

useActionFunction · 0.85

Tested by

no test coverage detected