@tuya-sat/sdf-main-sdk 0.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +5 -0
- package/README.md +1 -0
- package/antd.less.overwrite.js +56 -0
- package/color.js +140 -0
- package/dark-variable.less +1449 -0
- package/package.json +74 -0
- package/scripts/gen-localize-file.mjs +56 -0
- package/src/App.less +156 -0
- package/src/App.tsx +87 -0
- package/src/api/index.ts +52 -0
- package/src/api/req.ts +23 -0
- package/src/api/res.ts +29 -0
- package/src/api/urls.ts +30 -0
- package/src/api/utils.ts +41 -0
- package/src/assets/imgs/404.svg +194 -0
- package/src/assets/imgs/reLogin.png +0 -0
- package/src/components/404/index.tsx +44 -0
- package/src/components/500/index.tsx +49 -0
- package/src/components/BCustomNav/index.module.less +17 -0
- package/src/components/BCustomNav/index.tsx +108 -0
- package/src/components/BForgot/index.module.less +5 -0
- package/src/components/BForgot/index.tsx +96 -0
- package/src/components/BHeaderUser/account.png +0 -0
- package/src/components/BHeaderUser/app-scan-en.png +0 -0
- package/src/components/BHeaderUser/app-scan-zh.png +0 -0
- package/src/components/BHeaderUser/app-scan.png +0 -0
- package/src/components/BHeaderUser/components/BSwitchLang/index.module.less +6 -0
- package/src/components/BHeaderUser/components/BSwitchLang/index.tsx +56 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/Content.tsx +199 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.module.less +11 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.tsx +27 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/hooks.ts +104 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/index.module.less +70 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/index.tsx +184 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/table/index.tsx +184 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/table/read.tsx +67 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/tools/index.tsx +116 -0
- package/src/components/BHeaderUser/components/Badge/index.module.less +99 -0
- package/src/components/BHeaderUser/components/Badge/index.tsx +179 -0
- package/src/components/BHeaderUser/index.module.less +105 -0
- package/src/components/BHeaderUser/index.tsx +261 -0
- package/src/components/BHeaderUser/logout.tsx +26 -0
- package/src/components/BLayout/components/Header/index.module.less +27 -0
- package/src/components/BLayout/components/Header/index.tsx +36 -0
- package/src/components/BLayout/components/Layout/empty.tsx +35 -0
- package/src/components/BLayout/components/Layout/emptyPage.png +0 -0
- package/src/components/BLayout/components/Layout/index.tsx +72 -0
- package/src/components/BLayout/components/Logo.tsx +6 -0
- package/src/components/BLayout/components/Menu/collapse.tsx +41 -0
- package/src/components/BLayout/components/Menu/image/close.tsx +26 -0
- package/src/components/BLayout/components/Menu/image/closedefault.tsx +26 -0
- package/src/components/BLayout/components/Menu/image/open.tsx +38 -0
- package/src/components/BLayout/components/Menu/image/opendefault.tsx +38 -0
- package/src/components/BLayout/components/Menu/index.module.less +125 -0
- package/src/components/BLayout/components/Menu/index.tsx +244 -0
- package/src/components/BLayout/components/MenuIcon.module.less +5 -0
- package/src/components/BLayout/components/MenuIcon.tsx +46 -0
- package/src/components/BLayout/components/MultiSider/index.module.less +104 -0
- package/src/components/BLayout/components/MultiSider/index.tsx +172 -0
- package/src/components/BLayout/components/Sider/index.less +64 -0
- package/src/components/BLayout/components/Sider/index.module.less +17 -0
- package/src/components/BLayout/components/Sider/index.tsx +34 -0
- package/src/components/BLayout/index.tsx +78 -0
- package/src/components/BLayoutLogin/index.module.less +65 -0
- package/src/components/BLayoutLogin/index.tsx +68 -0
- package/src/components/BLayoutLogin/login.jpg +0 -0
- package/src/components/BLogin/component/Clause/index.module.less +25 -0
- package/src/components/BLogin/component/Clause/index.tsx +58 -0
- package/src/components/BLogin/component/ForgotBtn/index.module.less +9 -0
- package/src/components/BLogin/component/ForgotBtn/index.tsx +18 -0
- package/src/components/BLogin/component/Password/index.tsx +39 -0
- package/src/components/BLogin/component/SubmitBtn/index.tsx +30 -0
- package/src/components/BLogin/component/TenanSpace/index.tsx +28 -0
- package/src/components/BLogin/component/Title/index.module.less +6 -0
- package/src/components/BLogin/component/Title/index.tsx +12 -0
- package/src/components/BLogin/component/UserName/index.tsx +48 -0
- package/src/components/BLogin/component/VerifyCode/index.module.less +11 -0
- package/src/components/BLogin/component/VerifyCode/index.tsx +165 -0
- package/src/components/BLogin/index.module.less +31 -0
- package/src/components/BLogin/index.tsx +210 -0
- package/src/components/BRegister/components/TenantName/index.tsx +26 -0
- package/src/components/BRegister/index.module.less +5 -0
- package/src/components/BRegister/index.tsx +71 -0
- package/src/components/Back/index.tsx +25 -0
- package/src/components/IconFont/font.js +66 -0
- package/src/components/IconFont/index.tsx +18 -0
- package/src/components/MicroComponent/Header/index.module.less +7 -0
- package/src/components/MicroComponent/Header/index.tsx +220 -0
- package/src/components/PForgot/index.tsx +10 -0
- package/src/components/PLogin/index.tsx +12 -0
- package/src/components/PRegister/index.tsx +10 -0
- package/src/components/PSetting/index.module.less +53 -0
- package/src/components/PSetting/index.tsx +420 -0
- package/src/constant/chargeStatus.ts +6 -0
- package/src/constant/imgs.ts +6 -0
- package/src/constant/index.ts +293 -0
- package/src/dark-variable.less +1449 -0
- package/src/global.d.ts +54 -0
- package/src/hooks/index.ts +133 -0
- package/src/index.css +1493 -0
- package/src/index.tsx +105 -0
- package/src/lang/en.json +266 -0
- package/src/lang/index.ts +44 -0
- package/src/lang/utils.ts +285 -0
- package/src/lang/zh.json +270 -0
- package/src/micro-script/theme/index.ts +29 -0
- package/src/micro-script/theme/theme-css/static.js +73 -0
- package/src/micro-script/theme/theme-css/subscriber.ts +201 -0
- package/src/micro-script/theme/util/index.ts +58 -0
- package/src/mqtt/index.ts +121 -0
- package/src/pages/403.tsx +18 -0
- package/src/pages/404.tsx +17 -0
- package/src/pages/expiration.tsx +23 -0
- package/src/pages/forgot.tsx +9 -0
- package/src/pages/home/index.tsx +172 -0
- package/src/pages/home/setting/index.tsx +7 -0
- package/src/pages/index.ts +50 -0
- package/src/pages/login.tsx +46 -0
- package/src/pages/register.tsx +9 -0
- package/src/pages/relogin/index.module.less +0 -0
- package/src/pages/relogin/index.tsx +54 -0
- package/src/plugins/index.ts +11 -0
- package/src/public-path.js +8 -0
- package/src/qiankun/globalState.ts +6 -0
- package/src/qiankun/index.ts +174 -0
- package/src/qiankun/utils/index.ts +69 -0
- package/src/qiankun/xhook/index.ts +193 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/sentry/index.ts +33 -0
- package/src/sky/index.ts +57 -0
- package/src/theme/custom-dark.less +64 -0
- package/src/theme/custom-light.less +48 -0
- package/src/theme/index.less +327 -0
- package/src/theme/variable.less +13 -0
- package/src/utils/checkPass.ts +21 -0
- package/src/utils/common.ts +195 -0
- package/src/utils/eventBus.ts +112 -0
- package/src/utils/gt.js +293 -0
- package/src/utils/index.ts +89 -0
- package/src/utils/theme/base.ts +110 -0
- package/src/utils/theme/changeCssVariable.ts +157 -0
- package/src/utils/theme/changeMenuCssVariable.ts +176 -0
- package/src/utils/theme/index.ts +85 -0
- package/src/utils/theme/store.ts +37 -0
- package/tsconfig.json +28 -0
- package/typings.d.ts +10 -0
- package/webpack.config.js +103 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Form, Input } from 'antd';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { TENANT_ID_REGEXP } from '@/constant';
|
|
4
|
+
import Icon from '@/components/IconFont';
|
|
5
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
6
|
+
export default () => {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
return (
|
|
9
|
+
<Form.Item
|
|
10
|
+
name="tenantSpace"
|
|
11
|
+
label={t('login.form.tenantId.label')}
|
|
12
|
+
required={false}
|
|
13
|
+
rules={[
|
|
14
|
+
{ required: true, message: t('login.form.tenantId.require') },
|
|
15
|
+
{
|
|
16
|
+
pattern: TENANT_ID_REGEXP,
|
|
17
|
+
message: t('login.form.tenantId.pattern'),
|
|
18
|
+
},
|
|
19
|
+
]}
|
|
20
|
+
>
|
|
21
|
+
<Input
|
|
22
|
+
size="large"
|
|
23
|
+
prefix={<Icon type="icon-zuhuID" style={{ fontSize: '1em' }} />}
|
|
24
|
+
placeholder={t('login.form.tenantId.placeholder')}
|
|
25
|
+
/>
|
|
26
|
+
</Form.Item>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Typography } from 'antd';
|
|
2
|
+
import styles from './index.module.less';
|
|
3
|
+
const { Title } = Typography;
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
6
|
+
export default ({ title }) => {
|
|
7
|
+
return (
|
|
8
|
+
<div className={styles.wrap}>
|
|
9
|
+
<Title level={3}>{title}</Title>
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Form, Input } from 'antd';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { UserOutlined } from '@ant-design/icons';
|
|
5
|
+
import { EMAIL_REGEXP, US_TELE_REGEXP } from '@/constant';
|
|
6
|
+
|
|
7
|
+
const UserName = ({ label = undefined }) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const [, setPhoneNum] = useState<string>();
|
|
10
|
+
const rules = [
|
|
11
|
+
() => ({
|
|
12
|
+
validator(_, value) {
|
|
13
|
+
if (!value) {
|
|
14
|
+
return Promise.reject(
|
|
15
|
+
new Error(t('login.form.username.validate.require'))
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
if (EMAIL_REGEXP.test(value)) {
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
} else if (US_TELE_REGEXP.test(value)) {
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
} else {
|
|
23
|
+
return Promise.reject(
|
|
24
|
+
new Error(t('login.form.username.validate.pattern'))
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
// 请输入正确的手机号码或邮箱账号;
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Form.Item
|
|
34
|
+
name="username"
|
|
35
|
+
label={label || t('login.form.username.label')}
|
|
36
|
+
rules={rules}
|
|
37
|
+
>
|
|
38
|
+
<Input
|
|
39
|
+
size="large"
|
|
40
|
+
prefix={<UserOutlined className="site-form-item-icon" />}
|
|
41
|
+
placeholder={t('login.form.username.placeholder')}
|
|
42
|
+
onChange={(e) => setPhoneNum(e.target.value)}
|
|
43
|
+
/>
|
|
44
|
+
</Form.Item>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default UserName;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
Statistic,
|
|
5
|
+
Form,
|
|
6
|
+
Input,
|
|
7
|
+
Row,
|
|
8
|
+
Col,
|
|
9
|
+
Button,
|
|
10
|
+
Spin,
|
|
11
|
+
FormInstance,
|
|
12
|
+
} from 'antd';
|
|
13
|
+
import { MailOutlined } from '@ant-design/icons';
|
|
14
|
+
import { api, URLS } from '@/api';
|
|
15
|
+
import styles from './index.module.less';
|
|
16
|
+
import {
|
|
17
|
+
isOpenGt,
|
|
18
|
+
initGeetest,
|
|
19
|
+
geetestPromise,
|
|
20
|
+
showGeetest,
|
|
21
|
+
} from '@/utils/common';
|
|
22
|
+
import cx from 'classnames';
|
|
23
|
+
|
|
24
|
+
const { Countdown } = Statistic;
|
|
25
|
+
|
|
26
|
+
const VerifyCode = ({
|
|
27
|
+
form,
|
|
28
|
+
action = 'forgot',
|
|
29
|
+
}: {
|
|
30
|
+
form: FormInstance;
|
|
31
|
+
action: 'forgot' | 'register';
|
|
32
|
+
}) => {
|
|
33
|
+
const { t, i18n } = useTranslation();
|
|
34
|
+
|
|
35
|
+
const [deadline, setDeadline] = useState<number>(Date.now());
|
|
36
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
37
|
+
const [showCountdown, setShowCountdown] = useState(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
isOpenGt() && initGeetest();
|
|
41
|
+
}, []);
|
|
42
|
+
const sendCode = async () => {
|
|
43
|
+
if (isOpenGt()) {
|
|
44
|
+
await form.validateFields(['username']);
|
|
45
|
+
|
|
46
|
+
geetestPromise
|
|
47
|
+
.then((geetest) => {
|
|
48
|
+
showGeetest(geetest, null, processVerifyCode);
|
|
49
|
+
})
|
|
50
|
+
.catch(() => {
|
|
51
|
+
initGeetest();
|
|
52
|
+
geetestPromise.then((geetest) => {
|
|
53
|
+
showGeetest(geetest, null, processVerifyCode);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
processVerifyCode(null);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const processVerifyCode = (secureKey) => {
|
|
62
|
+
let params = {};
|
|
63
|
+
try {
|
|
64
|
+
if (action === 'register') {
|
|
65
|
+
const values = form.getFieldsValue();
|
|
66
|
+
if (values.username.includes('@')) {
|
|
67
|
+
params = {
|
|
68
|
+
mail: values.username,
|
|
69
|
+
tenantSpace: values.tenantSpace,
|
|
70
|
+
};
|
|
71
|
+
} else {
|
|
72
|
+
params = {
|
|
73
|
+
phone: values.username,
|
|
74
|
+
countryCode: localStorage.getItem('regionCode') || '86',
|
|
75
|
+
tenantSpace: values.tenantSpace,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
} else if (action === 'forgot') {
|
|
79
|
+
const values = form.getFieldsValue();
|
|
80
|
+
if (values.username.includes('@')) {
|
|
81
|
+
params = { mail: values.username, language: i18n.language };
|
|
82
|
+
} else {
|
|
83
|
+
params = {
|
|
84
|
+
phone: values.username,
|
|
85
|
+
country_code: localStorage.getItem('regionCode') || '86',
|
|
86
|
+
language: i18n.language,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
params = { ...params, secureKey };
|
|
91
|
+
api
|
|
92
|
+
.post(action === 'forgot' ? URLS.CODE : URLS.TENANDCODE, params)
|
|
93
|
+
.then((res) => {
|
|
94
|
+
setLoading(true);
|
|
95
|
+
setShowCountdown(true);
|
|
96
|
+
setDeadline(Date.now() + 60 * 1000);
|
|
97
|
+
setLoading(false);
|
|
98
|
+
})
|
|
99
|
+
.catch(() => {
|
|
100
|
+
setLoading(false);
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.log('register or forgot failed', error);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div className={styles.wrap}>
|
|
109
|
+
<Form.Item
|
|
110
|
+
className={styles['form-item']}
|
|
111
|
+
name="validateCode"
|
|
112
|
+
label={t('login.form.code.getCode')}
|
|
113
|
+
required={false}
|
|
114
|
+
rules={[
|
|
115
|
+
{ required: true, message: t('login.form.code.require') },
|
|
116
|
+
{
|
|
117
|
+
len: 6,
|
|
118
|
+
message: t('login.form.code.len'),
|
|
119
|
+
},
|
|
120
|
+
]}
|
|
121
|
+
>
|
|
122
|
+
<Input
|
|
123
|
+
size="large"
|
|
124
|
+
type="text"
|
|
125
|
+
autoComplete="new-password"
|
|
126
|
+
prefix={<MailOutlined />}
|
|
127
|
+
placeholder={t('login.form.code.placeholder')}
|
|
128
|
+
/>
|
|
129
|
+
</Form.Item>
|
|
130
|
+
<div className={cx(styles.code, 'main-verify-code')}>
|
|
131
|
+
{showCountdown ? (
|
|
132
|
+
<Button disabled size="large">
|
|
133
|
+
<div>
|
|
134
|
+
<Row>
|
|
135
|
+
<Col>{t('login.form.code.countdown')}</Col>
|
|
136
|
+
<Col>
|
|
137
|
+
<Countdown
|
|
138
|
+
format="ss"
|
|
139
|
+
value={deadline}
|
|
140
|
+
suffix="s"
|
|
141
|
+
onFinish={() => {
|
|
142
|
+
setShowCountdown(false);
|
|
143
|
+
}}
|
|
144
|
+
valueStyle={{
|
|
145
|
+
fontSize: 14,
|
|
146
|
+
width: 40,
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
</Col>
|
|
150
|
+
</Row>
|
|
151
|
+
</div>
|
|
152
|
+
</Button>
|
|
153
|
+
) : (
|
|
154
|
+
<Spin spinning={loading}>
|
|
155
|
+
<Button onClick={sendCode} size="large">
|
|
156
|
+
{t('login.form.code.getCode')}
|
|
157
|
+
</Button>
|
|
158
|
+
</Spin>
|
|
159
|
+
)}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default VerifyCode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.login-form {
|
|
2
|
+
position: relative;
|
|
3
|
+
:global(.main-form-item-control-input-content) {
|
|
4
|
+
text-align: right;
|
|
5
|
+
}
|
|
6
|
+
.forgot {
|
|
7
|
+
position: absolute;
|
|
8
|
+
left: 50%;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
transform: translateX(-50%);
|
|
11
|
+
height: 22px;
|
|
12
|
+
line-height: 22px;
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
padding-bottom: 30px;
|
|
16
|
+
}
|
|
17
|
+
.third-login {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
height: 30px;
|
|
22
|
+
.icon {
|
|
23
|
+
width: 28px;
|
|
24
|
+
height: 28px;
|
|
25
|
+
transition: all 0.3s;
|
|
26
|
+
&:hover {
|
|
27
|
+
width: 30px;
|
|
28
|
+
height: 30px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Form, message, Row } from 'antd';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { api, URLS } from '@/api';
|
|
4
|
+
import { sha256 } from 'js-sha256';
|
|
5
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
6
|
+
import UserName from './component/UserName';
|
|
7
|
+
import Password from './component/Password';
|
|
8
|
+
import SubmitBtn from './component/SubmitBtn';
|
|
9
|
+
import styles from './index.module.less';
|
|
10
|
+
import Clause from './component/Clause';
|
|
11
|
+
import Title from './component/Title';
|
|
12
|
+
import TenantSpace from './component/TenanSpace';
|
|
13
|
+
import ForgetBtn from './component/ForgotBtn';
|
|
14
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
15
|
+
import Logo from '@/components/BLayout/components/Logo';
|
|
16
|
+
import { gMainConfig } from '@/index';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
isOpenGt,
|
|
20
|
+
initGeetest,
|
|
21
|
+
afterLoginHook,
|
|
22
|
+
showGeetest,
|
|
23
|
+
geetestPromise,
|
|
24
|
+
} from '@/utils/common';
|
|
25
|
+
|
|
26
|
+
const LoginForm = () => {
|
|
27
|
+
const [form] = Form.useForm();
|
|
28
|
+
const {
|
|
29
|
+
title,
|
|
30
|
+
legal_notice,
|
|
31
|
+
privacy_policy,
|
|
32
|
+
service_terms,
|
|
33
|
+
tenant_type,
|
|
34
|
+
tenant_register_support,
|
|
35
|
+
} = window?._SDF?.saas;
|
|
36
|
+
const history = useHistory();
|
|
37
|
+
const { t } = useTranslation();
|
|
38
|
+
const { search } = useLocation();
|
|
39
|
+
const [agreed, setAgreed] = useState<boolean>();
|
|
40
|
+
const [logining, setLogining] = useState(false);
|
|
41
|
+
|
|
42
|
+
const hasTenantSpace = useMemo(() => {
|
|
43
|
+
return (
|
|
44
|
+
tenant_type === 'MULTI_TENANT' &&
|
|
45
|
+
window._SDF_CONFIG?.features.is_edgecloud
|
|
46
|
+
);
|
|
47
|
+
}, [tenant_type]);
|
|
48
|
+
|
|
49
|
+
const showClause = useMemo(() => {
|
|
50
|
+
const hasClause = !!legal_notice || !!privacy_policy || !!service_terms;
|
|
51
|
+
return window._SDF_CONFIG?.saas?.LOGIN_PROTO.ENABLE !== false && hasClause;
|
|
52
|
+
}, [legal_notice, privacy_policy, service_terms]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
isOpenGt() && initGeetest();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const toLogin = async (form) => {
|
|
59
|
+
setLogining(true);
|
|
60
|
+
// 是否添加极验
|
|
61
|
+
if (isOpenGt()) {
|
|
62
|
+
geetestPromise
|
|
63
|
+
.then((geetest) => {
|
|
64
|
+
geetest.onClose(() => {
|
|
65
|
+
setLogining(false);
|
|
66
|
+
});
|
|
67
|
+
showGeetest(geetest, form, processlogin);
|
|
68
|
+
})
|
|
69
|
+
.catch(() => {
|
|
70
|
+
initGeetest();
|
|
71
|
+
geetestPromise.then((geetest) => {
|
|
72
|
+
showGeetest(geetest, form, processlogin);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
processlogin(form, null);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const processlogin = async (form, secureKey) => {
|
|
81
|
+
if (gMainConfig?.hooks?.loginApiHook) {
|
|
82
|
+
await gMainConfig.hooks.loginApiHook(form, () => {
|
|
83
|
+
afterLoginHook({
|
|
84
|
+
search,
|
|
85
|
+
history,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
// 区分手机号和邮箱
|
|
90
|
+
if (form.username.includes('@')) {
|
|
91
|
+
if (gMainConfig?.hooks?.beforeLoginApiHook) {
|
|
92
|
+
await gMainConfig?.hooks?.beforeLoginApiHook(form);
|
|
93
|
+
}
|
|
94
|
+
let params;
|
|
95
|
+
if (secureKey) {
|
|
96
|
+
params = {
|
|
97
|
+
username: form.username?.trim(),
|
|
98
|
+
password: sha256(form.password?.trim()),
|
|
99
|
+
tenantSpace: hasTenantSpace ? form.tenantSpace : undefined,
|
|
100
|
+
secureKey,
|
|
101
|
+
};
|
|
102
|
+
} else {
|
|
103
|
+
params = {
|
|
104
|
+
username: form.username?.trim(),
|
|
105
|
+
password: sha256(form.password?.trim()),
|
|
106
|
+
tenantSpace: hasTenantSpace ? form.tenantSpace : undefined,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
api
|
|
110
|
+
.post<{
|
|
111
|
+
userToken: string;
|
|
112
|
+
accountType: 1 | 3;
|
|
113
|
+
roleName: string;
|
|
114
|
+
}>(URLS.LOGIN, params)
|
|
115
|
+
.then(async ({}) => {
|
|
116
|
+
if (gMainConfig?.hooks?.afterLoginApiHook) {
|
|
117
|
+
await gMainConfig?.hooks?.afterLoginApiHook(() => {
|
|
118
|
+
afterLoginHook({
|
|
119
|
+
search,
|
|
120
|
+
history,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
afterLoginHook({
|
|
125
|
+
search,
|
|
126
|
+
history,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
.catch(() => setLogining(false))
|
|
131
|
+
.finally(() => setLogining(false));
|
|
132
|
+
} else {
|
|
133
|
+
let params;
|
|
134
|
+
if (secureKey) {
|
|
135
|
+
params = {
|
|
136
|
+
country_code: localStorage.getItem('regionCode') || '86',
|
|
137
|
+
username: form.username?.trim(),
|
|
138
|
+
password: sha256(form.password?.trim()),
|
|
139
|
+
tenantSpace: hasTenantSpace ? form.tenantSpace : undefined,
|
|
140
|
+
secureKey,
|
|
141
|
+
};
|
|
142
|
+
} else {
|
|
143
|
+
params = {
|
|
144
|
+
country_code: localStorage.getItem('regionCode') || '86',
|
|
145
|
+
username: form.username?.trim(),
|
|
146
|
+
password: sha256(form.password?.trim()),
|
|
147
|
+
tenantSpace: hasTenantSpace ? form.tenantSpace : undefined,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
api
|
|
151
|
+
.post<{
|
|
152
|
+
userToken: string;
|
|
153
|
+
accountType: 1 | 3;
|
|
154
|
+
roleName: string;
|
|
155
|
+
}>(URLS.LOGIN, params)
|
|
156
|
+
.then(
|
|
157
|
+
({
|
|
158
|
+
userToken,
|
|
159
|
+
user_nick_name,
|
|
160
|
+
user_name,
|
|
161
|
+
roleName,
|
|
162
|
+
mobile,
|
|
163
|
+
email,
|
|
164
|
+
}) =>
|
|
165
|
+
afterLoginHook({
|
|
166
|
+
search,
|
|
167
|
+
history,
|
|
168
|
+
})
|
|
169
|
+
)
|
|
170
|
+
.catch(() => setLogining(false))
|
|
171
|
+
.finally(() => setLogining(false));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<>
|
|
178
|
+
<Form
|
|
179
|
+
form={form}
|
|
180
|
+
className={styles['login-form']}
|
|
181
|
+
onFinish={toLogin}
|
|
182
|
+
validateTrigger={['onBlur']}
|
|
183
|
+
layout="vertical"
|
|
184
|
+
>
|
|
185
|
+
{window._SDF_CONFIG?.saas?.LOGO_INSTEAD_OF_TITLE ? (
|
|
186
|
+
<Row style={{ marginBottom: '20px' }}>
|
|
187
|
+
<Logo />
|
|
188
|
+
</Row>
|
|
189
|
+
) : (
|
|
190
|
+
<Title title={title} />
|
|
191
|
+
)}
|
|
192
|
+
{hasTenantSpace && <TenantSpace />}
|
|
193
|
+
<UserName />
|
|
194
|
+
<Password />
|
|
195
|
+
{showClause && <Clause toggleAgreed={setAgreed} />}
|
|
196
|
+
<SubmitBtn
|
|
197
|
+
loading={logining}
|
|
198
|
+
top={13}
|
|
199
|
+
disabled={agreed}
|
|
200
|
+
btTx={t('login.signIn')}
|
|
201
|
+
/>
|
|
202
|
+
{window._SDF_CONFIG?.saas?.FORGET_PWD_ENABLE !== false && (
|
|
203
|
+
<ForgetBtn showRegister={!!tenant_register_support} />
|
|
204
|
+
)}
|
|
205
|
+
</Form>
|
|
206
|
+
</>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export default LoginForm;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Form, Input } from 'antd';
|
|
2
|
+
import Icon from '@/components/IconFont';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
5
|
+
export default () => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (
|
|
8
|
+
<Form.Item
|
|
9
|
+
name="tenantName"
|
|
10
|
+
label={t('register.form.enterprise.label')}
|
|
11
|
+
required={false}
|
|
12
|
+
rules={[
|
|
13
|
+
{
|
|
14
|
+
required: true,
|
|
15
|
+
message: t('register.form.enterprise.validate.require'),
|
|
16
|
+
},
|
|
17
|
+
]}
|
|
18
|
+
>
|
|
19
|
+
<Input
|
|
20
|
+
size="large"
|
|
21
|
+
prefix={<Icon type="icon-zuzhimingcheng" style={{ fontSize: '1em' }} />}
|
|
22
|
+
placeholder={t('register.form.enterprise.placeholder')}
|
|
23
|
+
/>
|
|
24
|
+
</Form.Item>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Form, message, Row, Typography } from 'antd';
|
|
2
|
+
import TenantSpace from '@/components/BLogin/component/TenanSpace';
|
|
3
|
+
import UserName from '@/components/BLogin/component/UserName';
|
|
4
|
+
import VerifyCode from '@/components/BLogin/component/VerifyCode';
|
|
5
|
+
import Password from '@/components/BLogin/component/Password';
|
|
6
|
+
import SubmitBtn from '@/components/BLogin/component/SubmitBtn';
|
|
7
|
+
import TenantName from './components/TenantName';
|
|
8
|
+
import IconFont from '@/components/IconFont';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { useHistory } from 'react-router-dom';
|
|
11
|
+
import { api, URLS } from '@/api';
|
|
12
|
+
import { sha256 } from 'js-sha256';
|
|
13
|
+
import styles from './index.module.less';
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
|
|
16
|
+
const { Title } = Typography;
|
|
17
|
+
const LTitle = ({ goback }) => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
return (
|
|
20
|
+
<Row style={{ marginBottom: '56px' }}>
|
|
21
|
+
<span onClick={goback}>
|
|
22
|
+
<IconFont
|
|
23
|
+
type="icon-jiantouda-zuo"
|
|
24
|
+
className={cx(styles.icon, 'main-primary-hover')}
|
|
25
|
+
/>
|
|
26
|
+
</span>
|
|
27
|
+
<Title level={3}>{t('login.back2login')}</Title>
|
|
28
|
+
</Row>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
32
|
+
export default () => {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
const history = useHistory();
|
|
35
|
+
const [form] = Form.useForm();
|
|
36
|
+
const toRegister = (form) => {
|
|
37
|
+
api
|
|
38
|
+
.post(URLS.REGISTER, {
|
|
39
|
+
tenantName: form.tenantName,
|
|
40
|
+
tenantSpace: form.tenantSpace,
|
|
41
|
+
username: form.username,
|
|
42
|
+
code: form.validateCode,
|
|
43
|
+
password: sha256(form.password),
|
|
44
|
+
})
|
|
45
|
+
.then((res) => {
|
|
46
|
+
if (res) {
|
|
47
|
+
afterRegister();
|
|
48
|
+
message.success(t('register.registerSuccess'));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const afterRegister = () => {
|
|
53
|
+
history.push('/login');
|
|
54
|
+
};
|
|
55
|
+
return (
|
|
56
|
+
<Form
|
|
57
|
+
form={form}
|
|
58
|
+
onFinish={toRegister}
|
|
59
|
+
layout="vertical"
|
|
60
|
+
validateTrigger={['onBlur']}
|
|
61
|
+
>
|
|
62
|
+
<LTitle goback={afterRegister} />
|
|
63
|
+
<TenantName />
|
|
64
|
+
<TenantSpace />
|
|
65
|
+
<UserName label={t('register.form.username.label')} />
|
|
66
|
+
<VerifyCode form={form} action="register" />
|
|
67
|
+
<Password isHide={true} name="password" />
|
|
68
|
+
<SubmitBtn top={16} btTx={t('register.register')} />
|
|
69
|
+
</Form>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useHistory } from 'react-router-dom';
|
|
2
|
+
import IconFont from '@/components/IconFont';
|
|
3
|
+
|
|
4
|
+
const Back = () => {
|
|
5
|
+
const history = useHistory();
|
|
6
|
+
function browserHistory() {
|
|
7
|
+
const historyState = window.history.state;
|
|
8
|
+
if (historyState === null) {
|
|
9
|
+
// history.push('/');
|
|
10
|
+
window.location.pathname = '/';
|
|
11
|
+
} else {
|
|
12
|
+
history.goBack();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return (
|
|
16
|
+
<a onClick={browserHistory} style={{ marginTop: '3px' }}>
|
|
17
|
+
<IconFont
|
|
18
|
+
type="icon-jiantouda-zuo"
|
|
19
|
+
className="main-text-color"
|
|
20
|
+
style={{ fontSize: '20px' }}
|
|
21
|
+
/>
|
|
22
|
+
</a>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
export default Back;
|