diff --git a/server/corpus-agent/static/index.html b/server/corpus-agent/static/index.html
index 5cc3611..09444f9 100644
--- a/server/corpus-agent/static/index.html
+++ b/server/corpus-agent/static/index.html
@@ -222,7 +222,7 @@ let chatHistory = [];
document.getElementById('user-badge').textContent = username;
fetch('/api/auth/quick-login?username=' + encodeURIComponent(u))
.then(function(r) { return r.json(); })
- .then(function(d) { if (d.ok) { token = d.token; document.getElementById('app').style.display = 'flex'; updateApiPanel(); loadStats(); loadSamples(); addSystemMsg('✅ 欢迎回来,有什么语料需要整理的?'); } })
+ .then(function(d) { if (d.ok) { token = d.token; localStorage.setItem('corpus_token', token); document.getElementById('app').style.display = 'flex'; updateApiPanel(); loadStats(); loadSamples(); addSystemMsg('✅ 欢迎回来,有什么语料需要整理的?'); } })
.catch(function() {});
})();
@@ -234,7 +234,7 @@ function doLogout() {
}
-// Auto-login
+// 自动恢复:页面刷新后从localStorage恢复session
if (token) {
(async () => {
try {
@@ -242,7 +242,6 @@ if (token) {
const d = await r.json();
if (d.ok) {
username = d.username;
-
document.getElementById('app').style.display = 'flex';
document.getElementById('user-badge').textContent = username;
updateApiPanel();
@@ -250,6 +249,9 @@ if (token) {
loadSamples();
} else {
localStorage.removeItem('corpus_token');
+ // fallback: re-login via homepage
+ var u = localStorage.getItem('current_user');
+ if (u) { window.location.href = '/corpus/'; }
}
} catch(e) { localStorage.removeItem('corpus_token'); }
})();