Skip to content

Commit

Permalink
fix: 🐛今天线错位
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjone committed May 11, 2023
1 parent faebcc7 commit 45b15fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/composables/useToday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ export default () => {
const { ganttColumnWidth, currentMillisecond } = useGanttWidth();

const today = new XDate();
today.date.setHours(0);
today.date.setMinutes(0);
today.date.setSeconds(0);
today.startOf();

const todayLeft = computed(
() =>
(today.intervalTo($data.start) / currentMillisecond.value) *
const todayLeft = computed(() => {
const start = $data.start?.clone();
start?.startOf();
return (
(today.intervalTo(start) / currentMillisecond.value) *
ganttColumnWidth.value
);
);
});

const showToday = computed(() => {
function isInArea(date: XDate) {
Expand Down
10 changes: 10 additions & 0 deletions src/models/param/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,14 @@ export class XDate {
const d = day(this.date).day();
return d === 6 || d === 0;
}

/**
* 将日期置为当日最开始(0点0分0秒)
*/
startOf() {
this.date.setHours(0);
this.date.setMinutes(0);
this.date.setSeconds(0);
this.date.setMilliseconds(0);
}
}

0 comments on commit 45b15fe

Please sign in to comment.