@@ -72,7 +83,7 @@ export const LoginView: React.FC = React.memo(() => {
/>
-
密码
+
{t('密码')}
{
onClick={handleLogin}
>
{loading &&
}
- 登录
+ {t('登录')}
diff --git a/web/src/routes/Entry/RegisterView.tsx b/web/src/routes/Entry/RegisterView.tsx
index 9e7596da..c74e5807 100644
--- a/web/src/routes/Entry/RegisterView.tsx
+++ b/web/src/routes/Entry/RegisterView.tsx
@@ -1,4 +1,4 @@
-import { registerWithEmail, useAsyncFn } from 'tailchat-shared';
+import { isValidStr, registerWithEmail, t, useAsyncFn } from 'tailchat-shared';
import React, { useCallback, useState } from 'react';
import { Spinner } from '../../components/Spinner';
import { string } from 'yup';
@@ -7,7 +7,6 @@ import { useHistory } from 'react-router';
import { setUserJWT } from '../../utils/jwt-helper';
import { setGlobalUserLoginInfo } from '../../utils/user-helper';
import { useSearchParam } from '@/hooks/useSearchParam';
-import { isValidStr } from '../../../../shared/utils/string-helper';
/**
* 注册视图
@@ -20,13 +19,13 @@ export const RegisterView: React.FC = React.memo(() => {
const [{ loading, error }, handleRegister] = useAsyncFn(async () => {
await string()
- .email('邮箱格式不正确')
- .required('邮箱不能为空')
+ .email(t('邮箱格式不正确'))
+ .required(t('邮箱不能为空'))
.validate(email);
await string()
- .min(6, '密码不能低于6位')
- .required('密码不能为空')
+ .min(6, t('密码不能低于6位'))
+ .required(t('密码不能为空'))
.validate(password);
const data = await registerWithEmail(email, password);
@@ -42,16 +41,20 @@ export const RegisterView: React.FC = React.memo(() => {
}, [email, password, navRedirect]);
const toLoginView = useCallback(() => {
- history.push('/entry/login');
+ // 携带上下文切换路由
+ history.push({
+ ...history.location,
+ pathname: '/entry/login',
+ });
}, [history]);
return (
-
注册账号
+
{t('注册账号')}
-
密码
+
{t('密码')}
{
onClick={handleRegister}
>
{loading &&
}
- 注册账号
+ {t('注册账号')}