File tree 1 file changed +55
-4
lines changed
apps/client/src/components
1 file changed +55
-4
lines changed Original file line number Diff line number Diff line change 5
5
:active =" active"
6
6
v-ripple
7
7
:disable =" disable"
8
+ v-bind =" {
9
+ ...$attrs,
10
+
11
+ onClick: (...args) => onClick(args, $attrs),
12
+ }"
8
13
>
9
14
<q-item-section avatar >
10
- <q-icon :name =" icon" />
15
+ <q-circular-progress
16
+ v-if =" loading"
17
+ indeterminate
18
+ size =" 20px"
19
+ style =" margin-left : 2px "
20
+ />
21
+
22
+ <q-icon
23
+ v-else
24
+ :name =" icon"
25
+ />
11
26
</q-item-section >
12
27
13
28
<q-tooltip
25
40
</q-item >
26
41
</template >
27
42
28
- <script setup lang="ts">
29
- defineProps <{
43
+ <script lang="ts">
44
+ export default {
45
+ inheritAttrs: false ,
46
+ };
47
+
48
+ export interface MiniSidebarBtnProps extends QItemProps {
49
+ delay? : boolean ;
30
50
active? : boolean ;
31
51
icon: string ;
32
52
tooltip: string ;
33
53
disable? : boolean ;
34
- }>();
54
+ }
55
+ </script >
56
+
57
+ <script setup lang="ts">
58
+ import { sleep } from ' @stdlib/misc' ;
59
+ import type { QItemProps } from ' quasar' ;
60
+
61
+ const props = defineProps <MiniSidebarBtnProps >();
62
+
63
+ const loading = ref (false );
64
+
65
+ async function onClick(args : any [], attrs : any ) {
66
+ if (attrs .onClick == null ) {
67
+ return ;
68
+ }
69
+
70
+ args [0 ].preventDefault ();
71
+
72
+ loading .value = true ;
73
+
74
+ if (props .delay ) {
75
+ await sleep (500 );
76
+ }
77
+
78
+ try {
79
+ await attrs .onClick (... args );
80
+ } catch (error ) {
81
+ mainLogger .error (error );
82
+ }
83
+
84
+ loading .value = false ;
85
+ }
35
86
</script >
You can’t perform that action at this time.
0 commit comments