@liujitcn/kratos-taro-app-core 0.0.21 → 0.0.23

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.
@@ -1,4 +1,5 @@
1
1
  .login-page {
2
+ position: relative;
2
3
  display: flex;
3
4
  flex-direction: column;
4
5
  justify-content: center;
@@ -8,6 +9,19 @@
8
9
  box-sizing: border-box;
9
10
  }
10
11
 
12
+ .login-locale {
13
+ position: absolute;
14
+ top: calc(24px + env(safe-area-inset-top));
15
+ right: 28px;
16
+ z-index: 2;
17
+ }
18
+
19
+ .login-locale__value {
20
+ padding: 12px 16px;
21
+ color: #16806d;
22
+ font-size: 24px;
23
+ }
24
+
11
25
  .login-hero {
12
26
  margin-bottom: 40px;
13
27
  text-align: center;
@@ -255,12 +269,17 @@
255
269
  .login-agreement {
256
270
  display: flex;
257
271
  align-items: center;
272
+ flex-wrap: wrap;
258
273
  justify-content: center;
274
+ width: 100%;
275
+ max-width: 100%;
276
+ min-width: 0;
259
277
  gap: 6px;
260
- white-space: nowrap;
278
+ box-sizing: border-box;
261
279
  }
262
280
 
263
281
  .login-agree-icon {
282
+ flex: 0 0 auto;
264
283
  width: 26px;
265
284
  height: 26px;
266
285
  margin-right: 2px;
@@ -277,13 +296,15 @@
277
296
  }
278
297
 
279
298
  .login-agree-link {
299
+ min-width: 0;
280
300
  color: #28bb9c;
281
- white-space: nowrap;
301
+ overflow-wrap: anywhere;
282
302
  }
283
303
 
284
304
  .login-agree-desc,
285
305
  .login-agree-separator {
286
- white-space: nowrap;
306
+ min-width: 0;
307
+ overflow-wrap: anywhere;
287
308
  }
288
309
 
289
310
  .login-agree-desc {
@@ -66,7 +66,7 @@ async function resolveMiniCaptchaImage(payload: string, captchaId: string): Prom
66
66
  data: payload.slice(commaIndex + 1),
67
67
  encoding: 'base64',
68
68
  success: () => resolve(),
69
- fail: () => reject(new Error(translate('core.login.captchaWriteFailed'))),
69
+ fail: () => reject(new Error(translate('core.login.captcha_write_failed'))),
70
70
  })
71
71
  })
72
72
  return filePath
@@ -97,8 +97,9 @@ export default function LoginPage() {
97
97
  const [miniForm, setMiniForm] = useState(emptyLoginForm)
98
98
  const [miniPassword, setMiniPassword] = useState('')
99
99
 
100
- const mainTitle = settings?.get('mainTitle') || t('core.home.mainTitle')
101
- const subTitle = settings?.get('subTitle') || t('core.login.defaultSubTitle')
100
+ const currentLanguageName = languageOptions.find((item) => item.language_code === locale)?.native_name || locale
101
+ const mainTitle = settings?.get('mainTitle') || t('core.home.main_title')
102
+ const subTitle = settings?.get('subTitle') || t('core.login.default_sub_title')
102
103
  const appLogo = settings?.get('appLogo') || defaultLogo
103
104
  const showTenantCode = settings?.get('showTenantCode') !== 'false'
104
105
  const configuredCaptchaType = settings?.get('captchaType') || ''
@@ -118,7 +119,7 @@ export default function LoginPage() {
118
119
  verticalPadding: 0,
119
120
  horizontalPadding: 0,
120
121
  iconSize: 20,
121
- title: t('core.login.behaviorRotate'),
122
+ title: t('core.login.behavior_rotate'),
122
123
  }
123
124
  }
