Files
PC-Light-Forum/component/hot-search/hot-search.js
DESKTOP-RQ919RC\Pc 6ce06b133a refactor(components): 重构图片资源引用方式,使用动态路径
将静态图片路径改为从valueUrl动态获取,统一管理图片资源路径
添加新的SVG图标资源
修复BI组件401未授权时的登录跳转逻辑
优化签到组件图片资源路径
2025-12-08 19:09:04 +08:00

34 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// my-component.js
// 引入全局 Vue 对象(因在 HTML 中通过 script 引入Vue 已挂载到 window
const { defineComponent, ref, onMounted } = Vue;
// 定义组件(直接使用模板)
export const hotSearch = defineComponent({
name: "hot-search",
props: {},
setup(props) {
let valueUrl = ref("");
onMounted(() => {
init();
const valueA = document.querySelector(".valueA");
valueUrl.value = valueA.innerText;
});
const init = () => {
ajaxGet("/v2/api/forum/getHotSearchWords?limit=20").then((res) => {
const data = res.data;
list.value = data || [];
});
};
const list = ref([]);
return { valueUrl, list };
},
components: {},
template: `<div class="hot-tag" v-if="list.length > 0"> <div class="hot-tag-title"> <img class="icon" :src="valueUrl + '/img/triangle-violet.svg'" /> 热门搜索 </div> <div class="list flexflex"> <a class="item" v-for="item in list" :href="'/search/' + item.keyword" target="_blank">{{ item.keyword }}</a> </div></div>`,
});