xto-fronted 0.4.8 → 0.4.10
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/dist/assets/index-4-QoJAgA.css +1 -0
- package/dist/assets/index-BHwEwbkp.js +1 -0
- package/dist/assets/{index-Te8_PRgJ.js → index-BTsRosKu.js} +1 -1
- package/dist/assets/index-CZAlkDIC.css +1 -0
- package/dist/assets/{index-1juADvYN.js → index-Do3gMkWw.js} +2 -2
- package/dist/index.html +2 -2
- package/package.json +4 -4
- package/src/assets/styles/_dark.scss +118 -0
- package/src/assets/styles/index.scss +8 -0
- package/src/components/Layout/Header.vue +0 -5
- package/src/components/Layout/Sidebar.vue +11 -1
- package/src/components/Layout/TopMenu.vue +186 -0
- package/src/components/Layout/index.vue +120 -443
- package/vite.config.ts +1 -1
- package/dist/App.vue.d.ts +0 -2
- package/dist/api/auth.d.ts +0 -8
- package/dist/api/system.d.ts +0 -16
- package/dist/api/user.d.ts +0 -13
- package/dist/assets/index-B-sX4Ru0.js +0 -1
- package/dist/assets/index-BMcziU5a.css +0 -1
- package/dist/assets/index-BZA0ksjx.css +0 -1
- package/dist/assets/index-BvzhR4zp.js +0 -1
- package/dist/assets/index-CVjdnIgR.css +0 -1
- package/dist/assets/index-CYq57-zj.js +0 -1
- package/dist/assets/index-CkL3sVAQ.js +0 -2
- package/dist/assets/index-CtrKVYJb.css +0 -1
- package/dist/assets/index-DfFR6NLf.js +0 -1
- package/dist/assets/index-Iaz1ZzPC.js +0 -2
- package/dist/assets/index-WyZ91RLx.css +0 -1
- package/dist/assets/index-tFYRoFdE.js +0 -1
- package/dist/assets/xto-navigation-CBPg4dCc.css +0 -1
- package/dist/assets/xto-navigation-CKabFu9d.js +0 -1
- package/dist/components/Layout/Footer.vue.d.ts +0 -2
- package/dist/components/Layout/Header.vue.d.ts +0 -5
- package/dist/components/Layout/Sidebar.vue.d.ts +0 -2
- package/dist/components/Layout/Tabs.vue.d.ts +0 -2
- package/dist/components/Layout/index.vue.d.ts +0 -2
- package/dist/composables/useApp.d.ts +0 -29
- package/dist/composables/useAuth.d.ts +0 -6
- package/dist/composables/useForm.d.ts +0 -20
- package/dist/composables/useTable.d.ts +0 -29
- package/dist/directives/permission.d.ts +0 -4
- package/dist/enums/index.d.ts +0 -32
- package/dist/index-54irhCHL.js +0 -1830
- package/dist/index-BzRf1eoJ.js +0 -372
- package/dist/index-DH4aoCZb.js +0 -142
- package/dist/index-Kqa7iZ9E.js +0 -475
- package/dist/index-pxkZlvBw.js +0 -345
- package/dist/index.d.ts +0 -31
- package/dist/index.es.js +0 -91
- package/dist/index.umd.js +0 -1
- package/dist/main.d.ts +0 -0
- package/dist/router/dynamicRoutes.d.ts +0 -30
- package/dist/router/guards.d.ts +0 -17
- package/dist/router/index.d.ts +0 -6
- package/dist/router/layoutRoute.d.ts +0 -18
- package/dist/router/staticRoutes.d.ts +0 -3
- package/dist/stores/app.d.ts +0 -87
- package/dist/stores/auth.d.ts +0 -41
- package/dist/stores/index.d.ts +0 -9
- package/dist/stores/menu.d.ts +0 -77
- package/dist/stores/user.d.ts +0 -92
- package/dist/style.css +0 -1
- package/dist/utils/auth.d.ts +0 -27
- package/dist/utils/config.d.ts +0 -30
- package/dist/utils/permission.d.ts +0 -18
- package/dist/utils/request.d.ts +0 -23
- package/dist/utils/storage.d.ts +0 -24
- package/dist/views/dashboard/index.vue.d.ts +0 -2
- package/dist/views/error/403.vue.d.ts +0 -2
- package/dist/views/error/404.vue.d.ts +0 -2
- package/dist/views/login/index.vue.d.ts +0 -4
- package/dist/views/system/menu/index.vue.d.ts +0 -4
- package/dist/views/system/role/index.vue.d.ts +0 -4
- package/dist/views/system/user/index.vue.d.ts +0 -4
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
4
|
+
import { useMenuStore } from '@/stores/menu'
|
|
5
|
+
import { useAppStore } from '@/stores/app'
|
|
6
|
+
import { Menu, MenuItem, SubMenu } from '@xto/navigation'
|
|
7
|
+
import { Icon } from '@xto/base'
|
|
8
|
+
|
|
9
|
+
const route = useRoute()
|
|
10
|
+
const router = useRouter()
|
|
11
|
+
const menuStore = useMenuStore()
|
|
12
|
+
const appStore = useAppStore()
|
|
13
|
+
|
|
14
|
+
const activeMenu = computed(() => route.path)
|
|
15
|
+
|
|
16
|
+
// 菜单主题相关
|
|
17
|
+
const menuBgColor = computed(() => appStore.isDark ? '#1d1e1f' : '#fff')
|
|
18
|
+
const menuTextColor = computed(() => appStore.isDark ? '#cfd3dc' : '#303133')
|
|
19
|
+
const menuActiveTextColor = computed(() => '#409eff')
|
|
20
|
+
|
|
21
|
+
// 菜单选择
|
|
22
|
+
const handleMenuSelect = (index: string) => {
|
|
23
|
+
if (index && index !== route.path) {
|
|
24
|
+
router.push(index)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 已知的图标名称列表
|
|
29
|
+
const knownIcons = new Set([
|
|
30
|
+
'arrow-up', 'arrow-down', 'arrow-left', 'arrow-right',
|
|
31
|
+
'caret-down', 'caret-right', 'plus', 'minus', 'close', 'check',
|
|
32
|
+
'edit', 'delete', 'copy', 'download', 'upload', 'refresh', 'search',
|
|
33
|
+
'filter', 'more', 'setting', 'share', 'loading', 'info', 'success',
|
|
34
|
+
'warning', 'error', 'question', 'user', 'user-add', 'user-group',
|
|
35
|
+
'logout', 'login', 'file', 'folder', 'folder-open', 'document',
|
|
36
|
+
'image', 'video', 'music', 'camera', 'mail', 'phone', 'chat',
|
|
37
|
+
'bell', 'message', 'eye', 'eye-off', 'calendar', 'clock', 'history',
|
|
38
|
+
'timer', 'location', 'map', 'globe', 'star', 'heart', 'thumb-up',
|
|
39
|
+
'link', 'external-link', 'lock', 'unlock', 'key', 'home', 'menu',
|
|
40
|
+
'menu-fold', 'menu-unfold', 'sidebar-fold', 'sidebar-expand',
|
|
41
|
+
'sidebar-left', 'dashboard', 'chart', 'chart-pie', 'chart-line',
|
|
42
|
+
'report', 'analytics', 'system', 'permission', 'role', 'user-manage',
|
|
43
|
+
'log', 'notification', 'app', 'list', 'grid', 'fullscreen',
|
|
44
|
+
'fullscreen-exit', 'zoom-in', 'zoom-out', 'print', 'bookmark',
|
|
45
|
+
'tag', 'code', 'terminal', 'database', 'server', 'cloud', 'gift',
|
|
46
|
+
'moon', 'sun', 'theme', 'skin'
|
|
47
|
+
])
|
|
48
|
+
|
|
49
|
+
// 获取菜单图标名称
|
|
50
|
+
const getMenuIcon = (icon?: string): string => {
|
|
51
|
+
if (!icon || icon === '') return ''
|
|
52
|
+
|
|
53
|
+
if (icon.startsWith('tineco-icon-')) {
|
|
54
|
+
const iconName = icon.replace('tineco-icon-', '')
|
|
55
|
+
const tinecoIconMap: Record<string, string> = {
|
|
56
|
+
home: 'home',
|
|
57
|
+
dashboard: 'dashboard',
|
|
58
|
+
system: 'system',
|
|
59
|
+
user: 'user',
|
|
60
|
+
role: 'role',
|
|
61
|
+
menu: 'list',
|
|
62
|
+
setting: 'setting',
|
|
63
|
+
file: 'file',
|
|
64
|
+
folder: 'folder',
|
|
65
|
+
chart: 'chart',
|
|
66
|
+
report: 'report',
|
|
67
|
+
analytics: 'analytics'
|
|
68
|
+
}
|
|
69
|
+
return tinecoIconMap[iconName] || iconName
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const iconMap: Record<string, string> = {
|
|
73
|
+
dashboard: 'dashboard',
|
|
74
|
+
system: 'system',
|
|
75
|
+
user: 'user',
|
|
76
|
+
role: 'role',
|
|
77
|
+
menu: 'list',
|
|
78
|
+
setting: 'setting',
|
|
79
|
+
home: 'home',
|
|
80
|
+
chart: 'chart',
|
|
81
|
+
report: 'report',
|
|
82
|
+
analytics: 'analytics',
|
|
83
|
+
permission: 'permission',
|
|
84
|
+
log: 'log',
|
|
85
|
+
notification: 'notification',
|
|
86
|
+
app: 'app',
|
|
87
|
+
list: 'list',
|
|
88
|
+
grid: 'grid'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return iconMap[icon] || icon
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const getFirstChar = (name?: string): string => {
|
|
95
|
+
if (!name) return ''
|
|
96
|
+
return name.charAt(0)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const iconExists = (iconName: string): boolean => {
|
|
100
|
+
return knownIcons.has(iconName)
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<div class="top-menu">
|
|
106
|
+
<Menu
|
|
107
|
+
:default-active="activeMenu"
|
|
108
|
+
mode="horizontal"
|
|
109
|
+
:background-color="menuBgColor"
|
|
110
|
+
:text-color="menuTextColor"
|
|
111
|
+
:active-text-color="menuActiveTextColor"
|
|
112
|
+
class="top-menu__menu"
|
|
113
|
+
@select="handleMenuSelect"
|
|
114
|
+
>
|
|
115
|
+
<template v-for="menu in menuStore.menuList" :key="menu.menuUrl">
|
|
116
|
+
<!-- 有子菜单 -->
|
|
117
|
+
<SubMenu v-if="menu.children && menu.children.length > 0" :index="menu.menuUrl">
|
|
118
|
+
<template #title>
|
|
119
|
+
<span class="top-menu__menu-icon">
|
|
120
|
+
<Icon v-if="iconExists(getMenuIcon(menu.icon))" :name="getMenuIcon(menu.icon)" :size="16" />
|
|
121
|
+
<span v-else class="top-menu__menu-char">{{ getFirstChar(menu.menuName) }}</span>
|
|
122
|
+
</span>
|
|
123
|
+
<span>{{ menu.menuName }}</span>
|
|
124
|
+
</template>
|
|
125
|
+
<MenuItem
|
|
126
|
+
v-for="child in menu.children"
|
|
127
|
+
:key="child.menuUrl"
|
|
128
|
+
:index="child.menuUrl"
|
|
129
|
+
>
|
|
130
|
+
<span class="top-menu__menu-icon">
|
|
131
|
+
<Icon v-if="iconExists(getMenuIcon(child.icon))" :name="getMenuIcon(child.icon)" :size="16" />
|
|
132
|
+
<span v-else class="top-menu__menu-char">{{ getFirstChar(child.menuName) }}</span>
|
|
133
|
+
</span>
|
|
134
|
+
<span>{{ child.menuName }}</span>
|
|
135
|
+
</MenuItem>
|
|
136
|
+
</SubMenu>
|
|
137
|
+
<!-- 无子菜单 -->
|
|
138
|
+
<MenuItem v-else :index="menu.menuUrl">
|
|
139
|
+
<span class="top-menu__menu-icon">
|
|
140
|
+
<Icon v-if="iconExists(getMenuIcon(menu.icon))" :name="getMenuIcon(menu.icon)" :size="16" />
|
|
141
|
+
<span v-else class="top-menu__menu-char">{{ getFirstChar(menu.menuName) }}</span>
|
|
142
|
+
</span>
|
|
143
|
+
<span>{{ menu.menuName }}</span>
|
|
144
|
+
</MenuItem>
|
|
145
|
+
</template>
|
|
146
|
+
</Menu>
|
|
147
|
+
</div>
|
|
148
|
+
</template>
|
|
149
|
+
|
|
150
|
+
<style lang="scss" scoped>
|
|
151
|
+
.top-menu {
|
|
152
|
+
width: 100%;
|
|
153
|
+
height: 100%;
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
padding: 0 20px;
|
|
157
|
+
|
|
158
|
+
&__menu {
|
|
159
|
+
flex: 1;
|
|
160
|
+
border-bottom: none;
|
|
161
|
+
height: 100%;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&__menu-icon {
|
|
165
|
+
display: inline-flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
width: 16px;
|
|
169
|
+
height: 16px;
|
|
170
|
+
margin-right: 8px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
&__menu-char {
|
|
174
|
+
display: inline-flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
width: 16px;
|
|
178
|
+
height: 16px;
|
|
179
|
+
font-size: 12px;
|
|
180
|
+
font-weight: 600;
|
|
181
|
+
color: var(--color-primary);
|
|
182
|
+
background-color: var(--color-primary-light-8);
|
|
183
|
+
border-radius: 4px;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
</style>
|