当前的项目负载时间轴在"当天"内无法精确展示多个事件的发生时间,因为:
getTodayPosition(): string {
const rangeStart = this.timeRangeStart.getTime();
const rangeEnd = this.timeRangeEnd.getTime();
const rangeDuration = rangeEnd - rangeStart;
const currentTimeMs = this.currentTime.getTime();
// 计算精确位置(包含小时和分钟)
const position = ((currentTimeMs - rangeStart) / rangeDuration) * 100;
return `${Math.max(0, Math.min(100, position))}%`;
}
private startAutoRefresh(): void {
// 立即更新一次当前时间
this.updateCurrentTime();
// 每10分钟刷新一次
this.refreshTimer = setInterval(() => {
console.log('🔄 项目时间轴:10分钟自动刷新触发');
this.updateCurrentTime();
this.initializeData(); // 重新加载数据和过滤
this.cdr.markForCheck(); // 触发变更检测
}, 600000);
console.log('⏰ 项目时间轴:已启动10分钟自动刷新');
}
ngOnInit() 时启动自动刷新ngOnDestroy() 时清理定时器.refresh-btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
&:active {
animation: refresh-spin 0.6s ease-in-out; // 点击时旋转360度
}
}
.today-line {
width: 3px;
background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
animation: today-pulse 2s ease-in-out infinite;
}
// 主线条脉动
@keyframes today-pulse {
0%, 100% {
opacity: 1;
box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}
50% {
opacity: 0.85;
box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
}
}
// 圆点脉动
@keyframes today-dot-pulse {
0%, 100% {
transform: translateX(-50%) scale(1);
}
50% {
transform: translateX(-50%) scale(1.3);
}
}
问题:一个项目当天有"对图"和"交付"两个事件
解决:
场景:组长在上午10:00查看时间轴
场景:临近交付时间,需要实时监控
// 存储精确到毫秒的当前时间
currentTime: Date = new Date();
// 定期更新
private updateCurrentTime(): void {
this.currentTime = new Date();
console.log('⏰ 当前精确时间已更新:', this.currentTime.toLocaleString('zh-CN'));
}
使用 OnPush 策略 + 手动触发:
constructor(private cdr: ChangeDetectorRef) {}
refresh(): void {
this.updateCurrentTime();
this.initializeData();
this.cdr.markForCheck(); // 手动触发变更检测
}
ngOnDestroy(): void {
if (this.refreshTimer) {
clearInterval(this.refreshTimer);
}
}
// 允许用户自定义刷新周期
refreshInterval: 5 | 10 | 15 | 30 = 10; // 分钟
// 根据视图内容智能调整刷新频率
if (hasUrgentProjects) {
refreshInterval = 5; // 5分钟
} else {
refreshInterval = 15; // 15分钟
}
实现日期:2025年11月5日
实现人员:AI Assistant
状态:✅ 已完成并验证