Skip to content

Commit

Permalink
refactor check service open
Browse files Browse the repository at this point in the history
  • Loading branch information
da-in committed Mar 16, 2024
1 parent b923f7e commit beedc46
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/ZInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const filled = computed(() => props.modelValue.length > 0)
const onInupt = (event: Event) => {
const target = event.target as HTMLInputElement
target.value = target.value.slice(0, 8)
target.value = target.value.replace(/^\s*/, '').slice(0, 8)
emit('update:model-value', target.value)
}
Expand Down
13 changes: 3 additions & 10 deletions src/pages/home/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,21 @@ import title from '../../assets/title-beta.svg'
import illustration from '../../assets/illustration.svg'
import ZButton from '../../components/button/ZButton.vue'
import Footer from '../../components/Footer.vue'
import {onBeforeUnmount, ref, watch} from 'vue'
import {onBeforeUnmount, ref} from 'vue'
import Notice from './_components/Notice.vue'
import ZInput from '../../components/ZInput.vue'
import {useRouter} from 'vue-router'
import {useUserStore} from '../../stores/user.ts'
import {isOpen} from '../../utils/check-open.ts'
const router = useRouter()
const userStore = useUserStore()
const closedRef = ref(false)
const currentTime = ref(new Date())
const targetTime = new Date('2024-03-17T19:00:00+09:00')
const interval = setInterval(() => {
currentTime.value = new Date()
closedRef.value = !isOpen()
}, 1000)
watch(currentTime, () => {
if (currentTime.value > targetTime) {
closedRef.value = true
}
})
onBeforeUnmount(() => clearInterval(interval))
const onClickPlay = () => {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/check-open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const isOpen = () => {
const targetTime = new Date('2024-03-17T19:00:00+09:00')
const current = new Date()
return current < targetTime
}

0 comments on commit beedc46

Please sign in to comment.