@@ -42,8 +42,6 @@ interface TaskBarSlotProps {
4242 currentTimeScale? : TimelineScale
4343 rowHeight: number
4444 dayWidth: number
45- // 新增:动态样式对象
46- dynamicStyles: Record <string , string >
4745}
4846
4947const props = defineProps <Props >()
@@ -246,13 +244,13 @@ const taskBarStyle = computed(() => {
246244 const startDateOnly = new Date (
247245 startDate .getFullYear (),
248246 startDate .getMonth (),
249- startDate .getDate (),
247+ startDate .getDate ()
250248 )
251249 const endDateOnly = new Date (endDate .getFullYear (), endDate .getMonth (), endDate .getDate ())
252250 const baseStartOnly = new Date (
253251 baseStart .getFullYear (),
254252 baseStart .getMonth (),
255- baseStart .getDate (),
253+ baseStart .getDate ()
256254 )
257255
258256 if (props .currentTimeScale === TimelineScale .YEAR ) {
@@ -274,15 +272,15 @@ const taskBarStyle = computed(() => {
274272 const startPosition = calculatePositionFromTimelineData (
275273 startDateOnly ,
276274 props .timelineData ,
277- props .currentTimeScale ,
275+ props .currentTimeScale
278276 )
279277 // 计算结束位置:为结束日期添加一天来获取正确的结束位置
280278 const nextDay = new Date (endDateOnly )
281279 nextDay .setDate (nextDay .getDate () + 1 )
282280 let endPosition = calculatePositionFromTimelineData (
283281 nextDay ,
284282 props .timelineData ,
285- props .currentTimeScale ,
283+ props .currentTimeScale
286284 )
287285
288286 // 如果结束日期+1天超出范围,使用结束日期的位置+一天的宽度
@@ -297,7 +295,7 @@ const taskBarStyle = computed(() => {
297295 calculatePositionFromTimelineData (
298296 endDateOnly ,
299297 props .timelineData ,
300- props .currentTimeScale ,
298+ props .currentTimeScale
301299 ) + dayWidth
302300 }
303301
@@ -306,7 +304,7 @@ const taskBarStyle = computed(() => {
306304 } else {
307305 // 日视图:基于日期的简单计算
308306 const startDiff = Math .floor (
309- (startDateOnly .getTime () - baseStartOnly .getTime ()) / (1000 * 60 * 60 * 24 ),
307+ (startDateOnly .getTime () - baseStartOnly .getTime ()) / (1000 * 60 * 60 * 24 )
310308 )
311309
312310 // 计算持续天数(基于日期,忽略时间)
@@ -395,7 +393,6 @@ const slotPayload = computed(() => ({
395393 currentTimeScale: props .currentTimeScale ,
396394 rowHeight: props .rowHeight ,
397395 dayWidth: props .dayWidth ,
398- dynamicStyles: getNameStyles (),
399396}))
400397
401398// 判断是否已完成
@@ -504,7 +501,7 @@ const handleMouseMove = (e: MouseEvent) => {
504501 mouseX: e .clientX ,
505502 isDragging: isDragging .value || isResizingLeft .value || isResizingRight .value ,
506503 },
507- }),
504+ })
508505 )
509506
510507 // 更新拖拽提示框位置
@@ -769,7 +766,7 @@ const handleMouseMove = (e: MouseEvent) => {
769766 const newDurationDays = newWidth / props .dayWidth
770767 const newEndDate = addDaysToLocalDate (
771768 props .startDate ,
772- resizeStartLeft .value / props .dayWidth + newDurationDays - 1 ,
769+ resizeStartLeft .value / props .dayWidth + newDurationDays - 1
773770 )
774771
775772 // 只更新临时数据,不触发事件
@@ -801,7 +798,7 @@ const handleMouseUp = () => {
801798 mouseX: 0 ,
802799 isDragging: false ,
803800 },
804- }),
801+ })
805802 )
806803
807804 // 如果有临时数据,说明发生了拖拽或拉伸,提交数据更新
@@ -885,7 +882,7 @@ watch(
885882 reportBarPosition ()
886883 })
887884 },
888- { deep: true },
885+ { deep: true }
889886)
890887
891888// 处理TaskBar双击事件
@@ -1174,7 +1171,7 @@ watch(
11741171 }
11751172 }, 200 )
11761173 }
1177- },
1174+ }
11781175)
11791176
11801177// 监听外部hideBubbles属性变化,确保Timeline的容器变化能及时反应
@@ -1187,7 +1184,7 @@ watch(
11871184 // 强制重新计算bubbleIndicator,确保容器宽度变化后正确显示半圆
11881185 })
11891186 }
1190- },
1187+ }
11911188)
11921189
11931190// 监听TaskBar可见性变化,只在滚动时实现重新出现动画
@@ -1196,7 +1193,7 @@ watch(
11961193 () => {
11971194 // TaskBar重新出现时,不需要动画效果
11981195 // 半圆会自然消失,TaskBar会立即显示
1199- },
1196+ }
12001197)
12011198
12021199// 监听页面缩放和大小变化,重新计算气泡位置
@@ -1356,13 +1353,13 @@ const calculateYearViewPosition = (targetDate: Date, baseStartDate: Date): numbe
13561353 const daysInHalfYear =
13571354 month <= 6
13581355 ? Math .floor (
1359- (new Date (targetYear , 6 , 1 ).getTime () - new Date (targetYear , 0 , 1 ).getTime ()) /
1360- (1000 * 60 * 60 * 24 ),
1361- )
1356+ (new Date (targetYear , 6 , 1 ).getTime () - new Date (targetYear , 0 , 1 ).getTime ()) /
1357+ (1000 * 60 * 60 * 24 )
1358+ )
13621359 : Math .floor (
1363- (new Date (targetYear + 1 , 0 , 1 ).getTime () - new Date (targetYear , 6 , 1 ).getTime ()) /
1364- (1000 * 60 * 60 * 24 ),
1365- )
1360+ (new Date (targetYear + 1 , 0 , 1 ).getTime () - new Date (targetYear , 6 , 1 ).getTime ()) /
1361+ (1000 * 60 * 60 * 24 )
1362+ )
13661363
13671364 const dayPositionInHalfYear = (dayOffset / daysInHalfYear ) * halfYearWidth
13681365 position += dayPositionInHalfYear
@@ -1386,7 +1383,7 @@ const calculatePositionFromTimelineData = (
13861383 subDays: Array <{ date: Date ; dayOfWeek? : number }>
13871384 }>
13881385 }>,
1389- timeScale : TimelineScale ,
1386+ timeScale : TimelineScale
13901387) => {
13911388 let cumulativePosition = 0
13921389
@@ -1404,11 +1401,11 @@ const calculatePositionFromTimelineData = (
14041401 // 找到目标日期所在的季度
14051402 const quarterWidth = 60
14061403 const daysInQuarter = Math .ceil (
1407- (quarterEnd .getTime () - quarterStart .getTime ()) / (1000 * 60 * 60 * 24 ),
1404+ (quarterEnd .getTime () - quarterStart .getTime ()) / (1000 * 60 * 60 * 24 )
14081405 )
14091406 const dayWidth = quarterWidth / daysInQuarter
14101407 const dayInQuarter = Math .ceil (
1411- (targetDate .getTime () - quarterStart .getTime ()) / (1000 * 60 * 60 * 24 ),
1408+ (targetDate .getTime () - quarterStart .getTime ()) / (1000 * 60 * 60 * 24 )
14121409 )
14131410 return cumulativePosition + dayInQuarter * dayWidth
14141411 }
@@ -1566,14 +1563,9 @@ onUnmounted(() => {
15661563 @mousedown =" e => (isInteractionDisabled ? null : handleMouseDown(e, 'drag'))"
15671564 >
15681565 <!-- 任务名称 -->
1569- <div ref =" taskBarNameRef" >
1570- <slot
1571- v-if =" hasContentSlot"
1572- name =" custom-task-content"
1573- v-bind =" slotPayload"
1574- :style =" getNameStyles()"
1575- />
1576- <div v-else class =" task-name" :style =" getNameStyles()" >
1566+ <div ref =" taskBarNameRef" :style =" getNameStyles()" >
1567+ <slot v-if =" hasContentSlot" name =" custom-task-content" v-bind =" slotPayload" />
1568+ <div v-else class =" task-name" >
15771569 {{ task.name }}
15781570 </div >
15791571 </div >
0 commit comments