fix: 设置页面返回按钮修复

- switchPage函数增加mainContent存在检查
- 如果当前页面不是主页结构,先调用showMainPage重建页面
- 确保从设置子页面返回能正确回到'我的'页面
This commit is contained in:
2026-04-27 12:22:37 +08:00
parent cacdb09201
commit f24cefb2ab
2 changed files with 13 additions and 8 deletions

View File

@@ -429,16 +429,21 @@ function switchPage(page) {
currentPage = page; currentPage = page;
localStorage.setItem('currentPage', page); localStorage.setItem('currentPage', page);
// 先确保页面结构正确(如果当前不在主页结构)
const mainContent = document.getElementById('mainContent');
if (!mainContent) {
// 重新渲染主页结构
showMainPage();
return; // showMainPage 会自动调用 renderCurrentPage
}
// 更新导航栏状态 // 更新导航栏状态
document.querySelectorAll('.nav-item').forEach(item => { document.querySelectorAll('.nav-item').forEach(item => {
item.classList.toggle('active', item.getAttribute('data-page') === page); item.classList.toggle('active', item.getAttribute('data-page') === page);
}); });
// 更新内容区 // 更新内容区
const mainContent = document.getElementById('mainContent');
if (mainContent) {
mainContent.innerHTML = renderCurrentPage(); mainContent.innerHTML = renderCurrentPage();
}
// 绑定页面事件 // 绑定页面事件
bindPageEvents(); bindPageEvents();
@@ -1440,7 +1445,7 @@ function renderProfilePage() {
</div> </div>
<div class="profile-footer"> <div class="profile-footer">
<p>AI助手 v3.5.0</p> <p>AI助手 v3.5.1</p>
<p>基于智谱 GLM-4.5-Air</p> <p>基于智谱 GLM-4.5-Air</p>
</div> </div>
</div> </div>

View File

@@ -8,12 +8,12 @@
<meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"> <meta http-equiv="Expires" content="0">
<title>AI助手</title> <title>AI助手</title>
<link rel="stylesheet" href="style.css?v=3.5.0"> <link rel="stylesheet" href="style.css?v=3.5.1">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script src="marked.min.js?v=3.5.0"></script> <script src="marked.min.js?v=3.5.1"></script>
<script src="app.js?v=3.5.0"></script> <script src="app.js?v=3.5.1"></script>
</body> </body>
</html> </html>