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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<template>
<q-item
clickable
@click="onClick"
:active="pageStore.activeRouter?.path === link ? true : false"
active-class="bg-primary-bg-light"
>
<q-item-section v-if="icon" avatar>
<q-avatar size="md" square>
<img :src="icon" />
</q-avatar>
</q-item-section>
<q-item-section>
<q-item-label>{{ title }}</q-item-label>
<q-item-label caption>{{ caption }}</q-item-label>
</q-item-section>
</q-item>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';
import { useRouter } from 'vue-router';
import { usePageStore } from 'src/common/hooks';
export default defineComponent({
name: 'EssentialLink',
props: {
active: {
type: Boolean,
required: true,
},
title: {
type: String,
required: true,
},
caption: {
type: String,
default: '',
},
link: {
type: String,
default: '#',
},
icon: {
type: String,
default: '',
},
},
setup(props) {
const pageStore = usePageStore();
const router = useRouter();
const state = reactive({
//
});
const onClick = () => {
const currentRouter = router.currentRoute.value.path;
if (currentRouter === props.link) return;
router.push(props.link);
};
return {
...toRefs(state),
onClick,
pageStore,
};
},
});
</script>