xto-fronted 0.9.3 → 0.9.4

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.
@@ -29,10 +29,70 @@ const knownIcons = new Set([
29
29
  'moon', 'sun', 'theme', 'skin'
30
30
  ])
31
31
 
32
+ // Element UI(el-icon-*)图标名到组件库图标名的映射:
33
+ // sys_menu.icon 大量使用 el-icon-* 命名,不映射时只能退化为首字徽标
34
+ const elIconMap: Record<string, string> = {
35
+ 'el-icon-s-platform': 'system',
36
+ 'el-icon-platform': 'system',
37
+ 'el-icon-s-data': 'database',
38
+ 'el-icon-data-analysis': 'chart',
39
+ 'el-icon-files': 'folder',
40
+ 'el-icon-folder': 'folder',
41
+ 'el-icon-folder-opened': 'folder-open',
42
+ 'el-icon-s-custom': 'user',
43
+ 'el-icon-user': 'user',
44
+ 'el-icon-s-grid': 'grid',
45
+ 'el-icon-menu': 'list',
46
+ 'el-icon-setting': 'setting',
47
+ 'el-icon-s-tools': 'setting',
48
+ 'el-icon-s-operation': 'setting',
49
+ 'el-icon-s-home': 'home',
50
+ 'el-icon-house': 'home',
51
+ 'el-icon-document': 'document',
52
+ 'el-icon-document-copy': 'copy',
53
+ 'el-icon-monitor': 'dashboard',
54
+ 'el-icon-odometer': 'dashboard',
55
+ 'el-icon-s-order': 'list',
56
+ 'el-icon-s-check': 'check',
57
+ 'el-icon-s-claim': 'file',
58
+ 'el-icon-s-comment': 'message',
59
+ 'el-icon-s-promotion': 'share',
60
+ 'el-icon-s-marketing': 'chart',
61
+ 'el-icon-s-finance': 'chart',
62
+ 'el-icon-s-management': 'list',
63
+ 'el-icon-s-cooperation': 'user-group',
64
+ 'el-icon-s-shop': 'gift',
65
+ 'el-icon-picture': 'image',
66
+ 'el-icon-location': 'location',
67
+ 'el-icon-map-location': 'map',
68
+ 'el-icon-lock': 'lock',
69
+ 'el-icon-unlock': 'unlock',
70
+ 'el-icon-key': 'key',
71
+ 'el-icon-bell': 'bell',
72
+ 'el-icon-edit': 'edit',
73
+ 'el-icon-delete': 'delete',
74
+ 'el-icon-link': 'link',
75
+ 'el-icon-connection': 'link',
76
+ 'el-icon-upload': 'upload',
77
+ 'el-icon-upload2': 'upload',
78
+ 'el-icon-download': 'download',
79
+ 'el-icon-search': 'search',
80
+ 'el-icon-timer': 'clock',
81
+ 'el-icon-time': 'clock',
82
+ 'el-icon-calendar': 'calendar',
83
+ 'el-icon-view': 'eye',
84
+ 'el-icon-message': 'mail',
85
+ 'el-icon-chat-dot-round': 'chat',
86
+ 'el-icon-cpu': 'server',
87
+ 'el-icon-cloudy': 'cloud'
88
+ }
89
+
32
90
  // 获取菜单图标名称
