新增下载周榜与月榜

pull/361/head
HXY 2 years ago
parent 3803e6cc72
commit d80833b881

@ -6,7 +6,6 @@ import (
"github.com/rocboss/paopao-ce/internal/core/ms"
"gorm.io/gorm"
"sort"
"strconv"
"strings"
)
@ -125,14 +124,14 @@ func (s RankService) GetHighQualityRanking() ([]*core.GetHighQualityRankingResp,
break
}
i++
fmt.Print(userScore.Username + " " + strconv.FormatInt(userScore.CommentCount, 10) +
" " + strconv.FormatInt(userScore.LikeCount, 10) +
" " + strconv.FormatInt(userScore.ImageCount, 10) +
" " + strconv.FormatInt(userScore.PostCount, 10) +
" " + strconv.FormatInt(userScore.VideoCount, 10) +
" " + strconv.FormatInt(userScore.ShareCodeCount, 10) +
" " + strconv.FormatInt(userScore.Score, 10) +
"\n")
//fmt.Print(userScore.Username + " " + strconv.FormatInt(userScore.CommentCount, 10) +
// " " + strconv.FormatInt(userScore.LikeCount, 10) +
// " " + strconv.FormatInt(userScore.ImageCount, 10) +
// " " + strconv.FormatInt(userScore.PostCount, 10) +
// " " + strconv.FormatInt(userScore.VideoCount, 10) +
// " " + strconv.FormatInt(userScore.ShareCodeCount, 10) +
// " " + strconv.FormatInt(userScore.Score, 10) +
// "\n")
rank = append(rank, &core.GetHighQualityRankingResp{
UserName: userScore.Username,
Avatar: userScore.Avatar,
@ -168,7 +167,7 @@ func (s RankService) GetDownloadRankList(listType int) ([]*core.GetDownloadRankL
var shareKeyInfos []ShareKeyInfoRank
//根据listType判断是获取周榜单还是月榜单
fmt.Print("listType:" + strconv.Itoa(listType) + "\n")
//fmt.Print("listType:" + strconv.Itoa(listType) + "\n")
if listType == 1 {
//获取总榜单
//对shareKeyInfos按照all_download_count进行排序
@ -225,10 +224,8 @@ func (s RankService) GetDownloadRankList(listType int) ([]*core.GetDownloadRankL
Avatar: shareKeyInfo.Avatar,
Download: shareKeyInfo.TotalDownloadCount,
})
fmt.Print(shareKeyInfo.UserName + " " + strconv.FormatInt(shareKeyInfo.TotalDownloadCount, 10) + " " + shareKeyInfo.Avatar + "\n")
//fmt.Print(shareKeyInfo.UserName + " " + strconv.FormatInt(shareKeyInfo.TotalDownloadCount, 10) + " " + shareKeyInfo.Avatar + "\n")
}
//fmt.Print(rank)
return ranks, nil
}

@ -291,7 +291,7 @@ func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp,
SenderUserID: req.User.ID,
ReceiverUserID: user.ID,
Type: ms.MsgTypePost,
Brief: "在新发布的泡泡动态中@了你",
Brief: "在新发布的Aimo动态中@了你",
PostID: post.ID,
})
}
@ -394,7 +394,7 @@ func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.Creat
SenderUserID: req.Uid,
ReceiverUserID: commentMaster.ID,
Type: ms.MsgTypeReply,
Brief: "在泡泡评论下回复了你",
Brief: "在Aimo评论下回复了你",
PostID: post.ID,
CommentID: comment.ID,
ReplyID: reply.ID,
@ -406,7 +406,7 @@ func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.Creat
SenderUserID: req.Uid,
ReceiverUserID: postMaster.ID,
Type: ms.MsgTypeReply,
Brief: "在泡泡评论下发布了新回复",
Brief: "在Aimo评论下发布了新回复",
PostID: post.ID,
CommentID: comment.ID,
ReplyID: reply.ID,
@ -420,7 +420,7 @@ func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.Creat
SenderUserID: req.Uid,
ReceiverUserID: user.ID,
Type: ms.MsgTypeReply,
Brief: "在泡泡评论的回复中@了你",
Brief: "在Aimo评论的回复中@了你",
PostID: post.ID,
CommentID: comment.ID,
ReplyID: reply.ID,
@ -526,7 +526,7 @@ func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateComment
SenderUserID: req.Uid,
ReceiverUserID: postMaster.ID,
Type: ms.MsgtypeComment,
Brief: "在泡泡中评论了你",
Brief: "在Aimo中评论了你",
PostID: post.ID,
CommentID: comment.ID,
})
@ -542,7 +542,7 @@ func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateComment
SenderUserID: req.Uid,
ReceiverUserID: user.ID,
Type: ms.MsgtypeComment,
Brief: "在泡泡评论中@了你",
Brief: "在Aimo评论中@了你",
PostID: post.ID,
CommentID: comment.ID,
})

