更新短信功能

This commit is contained in:
2026-04-01 15:14:37 +08:00
parent b870115444
commit e927026495
22 changed files with 581 additions and 307 deletions
+32 -2
View File
@@ -43,6 +43,7 @@
<span class="el-dropdown-link" style="cursor: pointer;">
<img :src="getImageUrl('user')" class="user" />
<span class="user-name">{{ displayName }}</span>
<el-tag v-if="roleLabel" size="small" effect="plain" class="user-role-tag">{{ roleLabel }}</el-tag>
</span>
<template #dropdown>
<el-dropdown-menu>
@@ -73,7 +74,7 @@ import { ref, computed, onMounted, onUnmounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useAllDataStore, useMenuStore, useTabsStore } from "@/stores";
import { useAuthStore } from "@/stores/auth";
import { logout } from "@/api/login";
import { logout, getCurrentUser } from "@/api/login";
import { User, SwitchButton, Sunny, Moon, Refresh, Bell, HomeFilled } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';
@@ -130,7 +131,18 @@ async function refreshCache() {
}
}
onMounted(loadMenu);
onMounted(async () => {
await loadMenu();
if (!authStore.token) return;
try {
const res = await getCurrentUser();
if (res && res.code === 200 && res.data) {
authStore.updateUserInfo({ ...authStore.user, ...res.data });
}
} catch (e) {
console.error("getCurrentUser failed", e);
}
});
// 根据菜单列表和当前路径计算出的面包屑导航
const breadcrumbs = computed(() => {
@@ -179,6 +191,12 @@ const displayName = computed(() => {
return user.account || '';
});
/** 角色展示名(来自 yz_admin_role.name */
const roleLabel = computed(() => {
const n = authStore.user?.role_name;
return typeof n === "string" && n.trim() ? n.trim() : "";
});
const handleCollapse = () => {
store.state.isCollapse = !store.state.isCollapse;
};
@@ -424,6 +442,18 @@ onUnmounted(() => {
color: #ffffff;
}
}
.user-role-tag {
flex-shrink: 0;
margin-left: 4px;
font-weight: 500;
}
html:not(.dark) & .user-role-tag {
color: #ffffff;
border-color: rgba(255, 255, 255, 0.85);
background: rgba(255, 255, 255, 0.12);
}
}
}