xto-fronted 0.3.3 → 0.3.5

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.
@@ -8,6 +8,7 @@ import { useAppStore } from '@/stores/app'
8
8
  import { Menu, MenuItem, SubMenu } from '@xto/navigation'
9
9
  import { Button } from '@xto/base'
10
10
  import { Input } from '@xto/form'
11
+ import { Icon } from '@xto/base'
11
12
  import type { MenuItem as MenuItemType } from '@/types/api'
12
13
 
13
14
  const route = useRoute()
@@ -91,26 +92,26 @@ const handleLogout = () => {
91
92
  router.push('/login')
92
93
  }
93
94
 
94
- // 菜单图标
95
- const getMenuIcon = (icon?: string) => {
95
+ // 获取菜单图标名称
96
+ const getMenuIcon = (icon?: string): string => {
96
97
  const iconMap: Record<string, string> = {
97
- dashboard: '📊',
98
- system: '⚙️',
99
- user: '👤',
100
- role: '👥',
101
- menu: '📋',
102
- setting: '🔧'
98
+ dashboard: 'dashboard',
99
+ system: 'system',
100
+ user: 'user',
101
+ role: 'role',
102
+ menu: 'list',
103
+ setting: 'setting'
103
104
  }
104
- return iconMap[icon || ''] || '📄'
105
+ return iconMap[icon || ''] || 'file'
105
106
  }
106
107
  </script>
107
108
 
108
109
  <template>
109
- <div class="sidebar">
110
+ <div class="sidebar" :class="{ 'sidebar--collapsed': isCollapsed }">
110
111
  <!-- Logo -->
111
112
  <div class="sidebar__logo">
112
113
  <img src="/vite.svg" alt="Logo" class="sidebar__logo-img" />
113
- <span v-show="!isCollapsed" class="sidebar__logo-text">Xto Demo</span>
114
+ <span v-show="!isCollapsed" class="sidebar__logo-text">{{ appStore.appName }}</span>
114
115
  </div>
115
116
 
116
117
  <!-- 搜索框 -->
@@ -129,7 +130,7 @@ const getMenuIcon = (icon?: string) => {
129
130
  class="sidebar__search-item"
130
131
  @click="handleSearchItemClick(item.path)"
131
132
  >
132
- <span class="menu-icon">{{ getMenuIcon(item.icon) }}</span>
133
+ <Icon :name="getMenuIcon(item.icon)" :size="16" />
133
134
  <div class="sidebar__search-item-info">
134
135
  <span class="sidebar__search-item-title">{{ item.title }}</span>
135
136
  <span v-if="item.parentTitle" class="sidebar__search-item-parent">{{ item.parentTitle }}</span>
@@ -141,6 +142,7 @@ const getMenuIcon = (icon?: string) => {
141
142
  <!-- 菜单 -->
142
143
  <Menu
143
144
  :default-active="activeMenu"
145
+ mode="vertical"
144
146
  :collapse="isCollapsed"
145
147
  :collapse-transition="false"
146
148
  :background-color="menuBgColor"
@@ -153,7 +155,7 @@ const getMenuIcon = (icon?: string) => {
153
155
  <!-- 有子菜单 -->
154
156
  <SubMenu v-if="menu.children && menu.children.length > 0" :index="menu.path">
155
157
  <template #title>
156
- <span class="menu-icon">{{ getMenuIcon(menu.icon) }}</span>
158
+ <Icon :name="getMenuIcon(menu.icon)" :size="16" />
157
159
  <span>{{ menu.title }}</span>
158
160
  </template>
159
161
  <MenuItem
@@ -161,23 +163,23 @@ const getMenuIcon = (icon?: string) => {
161
163
  :key="child.path"
162
164
  :index="child.path"
163
165
  >
164
- <span class="menu-icon">{{ getMenuIcon(child.icon) }}</span>
166
+ <Icon :name="getMenuIcon(child.icon)" :size="16" />
165
167
  <span>{{ child.title }}</span>
166
168
  </MenuItem>
167
169
  </SubMenu>
168
170
  <!-- 无子菜单 -->
169
171
  <MenuItem v-else :index="menu.path">
170
- <span class="menu-icon">{{ getMenuIcon(menu.icon) }}</span>
172
+ <Icon :name="getMenuIcon(menu.icon)" :size="16" />
171
173
  <span>{{ menu.title }}</span>
172
174
  </MenuItem>
173
175
  </template>
174
176
  </Menu>
175
177
 
176
178
  <!-- 用户信息 -->
177
- <div class="sidebar__user" v-if="!isCollapsed">
179
+ <div v-if="!isCollapsed" class="sidebar__user">
178
180
  <div class="sidebar__user-info">
179
181
  <span class="sidebar__user-name">{{ userStore.nickname }}</span>
180
- <span class="sidebar__user-role">{{ userStore.roles.join(', ') }}</span>
182
+ <span class="sidebar__user-role">{{ userStore.roles?.join(', ') }}</span>
181
183
  </div>
182
184
  <Button type="text" size="small" @click="handleLogout">退出</Button>
183
185
  </div>
@@ -190,12 +192,20 @@ const getMenuIcon = (icon?: string) => {
190
192
  display: flex;
191
193
  flex-direction: column;
192
194
  background-color: var(--bg-color);
195
+ border-right: 1px solid var(--color-border-lighter);
196
+
197
+ &--collapsed {
198
+ .sidebar__logo {
199
+ justify-content: center;
200
+ padding: 0;
201
+ }
202
+ }
193
203
 
194
204
  &__logo {
195
205
  height: 50px;
196
206
  display: flex;
197
207
  align-items: center;
198
- justify-content: center;
208
+ padding: 0 20px;
199
209
  gap: 10px;
200
210
  border-bottom: 1px solid var(--color-border-lighter);
201
211
  }
@@ -290,8 +300,4 @@ const getMenuIcon = (icon?: string) => {
290
300
  color: var(--color-text-secondary);
291
301
  }
292
302
  }
293
-
294
- .menu-icon {
295
- margin-right: 8px;
296
- }
297
303
  </style>
@@ -17,7 +17,9 @@ const sidebarWidth = computed(() =>
17
17
  <Sidebar />
18
18
  </aside>
19
19
  <div class="layout__main">
20
- <Header class="layout__header" />
20
+ <header class="layout__header">
21
+ <Header />
22
+ </header>
21
23
  <main class="layout__content">
22
24
  <router-view />
23
25
  </main>