33
91
  const getMenuIcon = (icon?: string): string => {
34
92
  if (!icon || icon === '') return ''
35
93
 
94
+ if (elIconMap[icon]) return elIconMap[icon]
95
+
36
96
  if (icon.startsWith('tineco-icon-')) {
37
97
  const iconName = icon.replace('tineco-icon-', '')
38
98
  const tinecoIconMap: Record<string, string> = {
@@ -74,7 +134,7 @@ const getMenuIcon = (icon?: string): string => {
74
134
  return iconMap[icon] || icon
75
135
  }
76
136
 
77
- // 获取菜单名称第一个字
137
+ // 获取菜单名称第一个字(无匹配图标时的兜底)
78
138
  const getFirstChar = (name?: string): string => {
79
139
  if (!name) return ''
80
140
  return name.charAt(0)
@@ -99,15 +159,11 @@ const hasChildren = computed(() => {
99
159
  <template>
100
160
  <!-- 有子菜单 -->
101
161
  <SubMenu v-if="hasChildren" :index="menuIndex">
102
- <template #title>
103
- <span class="menu-item__content">
104
- <span class="menu-item__icon">
105
- <Icon v-if="iconExists(getMenuIcon(menu.icon))" :name="getMenuIcon(menu.icon)" :size="16" />
106
- <span v-else class="menu-item__char">{{ getFirstChar(menu.menuName) }}</span>
107
- </span>
108
- <span class="menu-item__text">{{ menu.menuName }}</span>
109
- </span>
162
+ <template #icon>
163
+ <Icon v-if="iconExists(getMenuIcon(menu.icon))" :name="getMenuIcon(menu.icon)" :size="16" />
164
+ <span v-else class="menu-item__char">{{ getFirstChar(menu.menuName) }}</span>
110
165
  </template>
166
+ <template #title>{{ menu.menuName }}</template>
111
167
  <!-- 递归渲染子菜单 -->
112
168
  <template v-for="child in menu.children" :key="child.menuId || child.menuCode || child.menuUrl">
113
169
  <SidebarMenuItem :menu="child" />
@@ -116,38 +172,15 @@ const hasChildren = computed(() => {
116
172
 
117
173
  <!-- 无子菜单 -->
118
174
  <MenuItem v-else :index="menu.menuUrl || menuIndex">
119
- <span class="menu-item__content">
120
- <span v-if="menu.menuName !== '首页'" class="menu-item__icon">
121
- <Icon v-if="iconExists(getMenuIcon(menu.icon))" :name="getMenuIcon(menu.icon)" :size="16" />
122
- <span v-else class="menu-item__char">{{ getFirstChar(menu.menuName) }}</span>
123
- </span>
124
- <span class="menu-item__text">{{ menu.menuName }}</span>
125
- </span>
175
+ <template #icon>
176
+ <Icon v-if="iconExists(getMenuIcon(menu.icon))" :name="getMenuIcon(menu.icon)" :size="16" />
177
+ <span v-else class="menu-item__char">{{ getFirstChar(menu.menuName) }}</span>
178
+ </template>
179
+ {{ menu.menuName }}
126
180
  </MenuItem>
127
181
  </template>
128
182
 
129
183
  <style lang="scss" scoped>
130
- .menu-item__content {
131
- display: inline-flex;
132
- align-items: center;
133
- line-height: 1;
134
- }
135
-
136
- .menu-item__text {
137
- flex: 1;
138
- line-height: 1;
139
- }
140
-
141
- .menu-item__icon {
142
- display: inline-flex;
143
- align-items: center;
144
- justify-content: center;
145
- width: 16px;
146
- height: 16px;
147
- margin-right: 8px;
148
- flex-shrink: 0;
149
- }
150
-
151
184
  .menu-item__char {
152
185
  display: inline-flex;
153
186
  align-items: center;
@@ -53,7 +53,11 @@ const showMixSidebar = computed(() => {
53
53
  <template>
54
54
  <!-- sidebar模式:左侧菜单 + 顶部Header + 主内容 -->
55
55
  <div v-if="layoutMode === 'sidebar'" class="layout layout--sidebar">
56
- <aside class="layout__aside" :style="{ width: sidebarWidth }">
56
+ <aside
57
+ class="layout__aside"
58
+ :class="{ 'layout__aside--collapsed': appStore.isCollapsed }"
59
+ :style="{ width: sidebarWidth }"
60
+ >
57
61
  <Sidebar :menu-list="sidebarMenuList" :show-logo="true" :show-user="true" :logo-src="resolvedLogoSrc" />
58
62
  </aside>
59
63
  <div class="layout__main">
@@ -86,7 +90,12 @@ const showMixSidebar = computed(() => {
86
90
  </div>
87
91
  <!-- 下方:左侧子菜单 + 主内容 -->
88
92
  <div class="layout__mix-body">
89
- <aside v-if="showMixSidebar" class="layout__aside" :style="{ width: sidebarWidth }">
93
+ <aside
94
+ v-if="showMixSidebar"
95
+ class="layout__aside"
96
+ :class="{ 'layout__aside--collapsed': appStore.isCollapsed }"
97
+ :style="{ width: sidebarWidth }"
98
+ >
90
99
  <Sidebar :menu-list="sidebarMenuList" :show-logo="false" :show-user="false" />
91
100
  </aside>
92
101
  <main class="layout__content">
@@ -159,6 +168,11 @@ const showMixSidebar = computed(() => {
159
168
  overflow: hidden;
160
169
  flex-shrink: 0;
161
170
  height: 100%;
171
+
172
+ // 折叠态:弹出子菜单浮层需要溢出侧栏显示
173
+ &--collapsed {
174
+ overflow: visible;
175
+ }
162
176
  }
163
177
 
164
178
  &__top-menu {