feat: 去掉logger
This commit is contained in:
@@ -183,8 +183,6 @@ export default function AuthFormContent() {
|
|||||||
purpose: config.api.purpose
|
purpose: config.api.purpose
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.api.request('POST', '/api/auth/send-verification-code', requestData);
|
|
||||||
|
|
||||||
const response = await fetch('/api/auth/send-verification-code', {
|
const response = await fetch('/api/auth/send-verification-code', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -200,8 +198,6 @@ export default function AuthFormContent() {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
logger.api.response('POST', '/api/auth/send-verification-code', response.status, data);
|
|
||||||
|
|
||||||
if (!isMountedRef.current) return;
|
if (!isMountedRef.current) return;
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@@ -306,12 +302,6 @@ export default function AuthFormContent() {
|
|||||||
login_type: 'phone',
|
login_type: 'phone',
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.api.request('POST', '/api/auth/login-with-code', {
|
|
||||||
credential: cleanedPhone.substring(0, 3) + '****' + cleanedPhone.substring(7),
|
|
||||||
verification_code: verificationCode.substring(0, 2) + '****',
|
|
||||||
login_type: 'phone'
|
|
||||||
});
|
|
||||||
|
|
||||||
// 调用API(根据模式选择不同的endpoint
|
// 调用API(根据模式选择不同的endpoint
|
||||||
const response = await fetch('/api/auth/login-with-code', {
|
const response = await fetch('/api/auth/login-with-code', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -328,11 +318,6 @@ export default function AuthFormContent() {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
logger.api.response('POST', '/api/auth/login-with-code', response.status, {
|
|
||||||
...data,
|
|
||||||
user: data.user ? { id: data.user.id, phone: data.user.phone } : null
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!isMountedRef.current) return;
|
if (!isMountedRef.current) return;
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
selectRedirectUrl
|
selectRedirectUrl
|
||||||
} from '../store/slices/authModalSlice';
|
} from '../store/slices/authModalSlice';
|
||||||
import { useAuth } from '../contexts/AuthContext';
|
import { useAuth } from '../contexts/AuthContext';
|
||||||
import { logger } from '../utils/logger';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证弹窗自定义 Hook
|
* 认证弹窗自定义 Hook
|
||||||
@@ -49,11 +48,6 @@ export const useAuthModal = () => {
|
|||||||
const openAuthModal = useCallback((url = null, callback = null) => {
|
const openAuthModal = useCallback((url = null, callback = null) => {
|
||||||
onSuccessCallbackRef.current = callback;
|
onSuccessCallbackRef.current = callback;
|
||||||
dispatch(openModal({ redirectUrl: url }));
|
dispatch(openModal({ redirectUrl: url }));
|
||||||
|
|
||||||
logger.debug('useAuthModal', '打开认证弹窗', {
|
|
||||||
redirectUrl: url || '无',
|
|
||||||
hasCallback: !!callback
|
|
||||||
});
|
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,9 +61,6 @@ export const useAuthModal = () => {
|
|||||||
// ⭐ 如果用户关闭弹窗时仍未登录,跳转到首页
|
// ⭐ 如果用户关闭弹窗时仍未登录,跳转到首页
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
navigate('/home');
|
navigate('/home');
|
||||||
logger.debug('useAuthModal', '未登录关闭弹窗,跳转到首页');
|
|
||||||
} else {
|
|
||||||
logger.debug('useAuthModal', '关闭认证弹窗');
|
|
||||||
}
|
}
|
||||||
}, [dispatch, isAuthenticated, navigate]);
|
}, [dispatch, isAuthenticated, navigate]);
|
||||||
|
|
||||||
@@ -82,14 +73,8 @@ export const useAuthModal = () => {
|
|||||||
if (onSuccessCallbackRef.current) {
|
if (onSuccessCallbackRef.current) {
|
||||||
try {
|
try {
|
||||||
onSuccessCallbackRef.current(user);
|
onSuccessCallbackRef.current(user);
|
||||||
logger.debug('useAuthModal', '执行成功回调', {
|
|
||||||
userId: user?.id
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('useAuthModal', 'handleLoginSuccess 回调执行失败', error, {
|
console.error('useAuthModal: handleLoginSuccess 回调执行失败', error);
|
||||||
userId: user?.id,
|
|
||||||
hasCallback: !!onSuccessCallbackRef.current
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,10 +82,6 @@ export const useAuthModal = () => {
|
|||||||
// 移除了原有的 redirectUrl 跳转逻辑
|
// 移除了原有的 redirectUrl 跳转逻辑
|
||||||
dispatch(closeModal());
|
dispatch(closeModal());
|
||||||
onSuccessCallbackRef.current = null;
|
onSuccessCallbackRef.current = null;
|
||||||
|
|
||||||
logger.debug('useAuthModal', '登录成功,关闭弹窗', {
|
|
||||||
userId: user?.id
|
|
||||||
});
|
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// 认证弹窗状态管理 Redux Slice - 从 AuthModalContext 迁移
|
// 认证弹窗状态管理 Redux Slice - 从 AuthModalContext 迁移
|
||||||
|
|
||||||
import { createSlice } from '@reduxjs/toolkit';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
import { logger } from '../../utils/logger';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AuthModal Slice
|
* AuthModal Slice
|
||||||
@@ -22,9 +21,6 @@ const authModalSlice = createSlice({
|
|||||||
openModal: (state, action) => {
|
openModal: (state, action) => {
|
||||||
state.isOpen = true;
|
state.isOpen = true;
|
||||||
state.redirectUrl = action.payload?.redirectUrl || null;
|
state.redirectUrl = action.payload?.redirectUrl || null;
|
||||||
logger.debug('authModalSlice', '打开认证弹窗', {
|
|
||||||
redirectUrl: action.payload?.redirectUrl || '无'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +29,6 @@ const authModalSlice = createSlice({
|
|||||||
closeModal: (state) => {
|
closeModal: (state) => {
|
||||||
state.isOpen = false;
|
state.isOpen = false;
|
||||||
state.redirectUrl = null;
|
state.redirectUrl = null;
|
||||||
logger.debug('authModalSlice', '关闭认证弹窗');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user