mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 00:53:33 +00:00
fix: 修复用户菜单显示问题和真实用户名显示
- 修复登录接口返回真实用户名而非输入用户名 - 新增获取当前用户信息的API接口(/web/auth/user) - 修复前端用户名显示逻辑,页面初始化时获取真实用户名 - 提高下拉菜单z-index确保正确显示 - 解决用户名显示为Admin而非data/init.json中真实用户名的问题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -228,6 +228,9 @@ const app = createApp({
|
||||
if (this.authToken) {
|
||||
this.isLoggedIn = true;
|
||||
|
||||
// 加载当前用户信息
|
||||
this.loadCurrentUser();
|
||||
|
||||
// 初始化日期筛选器和图表数据
|
||||
this.initializeDateFilter();
|
||||
|
||||
@@ -808,8 +811,8 @@ const app = createApp({
|
||||
localStorage.setItem('authToken', this.authToken);
|
||||
this.isLoggedIn = true;
|
||||
|
||||
// 记录当前用户名
|
||||
this.currentUser.username = this.loginForm.username;
|
||||
// 记录当前用户名(使用服务器返回的真实用户名)
|
||||
this.currentUser.username = data.username;
|
||||
|
||||
this.loadDashboard();
|
||||
} else {
|
||||
@@ -823,6 +826,26 @@ const app = createApp({
|
||||
}
|
||||
},
|
||||
|
||||
// 加载当前用户信息
|
||||
async loadCurrentUser() {
|
||||
try {
|
||||
const response = await fetch('/web/auth/user', {
|
||||
headers: { 'Authorization': 'Bearer ' + this.authToken }
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
this.currentUser.username = data.user.username;
|
||||
console.log('Loaded current user:', data.user.username);
|
||||
} else {
|
||||
console.warn('Failed to load current user:', data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading current user:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 用户菜单相关方法
|
||||
openChangePasswordModal() {
|
||||
this.userMenuOpen = false;
|
||||
|
||||
Reference in New Issue
Block a user