Added calendar config base
This commit is contained in:
60
src/stores/calendar.ts
Normal file
60
src/stores/calendar.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { computed, ref, type Ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
type CalendarPeriod = 'ante' | 'nante'
|
||||
|
||||
type CalendarStaticConfig = {
|
||||
months: string[]
|
||||
monthsPerYear: number
|
||||
daysPerYear: number
|
||||
daysPerMonth: number
|
||||
daysPerWeek: number
|
||||
}
|
||||
|
||||
type CalendarCurrentConfig = {
|
||||
currentPeriod: Ref<CalendarPeriod>
|
||||
currentYear: Ref<number>
|
||||
currentMonth: Ref<number>
|
||||
currentDay: Ref<number>
|
||||
}
|
||||
|
||||
export const useCalendar = defineStore('calendar', () => {
|
||||
const months = [
|
||||
'Jalen',
|
||||
'Malsen',
|
||||
'Verlys',
|
||||
'Nalys',
|
||||
'Verdore',
|
||||
'Sidore',
|
||||
'Lyllion',
|
||||
'Rion',
|
||||
'Farene',
|
||||
'Dalvene'
|
||||
]
|
||||
const monthsPerYear = computed(() => months.length)
|
||||
const daysPerYear = 320
|
||||
const daysPerMonth = computed(() => daysPerYear / monthsPerYear.value)
|
||||
const daysPerWeek = 6
|
||||
|
||||
const staticConfig: CalendarStaticConfig = {
|
||||
months,
|
||||
monthsPerYear: monthsPerYear.value,
|
||||
daysPerYear,
|
||||
daysPerMonth: daysPerMonth.value,
|
||||
daysPerWeek
|
||||
}
|
||||
|
||||
const currentPeriod: Ref<'nante' | 'ante'> = ref('nante')
|
||||
const currentYear = ref(3209)
|
||||
const currentMonth = ref(8)
|
||||
const currentDay = ref(12)
|
||||
|
||||
const config: CalendarCurrentConfig = {
|
||||
currentPeriod,
|
||||
currentYear,
|
||||
currentMonth,
|
||||
currentDay
|
||||
}
|
||||
|
||||
return { staticConfig, config }
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useCounterStore = defineStore('counter', () => {
|
||||
const count = ref(0)
|
||||
const doubleCount = computed(() => count.value * 2)
|
||||
function increment() {
|
||||
count.value++
|
||||
}
|
||||
|
||||
return { count, doubleCount, increment }
|
||||
})
|
||||
@@ -1,5 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { useCalendar } from '@/stores/calendar'
|
||||
|
||||
const c = useCalendar()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="container">
|
||||
<h1 class="text-3xl font-bold">Hello world!</h1>
|
||||
<h1 class="text-3xl font-bold">{{ c }}</h1>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user