File diff suppressed because one or more lines are too long

@ -95,7 +95,7 @@
<n-icon :component="ChevronForward" />
</div>
</div>
<n-spin :show="loading">
<n-spin :show="rankloading">
<div
class="ranking-item"
v-for="(item, index) in getCurrentRankingList"
@ -164,6 +164,7 @@ import { ChevronForward } from "@vicons/ionicons5";
const hotTags = ref<Item.TagProps[]>([]);
const followTags = ref<Item.TagProps[]>([]);
const loading = ref(false);
const rankloading = ref(false);
const keyword = ref("");
const store = useStore();
const router = useRouter();
@ -182,27 +183,33 @@ const rightHotTopicMaxSize = Number(
// 模拟排行榜数据
const rankingList = ref<Item.RankingDataProps[]>([]);
const allDownloadRankingList = ref<Item.RankingDataProps[]>([]);
const DownloadPreWeekRankingList = ref<Item.RankingDataProps[]>([]);
const DownloadPreMonthRankingList = ref<Item.RankingDataProps[]>([]);
//获取排行榜数据
const locadHeighQuailtyRankingList = () => {
loading.value = true;
rankloading.value = true;
getHighQuailty()
.then((res) => {
rankingList.value = res.list;
loading.value = false;
rankloading.value = false;
})
.catch((err) => {
loading.value = false;
rankloading.value = false;
});
};
const loadDowmloadRankingByType = (type: number) => {
rankloading.value = true;
getDownloadRank(type)
.then((res) => {
allDownloadRankingList.value = res.list;
if (type ===1 ) allDownloadRankingList.value = res.list;
if (type === 2) DownloadPreWeekRankingList.value = res.list;
if (type === 3) DownloadPreMonthRankingList.value = res.list;
rankloading.value = false;
})
.catch((err) => {
loading.value = false;
rankloading.value = false;
});
};
@ -211,25 +218,40 @@ const rankingTitles: { [key: string]: string } = {
downloadPreWeek: "下载周榜",
downloadPreMonth: "下载月榜",
downloadAll: "下载总榜",
hot: "热门排行榜",
};
const rankingTypes = ['highQuality', 'downloadPreWeek', 'downloadPreMonth', 'downloadAll'];
let currentRankingTypeIndex = 0;
const currentRankingType = ref("highQuality");
const toggleRankingType = () => {
currentRankingTypeIndex = (currentRankingTypeIndex + 1) % rankingTypes.length;
currentRankingType.value = rankingTypes[currentRankingTypeIndex];
};
//1总 2周 3月
const getCurrentRankingList = computed(() => {
if (currentRankingType.value === "highQuality") {
return rankingList.value;
} else if (currentRankingType.value === "downloadAll") {
if (allDownloadRankingList.value.length === 0) {
loadDowmloadRankingByType(1);
}
return allDownloadRankingList.value;
} else if (currentRankingType.value === "downloadPreWeek") {
if (DownloadPreWeekRankingList.value.length === 0) {
loadDowmloadRankingByType(2);
}
return DownloadPreWeekRankingList.value;
} else if (currentRankingType.value === "downloadPreMonth") {
if (DownloadPreMonthRankingList.value.length === 0) {
loadDowmloadRankingByType(3);
}
return DownloadPreMonthRankingList.value;
}
return [];
});
const toggleRankingType = () => {
currentRankingType.value =
currentRankingType.value === "highQuality" ? "downloadAll" : "highQuality";
};
const loadHotTags = () => {
loading.value = true;
getTags({
@ -298,7 +320,6 @@ watch(
onMounted(() => {
loadHotTags();
locadHeighQuailtyRankingList();
loadDowmloadRankingByType(1);
});
</script>

Loading…
Cancel
Save