返回 AiToEarn
AddAccountModal.tsx
根目录 / project / aitoearn-electron / src / views / account / components / AddAccountModal.tsx
1 import { ForwardedRef, forwardRef, memo } from 'react';
2 import styles from './AddAccountModal.module.scss';
3 import { Button, message, Modal, Tooltip } from 'antd';
4 import { AccountInfo, AccountPlatInfoMap } from '@/views/account/comment';
5 import { accountLogin } from '@/icp/account';
6
7 export interface IAddAccountModalRef {}
8
9 export interface IAddAccountModalProps {
10 open: boolean;
11 onClose: () => void;
12 onAddSuccess: (accountInfo: AccountInfo) => void;
13 }
14
15 const AddAccountModal = memo(
16 forwardRef(
17 (
18 { open, onClose, onAddSuccess }: IAddAccountModalProps,
19 ref: ForwardedRef<IAddAccountModalRef>,
20 ) => {
21 const handleOk = () => {
22 onClose();
23 };
24
25 const handleCancel = () => {
26 onClose();
27 };
28
29 return (
30 <Modal
31 title="账号添加"
32 open={open}
33 onOk={handleOk}
34 onCancel={handleCancel}
35 footer={null}
36 width={650}
37 >
38 <div className={styles.addAccountModal}>
39 <h1>选择平台添加账号</h1>
40 <div className="addAccountModal_plats">
41 {Array.from(AccountPlatInfoMap).map(([key, value]) => {
42 return (
43 <Tooltip title={value.tips?.account} key={key}>
44 <Button
45 type="text"
46 className="addAccountModal_plats-item"
47 onClick={async () => {
48 const res = await accountLogin(key);
49 if (!res) return;
50 message.success('账号添加成功');
51 onAddSuccess(res);
52 }}
53 >
54 <div className="addAccountModal_plats-item-con">
55 {/*<LoadingOutlined style={{ fontSize: '20px' }} />*/}
56 <img src={value.icon} />
57 <span>{value.name}</span>
58 </div>
59 </Button>
60 </Tooltip>
61 );
62 })}
63 </div>
64 </div>
65 </Modal>
66 );
67 },
68 ),
69 );
70 AddAccountModal.displayName = 'AddAccountModal';
71
72 export default AddAccountModal;
73
73 lines Plain Text