feat: 优化

This commit is contained in:
jinyaqiu 2025-08-01 10:49:16 +08:00
parent 935753f6b3
commit d728ea05c0
8 changed files with 44 additions and 20 deletions

2
.env
View File

@ -1 +1 @@
API_ENDPOINT=http://192.168.31.16:31646/api
API_ENDPOINT=https://api.memorywake.com/api

View File

@ -136,6 +136,7 @@ const LoginScreen = () => {
setShowPassword={setShowPassword}
showPassword={showPassword}
/>
// <PhoneLogin />
)
};

View File

@ -7,10 +7,10 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
// 懒加载组件
import ChatSvg from '@/assets/icons/svg/chat.svg';
import AskNavbar from '@/components/layout/ask';
import UploaderProgress from '@/components/file-upload/upload-progress/uploader-progress';
import SkeletonItem from '@/components/memo/SkeletonItem';
import ErrorBoundary from '@/components/common/ErrorBoundary';
import UploaderProgress from '@/components/file-upload/upload-progress/uploader-progress';
import AskNavbar from '@/components/layout/ask';
import SkeletonItem from '@/components/memo/SkeletonItem';
// 类型定义
import { useUploadManager } from '@/hooks/useUploadManager';
@ -259,6 +259,7 @@ const MemoList = () => {
/>
{/* 底部导航栏 */}
<AskNavbar />
</View>
</ErrorBoundary>
);

View File

@ -37,20 +37,27 @@ const Code = ({ setSteps, phone }: LoginProps) => {
setError('');
const newCode = [...code];
// Handle pasted code from SMS
if (text.length === 6 && /^\d{6}$/.test(text)) {
const digits = text.split('');
// Handle pasted code from SMS or autofill
if ((text.length === 6 || text.length > 1) && /^\d+$/.test(text)) {
const digits = text.split('').slice(0, 6); // Ensure we only take first 6 digits
setCode(digits);
refs.current[5]?.focus(); // Focus on the last input after autofill
refs.current[5]?.focus(); // Focus on the last input
// Auto-submit if we have exactly 6 digits
if (digits.length === 6) {
handleTelLogin();
}
return;
}
// Handle manual input
if (text.length <= 1) {
// Handle single digit input
if (text.length <= 1 && /^\d?$/.test(text)) {
newCode[index] = text;
setCode(newCode);
if (text) {
// Auto-submit if this is the last digit
if (text && index === 5) {
handleTelLogin();
} else if (text) {
focusNext(index, text);
}
}
@ -145,14 +152,16 @@ const Code = ({ setSteps, phone }: LoginProps) => {
style={{ width: 40, height: 40 }}
className="bg-[#FFF8DE] rounded-xl text-textTertiary text-3xl text-center"
keyboardType="number-pad"
maxLength={1}
textContentType="oneTimeCode" // For iOS autofill
autoComplete='sms-otp' // For Android autofill
maxLength={6} // Allow pasting longer codes
value={digit}
onChangeText={text => handleCodeChange(text, index)}
onKeyPress={({ nativeEvent }) => focusPrevious(index, nativeEvent.key)}
selectTextOnFocus
caretHidden={true}
autoFocus={index === 0}
textContentType="oneTimeCode"
autoComplete="one-time-code"
importantForAutofill="yes"
/>
))}
</Animated.View>

View File

@ -84,9 +84,13 @@ const SignUp = ({ updateUrlParam, setError, setShowPassword, showPassword }: Log
}
if (password) {
// 校验密码是否符合规范
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
if (!passwordRegex.test(password)) {
setError(t('auth.signup.passwordAuth', { ns: 'login' }));
// const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
// if (!passwordRegex.test(password)) {
// setError(t('auth.signup.passwordAuth', { ns: 'login' }));
// return;
// }
if (password.length < 6) {
setError(t('auth.signup.pwdLengthError', { ns: 'login' }));
return;
}
}

View File

@ -74,7 +74,14 @@ function CarouselComponent(props: Props) {
height={width * 0.75}
data={carouselDataValue || []}
mode="parallax"
defaultIndex={carouselDataValue?.findIndex((item) => item?.key === 'total_count') - 1 || 0}
defaultIndex={
carouselDataValue?.length
? Math.max(0, Math.min(
carouselDataValue.length - 1,
carouselDataValue.findIndex((item) => item?.key === 'total_count') - 1
))
: 0
}
modeConfig={{
parallaxScrollingScale: 1,
parallaxScrollingOffset: 150,

View File

@ -119,7 +119,8 @@
"codeExpireTime": "Code will expire in",
"checkedRequired": "Please agree to the terms",
"emailAuth": "Please enter a valid email address",
"passwordAuth": "Please enter a valid password"
"passwordAuth": "Please enter a valid password",
"pwdLengthError": "Password length must be at least 6 characters"
}
}
}

View File

@ -120,7 +120,8 @@
"codeExpireTime": "验证码将在以下时间后过期",
"checkedRequired": "请勾选协议",
"emailAuth": "请输入一个有效的邮箱地址",
"passwordAuth": "请输入一个有效的密码"
"passwordAuth": "请输入一个有效的密码",
"pwdLengthError": "密码长度至少为6位"
}
}
}