security.tsx 2.83 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import React, { Component, Fragment } from 'react';
陈帅's avatar
陈帅 committed
2
import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
陈帅's avatar
陈帅 committed
3
import { List } from 'antd';
陈帅's avatar
陈帅 committed
4 5

type Unpacked<T> = T extends (infer U)[] ? U : T;
陈帅's avatar
陈帅 committed
6 7

const passwordStrength = {
张秀玲's avatar
张秀玲 committed
8
  strong: (
陈帅's avatar
陈帅 committed
9
    <span className="strong">
10
      <FormattedMessage id="BLOCK_NAME.security.strong" defaultMessage="Strong" />
陈帅's avatar
陈帅 committed
11
    </span>
张秀玲's avatar
张秀玲 committed
12 13
  ),
  medium: (
陈帅's avatar
陈帅 committed
14
    <span className="medium">
15
      <FormattedMessage id="BLOCK_NAME.security.medium" defaultMessage="Medium" />
陈帅's avatar
陈帅 committed
16
    </span>
张秀玲's avatar
张秀玲 committed
17 18
  ),
  weak: (
陈帅's avatar
陈帅 committed
19
    <span className="weak">
20
      <FormattedMessage id="BLOCK_NAME.security.weak" defaultMessage="Weak" />
21
      Weak
陈帅's avatar
陈帅 committed
22
    </span>
张秀玲's avatar
张秀玲 committed
23
  ),
陈帅's avatar
陈帅 committed
24 25
};

张秀玲's avatar
张秀玲 committed
26
class SecurityView extends Component {
27 28
  getData = () => [
    {
29
      title: formatMessage({ id: 'BLOCK_NAME.security.password' }, {}),
30 31
      description: (
        <Fragment>
32
          {formatMessage({ id: 'BLOCK_NAME.security.password-description' })}
33 34 35 36 37
          {passwordStrength.strong}
        </Fragment>
      ),
      actions: [
        <a>
38
          <FormattedMessage id="BLOCK_NAME.security.modify" defaultMessage="Modify" />
39 40 41 42
        </a>,
      ],
    },
    {
43
      title: formatMessage({ id: 'BLOCK_NAME.security.phone' }, {}),
44
      description: `${formatMessage(
45
        { id: 'BLOCK_NAME.security.phone-description' },
46 47 48 49
        {}
      )}:138****8293`,
      actions: [
        <a>
50
          <FormattedMessage id="BLOCK_NAME.security.modify" defaultMessage="Modify" />
51 52 53 54
        </a>,
      ],
    },
    {
55 56
      title: formatMessage({ id: 'BLOCK_NAME.security.question' }, {}),
      description: formatMessage({ id: 'BLOCK_NAME.security.question-description' }, {}),
57 58
      actions: [
        <a>
59
          <FormattedMessage id="BLOCK_NAME.security.set" defaultMessage="Set" />
60 61 62 63
        </a>,
      ],
    },
    {
64
      title: formatMessage({ id: 'BLOCK_NAME.security.email' }, {}),
65
      description: `${formatMessage(
66
        { id: 'BLOCK_NAME.security.email-description' },
67 68 69 70
        {}
      )}:ant***sign.com`,
      actions: [
        <a>
71
          <FormattedMessage id="BLOCK_NAME.security.modify" defaultMessage="Modify" />
72 73 74 75
        </a>,
      ],
    },
    {
76 77
      title: formatMessage({ id: 'BLOCK_NAME.security.mfa' }, {}),
      description: formatMessage({ id: 'BLOCK_NAME.security.mfa-description' }, {}),
78 79
      actions: [
        <a>
80
          <FormattedMessage id="BLOCK_NAME.security.bind" defaultMessage="Bind" />
81 82 83 84
        </a>,
      ],
    },
  ];
陈帅's avatar
陈帅 committed
85

陈帅's avatar
陈帅 committed
86
  render() {
陈帅's avatar
陈帅 committed
87
    const data = this.getData();
陈帅's avatar
陈帅 committed
88 89
    return (
      <Fragment>
陈帅's avatar
陈帅 committed
90
        <List<Unpacked<typeof data>>
陈帅's avatar
陈帅 committed
91
          itemLayout="horizontal"
陈帅's avatar
陈帅 committed
92
          dataSource={data}
陈帅's avatar
陈帅 committed
93 94
          renderItem={item => (
            <List.Item actions={item.actions}>
jim's avatar
jim committed
95
              <List.Item.Meta title={item.title} description={item.description} />
陈帅's avatar
陈帅 committed
96 97 98 99 100 101 102
            </List.Item>
          )}
        />
      </Fragment>
    );
  }
}
lijiehua's avatar
lijiehua committed
103

陈帅's avatar
陈帅 committed
104
export default SecurityView;