@authing/react-ui-components 2.4.58 → 3.0.0-rc.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.
Files changed (144) hide show
  1. package/lib/index.d.ts +2795 -0
  2. package/lib/index.min.css +2 -1
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +43 -0
  5. package/lib/static/media/loading.4a67a5f3.svg +29 -0
  6. package/package.json +41 -14
  7. package/.eslintignore +0 -6
  8. package/.eslintrc.js +0 -7
  9. package/.prettierrc +0 -5
  10. package/.vscode/settings.json +0 -31
  11. package/config/antdReplacer.js +0 -51
  12. package/config/env.js +0 -106
  13. package/config/getHttpsConfig.js +0 -66
  14. package/config/jest/cssTransform.js +0 -14
  15. package/config/jest/fileTransform.js +0 -40
  16. package/config/modules.js +0 -134
  17. package/config/paths.js +0 -71
  18. package/config/pnpTs.js +0 -35
  19. package/config/webpack.config.js +0 -857
  20. package/config/webpackDevServer.config.js +0 -130
  21. package/public/favicon.ico +0 -0
  22. package/public/index.html +0 -43
  23. package/public/logo192.png +0 -0
  24. package/public/logo512.png +0 -0
  25. package/public/manifest.json +0 -25
  26. package/public/robots.txt +0 -3
  27. package/scripts/build.js +0 -212
  28. package/scripts/lib.js +0 -200
  29. package/scripts/start.js +0 -166
  30. package/scripts/test.js +0 -53
  31. package/src/common/AuthingDropdown/index.tsx +0 -52
  32. package/src/common/AuthingDropdown/style.less +0 -43
  33. package/src/common/AuthingTabs/index.tsx +0 -98
  34. package/src/common/AuthingTabs/style.less +0 -135
  35. package/src/common/CopyAbleText/index.tsx +0 -54
  36. package/src/common/CopyAbleText/style.less +0 -13
  37. package/src/common/VerifyCodeInput/index.tsx +0 -76
  38. package/src/common/VerifyCodeInput/style.less +0 -24
  39. package/src/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  40. package/src/components/AuthingGuard/AppMFALayout/style.less +0 -12
  41. package/src/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  42. package/src/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  43. package/src/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  44. package/src/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  45. package/src/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  46. package/src/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  47. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -86
  48. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  49. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  50. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  51. package/src/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  52. package/src/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  53. package/src/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  54. package/src/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  55. package/src/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  56. package/src/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  57. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  58. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  59. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  60. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  61. package/src/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  62. package/src/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  63. package/src/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  64. package/src/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  65. package/src/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  66. package/src/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  67. package/src/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  68. package/src/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  69. package/src/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  70. package/src/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  71. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  72. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  73. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  74. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  75. package/src/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  76. package/src/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  77. package/src/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  78. package/src/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  79. package/src/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  80. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  81. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  82. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  83. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  84. package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  85. package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  86. package/src/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  87. package/src/components/AuthingGuard/Forms/index.ts +0 -13
  88. package/src/components/AuthingGuard/GuardLayout/index.tsx +0 -483
  89. package/src/components/AuthingGuard/GuardLayout/style.less +0 -111
  90. package/src/components/AuthingGuard/Header/index.tsx +0 -28
  91. package/src/components/AuthingGuard/Header/style.less +0 -64
  92. package/src/components/AuthingGuard/IconFont/iconfont.js +0 -74
  93. package/src/components/AuthingGuard/IconFont/index.tsx +0 -19
  94. package/src/components/AuthingGuard/IconFont/style.less +0 -6
  95. package/src/components/AuthingGuard/IconFont/svg.js +0 -2
  96. package/src/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  97. package/src/components/AuthingGuard/LoginLayout/style.less +0 -0
  98. package/src/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  99. package/src/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  100. package/src/components/AuthingGuard/MfaLayout/style.less +0 -3
  101. package/src/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  102. package/src/components/AuthingGuard/RegisterLayout/style.less +0 -0
  103. package/src/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  104. package/src/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  105. package/src/components/AuthingGuard/api/appConfig.ts +0 -153
  106. package/src/components/AuthingGuard/api/http.ts +0 -88
  107. package/src/components/AuthingGuard/api/index.ts +0 -3
  108. package/src/components/AuthingGuard/api/sso.ts +0 -29
  109. package/src/components/AuthingGuard/api/userPoolConfig.ts +0 -110
  110. package/src/components/AuthingGuard/constants.ts +0 -107
  111. package/src/components/AuthingGuard/hooks/index.tsx +0 -70
  112. package/src/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  113. package/src/components/AuthingGuard/index.tsx +0 -134
  114. package/src/components/AuthingGuard/locales/en/common.json +0 -185
  115. package/src/components/AuthingGuard/locales/en/index.ts +0 -6
  116. package/src/components/AuthingGuard/locales/en/login.json +0 -94
  117. package/src/components/AuthingGuard/locales/en/map.json +0 -4
  118. package/src/components/AuthingGuard/locales/en/user.json +0 -81
  119. package/src/components/AuthingGuard/locales/index.ts +0 -45
  120. package/src/components/AuthingGuard/locales/zh/common.json +0 -185
  121. package/src/components/AuthingGuard/locales/zh/index.ts +0 -6
  122. package/src/components/AuthingGuard/locales/zh/login.json +0 -94
  123. package/src/components/AuthingGuard/locales/zh/map.json +0 -4
  124. package/src/components/AuthingGuard/locales/zh/user.json +0 -81
  125. package/src/components/AuthingGuard/style.less +0 -104
  126. package/src/components/AuthingGuard/types/Forms.ts +0 -94
  127. package/src/components/AuthingGuard/types/GuardConfig.ts +0 -423
  128. package/src/components/AuthingGuard/types/GuardState.ts +0 -7
  129. package/src/components/AuthingGuard/types/Locales.ts +0 -12
  130. package/src/components/AuthingGuard/types/index.ts +0 -4
  131. package/src/components/index.ts +0 -7
  132. package/src/context/base.tsx +0 -28
  133. package/src/context/global/context.tsx +0 -39
  134. package/src/context/global/reducer.tsx +0 -56
  135. package/src/index.tsx +0 -131
  136. package/src/logo.svg +0 -7
  137. package/src/react-app-env.d.ts +0 -71
  138. package/src/reportWebVitals.ts +0 -15
  139. package/src/setupTests.ts +0 -5
  140. package/src/utils/clipboard.ts +0 -27
  141. package/src/utils/index.ts +0 -180
  142. package/src/utils/popupCenter.ts +0 -48
  143. package/tsconfig.json +0 -24
  144. package/yarn-error.log +0 -20371