124
125
  return {
@@ -132,7 +133,7 @@ export default function LoginPage() {
132
133
  buttonText: t('common.action.confirm'),
133
134
  iconSize: 20,
134
135
  dotSize: 20,
135
- title: captchaType === 'click' ? t('core.login.behaviorClick') : t('core.login.behaviorPuzzle'),
136
+ title: captchaType === 'click' ? t('core.login.behavior_click') : t('core.login.behavior_puzzle'),
136
137
  }
137
138
  }, [
138
139
  behaviorData.thumbHeight,
@@ -155,9 +156,9 @@ export default function LoginPage() {
155
156
  }
156
157
 
157
158
  const refreshCaptcha = async (requestedType = captchaType || configuredCaptchaType) => {
158
- if (!requestedType) throw new Error(t('core.login.captchaTypeMissing'))
159
+ if (!requestedType) throw new Error(t('core.login.captcha_type_missing'))
159
160
  const data = await defLoginService.Captcha({ type: requestedType })
160
- if (!data.type) throw new Error(t('core.login.captchaTypeResponseMissing'))
161
+ if (!data.type) throw new Error(t('core.login.captcha_type_response_missing'))
161
162
  setCaptchaType(data.type)
162
163
  setForm((current) => ({ ...current, captcha_id: data.captcha_id, captcha_code: '' }))
163
164
  if (!behaviorCaptchaTypes.has(data.type)) {
@@ -200,7 +201,7 @@ export default function LoginPage() {
200
201
  captcha_code: '',
201
202
  }))
202
203
  } catch {
203
- await Taro.showToast({ icon: 'none', title: t('core.login.captchaLoadFailed') })
204
+ await Taro.showToast({ icon: 'none', title: t('core.login.captcha_load_failed') })
204
205
  }
205
206
  }
206
207
 
