-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_navigation.html
More file actions
135 lines (119 loc) · 5.06 KB
/
Copy pathdebug_navigation.html
File metadata and controls
135 lines (119 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>导航调试 - Otherwise</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container" style="padding: 2rem;">
<h1>导航调试工具</h1>
<div class="card" style="margin-bottom: 2rem;">
<h2>当前localStorage数据</h2>
<div id="localStorageData" style="font-family: monospace; background: #f5f5f5; padding: 1rem; border-radius: 4px; white-space: pre-wrap; max-height: 300px; overflow-y: auto;"></div>
</div>
<div class="card" style="margin-bottom: 2rem;">
<h2>操作</h2>
<div style="display: flex; gap: 1rem; margin-bottom: 1rem;">
<button class="btn btn-primary" onclick="clearAllData()">清空所有数据</button>
<button class="btn btn-secondary" onclick="setDefaultUser()">设置默认用户</button>
<button class="btn btn-ghost" onclick="refreshData()">刷新数据显示</button>
</div>
<div style="display: flex; gap: 1rem;">
<button class="btn btn-primary" onclick="goToProjects()">前往项目页面</button>
<button class="btn btn-primary" onclick="goToProfile()">前往个人中心</button>
</div>
</div>
<div class="card">
<h2>测试导航栏</h2>
<header class="nav">
<div class="nav-container">
<div class="nav-brand">
<span>Otherwise</span>
<span style="font-weight: 400; color: var(--color-text-secondary); margin-left: 8px;">否则</span>
</div>
<nav class="nav-links">
<a href="index.html" class="nav-link">首页</a>
<a href="projects.html" class="nav-link">项目管理</a>
<div id="navButtons">
<!-- Content here will be dynamically inserted by navigation.js -->
</div>
</nav>
</div>
</header>
</div>
</div>
<!-- Scripts -->
<script src="navigation.js?v=20241219"></script>
<script src="main.js?v=20241219"></script>
<script>
function refreshData() {
const data = {};
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
data[key] = localStorage.getItem(key);
}
document.getElementById('localStorageData').textContent = JSON.stringify(data, null, 2);
}
function clearAllData() {
localStorage.clear();
console.log('所有localStorage数据已清空');
refreshData();
// 重新初始化导航
if (window.navigation) {
window.navigation.updateUserStatus();
}
}
function setDefaultUser() {
localStorage.clear();
localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('username', '张研究员');
const userData = {
username: '张研究员',
userType: 'university',
organization: '清华大学计算机系',
isLoggedIn: true,
profile: {
nickname: '张研究员',
userType: 'university',
organization: '清华大学计算机系',
researchField: '人工智能、机器学习',
bio: '专注于人工智能和机器学习领域的研究',
tags: ['人工智能', '机器学习', '深度学习'],
stats: {
followers: 128,
following: 45,
projects: 3
}
}
};
localStorage.setItem('currentUser', JSON.stringify(userData));
console.log('默认用户数据已设置');
refreshData();
// 重新初始化导航
if (window.navigation) {
window.navigation.updateUserStatus();
}
}
function goToProjects() {
window.location.href = 'projects.html';
}
function goToProfile() {
window.location.href = 'profile.html';
}
// 页面加载时刷新数据显示
document.addEventListener('DOMContentLoaded', function() {
refreshData();
// 延迟一下确保navigation.js加载完成
setTimeout(() => {
if (window.navigation) {
console.log('Navigation对象存在,状态正常');
} else {
console.error('Navigation对象不存在!');
}
}, 500);
});
</script>
</body>
</html>