更新Company页面的UI为FUI风格
This commit is contained in:
@@ -163,13 +163,20 @@ const CompactSearchBox = ({
|
|||||||
stockDisplayValueRef.current = null;
|
stockDisplayValueRef.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasTimeInFilters = filters.start_date || filters.end_date || filters.recent_days;
|
const hasTimeInFilters = filters.start_date || filters.end_date || filters.recent_days || filters.time_filter_key;
|
||||||
|
|
||||||
if (hasTimeInFilters && (!tradingTimeRange || !tradingTimeRange.key)) {
|
if (hasTimeInFilters && (!tradingTimeRange || !tradingTimeRange.key)) {
|
||||||
let inferredKey = 'custom';
|
// 优先使用 time_filter_key(来自 useEventFilters 的默认值)
|
||||||
|
let inferredKey = filters.time_filter_key || 'custom';
|
||||||
let inferredLabel = '';
|
let inferredLabel = '';
|
||||||
|
|
||||||
if (filters.recent_days) {
|
if (filters.time_filter_key === 'current-trading-day') {
|
||||||
|
inferredKey = 'current-trading-day';
|
||||||
|
inferredLabel = '当前交易日';
|
||||||
|
} else if (filters.time_filter_key === 'all') {
|
||||||
|
inferredKey = 'all';
|
||||||
|
inferredLabel = '全部';
|
||||||
|
} else if (filters.recent_days) {
|
||||||
if (filters.recent_days === '7') {
|
if (filters.recent_days === '7') {
|
||||||
inferredKey = 'week';
|
inferredKey = 'week';
|
||||||
inferredLabel = '近一周';
|
inferredLabel = '近一周';
|
||||||
@@ -377,7 +384,12 @@ const CompactSearchBox = ({
|
|||||||
const { range, type, label, key } = timeConfig;
|
const { range, type, label, key } = timeConfig;
|
||||||
let params = {};
|
let params = {};
|
||||||
|
|
||||||
if (type === 'recent_days') {
|
if (type === 'all') {
|
||||||
|
// "全部"按钮:清除所有时间限制
|
||||||
|
params.start_date = '';
|
||||||
|
params.end_date = '';
|
||||||
|
params.recent_days = '';
|
||||||
|
} else if (type === 'recent_days') {
|
||||||
params.recent_days = range;
|
params.recent_days = range;
|
||||||
params.start_date = '';
|
params.start_date = '';
|
||||||
params.end_date = '';
|
params.end_date = '';
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import dayjs from 'dayjs';
|
|||||||
import locale from 'antd/es/date-picker/locale/zh_CN';
|
import locale from 'antd/es/date-picker/locale/zh_CN';
|
||||||
import { logger } from '@utils/logger';
|
import { logger } from '@utils/logger';
|
||||||
import { PROFESSIONAL_COLORS } from '@constants/professionalTheme';
|
import { PROFESSIONAL_COLORS } from '@constants/professionalTheme';
|
||||||
|
import tradingDayUtils from '@utils/tradingDayUtils';
|
||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
@@ -83,28 +84,10 @@ const TradingTimeFilter = ({ value, onChange, compact = false, mobile = false })
|
|||||||
const yesterdayEnd = now.subtract(1, 'day').endOf('day');
|
const yesterdayEnd = now.subtract(1, 'day').endOf('day');
|
||||||
|
|
||||||
// 动态按钮配置(根据时段返回不同按钮数组)
|
// 动态按钮配置(根据时段返回不同按钮数组)
|
||||||
|
// 注意:"当前交易日"已在固定按钮中,这里只放特定时段的快捷按钮
|
||||||
const dynamicButtonsMap = {
|
const dynamicButtonsMap = {
|
||||||
'pre-market': [
|
'pre-market': [], // 盘前:使用"当前交易日"即可
|
||||||
{
|
|
||||||
key: 'latest',
|
|
||||||
label: '最新',
|
|
||||||
range: [yesterday1500, today0930],
|
|
||||||
tooltip: '盘前资讯',
|
|
||||||
timeHint: `昨日 15:00 - 今日 09:30`,
|
|
||||||
color: 'purple',
|
|
||||||
type: 'precise'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'morning': [
|
'morning': [
|
||||||
{
|
|
||||||
key: 'latest',
|
|
||||||
label: '最新',
|
|
||||||
range: [today0930, now],
|
|
||||||
tooltip: '早盘最新',
|
|
||||||
timeHint: `今日 09:30 - ${now.format('HH:mm')}`,
|
|
||||||
color: 'green',
|
|
||||||
type: 'precise'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'intraday',
|
key: 'intraday',
|
||||||
label: '盘中',
|
label: '盘中',
|
||||||
@@ -115,27 +98,8 @@ const TradingTimeFilter = ({ value, onChange, compact = false, mobile = false })
|
|||||||
type: 'precise'
|
type: 'precise'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'lunch': [
|
'lunch': [], // 午休:使用"当前交易日"即可
|
||||||
{
|
|
||||||
key: 'latest',
|
|
||||||
label: '最新',
|
|
||||||
range: [today1130, now],
|
|
||||||
tooltip: '午休时段',
|
|
||||||
timeHint: `今日 11:30 - ${now.format('HH:mm')}`,
|
|
||||||
color: 'orange',
|
|
||||||
type: 'precise'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'afternoon': [
|
'afternoon': [
|
||||||
{
|
|
||||||
key: 'latest',
|
|
||||||
label: '最新',
|
|
||||||
range: [today1300, now],
|
|
||||||
tooltip: '午盘最新',
|
|
||||||
timeHint: `今日 13:00 - ${now.format('HH:mm')}`,
|
|
||||||
color: 'green',
|
|
||||||
type: 'precise'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'intraday',
|
key: 'intraday',
|
||||||
label: '盘中',
|
label: '盘中',
|
||||||
@@ -155,21 +119,35 @@ const TradingTimeFilter = ({ value, onChange, compact = false, mobile = false })
|
|||||||
type: 'precise'
|
type: 'precise'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'after-hours': [
|
'after-hours': [] // 盘后:使用"当前交易日"即可
|
||||||
{
|
|
||||||
key: 'latest',
|
|
||||||
label: '最新',
|
|
||||||
range: [today1500, now],
|
|
||||||
tooltip: '盘后最新',
|
|
||||||
timeHint: `今日 15:00 - ${now.format('HH:mm')}`,
|
|
||||||
color: 'red',
|
|
||||||
type: 'precise'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取上一个交易日(使用 tdays.csv 数据)
|
||||||
|
const getPrevTradingDay = () => {
|
||||||
|
try {
|
||||||
|
const prevTradingDay = tradingDayUtils.getPreviousTradingDay(now.toDate());
|
||||||
|
return dayjs(prevTradingDay);
|
||||||
|
} catch (e) {
|
||||||
|
// 降级:简单地减一天(不考虑周末节假日)
|
||||||
|
logger.warn('TradingTimeFilter', '获取上一交易日失败,降级处理', e);
|
||||||
|
return now.subtract(1, 'day');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const prevTradingDay = getPrevTradingDay();
|
||||||
|
const prevTradingDay1500 = prevTradingDay.hour(15).minute(0).second(0);
|
||||||
|
|
||||||
// 固定按钮配置(始终显示)
|
// 固定按钮配置(始终显示)
|
||||||
const fixedButtons = [
|
const fixedButtons = [
|
||||||
|
{
|
||||||
|
key: 'current-trading-day',
|
||||||
|
label: '当前交易日',
|
||||||
|
range: [prevTradingDay1500, now],
|
||||||
|
tooltip: '当前交易日事件',
|
||||||
|
timeHint: `${prevTradingDay.format('MM-DD')} 15:00 - 现在`,
|
||||||
|
color: 'green',
|
||||||
|
type: 'precise'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'morning-fixed',
|
key: 'morning-fixed',
|
||||||
label: '早盘',
|
label: '早盘',
|
||||||
@@ -214,6 +192,15 @@ const TradingTimeFilter = ({ value, onChange, compact = false, mobile = false })
|
|||||||
timeHint: '过去30天',
|
timeHint: '过去30天',
|
||||||
color: 'volcano',
|
color: 'volcano',
|
||||||
type: 'recent_days'
|
type: 'recent_days'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'all',
|
||||||
|
label: '全部',
|
||||||
|
range: null, // 无时间限制
|
||||||
|
tooltip: '显示全部事件',
|
||||||
|
timeHint: '不限时间',
|
||||||
|
color: 'default',
|
||||||
|
type: 'all'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { logger } from '../../../utils/logger';
|
|||||||
import { usePostHogTrack } from '../../../hooks/usePostHogRedux';
|
import { usePostHogTrack } from '../../../hooks/usePostHogRedux';
|
||||||
import { RETENTION_EVENTS } from '../../../lib/constants';
|
import { RETENTION_EVENTS } from '../../../lib/constants';
|
||||||
import { getEventDetailUrl } from '@/utils/idEncoder';
|
import { getEventDetailUrl } from '@/utils/idEncoder';
|
||||||
|
import tradingDayUtils from '@utils/tradingDayUtils';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事件筛选逻辑 Hook
|
* 事件筛选逻辑 Hook
|
||||||
@@ -22,16 +24,43 @@ export const useEventFilters = ({ navigate, onEventClick, eventTimelineRef } = {
|
|||||||
|
|
||||||
// 筛选参数状态 - 初始化时从URL读取,之后只用本地状态
|
// 筛选参数状态 - 初始化时从URL读取,之后只用本地状态
|
||||||
const [filters, setFilters] = useState(() => {
|
const [filters, setFilters] = useState(() => {
|
||||||
|
// 计算当前交易日的默认时间范围
|
||||||
|
const getDefaultTimeRange = () => {
|
||||||
|
try {
|
||||||
|
const now = dayjs();
|
||||||
|
const prevTradingDay = tradingDayUtils.getPreviousTradingDay(now.toDate());
|
||||||
|
const prevTradingDay1500 = dayjs(prevTradingDay).hour(15).minute(0).second(0);
|
||||||
|
return {
|
||||||
|
start_date: prevTradingDay1500.format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
end_date: now.format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
recent_days: '', // 使用精确时间范围,不使用 recent_days
|
||||||
|
time_filter_key: 'current-trading-day' // 标记当前选中的时间按钮
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
// 降级:使用近一周
|
||||||
|
logger.warn('useEventFilters', '获取上一交易日失败,降级为近一周', e);
|
||||||
|
return {
|
||||||
|
start_date: '',
|
||||||
|
end_date: '',
|
||||||
|
recent_days: '7',
|
||||||
|
time_filter_key: 'week'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultTimeRange = getDefaultTimeRange();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sort: searchParams.get('sort') || 'new',
|
sort: searchParams.get('sort') || 'new',
|
||||||
importance: searchParams.get('importance') || 'all',
|
importance: searchParams.get('importance') || 'all',
|
||||||
q: searchParams.get('q') || '',
|
q: searchParams.get('q') || '',
|
||||||
industry_code: searchParams.get('industry_code') || '',
|
industry_code: searchParams.get('industry_code') || '',
|
||||||
// 时间筛选参数(从 TradingTimeFilter 传递)
|
// 时间筛选参数(从 TradingTimeFilter 传递)
|
||||||
// 默认显示近一周数据(recent_days=7)
|
// 默认显示当前交易日数据(上一交易日15:00 - 现在)
|
||||||
start_date: searchParams.get('start_date') || '',
|
start_date: searchParams.get('start_date') || defaultTimeRange.start_date,
|
||||||
end_date: searchParams.get('end_date') || '',
|
end_date: searchParams.get('end_date') || defaultTimeRange.end_date,
|
||||||
recent_days: searchParams.get('recent_days') || '7', // 默认近一周
|
recent_days: searchParams.get('recent_days') || defaultTimeRange.recent_days,
|
||||||
|
time_filter_key: searchParams.get('time_filter_key') || defaultTimeRange.time_filter_key,
|
||||||
page: parseInt(searchParams.get('page') || '1', 10)
|
page: parseInt(searchParams.get('page') || '1', 10)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user