@@ -1,483 +0,0 @@
1
- import { message, Spin } from 'antd'
2
- import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'
3
-
4
- import {
5
- getClassnames,
6
- insertStyles,
7
- deepMerge,
8
- removeStyles,
9
- } from '../../../utils'
10
- import { useGuardContext } from '../../../context/global/context'
11
- import { GuardHeader } from '../../../components/AuthingGuard/Header'
12
- import { MfaLayout } from '../../../components/AuthingGuard/MfaLayout'
13
- import { LoginLayout } from '../../../components/AuthingGuard/LoginLayout'
14
- import {
15
- defaultGuardConfig,
16
- HIDE_SOCIALS,
17
- } from '../../../components/AuthingGuard/constants'
18
- import { RegisterLayout } from '../../../components/AuthingGuard/RegisterLayout'
19
- import { ResetPwdLayout } from '../../../components/AuthingGuard/ResetPwdLayout'
20
- import {
21
- SessionData,
22
- trackSession,
23
- fetchAppConfig,
24
- ApplicationConfig,
25
- SocialConnectionItem,
26
- } from '../../../components/AuthingGuard/api'
27
- import {
28
- GuardMode,
29
- GuardScenes,
30
- GuardConfig,
31
- UserConfig,
32
- Lang,
33
- } from '../../../components/AuthingGuard/types'
34
-
35
- import './style.less'
36
- import { CompleteUserInfoLayout } from '../CompleteUserInfoLayout'
37
- import { AppMfaLayout } from '../AppMFALayout'
38
- import { IconFont } from '../IconFont'
39
- import { ToggleLang } from '../ToggleLang'
40
- import { useTranslation } from 'react-i18next'
41
- import i18n from 'i18next'
42
- import { changeLang } from '../locales'
43
-
44
- const checkConfig = (appId: string) => {
45
- // 不要去掉 console.warn,不然 vue 版打包出来每次都会 throw error,估计是 rollup 打包有问题
46
- if (!appId) {
47
- console.warn('APP ID: ', appId)
48
- throw new Error(i18n.t('common.unAppId'))
49
- }
50
- }
51
-
52
- const useGuardConfig = () => {
53
- const {
54
- state: { appId, userConfig },
55
- setValue,
56
- } = useGuardContext()
57
-
58
- const { t } = useTranslation()
59
-
60
- const [loading, setLoading] = useState(true)
61
-
62
- const [appConfig, setAppConfig] = useState<Partial<ApplicationConfig>>({})
63
- const [errorMsg, setErrorMsg] = useState('')
64
- const [errorDetail, setErrorDetail] = useState<any>()
65
-
66
- useEffect(() => {
67
- try {
68
- checkConfig(appId)
69
-
70
- setErrorDetail(null)
71
- setErrorMsg('')
72
- } catch (e: any) {
73
- setErrorDetail(e)
74
- setErrorMsg(e.message)
75
- console.error(e)
76
- }
77
- }, [appId])
78
-
79
- // 获取应用配置
80
- useEffect(() => {
81
- setLoading(true)
82
-
83
- if (!appId) {
84
- setLoading(false)
85
- return
86
- }
87
- fetchAppConfig(appId)
88
- .then((res) => {
89
- if (res.code !== 200) {
90
- setErrorMsg(res.message!)
91
- setErrorDetail(res)
92
- return
93
- }
94
-
95
- setAppConfig(res.data!)
96
- setValue('userPoolId', res.data?.userPoolId)
97
- })
98
- .catch((e: any) => {
99
- setErrorDetail(e)
100
- setErrorMsg(t('common.networkError'))
101
- })
102
- .finally(() => {
103
- setLoading(false)
104
- })
105
-
106
- // eslint-disable-next-line react-hooks/exhaustive-deps
107
- }, [appId])
108
-
109
- useEffect(() => {
110
- // 先移除之前的
111
- removeStyles('appConfig')
112
- removeStyles('userConfig')
113
-
114
- insertStyles(appConfig?.css, 'appConfig')
115
- insertStyles(userConfig.contentCss, 'userConfig')
116
- }, [appConfig, userConfig.contentCss])
117
-
118
- const guardConfig = useMemo<GuardConfig>(() => {
119
- /**
120
- * 将用应用配置与用户手动传入的配置合并
121
- * 优先级:用户传入 > 应用 > 用户池
122
- */
123
-
124
- // 社会化登录
125
- let socialConnectionObjs: SocialConnectionItem[] | undefined
126
- // 默认展示所有社会化登录
127
- if (!userConfig.socialConnections) {
128
- socialConnectionObjs = [...(appConfig.socialConnections || [])]
129
- } else {
130
- const socials = userConfig.socialConnections
131
- socialConnectionObjs = appConfig.socialConnections?.filter?.((item) =>
132
- socials.includes(item.provider)
133
- )
134
- }
135
-
136
- // 某些社会化登录会在 tabs 中显示,或者无法在 Guard 中使用,所以底部不显示了
137
- socialConnectionObjs = socialConnectionObjs?.filter(
138
- (item) => !HIDE_SOCIALS.includes(item.provider)
139
- )
140
-
141
- // 企业身份源
142
- let enterpriseConnectionObjs: ApplicationConfig['identityProviders']
143
-
144
- if (userConfig.enterpriseConnections) {
145
- enterpriseConnectionObjs =
146
- appConfig.identityProviders?.filter?.((item) =>
147
- userConfig.enterpriseConnections!.includes(item.identifier)
148
- ) || []
149
- } else {
150
- enterpriseConnectionObjs = appConfig.identityProviders || []
151
- }
152
-
153
- // 登录方式
154
- const loginMethods =
155
- userConfig.loginMethods ||
156
- appConfig.loginTabs?.list ||
157
- defaultGuardConfig.loginMethods
158
-
159
- // 扫码多源配置
160
- const qrcodeTabsSettings = appConfig.qrcodeTabsSettings
161
-
162
- // 账密登录的登录拆分
163
- const passwordLoginMethods =
164
- userConfig.passwordLoginMethods ||
165
- appConfig.passwordTabConfig?.enabledLoginMethods ||
166
- defaultGuardConfig.loginMethods
167
-
168
- // 默认登录方式
169
- const defaultLoginMethod =
170
- userConfig.defaultLoginMethod ||
171
- appConfig.loginTabs?.default ||
172
- defaultGuardConfig.defaultLoginMethod
173
-
174
- // 注册方式
175
- const registerMethods =
176
- userConfig.registerMethods ||
177
- appConfig.registerTabs?.list ||
178
- defaultGuardConfig.registerMethods
179
- // 默认注册方式
180
- const defaultRegisterMethod =
181
- userConfig.defaultRegisterMethod ||
182
- appConfig.registerTabs?.default ||
183
- defaultGuardConfig.defaultRegisterMethod
184
-
185
- // 应用名
186
- const title = loading
187
- ? ''
188
- : userConfig.title ?? appConfig.name ?? defaultGuardConfig.title
189
-
190
- const description = loading ? '' : appConfig.description ?? ''
191
-
192
- // 应用 logo
193
- const logo = loading
194
- ? ''
195
- : userConfig.logo ?? appConfig.logo ?? defaultGuardConfig.logo
196
-
197
- // 是否自动注册
198
- const autoRegister =
199
- userConfig.autoRegister ??
200
- appConfig.ssoPageComponentDisplay?.autoRegisterThenLoginHintInfo ??
201
- defaultGuardConfig.autoRegister
202
-
203
- // 禁止注册
204
- const disableRegister =
205
- userConfig.disableRegister ??
206
- !(
207
- appConfig.ssoPageComponentDisplay?.registerBtn ??
208
- !defaultGuardConfig.disableRegister
209
- )
210
-
211
- // 禁止重置密码
212
- const disableResetPwd =
213
- userConfig.disableResetPwd ??
214
- !(
215
- appConfig.ssoPageComponentDisplay?.registerBtn ??
216
- !defaultGuardConfig.disableResetPwd
217
- )
218
-
219
- return deepMerge<GuardConfig>(
220
- {} as GuardConfig,
221
- defaultGuardConfig,
222
- userConfig,
223
- {
224
- logo,
225
- title,
226
- description,
227
- autoRegister,
228
- loginMethods,
229
- passwordLoginMethods,
230
- extendsFields: appConfig.extendsFields,
231
- disableRegister,
232
- disableResetPwd,
233
- registerMethods,
234
- defaultLoginMethod,
235
- socialConnectionObjs,
236
- defaultRegisterMethod,
237
- enterpriseConnectionObjs,
238
- publicKey: appConfig.publicKey,
239
- qrcodeTabsSettings,
240
- agreementEnabled: appConfig.agreementEnabled,
241
- agreements: appConfig.agreements,
242
- }
243
- )
244
- }, [
245
- userConfig,
246
- appConfig.loginTabs?.list,
247
- appConfig.loginTabs?.default,
248
- appConfig.qrcodeTabsSettings,
249
- appConfig.passwordTabConfig?.enabledLoginMethods,
250
- appConfig.registerTabs?.list,
251
- appConfig.registerTabs?.default,
252
- appConfig.name,
253
- appConfig.description,
254
- appConfig.logo,
255
- appConfig.ssoPageComponentDisplay?.autoRegisterThenLoginHintInfo,
256
- appConfig.ssoPageComponentDisplay?.registerBtn,
257
- appConfig.extendsFields,
258
- appConfig.publicKey,
259
- appConfig.agreementEnabled,
260
- appConfig.agreements,
261
- appConfig.socialConnections,
262
- appConfig.identityProviders,
263
- loading,
264
- ])
265
-
266
- return {
267
- loading,
268
- errorMsg,
269
- guardConfig,
270
- errorDetail,
271
- }
272
- }
273
-
274
- const useModal = (visible?: boolean) => {
275
- const {
276
- state: { userConfig },
277
- } = useGuardContext()
278
-
279
- const isModal = userConfig.mode === GuardMode.Modal
280
- // 传入了 visible 则为受控组件
281
- const isControlled = typeof visible !== 'undefined'
282
-
283
- // modal 模式,没传 visible,默认为 true
284
- const [localVisible, setLocalVisible] = useState(
285
- isModal && isControlled ? visible : true
286
- )
287
-
288
- const toggleLocalVisible = () => {
289
- setLocalVisible((v) => !v)
290
- }
291
-
292
- const realVisible = useMemo(() => {
293
- return isControlled ? visible : localVisible
294
- }, [isControlled, localVisible, visible])
295
-
296
- return {
297
- isModal,
298
- realVisible,
299
- isControlled,
300
- toggleLocalVisible,
301
- }
302
- }
303
-
304
- export const GuardLayout: FC<{
305
- visible?: boolean
306
- className?: string
307
- id?: string
308
- style?: React.CSSProperties
309
- lang?: Lang
310
- // 这个传下是为了响应 config 变化,好蠢,以后优化
311
- userConfig: UserConfig
312
- }> = ({
313
- visible,
314
- id,
315
- className,
316
- style,
317
- lang,
318
- userConfig: reactiveUserConfig,
319
- }) => {
320
- const { t } = useTranslation()
321
- const {
322
- state: { guardScenes, authClient, guardEvents, activeTabs, localesConfig },
323
- setValue,
324
- } = useGuardContext()
325
-
326
- const { realVisible, isControlled, toggleLocalVisible } = useModal(visible)
327
-
328
- const { loading, errorMsg, guardConfig, errorDetail } = useGuardConfig()
329
-
330
- useEffect(() => {
331
- if (lang) {
332
- authClient.setLang(lang)
333
- changeLang(lang)
334
- }
335
- }, [authClient, lang])
336
-
337
- useEffect(() => {
338
- if (!loading) {
339
- guardEvents.onLoginTabChange?.(activeTabs.login)
340
- }
341
- }, [activeTabs.login, loading, guardEvents])
342
-
343
- useEffect(() => {
344
- if (!loading) {
345
- guardEvents.onRegisterTabChange?.(activeTabs.register)
346
- }
347
- }, [activeTabs.register, loading, guardEvents])
348
-
349
- useEffect(() => {
350
- setValue('userConfig', reactiveUserConfig)
351
- }, [reactiveUserConfig, setValue])
352
-
353
- // 动画完成后完全隐藏 dom
354
- const [hidden, setHidden] = useState(false)
355
- useEffect(() => {
356
- setHidden(false)
357
- }, [realVisible])
358
-
359
- const closeHandler = useCallback(() => {
360
- if (!isControlled && realVisible) {
361
- toggleLocalVisible()
362
- }
363
- guardEvents.onClose?.()
364
- }, [isControlled, guardEvents, toggleLocalVisible, realVisible])
365
-
366
- useEffect(() => {
367
- if (loading) {
368
- return
369
- }
370
- if (errorDetail) {
371
- guardEvents.onLoadError?.(errorDetail)
372
- return
373
- }
374
-
375
- guardEvents.onLoad?.(authClient)
376
- }, [authClient, errorDetail, guardEvents, loading, t])
377
-
378
- useEffect(() => {
379
- if (guardConfig.isSSO) {
380
- trackSession().then((sessionData) => {
381
- // 这个接口没有 code, data, 直接返回了数据
382
- let typedData = (sessionData as unknown) as SessionData
383
- if (typedData.userInfo) {
384
- message.success(t('common.LoginSuccess'))
385
- guardEvents.onLogin?.(typedData.userInfo, authClient)
386
- }
387
- })
388
- }
389
- }, [guardConfig.isSSO, guardEvents, authClient, t])
390
-
391
- useEffect(() => {
392
- setValue('config', guardConfig)
393
- setValue('activeTabs', {
394
- [GuardScenes.Login]: guardConfig.defaultLoginMethod,
395
- [GuardScenes.Register]: guardConfig.defaultRegisterMethod,
396
- })
397
- // eslint-disable-next-line react-hooks/exhaustive-deps
398
- }, [guardConfig])
399
-
400
- const isModal = useMemo(() => guardConfig.mode === GuardMode.Modal, [
401
- guardConfig,
402
- ])
403
-
404
- // 监听 esc 关闭 modal
405
- useEffect(() => {
406
- const handler = (evt: KeyboardEvent) => {
407
- if (evt.keyCode === 27 && isModal && guardConfig.escCloseable) {
408
- closeHandler()
409
- }
410
- }
411
-
412
- window.addEventListener('keydown', handler)
413
- return () => window.removeEventListener('keydown', handler)
414
- }, [closeHandler, guardConfig, isModal])
415
-
416
- const layoutMap = {
417
- [GuardScenes.Login]: <LoginLayout />,
418
- [GuardScenes.Register]: <RegisterLayout />,
419
- [GuardScenes.RestPassword]: <ResetPwdLayout />,
420
- [GuardScenes.MfaVerify]: <MfaLayout />,
421
- [GuardScenes.CompleteUserInfo]: <CompleteUserInfoLayout />,
422
- [GuardScenes.AppMfaVerify]: <AppMfaLayout />,
423
- }
424
-
425
- return (
426
- <div
427
- id={id}
428
- style={{
429
- ...style,
430
- zIndex: guardConfig.zIndex || 100,
431
- }}
432
- className={getClassnames([
433
- 'authing-guard-layout',
434
- !realVisible && 'authing-guard-layout__hidden',
435
- isModal && 'authing-guard-layout__modal',
436
- hidden && 'authing-guard-layout__dis-none',
437
- className,
438
- ])}
439
- onTransitionEnd={() => {
440
- if (!realVisible) {
441
- setHidden(true)
442
- }
443
- }}
444
- >
445
- <>
446
- {isModal && (
447
- <div
448
- className={getClassnames([
449
- 'authing-guard-mask',
450
- !realVisible && 'authing-guard-mask__hidden',
451
- ])}
452
- ></div>
453
- )}
454
- <div
455
- className={getClassnames([
456
- 'authing-guard-container',
457
- !realVisible && 'authing-guard-container__hidden',
458
- ])}
459
- >
460
- {isModal && guardConfig.clickCloseable && (
461
- <button onClick={closeHandler} className="authing-guard-close-btn">
462
- <IconFont type="authing-guanbi" />
463
- </button>
464
- )}
465
-
466
- <GuardHeader />
467
-
468
- {loading ? (
469
- <Spin size="large" className="authing-guard-loading" />
470
- ) : errorMsg ? (
471
- <div className="authing-guard-load-error">{errorMsg}</div>
472
- ) : (
473
- layoutMap[guardScenes]
474
- )}
475
- {/* <div>{localesConfig?.isShowChange && <ToggleLang />}</div> */}
476
- <div>
477
- {localesConfig?.isShowChange === false ? null : <ToggleLang />}
478
- </div>
479
- </div>
480
- </>
481
- </div>
482
- )
483
- }
@@ -1,111 +0,0 @@
1
- .authing-guard-layout {
2
- display: flex;
3
- justify-content: center;
4
- align-items: center;
5
- width: 100%;
6
- padding: 24px 0;
7
- height: 100%;
8
- }
9
-
10
- .authing-guard-layout__hidden {
11
- pointer-events: none;
12
- }
13
-
14
- .authing-guard-layout__dis-none {
15
- z-index: -1;
16
- opacity: 0;
17
- }
18
-
19
- .authing-guard-layout__modal {
20
- position: fixed;
21
- left: 0;
22
- top: 0;
23
- }
24
-
25
- .authing-guard-mask {
26
- position: absolute;
27
- left: 0;
28
- right: 0;
29
- top: 0;
30
- bottom: 0;
31
- background-color: rgba(0, 0, 0, 0.45);
32
- opacity: 1;
33
- transition: all 0.3s;
34
- }
35
-
36
- .authing-guard-mask__hidden {
37
- opacity: 0;
38
- }
39
-
40
- .authing-guard-container {
41
- width: 440px;
42
- min-height: 610px;
43
- max-height: 100%;
44
- box-sizing: border-box;
45
- background-color: #fff;
46
- padding: 39px 38px 31px;
47
- border-radius: 10px;
48
- display: flex;
49
- flex-direction: column;
50
- box-shadow: 0 2px 10px 0 rgba(57, 106, 255, 0.2);
51
- margin-left: auto;
52
- margin-right: auto;
53
- overflow: auto;
54
- position: relative;
55
- transform: translateY(0);
56
- transition: all 0.3s;
57
- }
58
-
59
- .authing-guard-container__hidden {
60
- transform: translateY(2000px);
61
- }
62
-
63
- .authing-guard-loading,
64
- .authing-guard-load-error {
65
- flex: 1;
66
- display: flex;
67
- align-items: center;
68
- justify-content: center;
69
- }
70
-
71
- .authing-guard-close-btn {
72
- position: absolute;
73
- right: 12px;
74
- top: 12px;
75
- border: none;
76
- outline: none;
77
- box-shadow: none;
78
- background-color: #fff;
79
- border-radius: 50%;
80
- width: 30px;
81
- height: 30px;
82
- text-align: center;
83
- line-height: 20px;
84
- cursor: pointer;
85
- &:focus {
86
- outline: none;
87
- border: none;
88
- box-shadow: none;
89
- }
90
- &:hover {
91
- color: #396aff;
92
- }
93
- }
94
-
95
- @media only screen and (max-width: 719px) {
96
- .authing-guard-layout {
97
- padding: 0;
98
- }
99
- .authing-guard-container {
100
- width: 100%;
101
- min-height: 100%;
102
- border: none;
103
- border-radius: initial;
104
- box-shadow: initial;
105
- padding-left: 24px;
106
- padding-right: 24px;
107
- }
108
- .authing-ant-input {
109
- font-size: 14px;
110
- }
111
- }
@@ -1,28 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { Avatar } from 'antd'
3
-
4
- import { useGuardContext } from '../../../context/global/context'
5
-
6
- import './style.less'
7
-
8
- export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
9
-
10
- export const GuardHeader: FC<HeaderProps> = (props) => {
11
- const {
12
- state: {
13
- config: { logo, title, description },
14
- },
15
- } = useGuardContext()
16
-
17
- return (
18
- <div className="authing-guard-header">
19
- {Boolean(logo) && (
20
- <Avatar className="authing-guard-logo" src={logo} size={50}></Avatar>
21
- )}
22
- <div className="authing-guard-title-container">
23
- <div className="authing-guard-title">{title}</div>
24
- <div className="authing-guard-description">{description}</div>
25
- </div>
26
- </div>
27
- )
28
- }
@@ -1,64 +0,0 @@
1
- .authing-guard-header {
2
- display: flex;
3
- flex-direction: column;
4
- justify-content: center;
5
- align-items: center;
6
- }
7
-
8
- .authing-guard-logo {
9
- margin-bottom: 8px;
10
- }
11
-
12
- .authing-guard-logo img {
13
- object-fit: contain;
14
- }
15
-
16
- .authing-guard-title-container {
17
- display: flex;
18
- justify-content: center;
19
- flex-direction: column;
20
- align-items: center;
21
- }
22
-
23
- .authing-guard-title {
24
- color: #282d3c;
25
- font-size: 24px;
26
- margin-bottom: 4px;
27
- width: 100%;
28
- word-break: break-all;
29
- text-align: center;
30
- }
31
- .authing-guard-description {
32
- font-size: 16px;
33
- color: #878a95;
34
- margin-bottom: 23px;
35
- }
36
-
37
- @media only screen and (max-width: 719px) {
38
- .authing-guard-header {
39
- align-items: flex-start;
40
- flex-direction: row;
41
- align-items: center;
42
- justify-content: flex-start;
43
- padding-top: 40px;
44
- padding-bottom: 48px;
45
- }
46
- .authing-guard-title {
47
- margin-bottom: 0;
48
- padding-left: 8px;
49
- color: #333333;
50
- font-weight: 500;
51
- text-align: unset;
52
- }
53
- .authing-guard-logo {
54
- margin: 0;
55
- }
56
- .authing-guard-title-container {
57
- flex-direction: column;
58
- align-items: flex-start;
59
- }
60
- .authing-guard-description {
61
- margin-bottom: 0px;
62
- padding-left: 8px;
63
- }
64
- }