@@ -52,6 +53,7 @@
:items="getGameForums(curGid)"
variant="outlined"
label="版块"
+ :disabled="isReq"
>
@@ -86,6 +88,7 @@
item-value="value"
variant="outlined"
label="排序"
+ :disabled="isReq"
/>
(1);
const search = ref("");
const showSearch = ref(false);
const firstLoad = ref(false);
-const selectedForum = ref();
+const isReq = ref(false);
+const selectedForum = shallowRef();
const sortGameList = shallowRef>([]);
const postRaw = shallowRef({ isLast: false, lastId: "", total: 0 });
const posts = shallowRef>([]);
@@ -271,12 +275,13 @@ async function getCurrentPosts(
}
async function freshPostData(): Promise {
- if (!selectedForum.value) return;
+ if (!selectedForum.value || isReq.value) return;
await router.push({
name: "酒馆",
params: route.params,
query: { gid: curGid.value, forum: selectedForum.value.value },
});
+ isReq.value = true;
await showLoading.start(`正在刷新${getGameLabel(curGid.value)}帖子`);
const gameLabel = getGameLabel(curGid.value);
const forumLabel = getForum(curGid.value, selectedForum.value.value).text;
@@ -295,6 +300,7 @@ async function freshPostData(): Promise {
};
showSnackbar.success(`刷新成功,共加载 ${postsGet.list.length} 条帖子`);
await showLoading.end();
+ isReq.value = false;
}
async function loadMore(): Promise {
@@ -306,6 +312,8 @@ async function loadMore(): Promise {
showSnackbar.warn("没有更多帖子了");
return;
}
+ if (isReq.value) return;
+ isReq.value = true;
await showLoading.start("正在加载更多帖子数据", `游戏:${getGameLabel(curGid.value)}`);
const postsGet = await getCurrentPosts(true, selectedForum.value.value);
await showLoading.update(
@@ -319,6 +327,7 @@ async function loadMore(): Promise {
};
showSnackbar.success(`加载成功,共加载 ${postsGet.list.length} 条帖子`);
await showLoading.end();
+ isReq.value = false;
}
function searchPost(): void {
diff --git a/src/pages/common/PostTopic.vue b/src/pages/common/PostTopic.vue
index 278403c7..7f46ae4b 100644
--- a/src/pages/common/PostTopic.vue
+++ b/src/pages/common/PostTopic.vue
@@ -21,6 +21,7 @@
:item-value="(item) => item"
variant="outlined"
label="分区"
+ :disabled="isReq"
>
@@ -55,6 +56,7 @@
item-value="value"
variant="outlined"
label="排序"
+ :disabled="isReq"
/>
(0);
const curSortType = ref<0 | 1 | 2>(0);
const search = ref("");
const curTopic = ref("");
+const isReq = ref(false);
const allGames = shallowRef>([]);
const postRaw = shallowRef({ isLast: false, lastId: "", total: 0 });
const topicInfo = shallowRef();
@@ -169,6 +172,8 @@ watch(
);
async function firstLoad(): Promise {
+ if (isReq.value) return;
+ isReq.value = true;
await showLoading.start(`正在加载话题${topicInfo.value?.topic.name}信息`);
await router.push({
name: "话题",
@@ -190,10 +195,13 @@ async function firstLoad(): Promise {
};
posts.value = postList.posts;
await showLoading.end();
+ isReq.value = false;
showSnackbar.success(`加载了 ${postList.posts.length} 条帖子`);
}
async function freshPostData(): Promise {
+ if (isReq.value) return;
+ isReq.value = true;
if (postRaw.value.isLast) {
showSnackbar.warn("已经到底了");
return;
@@ -201,27 +209,29 @@ async function freshPostData(): Promise {
await showLoading.start(`正在刷新${topicInfo.value?.topic.name}帖子列表`);
const mod20 = postRaw.value.total % 20;
const pageSize = mod20 === 0 ? 20 : 20 - mod20;
- const postList = await postReq.topic(
+ const resp = await postReq.topic(
curGid.value,
curTopic.value,
curSortType.value,
postRaw.value.lastId,
pageSize,
);
- if ("retcode" in postList) {
+ if ("retcode" in resp) {
await showLoading.end();
- showSnackbar.error(`[${postList.retcode}] ${postList.message}`);
+ isReq.value = false;
+ showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
return;
}
- await showLoading.update(`数量:${postList.posts.length},是否最后一页:${postList.is_last}`);
+ await showLoading.update(`数量:${resp.posts.length},是否最后一页:${resp.is_last}`);
postRaw.value = {
- isLast: postList.is_last,
- lastId: postList.last_id,
- total: postRaw.value.total + postList.posts.length,
+ isLast: resp.is_last,
+ lastId: resp.last_id,
+ total: postRaw.value.total + resp.posts.length,
};
- posts.value = posts.value.concat(postList.posts);
+ posts.value = posts.value.concat(resp.posts);
await showLoading.end();
- showSnackbar.success(`加载了 ${postList.posts.length} 条帖子`);
+ isReq.value = false;
+ showSnackbar.success(`加载了 ${resp.posts.length} 条帖子`);
}
function searchPost(): void {