From d4244fc783ed88bbba22c2eefa35d0a19aa44655 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RQ919RC\\Pc" <1300399510@qq.com> Date: Thu, 30 Oct 2025 19:09:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(components):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E7=BB=84=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构了item-head、item-bottom、item-offer、item-summary和item-tenement组件,优化了props传递和数据处理逻辑 将公共头部和导航样式提取到public.css中,避免重复代码 修复了item-tenement组件中图片显示和数据处理的问题 更新了item-bottom组件的点赞和收藏逻辑,增加错误提示 优化了item-head组件的用户信息显示逻辑 调整了多个组件的样式细节,包括间距、图标大小等 --- component/head-top/head-top.js | 23 + component/head-top/head-top.txt | 26 + component/item-bottom/item-bottom.js | 21 +- component/item-bottom/item-bottom.txt | 10 +- component/item-forum/item-forum.js | 3 +- component/item-head/item-head.js | 4 +- component/item-head/item-head.txt | 6 +- component/item-offer/item-offer.js | 64 +- component/item-offer/item-offer.txt | 4 +- component/item-summary/item-summary.js | 12 +- component/item-summary/item-summary.txt | 4 +- component/item-tenement/item-tenement.js | 62 +- component/item-tenement/item-tenement.txt | 4 +- css/details.css | 71 +- css/details.less | 86 +- css/homepage-me.css | 142 +- css/homepage-me.less | 160 +- css/homepage-other.css | 129 +- css/homepage-other.less | 146 +- css/public.css | 150 +- css/public.less | 174 ++- css/search.css | 4 + css/search.less | 4 + css/section-index.css | 138 -- css/section-index.less | 157 -- details.html | 854 ++++++----- homepage-me.html | 109 +- homepage-other.html | 101 +- img/mj-icon.png | Bin 0 -> 6026 bytes index.html | 2 +- js/details.js | 503 ++++++- js/homepage-me.js | 1646 +++----------------- js/homepage-other.js | 1655 +++------------------ js/public.js | 48 +- js/save.js | 2 + js/search.js | 23 + js/section-index.js | 3 +- search.html | 27 + 38 files changed, 2092 insertions(+), 4485 deletions(-) create mode 100644 component/head-top/head-top.js create mode 100644 component/head-top/head-top.txt create mode 100644 css/search.css create mode 100644 css/search.less create mode 100644 img/mj-icon.png create mode 100644 js/search.js create mode 100644 search.html diff --git a/component/head-top/head-top.js b/component/head-top/head-top.js new file mode 100644 index 0000000..e53e4c9 --- /dev/null +++ b/component/head-top/head-top.js @@ -0,0 +1,23 @@ +// my-component.js +// 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window) +const { defineComponent, ref, onMounted, nextTick } = Vue; + +// 定义组件(直接使用模板) +export const headTop = defineComponent({ + name: "headTop", + props: { + itemdata: { + type: Object, + default: () => {}, + }, + }, + + setup(props) { + onMounted(() => {}); + + let signInAlreadyState = ref(false); + return { signInAlreadyState }; + }, + + template: `
已签到,明天再来
签到领寄托币
GO
`, +}); diff --git a/component/head-top/head-top.txt b/component/head-top/head-top.txt new file mode 100644 index 0000000..37918b6 --- /dev/null +++ b/component/head-top/head-top.txt @@ -0,0 +1,26 @@ +
+ +
+
+ + +
+ +
+ + 已签到,明天再来 +
+
+ + + + 签到领寄托币 +
+ + GO +
+ + + +
+
\ No newline at end of file diff --git a/component/item-bottom/item-bottom.js b/component/item-bottom/item-bottom.js index 7b8b2bb..6ad174a 100644 --- a/component/item-bottom/item-bottom.js +++ b/component/item-bottom/item-bottom.js @@ -23,6 +23,8 @@ export const itemBottom = defineComponent({ let isLikeGif = ref(false); + let cancelOperate = inject("cancelOperate"); + const likeClick = () => { if (realname.value == 0 && userInfoWin.value?.uin > 0) { openAttest(); @@ -36,11 +38,19 @@ export const itemBottom = defineComponent({ const token = item.value.token || ""; + if (["offer", "offer_summary", "interviewexperience"].includes(item.value["type"]) && item.value["is_like"]) { + creationAlertBox("error", "不可取消点赞"); + return; + } + ajax(`/v2/api/forum/postTopicLike`, { token, }) .then((res) => { - if (res.code != 200) return; + if (res.code != 200) { + creationAlertBox("error", res.message); + return; + } let data = res.data; item.value["is_like"] = data.status; @@ -71,12 +81,17 @@ export const itemBottom = defineComponent({ token, }) .then((res) => { - if (res.code != 200) return; + if (res.code != 200) { + creationAlertBox("error", res.message); + return; + } const data = res.data || {}; item.value["is_collect"] = data.status; item.value["collections"] = data.collections; creationAlertBox("success", res.message); + // 调用父组件的方法 + cancelOperate(token); // this.triggerEvent("uncollect", item.token); }) .catch((err) => { @@ -91,5 +106,5 @@ export const itemBottom = defineComponent({ like, }, - template: `
{{ item?.commentreviews?.content }}
{{ item.likes || "赞" }}
{{ item.collections || "收藏" }}
{{ item.comments || "讨论" }}
{{ item.coins || "投币" }}
转发
`, + template: `
{{ item?.commentreviews?.content }}
{{ item.likes || "赞" }}
{{ item.collections || "收藏" }}
{{ item.comments || "讨论" }}
{{ item.coins || "投币" }}
转发
`, }); diff --git a/component/item-bottom/item-bottom.txt b/component/item-bottom/item-bottom.txt index 205e073..64eecaf 100644 --- a/component/item-bottom/item-bottom.txt +++ b/component/item-bottom/item-bottom.txt @@ -1,24 +1,26 @@ -
+
{{ item?.commentreviews?.content }}
-