first commit after refactor to vite
This commit is contained in:
40
src/views/Home.vue
Normal file
40
src/views/Home.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template lang="pug">
|
||||
|
||||
p SelectedMonth: {{selectedMonth}}, SelectedYear: {{selectedYear}}
|
||||
|
||||
MonthPicker(:selectedMonth="selectedMonth" :selectedYear="selectedYear" state="closed")
|
||||
|
||||
div(class="mt-5" v-for="(month, index) in months" :key="index")
|
||||
Schedule( :startDate="month" :initialOffset="iOffsets[index]")
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { getYear, getMonth, eachMonthOfInterval, getDaysInMonth, getISODay } from 'date-fns'
|
||||
import Schedule from '/src/components/Schedule.vue'
|
||||
import MonthPicker from '/src/components/MonthPicker.vue'
|
||||
|
||||
const selectedMonth = ref(getMonth(new Date()))
|
||||
const selectedYear = ref(getYear(new Date()))
|
||||
|
||||
const months = computed(() => {
|
||||
return eachMonthOfInterval({
|
||||
start: new Date(selectedYear.value, selectedMonth.value - 1),
|
||||
end : new Date(selectedYear.value, selectedMonth.value + 1)
|
||||
})
|
||||
})
|
||||
|
||||
const iOffsets = computed(() => {
|
||||
let arr : number[] = []
|
||||
arr.push(0)
|
||||
|
||||
months.value.forEach(month => {
|
||||
if ( getDaysInMonth(month) + getISODay(month) - 1 + arr[arr.length - 1] > 34) {
|
||||
arr.push(7)
|
||||
}
|
||||
else arr.push(0)
|
||||
})
|
||||
return arr
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user