diff --git a/src/app/mylist/page.tsx b/src/app/mylist/page.tsx
index 0358497..b5d38c6 100644
--- a/src/app/mylist/page.tsx
+++ b/src/app/mylist/page.tsx
@@ -36,7 +36,6 @@ export default function Journal() {
// journal: apiGetSongCollect,
// };
const result = await apiGetSongCollect({ userId: userInfo?.id, pageNum, pageSize });
- console.log(result.data);
if (result.code === 200) setList(result.data.rows);
};
diff --git a/src/components/Header/UserCard.tsx b/src/components/Header/UserCard.tsx
index d4679a0..61327e4 100644
--- a/src/components/Header/UserCard.tsx
+++ b/src/components/Header/UserCard.tsx
@@ -5,6 +5,9 @@ import { useRouter } from 'next/navigation';
import { useShallow } from 'zustand/react/shallow';
import { Avatar } from '@/components';
+
+import logout from '@/utils/logout';
+
import useUserStore from '@/store/user';
interface Props {
@@ -19,10 +22,9 @@ interface TDataList {
export default function UserCard({ onClose, className }: Props) {
const router = useRouter();
- const { userInfo, userLogout } = useUserStore(
+ const { userInfo } = useUserStore(
useShallow((state) => ({
userInfo: state.userInfo,
- userLogout: state.userLogout,
})),
);
@@ -38,12 +40,6 @@ export default function UserCard({ onClose, className }: Props) {
onClose();
};
- const handleLogout = async () => {
- userLogout();
- router.push('/');
- onClose();
- };
-
useEffect(() => {
setUserDataList([
{ label: '关注', value: userInfo.followCount },
@@ -87,7 +83,7 @@ export default function UserCard({ onClose, className }: Props) {
退出登录
diff --git a/src/components/Login/LoginForm.tsx b/src/components/Login/LoginForm.tsx
index e59eaa0..c6ecad2 100644
--- a/src/components/Login/LoginForm.tsx
+++ b/src/components/Login/LoginForm.tsx
@@ -5,7 +5,7 @@ import React, { useState, useMemo, useEffect } from 'react';
import { debounce } from 'lodash';
import { useShallow } from 'zustand/react/shallow';
-import { Input, Button } from '@/components';
+import { Button } from '@/components';
import { apiSendSMS } from '@/services';
import useUserStore from '@/store/user';
@@ -19,6 +19,7 @@ export default function LoginForm() {
const [phone, setPhone] = useState('17861518060'); // 手机号
const [authCode, seAuthCode] = useState('111111'); // 验证码
+ const [errorText, setErrorText] = useState(''); // 验证码
const [time, setTime] = useState(0); // 倒计时
const [btnLoading, setBtnLoading] = useState(false);
const deviceId = '1'; // 设备id 暂时写死
@@ -29,23 +30,33 @@ export default function LoginForm() {
setBtnLoading(true);
const result = await apiSendSMS({ mobile: phone, deviceId });
- if (result.code === 200) {
- setTime(59);
- setTimeout(() => {
- setBtnLoading(false);
- }, 60000);
+ if (result.code !== 200) {
+ setErrorText(result.message);
+ setBtnLoading(false);
+ return;
}
- setBtnLoading(false);
+ setTime(59);
+ setTimeout(() => {
+ setBtnLoading(false);
+ }, 60000);
};
// 登录
const handleLogin = async () => {
+ setBtnLoading(true);
const result = await userLogin({ mobile: phone, mobileCheckCode: authCode, deviceId: '1' });
- if (result) setShowLogin(false);
+ if (result.code === 200) {
+ setShowLogin(false);
+ window.location.reload();
+ } else {
+ setErrorText(result.message);
+ setBtnLoading(false);
+ }
};
// 输入框,只允许输入数字
const handleInputChange = (e: React.ChangeEvent, fn: (text: string) => void) => {
+ if (errorText) setErrorText('');
const inputValue = e.target.value;
const regex = /^[0-9]*$/;
if (regex.test(inputValue) || inputValue === '') fn(e.target.value);
@@ -64,7 +75,8 @@ export default function LoginForm() {
return (