v1.3.0 - bugfix
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"dev:demo": "vite",
|
"dev:demo": "vite",
|
||||||
"build": "vue-tsc --noEmit --skipLibCheck && vite build",
|
"build": "vue-tsc -b && vite build",
|
||||||
"build:demo": "vue-tsc -b && vite build",
|
"build:demo": "vue-tsc -b && vite build",
|
||||||
"build:lib": "vite build --config vite.config.lib.ts",
|
"build:lib": "vite build --config vite.config.lib.ts",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
|||||||
+14
-25
@@ -340,29 +340,15 @@ const getCachedTimelineData = (): unknown => {
|
|||||||
|
|
||||||
// 获取虚拟滚动优化后的时间轴数据
|
// 获取虚拟滚动优化后的时间轴数据
|
||||||
const optimizedTimelineData = computed(() => {
|
const optimizedTimelineData = computed(() => {
|
||||||
const cachedData = getCachedTimelineData()
|
const cachedData = getCachedTimelineData() as any
|
||||||
|
|
||||||
// 只在小时视图中应用虚拟滚动
|
// 只在小时视图中应用虚拟滚动
|
||||||
if (currentTimeScale.value === TimelineScale.HOUR && Array.isArray(cachedData)) {
|
if (currentTimeScale.value === TimelineScale.HOUR && Array.isArray(cachedData)) {
|
||||||
const { startHour, endHour } = visibleHourRange.value
|
const { startHour, endHour } = visibleHourRange.value
|
||||||
|
|
||||||
return cachedData
|
return (cachedData as any[])
|
||||||
.map(
|
.map(
|
||||||
(day: {
|
(day: any) => {
|
||||||
year: number
|
|
||||||
month: number
|
|
||||||
day: number
|
|
||||||
hours: Array<{
|
|
||||||
hour: number
|
|
||||||
label: string
|
|
||||||
shortLabel: string
|
|
||||||
date: Date
|
|
||||||
isToday: boolean
|
|
||||||
isWorkingHour: boolean
|
|
||||||
isWeekend: boolean
|
|
||||||
}>
|
|
||||||
[key: string]: unknown
|
|
||||||
}) => {
|
|
||||||
// 计算当前天相对于时间线开始的小时偏移
|
// 计算当前天相对于时间线开始的小时偏移
|
||||||
const dayStart = new Date(timelineConfig.value.startDate)
|
const dayStart = new Date(timelineConfig.value.startDate)
|
||||||
dayStart.setHours(0, 0, 0, 0)
|
dayStart.setHours(0, 0, 0, 0)
|
||||||
@@ -394,7 +380,7 @@ const optimizedTimelineData = computed(() => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.filter((day: { hours: unknown[] }) => day.hours.length > 0)
|
.filter((day: any) => day.hours.length > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cachedData
|
return cachedData
|
||||||
@@ -402,12 +388,12 @@ const optimizedTimelineData = computed(() => {
|
|||||||
|
|
||||||
// 计算完整时间线的总宽度(用于虚拟滚动容器)
|
// 计算完整时间线的总宽度(用于虚拟滚动容器)
|
||||||
const totalTimelineWidth = computed(() => {
|
const totalTimelineWidth = computed(() => {
|
||||||
const cachedData = getCachedTimelineData()
|
const cachedData = getCachedTimelineData() as any
|
||||||
|
|
||||||
if (currentTimeScale.value === TimelineScale.HOUR) {
|
if (currentTimeScale.value === TimelineScale.HOUR) {
|
||||||
if (Array.isArray(cachedData)) {
|
if (Array.isArray(cachedData)) {
|
||||||
// 计算总小时数
|
// 计算总小时数
|
||||||
const totalHours = cachedData.reduce((total, day: { hours: unknown[] }) => {
|
const totalHours = (cachedData as any[]).reduce((total, day: any) => {
|
||||||
return total + day.hours.length
|
return total + day.hours.length
|
||||||
}, 0)
|
}, 0)
|
||||||
return totalHours * HOUR_WIDTH
|
return totalHours * HOUR_WIDTH
|
||||||
@@ -415,7 +401,7 @@ const totalTimelineWidth = computed(() => {
|
|||||||
} else if (currentTimeScale.value === TimelineScale.QUARTER) {
|
} else if (currentTimeScale.value === TimelineScale.QUARTER) {
|
||||||
if (Array.isArray(cachedData)) {
|
if (Array.isArray(cachedData)) {
|
||||||
// 计算总季度数:每年4个季度,每个季度60px
|
// 计算总季度数:每年4个季度,每个季度60px
|
||||||
const totalQuarters = cachedData.reduce((total, year: { quarters: unknown[] }) => {
|
const totalQuarters = (cachedData as any[]).reduce((total, year: any) => {
|
||||||
return total + year.quarters.length
|
return total + year.quarters.length
|
||||||
}, 0)
|
}, 0)
|
||||||
return totalQuarters * 60
|
return totalQuarters * 60
|
||||||
@@ -1890,7 +1876,7 @@ const yearTimelineData = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = generateYearTimelineData()
|
const data = generateYearTimelineData() as any
|
||||||
return Array.isArray(data) ? data : []
|
return Array.isArray(data) ? data : []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 发生错误时返回空数组
|
// 发生错误时返回空数组
|
||||||
@@ -2549,10 +2535,13 @@ const handleAddSuccessor = (task: Task) => {
|
|||||||
|
|
||||||
<!-- 年度视图背景列 -->
|
<!-- 年度视图背景列 -->
|
||||||
<template v-if="currentTimeScale === TimelineScale.YEAR">
|
<template v-if="currentTimeScale === TimelineScale.YEAR">
|
||||||
<template v-for="yearData in yearTimelineData" :key="`year-col-${yearData.year}`">
|
<template
|
||||||
|
v-for="yearData in yearTimelineData"
|
||||||
|
:key="`year-col-${(yearData as any).year}`"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
v-for="halfYear in yearData.halfYears || []"
|
v-for="halfYear in (yearData as any).halfYears || []"
|
||||||
:key="`halfyear-col-${yearData.year}-${halfYear.label}`"
|
:key="`halfyear-col-${(yearData as any).year}-${(halfYear as any).label}`"
|
||||||
class="half-year-column"
|
class="half-year-column"
|
||||||
:style="{ width: '180px', height: `${contentHeight}px` }"
|
:style="{ width: '180px', height: `${contentHeight}px` }"
|
||||||
></div>
|
></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user