forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic.vue
More file actions
46 lines (40 loc) · 1.03 KB
/
Basic.vue
File metadata and controls
46 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<template>
<div class="q-pa-md">
<div>
Switch to another browser tab or app then come back here to see some changes.
</div>
<q-markup-table v-if="eventList.length > 0" class="q-mt-md">
<tbody>
<tr v-for="evt in eventList" :key="evt.timestamp">
<td>{{ evt.timestamp }}</td>
<td>{{ evt.label }}</td>
</tr>
</tbody>
</q-markup-table>
</div>
</template>
<script>
import { useQuasar } from 'quasar'
import { ref, watch } from 'vue'
function pad (number) {
return (number < 10 ? '0' : '') + number
}
export default {
setup () {
const $q = useQuasar()
const eventList = ref([])
watch(() => $q.appVisible, state => {
const date = new Date()
eventList.value.unshift({
timestamp: pad(date.getHours()) + ':' +
pad(date.getMinutes()) + ':' + pad(date.getSeconds()) + '.' +
date.getMilliseconds(),
label: `App became ${state ? 'visible' : 'hidden'}`
})
})
return {
eventList
}
}
}
</script>