| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <template>
- <v-alert
- v-model="show"
- :type="alert.type"
- class="position"
- border="left"
- width="400"
- dismissible
- transition="fade-transition"
- @mouseover="onMouseOver"
- @mouseout="onMouseOut"
- >
- {{ $t(alert.message) }}
- </v-alert>
- </template>
- <script lang="ts">
- import { defineComponent, ref, Ref } from '@vue/composition-api'
- import { useContext } from '@nuxtjs/composition-api'
- import { alert } from '~/types/interfaces'
- export default defineComponent({
- props: {
- alert: {
- type: Object as () => alert,
- required: true
- }
- },
- setup () {
- const { store } = useContext()
- const show:Ref<boolean> = ref(true)
- let timeout: any = null
- const clearAlert = (time:number = 2000) => {
- timeout = setTimeout(() => {
- show.value = false
- store.dispatch('page/removeSlowlyAlert')
- }, time)
- }
- const onMouseOver = () => {
- clearTimeout(timeout)
- }
- const onMouseOut = () => {
- clearAlert(1000)
- }
- clearAlert()
- return {
- show,
- onMouseOver,
- onMouseOut
- }
- }
- })
- </script>
- <style scoped>
- </style>
|