From 28c890cf9412d384649ee42ba982a04c5588b979 Mon Sep 17 00:00:00 2001 From: A1300399510 <1300399510@qq.com> Date: Thu, 30 Oct 2025 01:50:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=B1=95=E7=A4=BA=E6=A0=B7=E5=BC=8F=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E4=BA=A4=E4=BA=92=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整评论图片容器样式,支持横向滚动 - 为评论图片添加圆角和点击效果 - 实现用户主页跳转和私信功能 - 修复section变量名错误并优化初始化逻辑 - 添加评论点赞和子评论展开功能 --- component/item-head/item-head.js | 2 +- component/item-head/item-head.txt | 14 +- css/details.css | 9 +- css/details.less | 10 +- details.html | 825 +++++++++++++++--------------- js/details.js | 102 +++- js/public.js | 21 + js/section-index.js | 18 +- 8 files changed, 587 insertions(+), 414 deletions(-) diff --git a/component/item-head/item-head.js b/component/item-head/item-head.js index 9b9c9a8..fe15d17 100644 --- a/component/item-head/item-head.js +++ b/component/item-head/item-head.js @@ -96,5 +96,5 @@ export const itemHead = defineComponent({ report, }, - template: `
{{ item.user.nickname || item.nickname || '匿名用户' }}
{{ timestamp }}
{{ item.views }}
举报
{{ item }}
{{ item }}
`, + template: `
{{ item.user.nickname || item.nickname || "匿名用户" }}
{{ timestamp }}
{{ item.views }}
举报
{{ item }}
{{ item }}
`, }); diff --git a/component/item-head/item-head.txt b/component/item-head/item-head.txt index 2dd8ed0..ef9057c 100644 --- a/component/item-head/item-head.txt +++ b/component/item-head/item-head.txt @@ -1,6 +1,6 @@
-
{{ item.user.nickname || item.nickname || '匿名用户' }}
+
{{ item.user.nickname || item.nickname || "匿名用户" }}
{{ timestamp }}
@@ -19,19 +19,19 @@
举报
-
+
-
{{ item }}
+
{{ item }}
{{ item }}
- \ No newline at end of file + diff --git a/css/details.css b/css/details.css index 5eff487..6281540 100644 --- a/css/details.css +++ b/css/details.css @@ -889,9 +889,16 @@ display: inline; margin-right: 10px; } +.answer-discuss .comments-box .comments-item .comments-content .comments-img-box { + overflow: auto; + white-space: nowrap; +} .answer-discuss .comments-box .comments-item .comments-content .comments-img { - width: 75px; + height: 100px; + margin-right: 10px; margin-bottom: 13px; + border-radius: 8px; + cursor: pointer; } .answer-discuss .comments-box .comments-item .comments-content .comments-input-box { margin-top: 13px; diff --git a/css/details.less b/css/details.less index 3f40b81..7ccbf75 100644 --- a/css/details.less +++ b/css/details.less @@ -1040,9 +1040,17 @@ margin-right: 10px; } +.answer-discuss .comments-box .comments-item .comments-content .comments-img-box { + overflow: auto; + white-space: nowrap; +} + .answer-discuss .comments-box .comments-item .comments-content .comments-img { - width: 75px; + height: 100px; + margin-right: 10px; margin-bottom: 13px; + border-radius: 8px; + cursor: pointer; } .answer-discuss .comments-box .comments-item .comments-content .comments-input-box { diff --git a/details.html b/details.html index d1fec6d..7f4a472 100644 --- a/details.html +++ b/details.html @@ -1,467 +1,492 @@ + + + + 版块首页 + + + + + - - - - 版块首页 - - - - - + +
+
+ +
+
+ + +
- -
-
- -
-
- - +
+ + + + + +
-
- - - - - -
-
- -
- - 首页 - - -
{{ info.title || info.content }}
-
+
{{ info.title || info.content }}
+
-
-
-
-
- -
-
-
{{ authorInfo.nickname || '匿名用户' }}
{{ authorInfo.group?.image }} - +
+
+
+
+ +
+
+
{{ authorInfo.nickname || '匿名用户' }}
+ {{ authorInfo.group?.image }} + +
+
{{ timestamp }}
+
+
+
+ +
{{ info.views || 0 }}
+
+ +
+ +
-
{{ timestamp }}
-
-
- -
{{ info.views || 0 }}
-
-
- +
+ + +
{{ item }}
+
{{ item }}
+
+ +
{{ info.title }}
+ +
+ +
最后编辑:{{ updatedTime || timestamp }}
+
+
+ + +
{{ info.likes || "赞" }}
+
+
+ + +
{{ info.collections || "收藏" }}
+
+
+ +
{{ info.comments || "讨论" }}
+
+
+ +
{{ info.coins || "投币" }}
+
+
+ +
转发
-
- - -
{{ item }}
-
{{ item }}
-
- -
{{ info.title }}
- -
- -
最后编辑:{{ updatedTime || timestamp }}
-
-
- - -
{{ info.likes || "赞" }}
+ - - -
- -
+
- -
-
- -
-
- - -
-
-
编辑评论
-
-
- -
-
-
- - -
-
- -
-
-
- -
-
-
{{ item }}
-
-
-
- - - 最多可上传1张图片,支持在输入框中直接粘贴图片。 -
-
-
-
-
-
取消
-
发送
-
-
-
-
- 讨论 - {{ commentTotalCount || "" }} -
-
-
- - -
-
-
- - + +
+
+
-
-
-
- -
-
{{ item }}
-
-
-
- - - 最多可上传1张图片,支持在输入框中直接粘贴图片。 -
-
-
发送
-
-
-
-
-
-
- -
{{ item["nickname"] || "匿名用户" }}
-
{{ item["timestamp"] }}
-
作者
- - - -
-
- - - -
-
-
-
- -
- + +
+
+
编辑评论
+
- +
-
+
- - + +
+
-
- +
+ +
-
{{ item }}
+
{{ item }}
-
- - +
+ + 最多可上传1张图片,支持在输入框中直接粘贴图片。
-
发送
+
+
取消
+
发送
+
-
-
-
-
- -
{{ ite["nickname"] || "匿名用户" }}
-
{{ ite["timestamp"] }}
-
作者
- - -
-
- - - +
+
+ 讨论 + {{ commentTotalCount || "" }} +
+
+
+ + +
+
+
+ + +
+
+ +
+
+
+ +
+
{{ item }}
-
-
-
@{{ ite["reply"]["nickname"] || "匿名用户" }}
+
+ + + 最多可上传1张图片,支持在输入框中直接粘贴图片。 +
+
+
发送
+
+
+
+
+
+
+ +
{{ item.user["nickname"] || "匿名用户" }}
+
{{ item["timestamp"] }}
+
作者
+ + + - -
- -
- +
+
+ +
+
+
+ + + + +
+
+ +
+ +
+
+
+ + +
+
+
+
+
+ +
+
{{ item }}
+
+
+
+ + + 最多可上传1张图片,支持在输入框中直接粘贴图片。
-
-
-
- -
-
{{ item }}
+
发送
+
+
+
+
+
+
+
+ +
{{ ite.user["nickname"] || "匿名用户" }}
+
{{ ite["timestamp"] }}
+
作者
+ + +
+
+ + + +
+
+
+
+
@{{ ite["reply"]["nickname"] || "匿名用户" }}
+ +
+
+ +
+ +
+ +
+ +
+
+
+ + +
+
+
+
+
+ +
+
{{ item }}
+
+
+
+ + + 最多可上传1张图片,支持在输入框中直接粘贴图片。
-
- - - 最多可上传1张图片,支持在输入框中直接粘贴图片。 -
+
发送
-
发送
-
-
-
还有{{ item["childnum"] - item.child.length }}条回复
- +
+
还有{{ item["childnum"] - item.child.length }}条回复
+ +
+
+
+
+
+ +
缺少你的留言,我的世界是黑白的
+
+
+
+ + + +
+
+ +
+ +
+ 该帖子已获得 +
{{ info.coins }}
+ 个寄托币 +
+
+
+ +
投币
+
+ +
+ + 你当前共有 +
{{ mybalance }}
+ 寄托币 + [挣币攻略] +
+ +
+
+ 共 +
{{ coinNubmer }}
+ 人参与投币: +
+
+
+
{{ item.rank }}
+
+ +
{{ item.user.nickname || '匿名用户' }}
+
+
+ {{ item.coins }} +
+
+
+
- +
- -
-
- -
- -
该帖子已获得
{{ info.coins }}
个寄托币
-
-
- -
投币
-
- -
- - 你当前共有
{{ mybalance }}
寄托币 - [挣币攻略] -
- -
-
{{ coinNubmer }}
人参与投币:
-
-
-
{{ item.rank }}
-
- -
{{ item.user.nickname || '匿名用户' }}
-
-
{{ item.coins }}
-
-
-
-
-
-
- - - - -
- - - - - - \ No newline at end of file + + + + + diff --git a/js/details.js b/js/details.js index 29ce868..81743fc 100644 --- a/js/details.js +++ b/js/details.js @@ -92,8 +92,13 @@ const appSectionIndex = createApp({ const init = () => { ajaxget(`/v2/api/forum/getTopicDetails?uniqid=${uniqid}`).then((res) => { + if (res.code != 200) { + creationAlertBox("error", res.message || "主题不存在"); + return; + } const data = res.data; + console.log(data, "data"); let targetInfo = data.info; if (!targetInfo.hidden) targetInfo.hidden = 0; @@ -335,7 +340,102 @@ const appSectionIndex = createApp({ let picture = ref({}); - return { permissions, commentList, commentPage, commentTotalCount, picture, userInfoWin, relatedList, relatedTime, coinNubmer, coinList, coinAmount, coinSubmit, strategy, mybalance, coinsState, openCoinBox, closeCoinBox, isLikeGif, likeClick, collectClick, islike, iscollect, recentlyList, medal, count, sectionn, tags, signInAlreadyState, authorInfo, info, timestamp, updatedTime }; + const openUserInfo = (index, i) => { + if (i != undefined && commentList.value[index].child[i].user["uin"] > 0) commentList.value[index].child[i]["avatarState"] = true; + if (i == undefined && index != undefined && commentList.value[index].user["uin"] > 0) commentList.value[index]["avatarState"] = true; + }; + + const closeUserInfo = (index, i) => { + if (i != undefined) commentList.value[index].child[i]["avatarState"] = false; + else if (index != undefined) commentList.value[index]["avatarState"] = false; + }; + + // 打开 回答-评论 的子评论 + const openAnswerCommentsChild = (index, i) => { + if (realname.value == 0 && userInfoWin.value?.uin > 0) { + openAttest(); + return; + } + + if (!isLogin.value) { + goLogin(); + return; + } + + closeAnswerCommentsChild(); + + if (i == null) commentList.value[index]["childState"] = true; + else commentList.value[index].child[i]["childState"] = true; + }; + + // 关闭 回答-评论 的子评论 + const closeAnswerCommentsChild = () => { + commentList.value.forEach((ele) => { + ele["childState"] = false; + ele["commentInput"] = ""; // 删除原本输入值 + if (ele["child"] && ele["child"].length != 0) { + ele["child"].forEach((el) => { + el["childState"] = false; + el["commentInput"] = ""; + }); + } + }); + }; + + let dialogSrc = ref(""); + const handleAnswerText = (e) => { + if (e.target.tagName === "IMG") { + var src = e.target.getAttribute("src"); + dialogSrc.value = src; + window.addEventListener("keydown", handleKeydown); + } + }; + + const handleKeydown = (event) => { + if (event.key !== "Escape") return; + dialogSrc.value = ""; + window.removeEventListener("keydown", handleKeydown); // 取消监听 + }; + + // 回答-评论 点赞 + const operateAnswerCommentsLike = (token, index, i) => { + if (realname.value == 0 && userInfoWin.value?.uin > 0) { + openAttest(); + return; + } + + if (!isLogin.value) { + goLogin(); + return; + } + + ajax("https://api.gter.net/v2/api/forum/likeComment", { + token, + }).then((res) => { + if (res.code != 200) { + creationAlertBox("error", res.message || "操作成功"); + return; + } + let data = res.data; + + if (i != undefined) { + commentList.value[index].child[i]["islike"] = data["status"]; + commentList.value[index].child[i]["likenum"] = data["count"]; + } else { + commentList.value[index]["islike"] = data["status"]; + commentList.value[index]["likenum"] = data["count"]; + } + + creationAlertBox("success", res.message || "操作成功"); + + // if (status) this.$parent.openLikeGif(); + }); + }; + + const TAHomePage = (uin) => goHomePage(uin); + const sendMessage = (uin) => goSendMessage(uin); + + return { closeAnswerCommentsChild, openAnswerCommentsChild, dialogSrc, handleAnswerText, sendMessage, TAHomePage, operateAnswerCommentsLike, closeUserInfo, openUserInfo, permissions, commentList, commentPage, commentTotalCount, picture, userInfoWin, relatedList, relatedTime, coinNubmer, coinList, coinAmount, coinSubmit, strategy, mybalance, coinsState, openCoinBox, closeCoinBox, isLikeGif, likeClick, collectClick, islike, iscollect, recentlyList, medal, count, sectionn, tags, signInAlreadyState, authorInfo, info, timestamp, updatedTime }; }, }); diff --git a/js/public.js b/js/public.js index dca6db9..71245c4 100644 --- a/js/public.js +++ b/js/public.js @@ -315,3 +315,24 @@ const updateUrlParams = (params, replace = false) => { } }; +// 跳转 url +const redirectToExternalWebsite = (url) => { + const link = document.createElement("a"); + link.href = url; + link.target = "_blank"; + link.click(); +}; + +// 点击ta的主页 +const goHomePage = (uin) => { + redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&uid=${uin}`); +}; + +// 点击发送信息 +const goSendMessage = (uin) => { + if (uin && typeof messagePrivateItem == "function") { + messagePrivateItem({ uin: uin }); + return; + } + redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&showmsg=1&uid=${uin}`); +}; diff --git a/js/section-index.js b/js/section-index.js index 5a42f6c..c69953f 100644 --- a/js/section-index.js +++ b/js/section-index.js @@ -6,8 +6,13 @@ const appSectionIndex = createApp({ let signInAlreadyState = ref(false); onMounted(() => { const params = getUrlParams(); + const id = params.section || ""; + if (id) { + section.value = id; + init(); + } - section.value = params.section || ""; + section.value = id; getSectionList(); @@ -39,8 +44,15 @@ const appSectionIndex = createApp({ let obj = {}; data.forEach((element) => (obj[element.cid] = element)); - - sectionList.value = insertLineBetweenCategories(data, "cid"); + const list = insertLineBetweenCategories(data, "cid"); + sectionList.value = list; + console.log(list, "list"); + if (!section.value) { + const uniqid = list[0].uniqid; + section.value = uniqid; + updateUrlParams({ section: uniqid }); + init(); + } }); };