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

陈帅's avatar
陈帅 committed
4
import { List } from 'antd';
陈帅's avatar
陈帅 committed
5 6

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

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

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

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

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