@@ -212,7 +213,7 @@ export default function LoginPage() {
212
213
  await loadSettings()
213
214
  const nextCaptchaType = useSettingStore.getState().getData('captchaType')
214
215
  if (process.env.TARO_ENV === 'h5') {
215
- if (!nextCaptchaType) throw new Error(t('core.login.captchaTypeMissing'))
216
+ if (!nextCaptchaType) throw new Error(t('core.login.captcha_type_missing'))
216
217
  setCaptchaType(nextCaptchaType)
217
218
  if (!behaviorCaptchaTypes.has(nextCaptchaType)) await refreshCaptcha(nextCaptchaType)
218
219
  } else {
@@ -223,7 +224,7 @@ export default function LoginPage() {
223
224
  } catch (error) {
224
225
  await Taro.showToast({
225
226
  icon: 'none',
226
- title: error instanceof Error ? error.message : t('core.protocol.loadFailed'),
227
+ title: error instanceof Error ? error.message : t('core.protocol.load_failed'),
227
228
  })
228
229
  settingsPromise.current = undefined
229
230
  return false
@@ -240,7 +241,7 @@ export default function LoginPage() {
240
241
  if (!(await loadLoginSettings())) return false
241
242
  const currentSettings = useSettingStore.getState()
242
243
  if (!currentSettings.getData('serviceProtocol') || !currentSettings.getData('privacyProtocol')) {
243
- await Taro.showToast({ icon: 'none', title: t('core.login.protocolMissing') })
244
+ await Taro.showToast({ icon: 'none', title: t('core.login.protocol_missing') })
244
245
  return false
245
246
  }
246
247
  if (agreed) return true
@@ -248,7 +249,7 @@ export default function LoginPage() {
248
249
  setTimeout(() => setShake(false), 500)
249
250
  const result = await Taro.showModal({
250
251
  title: t('common.title.notice'),
251
- content: t('core.login.protocolPrompt'),
252
+ content: t('core.login.protocol_prompt'),
252
253
  confirmText: t('common.action.confirm'),
253
254
  cancelText: t('common.action.cancel'),
254
255
  })
@@ -259,7 +260,7 @@ export default function LoginPage() {
259
260
  /** 完成用户资料加载并恢复登录前页面。 */
260
261
  const loginSuccess = async () => {
261
262
  await userStore.getUserProfile()
262
- await Taro.showToast({ icon: 'success', title: t('core.login.loginSuccess') })
263
+ await Taro.showToast({ icon: 'success', title: t('core.login.login_success') })
263
264
  await new Promise<void>((resolve) => setTimeout(resolve, 500))
264
265
  await restoreLoginRedirect()
265
266
  }
@@ -268,7 +269,7 @@ export default function LoginPage() {
268
269
  if (!(await loadLoginSettings())) return false
269
270
  const validations: Array<[boolean, string]> = [
270
271
  [!showTenantCode || Boolean(form.tenant_code), t('core.login.tenant')],
271
- [Boolean(form.user_name), t('core.login.userName')],
272
+ [Boolean(form.user_name), t('core.login.user_name')],
272
273
  [Boolean(password), t('core.login.password')],
273
274
  [isBehaviorCaptcha || Boolean(form.captcha_code), t('core.login.captcha')],
274
275
  ]
@@ -281,7 +282,7 @@ export default function LoginPage() {
281
282
  }
282
283
 
283
284
  const submitLogin = async (captchaCode: string) => {
284
- const encrypted = await encryptPassword(password, PASSWORD_CRYPTO_SCENE.LOGIN)
285
+ const encrypted = await encryptPassword(password, PASSWORD_CRYPTO_SCENE.PASSWORD_CRYPTO_SCENE_LOGIN)
285
286
  await userStore.login({
286
287
  ...form,
287
288
  tenant_code: showTenantCode ? form.tenant_code : '0000',
@@ -309,7 +310,7 @@ export default function LoginPage() {
309
310
  } catch (error) {
310
311
  await refreshCaptcha().catch(() => undefined)
311
312
  if (error instanceof Error) {
312
- await Taro.showToast({ icon: 'none', title: error.message || t('core.login.loginFailed') })
313
+ await Taro.showToast({ icon: 'none', title: error.message || t('core.login.login_failed') })
313
314
  }
314
315
  } finally {
315
316
  setLoading(false)
@@ -370,7 +371,7 @@ export default function LoginPage() {
370
371
  setMiniBinding(true)
371
372
  await refreshMiniCaptcha()
372
373
  } else {
373
- await Taro.showToast({ icon: 'none', title: t('core.login.wechatFailed') })
374
+ await Taro.showToast({ icon: 'none', title: t('core.login.wechat_failed') })
374
375
  }
375
376
  } finally {
376
377
  setLoading(false)
@@ -381,7 +382,7 @@ export default function LoginPage() {
381
382
  if (loading || !(await checkedAgreePrivacy())) return
382
383
  const failed = [
383
384
  [showTenantCode && !miniForm.tenant_code, t('core.login.tenant')],
384
- [!miniForm.user_name || !miniPassword, t('core.login.userNamePassword')],
385
+ [!miniForm.user_name || !miniPassword, t('core.login.user_name_password')],
385
386
  [!miniForm.captcha_id || !miniForm.captcha_code, t('core.login.captcha')],
386
387
  ].find(([invalid]) => invalid)
387
388
  if (failed) {
@@ -390,7 +391,7 @@ export default function LoginPage() {
390
391
  }
391
392
  setLoading(true)
392
393
  try {
393
- const encrypted = await encryptPassword(miniPassword, PASSWORD_CRYPTO_SCENE.LOGIN)
394
+ const encrypted = await encryptPassword(miniPassword, PASSWORD_CRYPTO_SCENE.PASSWORD_CRYPTO_SCENE_LOGIN)
394
395
  const code = (await Taro.login()).code
395
396
  await userStore.bindOauthSession({
396
397
  provider: wechatMiniProvider,
@@ -414,7 +415,7 @@ export default function LoginPage() {
414
415
  <View className={`login-tips${shake ? ' login-tips--shake' : ''}`}>
415
416
  <View className='login-agreement' onClick={() => setAgreed((value) => !value)}>
416
417
  <View className={`login-agree-icon${agreed ? ' checked' : ''}`} />
417
- <Text className='login-agree-desc'>{t('core.login.agreePrefix')}</Text>
418
+ <Text className='login-agree-desc'>{t('core.login.agree_prefix')}</Text>
418
419
  <Text
419
420
  className='login-agree-link'
420
421
  onClick={(event) => {
@@ -424,7 +425,7 @@ export default function LoginPage() {
424
425
  >
425
426
  {t('core.login.service')}
426
427
  </Text>
427
- <Text className='login-agree-separator'>{t('core.login.agreeSeparator')}</Text>
428
+ <Text className='login-agree-separator'>{t('core.login.agree_separator')}</Text>
428
429
  <Text
429
430
  className='login-agree-link'
430
431
  onClick={(event) => {
@@ -443,14 +444,14 @@ export default function LoginPage() {
443
444
  <Picker
444
445
  className='login-locale'
445
446
  mode='selector'
446
- range={languageOptions.map((item) => item.language_name)}
447
+ range={languageOptions.map((item) => item.native_name)}
447
448
  value={Math.max(0, languageOptions.findIndex((item) => item.language_code === locale))}
448
449
  onChange={(event) => {
449
450
  const nextLocale = languageOptions[Number(event.detail.value)]?.language_code as SupportedLocale | undefined
450
451
  if (nextLocale) void setLocale(nextLocale)
451
452
  }}
452
453
  >
453
- <View className='login-locale__value'>{t(`common.language.${locale}`)}</View>
454
+ <View className='login-locale__value'>{currentLanguageName}</View>
454
455
  </Picker>
455
456
  <View className='login-hero'>
456
457
  <View className='login-logo-shell'>
@@ -467,7 +468,7 @@ export default function LoginPage() {
467
468
  {showTenantCode ? (
468
469
  <Input className='login-input' placeholder={t('core.login.tenant')} value={form.tenant_code} onInput={(event) => updateForm('tenant_code', event.detail.value)} />
469
470
  ) : null}
470
- <Input className='login-input' placeholder={t('core.login.userNameMobile')} value={form.user_name} onInput={(event) => updateForm('user_name', event.detail.value)} />
471
+ <Input className='login-input' placeholder={t('core.login.user_name_mobile')} value={form.user_name} onInput={(event) => updateForm('user_name', event.detail.value)} />
471
472
  <Input className='login-input' password placeholder={t('core.login.password')} value={password} onInput={(event) => setPassword(event.detail.value)} onConfirm={() => void onSubmit()} />
472
473
  {!isBehaviorCaptcha ? (
473
474
  <View className='captcha-row'>
@@ -482,7 +483,7 @@ export default function LoginPage() {
482
483
  {behaviorVisible ? (
483
484
  <View className='login-behavior-mask'>
484
485
  <View className='login-behavior-panel'>
485
- {behaviorLoading ? <View className='login-behavior-loading'>{t('core.login.behaviorLoading')}</View> : null}
486
+ {behaviorLoading ? <View className='login-behavior-loading'>{t('core.login.behavior_loading')}</View> : null}
486
487
  <BehaviorCaptcha type={captchaType} data={behaviorData} config={behaviorConfig} onConfirm={(value, reset) => void verifyBehaviorCaptcha(value, reset)} onRefresh={() => void refreshCaptcha()} onClose={() => setBehaviorVisible(false)} />
487
488
  </View>
488
489
  </View>
@@ -494,16 +495,16 @@ export default function LoginPage() {
494
495
  </Button>
495
496
  ) : (
496
497
  <View className='login-form'>
497
- <View className='login-bind-tip'>{t('core.login.wechatBindTip')}</View>
498
+ <View className='login-bind-tip'>{t('core.login.wechat_bind_tip')}</View>
498
499
  {showTenantCode ? <Input className='login-input' placeholder={t('core.login.tenant')} value={miniForm.tenant_code} onInput={(event) => updateMiniForm('tenant_code', event.detail.value)} /> : null}
499
- <Input className='login-input' placeholder={t('core.login.userNameMobile')} value={miniForm.user_name} onInput={(event) => updateMiniForm('user_name', event.detail.value)} />
500
+ <Input className='login-input' placeholder={t('core.login.user_name_mobile')} value={miniForm.user_name} onInput={(event) => updateMiniForm('user_name', event.detail.value)} />
500
501
  <Input className='login-input' password placeholder={t('core.login.password')} value={miniPassword} onInput={(event) => setMiniPassword(event.detail.value)} />
501
502
  <View className='captcha-row'>
502
503
  <Input className='login-input captcha-input' placeholder={t('core.login.captcha')} value={miniForm.captcha_code} onInput={(event) => updateMiniForm('captcha_code', event.detail.value)} />
503
504
  <View className='captcha-divider' />
504
505
  <View className='captcha-trigger' onClick={() => void refreshMiniCaptcha()}><Image className='captcha-image' src={miniCaptchaImage} mode='aspectFit' /></View>
505
506
  </View>
506
- <Button className='login-button login-button-primary' loading={loading} onClick={() => void bindMiniAccount()}>{t('core.login.bindWechat')}</Button>
507
+ <Button className='login-button login-button-primary' loading={loading} onClick={() => void bindMiniAccount()}>{t('core.login.bind_wechat')}</Button>
507
508
  </View>
508
509
  )}
509
510
  {agreement}
@@ -52,14 +52,14 @@ export default function ProtocolPage() {
52
52
  .loadData()
53
53
  .then(() => {
54
54
  const protocol = settingStore.getData(key)
55
- if (!protocol) throw new Error(t('core.protocol.notConfigured', { title }))
55
+ if (!protocol) throw new Error(t('core.protocol.not_configured', { title }))
56
56
  void Taro.setNavigationBarTitle({ title })
57
57
  setContent(decorateProtocolContent(protocol))
58
58
  })
59
59
  .catch(async (error: unknown) => {
60
60
  await Taro.showToast({
61
61
  icon: 'none',
62
- title: error instanceof Error ? error.message : t('core.protocol.loadFailed'),
62
+ title: error instanceof Error ? error.message : t('core.protocol.load_failed'),
63
63
  })
64
64
  setTimeout(() => void Taro.navigateBack(), 300)
65
65
  })
@@ -29,8 +29,8 @@ export default function WebViewPage() {
29
29
 
30
30
  const showFallback = !url || (isH5 && iframeTimedOut && !iframeLoaded)
31
31
  const emptyDescription = url
32
- ? t('core.webview.embedBlocked')
33
- : t('core.webview.invalidUrl')
32
+ ? t('core.webview.embed_blocked')
33
+ : t('core.webview.invalid_url')
34
34
 
35
35
  return (
36
36
  <View className='webview-container'>
@@ -43,7 +43,7 @@ export default function WebViewPage() {
43
43
  ) : null}
44
44
  {showFallback ? (
45
45
  <View className='webview-empty'>
46
- <Text className='webview-empty__title'>{t('core.webview.openFailed')}</Text>
46
+ <Text className='webview-empty__title'>{t('core.webview.open_failed')}</Text>
47
47
  <Text className='webview-empty__desc'>{emptyDescription}</Text>
48
48
  </View>
49
49
  ) : null}
@@ -52,7 +52,7 @@ export default function WebViewPage() {
52
52
  className='webview-open-button'
53
53
  onClick={() => window.open(url, '_blank', 'noopener,noreferrer')}
54
54
  >
55
- {t('common.action.openInNewWindow')}
55
+ {t('common.action.open_in_new_window')}
56
56
  </Button>
57
57
  ) : null}
58
58
  </View>
@@ -1,54 +0,0 @@
1
- // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
- // versions:
3
- // protoc-gen-ts_proto v2.11.8
4
- // protoc unknown
5
- // source: base/v1/enum.proto
6
-
7
- /* eslint-disable */
8
-
9
- /** AI 助手消息状态 */
10
- export enum AiMessageStatus {
11
- /** UNKNOWN_AMS - 未知AI助手消息状态 */
12
- UNKNOWN_AMS = 0,
13
- /** GENERATING_AMS - 生成中 */
14
- GENERATING_AMS = 1,
15
- /** SUCCESS_AMS - 成功 */
16
- SUCCESS_AMS = 2,
17
- /** FAILED_AMS - 失败 */
18
- FAILED_AMS = 3,
19
- }
20
-
21
- /** 终端类型 */
22
- export enum Terminal {
23
- /** UNKNOWN_TERMINAL - 未知终端 */
24
- UNKNOWN_TERMINAL = 0,
25
- /** TERMINAL_APP - 移动端 */
26
- TERMINAL_APP = 1,
27
- /** TERMINAL_ADMIN - 管理端 */
28
- TERMINAL_ADMIN = 2,
29
- }
30
-
31
- /** 系统配置位置 */
32
- export enum BaseConfigSite {
33
- UNKNOWN_BCS = 0,
34
- /** SYSTEM - 系统内使用 */
35
- SYSTEM = 1,
36
- /** ADMIN - 管理端 */
37
- ADMIN = 2,
38
- /** APP - 移动端 */
39
- APP = 3,
40
- }
41
-
42
- /** 密码加密场景枚举 */
43
- export enum PasswordCryptoScene {
44
- /** UNKNOWN_PCS - 未指定密码加密场景 */
45
- UNKNOWN_PCS = 0,
46
- /** LOGIN - 登录密码加密场景 */
47
- LOGIN = 1,
48
- /** CREATE_BASE_USER - 新增后台用户密码加密场景 */
49
- CREATE_BASE_USER = 2,
50
- /** RESET_BASE_USER_PASSWORD - 重置后台用户密码加密场景 */
51
- RESET_BASE_USER_PASSWORD = 3,
52
- /** UPDATE_USER_PASSWORD - 个人修改密码加密场景 */
53
- UPDATE_USER_PASSWORD = 4,
54
- }
@@ -1,80 +0,0 @@
1
- // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
- // versions:
3
- // protoc-gen-ts_proto v2.11.8
4
- // protoc unknown
5
- // source: system/common/v1/enum.proto
6
-
7
- /* eslint-disable */
8
-
9
- /** 系统配置类型 */
10
- export enum BaseConfigType {
11
- UNKNOWN_BCT = 0,
12
- /** TEXT - 文本 */
13
- TEXT = 1,
14
- /** IMAGE - 图片 */
15
- IMAGE = 2,
16
- /** RICH_TEXT - 富文本 */
17
- RICH_TEXT = 3,
18
- /** DICT - 字典 */
19
- DICT = 4,
20
- /** BOOLEAN - 布尔 */
21
- BOOLEAN = 5,
22
- }
23
-
24
- /** 定时任务日志状态 */
25
- export enum BaseJobLogStatus {
26
- UNKNOWN_BJLS = 0,
27
- /** SUCCESS - 成功 */
28
- SUCCESS = 1,
29
- /** FAIL - 失败 */
30
- FAIL = 2,
31
- }
32
-
33
- /** 菜单类型 */
34
- export enum BaseMenuType {
35
- UNKNOWN_MT = 0,
36
- /** FOLDER - 目录 */
37
- FOLDER = 1,
38
- /** MENU - 菜单 */
39
- MENU = 2,
40
- /** BUTTON - 按钮 */
41
- BUTTON = 3,
42
- /** EXT_LINK - 外部链接 */
43
- EXT_LINK = 4,
44
- }
45
-
46
- /** 角色数据范围 */
47
- export enum BaseRoleDataScope {
48
- UNKNOWN_RDS = 0,
49
- /** ALL - 全部数据 */
50
- ALL = 1,
51
- /** DEPT_AND_CHILDREN - 部门及子部门数据 */
52
- DEPT_AND_CHILDREN = 2,
53
- /** SELF_DEPT - 本部门数据 */
54
- SELF_DEPT = 3,
55
- /** SELF_USER - 本人数据 */
56
- SELF_USER = 4,
57
- }
58
-
59
- /** 用户性别 */
60
- export enum BaseUserGender {
61
- UNKNOWN_BUG = 0,
62
- /** SECRET - 保密 */
63
- SECRET = 1,
64
- /** BOY - 男 */
65
- BOY = 2,
66
- /** GIRL - 禁用 */
67
- GIRL = 3,
68
- }
69
-
70
- /** 代码生成表状态 */
71
- export enum CodeGenTableStatus {
72
- /** UNKNOWN_CGTS - 未指定 */
73
- UNKNOWN_CGTS = 0,
74
- /** DRAFT_CGTS - 草稿 */
75
- DRAFT_CGTS = 1,
76
- /** GENERATED_CGTS - 已生成 */
77
- GENERATED_CGTS = 2,
78
- /** DISABLED_CGTS - 停用 */
79
- DISABLED_CGTS = 3,
80
- }