Skip to content

Commit

Permalink
🎨 调整帖子数量
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Nov 8, 2024
1 parent dafcc30 commit 6b8cbe0
Showing 1 changed file with 19 additions and 66 deletions.
85 changes: 19 additions & 66 deletions src/pages/common/Posts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,41 +141,13 @@ const forumDbyList: SortSelect[] = [
{ text: "公告", value: 36 },
];
const sortGameList: SortSelectGame[] = [
{
gid: 2,
forum: forumYsList,
text: "原神",
},
{
gid: 6,
forum: forumSrList,
text: "崩坏:星穹铁道",
},
{
gid: 8,
forum: forumZzzList,
text: "绝区零",
},
{
gid: 1,
forum: forumBh3List,
text: "崩坏3",
},
{
gid: 3,
forum: forumBh2List,
text: "崩坏2",
},
{
gid: 4,
forum: forumWdList,
text: "未定事件簿",
},
{
gid: 5,
forum: forumDbyList,
text: "大别野",
},
{ gid: 2, forum: forumYsList, text: "原神" },
{ gid: 6, forum: forumSrList, text: "崩坏:星穹铁道" },
{ gid: 8, forum: forumZzzList, text: "绝区零" },
{ gid: 1, forum: forumBh3List, text: "崩坏3" },
{ gid: 3, forum: forumBh2List, text: "崩坏2" },
{ gid: 4, forum: forumWdList, text: "未定事件簿" },
{ gid: 5, forum: forumDbyList, text: "大别野" },
];
// 路由
Expand All @@ -184,17 +156,13 @@ const forum = useRoute().params.forum;
function getGameForums(gid: number): SortSelect[] {
const game = sortGameList.find((item) => item.gid === gid);
if (game) {
return game.forum;
}
if (game) return game.forum;
return [];
}
function getGameLabel(gid: number): string {
const game = sortGameList.find((item) => item.gid === gid);
if (game) {
return game.text;
}
if (game) return game.text;
return "";
}
Expand Down Expand Up @@ -240,16 +208,10 @@ watch(
async (newVal: number) => {
const forums = getGameForums(newVal);
const forumFind = forums.find((item) => item.text === curForumLabel.value);
if (forumFind) {
curForum.value = forumFind.value;
} else {
curForum.value = forums[0].value;
}
if (forumFind) curForum.value = forumFind.value;
else curForum.value = forums[0].value;
await nextTick();
showSnackbar({
text: `已将分区切换到 ${getGameLabel(newVal)}`,
color: "success",
});
showSnackbar({ text: `已将分区切换到 ${getGameLabel(newVal)}`, color: "success" });
},
);
watch(
Expand All @@ -268,13 +230,10 @@ watch(
);
watch(
() => curSortType.value,
async (newVal) => {
async () => {
await freshPostData();
const sortLabel = getSortLabel(newVal);
showSnackbar({
text: `已将排序切换到 ${sortLabel}`,
color: "success",
});
const sortLabel = getSortLabel(curSortType.value);
showSnackbar({ text: `已将排序切换到 ${sortLabel}`, color: "success" });
},
);
Expand All @@ -287,7 +246,7 @@ async function freshPostData(): Promise<void> {
);
loading.value = true;
loadingTitle.value = `正在加载 ${gameLabel}-${forumLabel}-${sortLabel} 数据`;
const postsGet = await Mys.Post.getForumPostList(curForum.value, curSortType.value, 12);
const postsGet = await Mys.Post.getForumPostList(curForum.value, curSortType.value);
posts.value = postsGet.list;
await nextTick();
loading.value = false;
Expand All @@ -296,18 +255,12 @@ async function freshPostData(): Promise<void> {
// 查询帖子
function searchPost(): void {
if (search.value === "") {
showSnackbar({
text: "请输入搜索内容",
color: "error",
});
showSnackbar({ text: "请输入搜索内容", color: "error" });
return;
}
const numCheck = Number(search.value);
if (isNaN(numCheck)) {
showSearch.value = true;
} else {
createPost(search.value);
}
if (isNaN(numCheck)) showSearch.value = true;
else createPost(search.value);
}
</script>
<style lang="css" scoped>
Expand Down

0 comments on commit 6b8cbe0

Please sign in to comment.