diff --git a/component/helper-pop/helper-pop.js b/component/helper-pop/helper-pop.js index 3292e3f..6c722fc 100644 --- a/component/helper-pop/helper-pop.js +++ b/component/helper-pop/helper-pop.js @@ -4,7 +4,7 @@ const { defineComponent, ref, inject, defineAsyncComponent, onMounted } = Vue; // 定义组件(直接使用模板) export const helperPop = defineComponent({ - name: "item-bottom", + name: "helper-pop", props: {}, setup(props) { diff --git a/component/hot-search/hot-search.js b/component/hot-search/hot-search.js index a4f776c..5bfe083 100644 --- a/component/hot-search/hot-search.js +++ b/component/hot-search/hot-search.js @@ -1,20 +1,41 @@ // my-component.js // 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window) -const { defineComponent, ref, onMounted } = Vue; +const { defineComponent, ref, onMounted, watch } = Vue; // 定义组件(直接使用模板) export const hotSearch = defineComponent({ name: "hot-search", - props: {}, + props: { + isnorequestdata: { + type: Boolean, + }, + + searchlist: { + type: Array, + }, + }, setup(props) { let valueUrl = ref(""); onMounted(() => { - init(); + if (!props.isnorequestdata) init(); const valueA = document.querySelector(".valueA"); valueUrl.value = valueA.innerText; }); + const list = ref([]); + + watch( + () => props.searchlist, + (newVal) => { + if (newVal) list.value = newVal; + }, + { + deep: true, // 核心:开启深度监听(监听对象/数组内部属性变化) + immediate: true, // 可选:组件挂载时立即执行一次回调(根据需求决定) + } + ); + const init = () => { ajaxGet("/v2/api/forum/getHotSearchWords?limit=20").then((res) => { const data = res.data; @@ -22,12 +43,10 @@ export const hotSearch = defineComponent({ }); }; - const list = ref([]); - return { valueUrl, list }; }, components: {}, - template: `
热门搜索
{{ item.keyword }}
`, + template: `
热门搜索
{{ item.keyword }}
`, }); diff --git a/component/hot-search/hot-search.txt b/component/hot-search/hot-search.txt index 86c0920..ac2db8f 100644 --- a/component/hot-search/hot-search.txt +++ b/component/hot-search/hot-search.txt @@ -1,4 +1,4 @@ -
+
热门搜索 diff --git a/component/hot-tag/hot-tag.js b/component/hot-tag/hot-tag.js index b5e0e6d..bceb481 100644 --- a/component/hot-tag/hot-tag.js +++ b/component/hot-tag/hot-tag.js @@ -1,16 +1,23 @@ // my-component.js // 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window) -const { defineComponent, ref, onMounted } = Vue; +const { defineComponent, ref, onMounted, emit, watch } = Vue; // 定义组件(直接使用模板) export const hotTag = defineComponent({ name: "hot-tag", - props: {}, + props: { + isnorequestdata: { + type: Boolean, + }, + taglist: { + type: Array, + }, + }, setup(props) { let valueUrl = ref(""); onMounted(() => { - init(); + if (!props.isnorequestdata) init(); const valueA = document.querySelector(".valueA"); valueUrl.value = valueA.innerText; }); @@ -24,10 +31,22 @@ export const hotTag = defineComponent({ const list = ref([]); + watch( + () => props.taglist, + (newVal) => { + if (newVal) list.value = newVal; + }, + { + deep: true, // 核心:开启深度监听(监听对象/数组内部属性变化) + immediate: true, // 可选:组件挂载时立即执行一次回调(根据需求决定) + } + ); + + return { valueUrl, list }; }, components: {}, - template: `
热门标签
`, + template: `
热门标签
`, }); diff --git a/component/hot-tag/hot-tag.txt b/component/hot-tag/hot-tag.txt index 25d52c9..653bc15 100644 --- a/component/hot-tag/hot-tag.txt +++ b/component/hot-tag/hot-tag.txt @@ -1,4 +1,4 @@ -
+
热门标签 diff --git a/component/huddle-box/huddle-box.js b/component/huddle-box/huddle-box.js index 1dbefb3..2d4c6cb 100644 --- a/component/huddle-box/huddle-box.js +++ b/component/huddle-box/huddle-box.js @@ -4,7 +4,7 @@ const { defineComponent, ref, inject, defineAsyncComponent, onMounted } = Vue; // 定义组件(直接使用模板) export const huddleBox = defineComponent({ - name: "item-bottom", + name: "huddle-box", props: {}, setup(props) { diff --git a/component/item-bottom/item-bottom.js b/component/item-bottom/item-bottom.js index ea868f3..415ef92 100644 --- a/component/item-bottom/item-bottom.js +++ b/component/item-bottom/item-bottom.js @@ -17,25 +17,25 @@ export const itemBottom = defineComponent({ setup(props) { let valueUrl = ref(""); - let isMobile = ref(false) + let isMobile = ref(false); onMounted(() => { const valueA = document.querySelector(".valueA"); valueUrl.value = valueA.innerText; - isMobile.value = window.isMobile + isMobile.value = window.isMobile; }); let item = ref({ ...props.itemdata }); let isLogin = inject("isLogin"); let userInfoWin = inject("userInfoWin"); - let realname = inject("realname"); + let realname = inject("realname", null); let goLogin = inject("goLogin"); let openAttest = inject("openAttest"); let isLikeGif = ref(false); - let cancelOperate = inject("cancelOperate"); + let cancelOperate = inject("cancelOperate", () => {}); const likeClick = () => { if (realname.value == 0 && userInfoWin.value?.uin > 0) { @@ -50,7 +50,7 @@ export const itemBottom = defineComponent({ const token = item.value.token || ""; - if (["offer", "offer_summary", "interviewexperience"].includes(itemvalue["type"]) && item.value["is_like"]) { + if (["offer", "offer_summary", "interviewexperience"].includes(item.value["type"]) && item.value["is_like"]) { creationAlertBox("error", "不可取消点赞"); return; } @@ -154,5 +154,5 @@ export const itemBottom = defineComponent({ like, }, - template: `
{{ item?.commentreviews?.content || "[图]" }}
{{ item.collections || "收藏" }}
{{ item.comments || "讨论" }}
{{ item.coins || "投币" }}
`, + template: `
{{ item?.commentreviews?.content || "[图]" }}
{{ item.collections || "收藏" }}
{{ item.comments || "讨论" }}
{{ item.coins || "投币" }}
`, }); diff --git a/component/item-bottom/item-bottom.txt b/component/item-bottom/item-bottom.txt index f8d7dd5..d4ea762 100644 --- a/component/item-bottom/item-bottom.txt +++ b/component/item-bottom/item-bottom.txt @@ -1,60 +1,62 @@ - - -
{{ item?.commentreviews?.content || "[图]" }}
-
- -
- + +
+ -
- - -
{{ item.collections || "收藏" }}
-
+
+ + +
{{ item.collections || "收藏" }}
+
- - -
{{ item.comments || "讨论" }}
-
+ + +
{{ item.comments || "讨论" }}
+
- - -
{{ item.coins || "投币" }}
-
+ + +
{{ item.coins || "投币" }}
+
- -