添加管理员标签页持久化功能

- 刷新页面后管理员标签页保持不变(概览/设置/监控/用户/工具)
- 使用localStorage存储当前标签页状态
- 登出时自动清理保存的标签页状态

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-30 11:03:55 +08:00
parent a28909baca
commit 9f0f8f69af

View File

@@ -1003,6 +1003,7 @@ handleDragLeave(e) {
this.stopTokenRefresh(); this.stopTokenRefresh();
localStorage.removeItem('user'); localStorage.removeItem('user');
localStorage.removeItem('lastView'); localStorage.removeItem('lastView');
localStorage.removeItem('adminTab');
this.showResendVerify = false; this.showResendVerify = false;
this.resendVerifyEmail = ''; this.resendVerifyEmail = '';
@@ -1066,6 +1067,14 @@ handleDragLeave(e) {
targetView = 'files'; targetView = 'files';
} }
// 恢复管理员标签页
if (this.user.is_admin) {
const savedAdminTab = localStorage.getItem('adminTab');
if (savedAdminTab && ['overview', 'settings', 'monitor', 'users', 'tools'].includes(savedAdminTab)) {
this.adminTab = savedAdminTab;
}
}
// 强制切换到目标视图并加载数据 // 强制切换到目标视图并加载数据
this.switchView(targetView, true); this.switchView(targetView, true);
} }
@@ -2886,6 +2895,12 @@ handleDragLeave(e) {
if (this.isLoggedIn && this.isViewAllowed(newView)) { if (this.isLoggedIn && this.isViewAllowed(newView)) {
localStorage.setItem('lastView', newView); localStorage.setItem('lastView', newView);
} }
},
// 记住管理员当前标签页
adminTab(newTab) {
if (this.isLoggedIn && this.user?.is_admin) {
localStorage.setItem('adminTab', newTab);
}
} }
} }
}).mount('#app'); }).mount('#app');