diff --git a/static/public/index.html b/static/public/index.html index 608b0f5..d86131d 100644 --- a/static/public/index.html +++ b/static/public/index.html @@ -1,5 +1,5 @@ - + @@ -24,6 +24,13 @@ margin-left: 5px; margin-right: 5px; } + .site-intro { + max-width: 640px; + margin: 0 auto; + font-size: 0.95rem; + line-height: 1.9; + color: var(--fg-secondary); + } DNFS 欢迎来到树状笔记 @@ -33,16 +40,23 @@
头像加载失败 DNFS - - + + + +
-

推荐节点

- +

关于本站

+

+ DNFS 树状笔记是一个以树状结构组织内容的笔记社区:每个节点都可以生长出子节点, + 像树枝一样层层延展,让知识自然成体系。支持 Markdown 文本、链接卡片、图片与文件分享, + 注册登录后即可创建属于你自己的知识树。 +

+ \ No newline at end of file diff --git a/static/public/js/index.js b/static/public/js/index.js index e69de29..15c6706 100644 --- a/static/public/js/index.js +++ b/static/public/js/index.js @@ -0,0 +1,42 @@ +/* index.js — 社区首页逻辑 + * + * 登录态检测:POST /whoami(HttpOnly q4_token Cookie 自动携带,JS 不经手 Token) + * 已登录:显示用户名与"进入笔记/退出"按钮;未登录:显示"登录/注册" + */ +(function () { + 'use strict'; + + const nameEl = document.getElementById('name'); + const enterBtn = document.getElementById('enterBtn'); + const logoutBtn = document.getElementById('logoutBtn'); + const loginBtn = document.getElementById('loginBtn'); + const registerBtn = document.getElementById('registerBtn'); + + async function checkLogin() { + try { + const res = await fetch('/whoami', { method: 'POST' }); + if (!res.ok) return; + const data = await res.json(); + if (data && data.login && data.user) { + nameEl.textContent = String(data.user); + enterBtn.style.display = ''; + logoutBtn.style.display = ''; + loginBtn.style.display = 'none'; + registerBtn.style.display = 'none'; + } + } catch (e) { + console.warn('index: 登录态检测失败', e.message); + } + } + + logoutBtn.addEventListener('click', async function () { + try { + await fetch('/logout', { method: 'POST' }); + } catch (e) { + console.warn('index: 退出登录请求异常', e.message); + } + location.reload(); + }); + + checkLogin(); +})();