mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🔥 移除帖子的 loadmore,刷新已经够用
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
@click:append="searchPost"
|
@click:append="searchPost"
|
||||||
@keyup.enter="searchPost"
|
@keyup.enter="searchPost"
|
||||||
/>
|
/>
|
||||||
<v-btn class="post-fresh-btn" @click="freshPostData(false)">
|
<v-btn class="post-fresh-btn" @click="freshPostData()">
|
||||||
<v-icon>mdi-refresh</v-icon>
|
<v-icon>mdi-refresh</v-icon>
|
||||||
<span>刷新</span>
|
<span>刷新</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -50,7 +50,6 @@
|
|||||||
<span>{{ navItem.name }}</span>
|
<span>{{ navItem.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- todo 无限加载 -->
|
|
||||||
<div class="posts-grid">
|
<div class="posts-grid">
|
||||||
<v-card v-for="post in posts" :key="post.postId" class="post-card">
|
<v-card v-for="post in posts" :key="post.postId" class="post-card">
|
||||||
<div class="post-cover" @click="createPost(post)">
|
<div class="post-cover" @click="createPost(post)">
|
||||||
@@ -101,12 +100,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
<!-- todo 完善 loadmore -->
|
|
||||||
<div class="load-more">
|
|
||||||
<v-btn :loading="loading" @click="freshPostData(true)">
|
|
||||||
第{{ rawData.page }}页,已加载:{{ posts.length }},加载更多
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -195,7 +188,6 @@ const gameList = {
|
|||||||
const curForumLabel = ref<string>("酒馆");
|
const curForumLabel = ref<string>("酒馆");
|
||||||
const forumItem = ref<string[]>(["酒馆", "攻略", "同人图", "COS", "硬核"]);
|
const forumItem = ref<string[]>(["酒馆", "攻略", "同人图", "COS", "硬核"]);
|
||||||
const curForum = ref<number>(26);
|
const curForum = ref<number>(26);
|
||||||
const rawData = ref({ page: 1, is_last: false });
|
|
||||||
|
|
||||||
// 游戏相关
|
// 游戏相关
|
||||||
const curGameLabel = ref<keyof typeof gameList>("原神");
|
const curGameLabel = ref<keyof typeof gameList>("原神");
|
||||||
@@ -223,7 +215,7 @@ const search = ref<string>();
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await freshNavData();
|
await freshNavData();
|
||||||
await freshPostData(false);
|
await freshPostData();
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -236,7 +228,7 @@ watch(curGameLabel, async (newVal) => {
|
|||||||
freshCurForum(forumItem.value[0]);
|
freshCurForum(forumItem.value[0]);
|
||||||
} else {
|
} else {
|
||||||
freshCurForum(curForumLabel.value);
|
freshCurForum(curForumLabel.value);
|
||||||
await freshPostData(false);
|
await freshPostData();
|
||||||
}
|
}
|
||||||
await freshNavData();
|
await freshNavData();
|
||||||
});
|
});
|
||||||
@@ -244,13 +236,13 @@ watch(curGameLabel, async (newVal) => {
|
|||||||
// 监听论坛变化
|
// 监听论坛变化
|
||||||
watch(curForumLabel, async (newVal) => {
|
watch(curForumLabel, async (newVal) => {
|
||||||
freshCurForum(newVal);
|
freshCurForum(newVal);
|
||||||
await freshPostData(false);
|
await freshPostData();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听排序变化
|
// 监听排序变化
|
||||||
watch(curSortLabel, async (newVal) => {
|
watch(curSortLabel, async (newVal) => {
|
||||||
curSortType.value = sortList[newVal];
|
curSortType.value = sortList[newVal];
|
||||||
await freshPostData(false);
|
await freshPostData();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function toNav(path: string): Promise<void> {
|
async function toNav(path: string): Promise<void> {
|
||||||
@@ -310,33 +302,11 @@ async function freshNavData(): Promise<void> {
|
|||||||
nav.value = await Mys.Posts.nav(curGid.value);
|
nav.value = await Mys.Posts.nav(curGid.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function freshPostData(more: boolean = false): Promise<void> {
|
async function freshPostData(): Promise<void> {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
loadingTitle.value = `正在加载 ${curGameLabel.value}-${curForumLabel.value}-${curSortLabel.value} 的数据`;
|
loadingTitle.value = `正在加载 ${curGameLabel.value}-${curForumLabel.value}-${curSortLabel.value} 的数据`;
|
||||||
if (more) {
|
const postsGet = await Mys.Posts.get(curForum.value, curSortType.value);
|
||||||
const postsGet = await Mys.Posts.get(
|
posts.value = Mys.Posts.card(postsGet);
|
||||||
curForum.value,
|
|
||||||
curGid.value,
|
|
||||||
curSortType.value,
|
|
||||||
rawData.value.page,
|
|
||||||
);
|
|
||||||
if (rawData.value.is_last) {
|
|
||||||
showSnackbar({
|
|
||||||
text: "已经是最后一页了",
|
|
||||||
color: "warn",
|
|
||||||
});
|
|
||||||
loading.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
posts.value = posts.value.concat(Mys.Posts.card(postsGet));
|
|
||||||
rawData.value.is_last = postsGet.is_last;
|
|
||||||
rawData.value.page = postsGet.page;
|
|
||||||
} else {
|
|
||||||
const postsGet = await Mys.Posts.get(curForum.value, curGid.value, curSortType.value);
|
|
||||||
posts.value = Mys.Posts.card(postsGet);
|
|
||||||
rawData.value.is_last = false;
|
|
||||||
rawData.value.page = 1;
|
|
||||||
}
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
@@ -605,19 +575,4 @@ function searchPost(): void {
|
|||||||
gap: 5px;
|
gap: 5px;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin: 10px;
|
|
||||||
font-family: var(--font-title);
|
|
||||||
transition: all 0.3s linear;
|
|
||||||
}
|
|
||||||
|
|
||||||
.load-more button {
|
|
||||||
border-radius: 5px;
|
|
||||||
background: var(--tgc-btn-1);
|
|
||||||
color: var(--btn-text);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file plugins/Mys/api/index.ts
|
* @file plugins/Mys/api/index.ts
|
||||||
* @description Mys API
|
* @description Mys API
|
||||||
* @since Beta v0.3.7
|
* @since Beta v0.3.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MysApi = {
|
const MysApi = {
|
||||||
@@ -10,7 +10,7 @@ const MysApi = {
|
|||||||
Lottery: "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?id={lotteryId}",
|
Lottery: "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?id={lotteryId}",
|
||||||
News: "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids={gid}&page_size={pageSize}&type={newsType}&last_id={lastId}",
|
News: "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids={gid}&page_size={pageSize}&type={newsType}&last_id={lastId}",
|
||||||
Forum:
|
Forum:
|
||||||
"https://bbs-api.miyoushe.com/post/wapi/getForumPostList?forum_id={forum}&gids={gid}&sort_type={type}&page={page}&page_size=20",
|
"https://bbs-api.miyoushe.com/post/wapi/getForumPostList?forum_id={forum}&sort_type={type}",
|
||||||
Feed: "https://bbs-api.miyoushe.com/post/api/feeds/posts?gids={gid}",
|
Feed: "https://bbs-api.miyoushe.com/post/api/feeds/posts?gids={gid}",
|
||||||
Navigator: "https://bbs-api.miyoushe.com/apihub/api/home/new?gids={gid}",
|
Navigator: "https://bbs-api.miyoushe.com/apihub/api/home/new?gids={gid}",
|
||||||
Position: "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc",
|
Position: "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc",
|
||||||
|
|||||||
@@ -10,23 +10,19 @@ import MysApi from "../api";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取特定论坛列表
|
* @description 获取特定论坛列表
|
||||||
* @since Beta v0.3.7
|
* @since Beta v0.3.9
|
||||||
* @param {number} forumId 特定论坛 ID
|
* @param {number} forumId 特定论坛 ID
|
||||||
* @param {number} gid GID
|
|
||||||
* @param {number} type 排序方式: 0-按热度排序,1-最新回复,2-按时间排序
|
* @param {number} type 排序方式: 0-按热度排序,1-最新回复,2-按时间排序
|
||||||
* @param {number} page 页码
|
|
||||||
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
||||||
*/
|
*/
|
||||||
async function getForumList(
|
async function getForumList(
|
||||||
forumId: number,
|
forumId: number,
|
||||||
gid: number = 2,
|
|
||||||
type: number = 0,
|
type: number = 0,
|
||||||
page: number = 1,
|
|
||||||
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||||
const url = MysApi.Forum.replace("{forum}", forumId.toString())
|
const url = MysApi.Forum.replace("{forum}", forumId.toString()).replace(
|
||||||
.replace("{gid}", gid.toString())
|
"{type}",
|
||||||
.replace("{type}", type.toString())
|
type.toString(),
|
||||||
.replace("{page}", page.toString());
|
);
|
||||||
return await http.fetch<TGApp.Plugins.Mys.Forum.Response>(url).then((res) => res.data.data);
|
return await http.fetch<TGApp.Plugins.Mys.Forum.Response>(url).then((res) => res.data.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user