Skip to content

Commit

Permalink
fix: 修复带参数的热点信息
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Feb 2, 2024
1 parent 9724124 commit 339248b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/components/HotList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
secondary
strong
round
@click.stop="getHotListsData(hotData)"
@click.stop="getHotListsData(hotData.name)"
>
<template #icon>
<n-icon :component="Refresh" />
Expand Down Expand Up @@ -166,10 +166,11 @@ const listLoading = ref(false);
const loadingError = ref(false);
// 获取热榜数据
const getHotListsData = async (item, isNew = false) => {
const getHotListsData = async (name, isNew = false) => {
try {
// hotListData.value = null;
loadingError.value = false;
const item = store.newsArr.find((item) => item.name == name)
const result = await getHotLists(item.name, isNew, item.params);
// console.log(result);
if (result.code === 200) {
Expand All @@ -195,7 +196,7 @@ const getNewData = () => {
if (now - lastClickTime.value > 60000) {
// 点击事件
listLoading.value = true;
getHotListsData(props.hotData, true);
getHotListsData(props.hotData.name, true);
// 更新最后一次点击时间
lastClickTime.value = now;
localStorage.setItem(`${props.hotData.name}Btn`, now);
Expand Down Expand Up @@ -241,7 +242,7 @@ watch(
);
onMounted(() => {
if (props.hotData.name) getHotListsData(props.hotData);
if (props.hotData.name) getHotListsData(props.hotData.name);
});
</script>

Expand Down
5 changes: 3 additions & 2 deletions src/views/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ const pageNumber = ref(
const listData = ref(null);
// 获取热榜数据
const getHotListsData = (type, isNew = false) => {
const getHotListsData = async (name, isNew = false) => {
listData.value = null;
getHotLists(type, isNew).then((res) => {
const item = store.newsArr.find((item) => item.name == name)
getHotLists(item.name, isNew, item.params).then((res) => {
console.log(res);
if (res.code === 200) {
listData.value = res;
Expand Down

0 comments on commit 339248b

Please sign in to comment.