feat: 日志优化
This commit is contained in:
@@ -45,6 +45,7 @@ import {
|
||||
} from 'components/Scrollbar/Scrollbar';
|
||||
import { useRef, useState } from 'react';
|
||||
import { Scrollbars } from 'react-custom-scrollbars-2';
|
||||
import { logger } from '../../utils/logger';
|
||||
|
||||
function Kanban() {
|
||||
// Chakra color mode
|
||||
@@ -149,6 +150,15 @@ function Kanban() {
|
||||
return newCardLocal;
|
||||
}
|
||||
|
||||
// 卡片创建日志处理函数
|
||||
function handleCardNew(cardData) {
|
||||
logger.debug('Kanban', '创建新卡片', {
|
||||
cardId: cardData?.id,
|
||||
title: cardData?.title,
|
||||
boardCounter: initialBoard.counter
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Flex
|
||||
direction='column'
|
||||
@@ -167,7 +177,7 @@ function Kanban() {
|
||||
initialBoard={board}
|
||||
allowAddCard
|
||||
onNewCardConfirm={onCardNew}
|
||||
onCardNew={console.log}
|
||||
onCardNew={handleCardNew}
|
||||
renderColumnHeader={function ({ title }, { addCard }) {
|
||||
const kanbanForm = useRef(null);
|
||||
const cardInput = useRef(null);
|
||||
|
||||
@@ -145,7 +145,10 @@ export default function CenterDashboard() {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载实时行情失败:', error);
|
||||
logger.error('Center', 'loadRealtimeQuotes', error, {
|
||||
userId: user?.id,
|
||||
watchlistLength: watchlist.length
|
||||
});
|
||||
} finally {
|
||||
setQuotesLoading(false);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import { useAuth } from '../../contexts/AuthContext';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import heroBg from '../../assets/img/BackgroundCard1.png';
|
||||
import '../../styles/home-animations.css';
|
||||
import { logger } from '../../utils/logger';
|
||||
|
||||
export default function HomePage() {
|
||||
const { user, isAuthenticated } = useAuth(); // ⚡ 移除 isLoading,不再依赖它
|
||||
@@ -27,15 +28,12 @@ export default function HomePage() {
|
||||
|
||||
// 保留原有的调试信息
|
||||
useEffect(() => {
|
||||
console.log('🏠 HomePage AuthContext 状态:', {
|
||||
user,
|
||||
logger.debug('HomePage', 'AuthContext状态', {
|
||||
userId: user?.id,
|
||||
username: user?.username,
|
||||
nickname: user?.nickname,
|
||||
isAuthenticated,
|
||||
hasUser: !!user,
|
||||
userInfo: user ? {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
nickname: user.nickname
|
||||
} : null
|
||||
hasUser: !!user
|
||||
});
|
||||
}, [user, isAuthenticated]);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
Icon,
|
||||
} from '@chakra-ui/react';
|
||||
import { StarIcon, TriangleUpIcon } from '@chakra-ui/icons';
|
||||
import { logger } from '../../../utils/logger';
|
||||
|
||||
const HighPositionStocks = ({ dateStr }) => {
|
||||
const [highPositionData, setHighPositionData] = useState(null);
|
||||
@@ -45,17 +46,26 @@ const HighPositionStocks = ({ dateStr }) => {
|
||||
const API_URL = process.env.NODE_ENV === 'production' ? '/report-api' : 'http://111.198.58.126:5001';
|
||||
const response = await fetch(`${API_URL}/api/limit-analyse/high-position-stocks?date=${dateStr}`);
|
||||
const data = await response.json();
|
||||
|
||||
console.log('High position stocks API response:', data); // 添加调试信息
|
||||
|
||||
|
||||
logger.debug('HighPositionStocks', 'API响应', {
|
||||
date: dateStr,
|
||||
success: data.success,
|
||||
dataLength: data.data?.length
|
||||
});
|
||||
|
||||
if (data.success) {
|
||||
setHighPositionData(data.data);
|
||||
} else {
|
||||
console.error('API returned success: false', data);
|
||||
logger.warn('HighPositionStocks', 'API返回失败', {
|
||||
date: dateStr,
|
||||
error: data.error
|
||||
});
|
||||
setHighPositionData(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch high position stocks:', error);
|
||||
logger.error('HighPositionStocks', 'fetchHighPositionStocks', error, {
|
||||
date: dateStr
|
||||
});
|
||||
setHighPositionData(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { FaCheckCircle, FaTimesCircle } from "react-icons/fa";
|
||||
import { authService } from "../../services/authService";
|
||||
import { useAuth } from "../../contexts/AuthContext";
|
||||
import { logger } from "../../utils/logger";
|
||||
|
||||
/**
|
||||
* 微信H5授权回调页面
|
||||
@@ -69,7 +70,11 @@ export default function WechatCallback() {
|
||||
navigate("/home", { replace: true });
|
||||
}, 1500);
|
||||
} catch (error) {
|
||||
console.error("微信授权回调处理失败:", error);
|
||||
logger.error('WechatCallback', 'handleCallback', error, {
|
||||
code: searchParams.get("code"),
|
||||
state: searchParams.get("state"),
|
||||
errorMessage: error.message
|
||||
});
|
||||
setStatus("error");
|
||||
setMessage(error.message || "授权失败,请重试");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user