perf(Company): 优化渲染性能和 API 请求

- StockQuoteCard: 添加 memo 包装减少重渲染
- Company/index: componentProps 使用 useMemo 缓存
- useCompanyEvents: 页面浏览事件只触发一次,避免重复追踪
- useCompanyData: 自选股状态改用单股票查询接口,减少数据传输
- CompanyHeader: inputCode 状态下移到 SearchActions,减少父组件重渲染
- CompanyHeader: 移除重复环境光效果,由全局 AmbientGlow 统一处理

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-19 10:14:07 +08:00
parent c979e775a5
commit 51721ce9bf
5 changed files with 96 additions and 94 deletions

View File

@@ -1,7 +1,7 @@
// src/views/Company/hooks/useCompanyEvents.js
// 公司详情页面事件追踪 Hook
import { useCallback, useEffect } from 'react';
import { useCallback, useEffect, useRef } from 'react';
import { usePostHogTrack } from '../../../hooks/usePostHogRedux';
import { RETENTION_EVENTS } from '../../../lib/constants';
import { logger } from '../../../utils/logger';
@@ -14,9 +14,13 @@ import { logger } from '../../../utils/logger';
*/
export const useCompanyEvents = ({ stockCode } = {}) => {
const { track } = usePostHogTrack();
const hasTrackedPageView = useRef(false);
// 🎯 页面浏览事件 - 页面加载时触发
// 🎯 页面浏览事件 - 页面首次加载时触发一次
useEffect(() => {
if (hasTrackedPageView.current) return;
hasTrackedPageView.current = true;
track(RETENTION_EVENTS.COMPANY_PAGE_VIEWED, {
timestamp: new Date().toISOString(),
stock_code: stockCode || null,