🐛 修复分类更新无效

This commit is contained in:
目棃
2024-11-15 13:41:12 +08:00
parent 10a5b88d24
commit 83e0d35245
3 changed files with 21 additions and 44 deletions

View File

@@ -26,7 +26,7 @@
<v-select
v-model="curSortType"
class="post-switch-item"
:items="sortOrderList"
:items="sortList"
item-title="text"
item-value="value"
variant="outlined"
@@ -43,7 +43,7 @@
@click:append="searchPost"
@keyup.enter="searchPost"
/>
<v-btn :rounded="true" class="post-fresh-btn" @click="freshPostData()">
<v-btn :rounded="true" class="post-fresh-btn" @click="firstLoad()">
<v-icon>mdi-refresh</v-icon>
<span>刷新</span>
</v-btn>
@@ -62,7 +62,7 @@
<ToPostSearch :gid="curGid.toString()" v-model="showSearch" :keyword="search" />
</template>
<script lang="ts" setup>
import { onMounted, ref, toRaw, watch } from "vue";
import { computed, onMounted, ref, toRaw, watch } from "vue";
import { useRoute } from "vue-router";
import showSnackbar from "../../components/func/snackbar.js";
@@ -90,12 +90,20 @@ const isLastPage = ref<boolean>(false);
const curGame = ref<TGApp.Plugins.Mys.Topic.GameInfo>();
type SortSelect = { text: string; value: number };
// todo 根据实际情况修改
const sortOrderList: SortSelect[] = [
{ text: "默认排序", value: 0 },
{ text: "按时间排序", value: 1 },
{ text: "按热度排序", value: 2 },
];
const sortList = computed<SortSelect[]>(() => {
if (!topicInfo.value) return [];
if (!topicInfo.value.good_post_exist) {
return [
{ text: "最新", value: 0 },
{ text: "热门", value: 2 },
];
}
return [
{ text: "最新", value: 0 },
{ text: "热门", value: 2 },
{ text: "精华", value: 1 },
];
});
onMounted(async () => await firstLoad());
watch(
@@ -122,7 +130,7 @@ async function firstLoad(): Promise<void> {
}
if (curGame.value === undefined) curGame.value = info.game_info_list[0];
loadingTitle.value = `正在加载${curGame.value.name}帖子列表`;
const postList = await Mys.Post.getTopicPostList(gid, topic);
const postList = await Mys.Post.getTopicPostList(gid, topic, curSortType.value);
if ("retcode" in postList) {
showSnackbar.error(`[${postList.retcode}] ${postList.message}`);
loading.value = false;

View File

@@ -1,15 +1,9 @@
/**
* @file plugins/Mys/types/post.d.ts
* @description Mys 插件帖子类型定义文件
* @since Beta v0.5.5
* @since Beta v0.6.3
*/
/**
* @description Mys 插件帖子类型
* @since Beta v0.5.5
* @namespace TGApp.Plugins.Mys.Post
* @memberof TGApp.Plugins.Mys
*/
declare namespace TGApp.Plugins.Mys.Post {
/**
* @description 帖子返回数据
@@ -55,7 +49,7 @@ declare namespace TGApp.Plugins.Mys.Post {
interface FullData {
post: Post;
forum: Forum | null;
topics: Topic[];
topics: TGApp.Plugins.Mys.Topic.Info[];
user: TGApp.Plugins.Mys.User.Post | null;
self_operation: TGApp.Plugins.Mys.User.SelfOperation;
stat: Stat | null;
@@ -195,31 +189,6 @@ declare namespace TGApp.Plugins.Mys.Post {
forum_cate: unknown | null;
}
/**
* @description 话题信息
* @since Alpha v0.2.1
* @interface Topic
* @property {number} id 话题 ID
* @property {string} name 话题名称
* @property {string} cover 话题封面图 URL
* @property {boolean} is_top 是否置顶
* @property {boolean} is_good 是否加精
* @property {boolean} is_interactive 是否互动
* @property {number} game_id 游戏 ID
* @property {number} content_type 内容类型
* @return Topic
*/
interface Topic {
id: number;
name: string;
cover: string;
is_top: boolean;
is_good: boolean;
is_interactive: boolean;
game_id: number;
content_type: number;
}
/**
* @description 帖子状态
* @since Beta v0.3.7

View File

@@ -211,7 +211,7 @@ watch(
},
);
async function toTopic(topic: TGApp.Plugins.Mys.Post.Topic): Promise<void> {
async function toTopic(topic: TGApp.Plugins.Mys.Topic.Info): Promise<void> {
const gid = postData.value?.post.game_id ?? topic.game_id;
await emit("active_deep_link", `router?path=/posts/${gid}/${topic.id}`);
}