@aquiferre/ui-kit 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/SideMenu.vue +23 -8
- package/package.json +1 -1
package/components/SideMenu.vue
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<aside class="sidebar" style="width: 200px
|
|
3
|
-
<
|
|
2
|
+
<aside class="sidebar transition-all duration-200" :style="{ width: collapsed ? '52px' : '200px' }" :data-testid="baseTestId">
|
|
3
|
+
<div class="flex items-center justify-end px-1 pt-2 pb-1">
|
|
4
|
+
<button
|
|
5
|
+
v-if="collapsible"
|
|
6
|
+
class="sidebar-collapse-btn text-xs w-5 h-5 flex items-center justify-center rounded hover:bg-white/10 transition-colors"
|
|
7
|
+
:title="collapsed ? '展开菜单' : '收起菜单'"
|
|
8
|
+
@click="collapsed = !collapsed"
|
|
9
|
+
>{{ collapsed ? '▶' : '◀' }}</button>
|
|
10
|
+
</div>
|
|
11
|
+
<nav class="mt-1">
|
|
4
12
|
<router-link
|
|
13
|
+
v-if="showHome"
|
|
5
14
|
to="/"
|
|
6
15
|
class="sidebar-item text-xs"
|
|
7
16
|
exact-active-class="sidebar-item-active"
|
|
8
17
|
:data-testid="baseTestId ? `${baseTestId}-item-home` : undefined"
|
|
18
|
+
:title="collapsed ? '首页' : undefined"
|
|
9
19
|
>
|
|
10
20
|
<span class="w-5 text-center text-sm">🏠</span>
|
|
11
|
-
<span class="ml-2">首页</span>
|
|
21
|
+
<span v-if="!collapsed" class="ml-2">首页</span>
|
|
12
22
|
</router-link>
|
|
13
23
|
|
|
14
24
|
<template v-for="group in menuGroups" :key="group.key">
|
|
15
|
-
<div class="sidebar-section-title text-[10px]">{{ group.label }}</div>
|
|
25
|
+
<div v-if="!collapsed" class="sidebar-section-title text-[10px]">{{ group.label }}</div>
|
|
16
26
|
<router-link
|
|
17
27
|
v-for="item in group.items"
|
|
18
28
|
:key="item.path"
|
|
@@ -20,9 +30,10 @@
|
|
|
20
30
|
class="sidebar-item text-xs"
|
|
21
31
|
active-class="sidebar-item-active"
|
|
22
32
|
:data-testid="baseTestId ? `${baseTestId}-item-${item.path}` : undefined"
|
|
33
|
+
:title="collapsed ? item.label : undefined"
|
|
23
34
|
>
|
|
24
35
|
<span class="w-5 text-center text-sm">{{ item.icon }}</span>
|
|
25
|
-
<span class="ml-2">{{ item.label }}</span>
|
|
36
|
+
<span v-if="!collapsed" class="ml-2">{{ item.label }}</span>
|
|
26
37
|
</router-link>
|
|
27
38
|
</template>
|
|
28
39
|
</nav>
|
|
@@ -30,14 +41,18 @@
|
|
|
30
41
|
</template>
|
|
31
42
|
|
|
32
43
|
<script setup lang="ts">
|
|
33
|
-
import { computed, useAttrs } from 'vue'
|
|
44
|
+
import { computed, ref, useAttrs } from 'vue'
|
|
34
45
|
import type { MenuGroup } from '../types'
|
|
35
46
|
|
|
36
47
|
const props = withDefaults(defineProps<{
|
|
37
48
|
menuGroups: MenuGroup[]
|
|
38
49
|
testId?: string
|
|
39
|
-
|
|
50
|
+
collapsible?: boolean
|
|
51
|
+
showHome?: boolean
|
|
52
|
+
}>(), { collapsible: false, showHome: true })
|
|
53
|
+
|
|
54
|
+
const collapsed = ref(false)
|
|
40
55
|
|
|
41
56
|
const attrs = useAttrs()
|
|
42
57
|
const baseTestId = computed<string | undefined>(() => props.testId ?? (attrs['data-testid'] as string | undefined))
|
|
43
|
-
</script>
|
|
58
|
+
</script>
|