diff --git a/src/components/layout/TopBar.vue b/src/components/layout/TopBar.vue
index f0e6373..252988d 100644
--- a/src/components/layout/TopBar.vue
+++ b/src/components/layout/TopBar.vue
@@ -6,35 +6,40 @@
-
-
-
- {{ userStore.userInfo.nickname || '用户' }}
-
-
-
-
-
-
- 个人中心
-
-
-
- 设置
-
-
-
- 退出登录
-
-
+
+
+
+
+
{{ userStore.userInfo.nickname || '用户' }}
+
+
-
+
+
+
-
登录
@@ -57,7 +62,6 @@ import defaultAvatar from '@/assets/default-avatar.png'
const router = useRouter()
const userStore = useUserStore()
-// 初始化时获取用户信息
onMounted(async () => {
const token = localStorage.getItem('token')
if (token && !userStore.userInfo) {
@@ -66,30 +70,26 @@ onMounted(async () => {
}
})
-// 处理菜单点击
-const handleCommand = async (command: string) => {
- console.log('Menu clicked:', command) // 添加调试日志
- switch (command) {
- case 'profile':
- router.push('/profile')
- break
- case 'settings':
- router.push('/settings')
- break
- case 'logout':
- try {
- await ElMessageBox.confirm('确定要退出登录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- userStore.clearUserInfo()
- ElMessage.success('退出登录成功')
- router.push('/login')
- } catch {
- // 用户取消操作
- }
- break
+const handleProfile = () => {
+ router.push('/profile')
+}
+
+const handleSettings = () => {
+ router.push('/settings')
+}
+
+const handleLogout = async () => {
+ try {
+ await ElMessageBox.confirm('确定要退出登录吗?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ })
+ userStore.clearUserInfo()
+ ElMessage.success('退出登录成功')
+ router.push('/login')
+ } catch {
+ // 用户取消操作
}
}
@@ -126,7 +126,6 @@ const handleCommand = async (command: string) => {
padding: 2px 8px;
border-radius: 4px;
transition: background-color 0.3s;
- user-select: none; /* 防止文本被选中 */
}
.user-info:hover {
@@ -143,24 +142,40 @@ const handleCommand = async (command: string) => {
text-decoration: none;
}
-.el-dropdown-menu__item {
+.menu-items {
+ padding: 4px 0;
+}
+
+.menu-item {
display: flex;
align-items: center;
gap: 8px;
+ padding: 8px 16px;
+ cursor: pointer;
+ transition: background-color 0.3s;
+}
+
+.menu-item:hover {
+ background-color: #f5f7fa;
+}
+
+.divider {
+ height: 1px;
+ background-color: #ebeef5;
+ margin: 4px 0;
}
.el-icon {
- margin-right: 4px;
+ font-size: 16px;
}
-/* 添加下拉箭头样式 */
.el-icon--right {
margin-left: 4px;
font-size: 12px;
transition: transform 0.3s;
}
-.el-dropdown:hover .el-icon--right {
+.user-info:hover .el-icon--right {
transform: rotate(180deg);
}
diff --git a/src/main.ts b/src/main.ts
index 7ef65e2..ff4cfaf 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,22 +1,16 @@
import './assets/styles/global.css'
-import { createApp, type Component } from 'vue'
-import { createPinia } from 'pinia'
+import { createApp } from 'vue'
import ElementPlus from 'element-plus'
-import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
-
import App from './App.vue'
import router from './router'
+import { createPinia } from 'pinia'
const app = createApp(App)
+const pinia = createPinia()
-// 注册 Element Plus 图标
-for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
- app.component(key, component as Component)
-}
-
-app.use(createPinia())
-app.use(router)
app.use(ElementPlus)
+app.use(pinia)
+app.use(router)
app.mount('#app')