From f19c3c793a545127147fa76f71a3787fbc8d9bc5 Mon Sep 17 00:00:00 2001 From: MoonLeeeaf <150461955+MoonLeeeaf@users.noreply.github.com> Date: Fri, 17 May 2024 23:35:07 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=89=AA=E8=B4=B4=E6=9D=BF=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ling_chair_http/index.css | 9 +++++++++ ling_chair_http/index.html | 10 +++++++--- ling_chair_http/index.js | 18 +++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ling_chair_http/index.css b/ling_chair_http/index.css index c1b3b46..debc8f2 100644 --- a/ling_chair_http/index.css +++ b/ling_chair_http/index.css @@ -43,3 +43,12 @@ body { margin-top: 60px; z-index: 100; } + +[n-id=pageChatSeesion]::after { + content: ""; + position: sticky; + bottom: 0; + display: block; + height: var(--pseudo-height); /* 设置伪元素的高度 */ + z-index: -1; /* 防止遮挡实际内容 */ + } diff --git a/ling_chair_http/index.html b/ling_chair_http/index.html index 652530e..10684b0 100644 --- a/ling_chair_http/index.html +++ b/ling_chair_http/index.html @@ -41,6 +41,7 @@ + 铃之椅 @@ -49,7 +50,7 @@ class="mdui-theme-primary-teal mdui-theme-accent-teal mdui-drawer-body-left mdui-appbar-with-toolbar mdui-theme-layout-auto" id="app"> - +
@@ -94,7 +95,10 @@ refresh - + + add + + notifications_off @@ -136,7 +140,7 @@
点我继续加载前面的聊天记录, 或者回到底部
-
+
diff --git a/ling_chair_http/index.js b/ling_chair_http/index.js index 8cd5fcc..02f2ce5 100644 --- a/ling_chair_http/index.js +++ b/ling_chair_http/index.js @@ -189,11 +189,12 @@ if (localStorage.useNotifications == "true") // https://www.runoob.com/w3cnote/javascript-copy-clipboard.html function copyText(t) { - let cp = viewBinding.textCopier.get(0) - cp.value = t - cp.select() - cp.setSelectionRange(0, 99999) - navigator.clipboard.writeText(cp.value) + let btn = viewBinding.textCopierBtn + btn.attr("data-clipboard-text", t) + new ClipboardJS(btn.get(0)).on('success', (e) => { + e.clearSelection() + }) + btn.click() } // https://zhuanlan.zhihu.com/p/162910462 @@ -407,8 +408,10 @@ class ChatMsgAdapter { static addSystemMsg(m, re) { let e if (re) + // 加到头部 e = $($.parseHTML(m)).prependTo(viewBinding.pageChatSeesion) else + // 加到尾部 e = $($.parseHTML(m)).appendTo(viewBinding.pageChatSeesion) return e } @@ -416,7 +419,8 @@ class ChatMsgAdapter { let elementRect = viewBinding.pageChatSeesion.get(0).getBoundingClientRect() return (elementRect.bottom <= window.innerHeight) } - // 不会压栈 只添加消息 返回消息的JQ对象 + // 添加消息 返回消息的JQ对象 + // name: 用户id m: 消息 t: 时间戳 re: 默认加到尾部 msgid: 消息id static async addMsg(name, m, t, re, msgid) { let nick = await NickCache.getNick(name) // re.data == null ? name : re.data.nick @@ -716,7 +720,7 @@ else // 登录到账号 let dialogSignIn // 谨防 localStorage 字符串数据大坑 -if (localStorage.isSignIn === "false") +if (localStorage.isSignIn == "false") dialogSignIn = new mdui.Dialog(viewBinding.dialogSignIn.get(0), { modal: true, closeOnEsc: false,