mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-29 06:09:45 +08:00
👽️ 完善类型,改用常量枚举,适配typescript 6
This commit is contained in:
@@ -2,22 +2,22 @@
|
||||
<template>
|
||||
<div class="tpr-main-box" title="查看回复">
|
||||
<v-menu
|
||||
location="end"
|
||||
:close-on-content-click="false"
|
||||
v-model="showOverlay"
|
||||
:persistent="true"
|
||||
:close-on-content-click="false"
|
||||
:no-click-animation="true"
|
||||
z-index="60"
|
||||
:offset="[12, 0]"
|
||||
:persistent="true"
|
||||
location="end"
|
||||
z-index="60"
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<v-btn
|
||||
:loading="loading"
|
||||
class="tpr-btn"
|
||||
size="36"
|
||||
v-bind="props"
|
||||
variant="outlined"
|
||||
@click="showReply()"
|
||||
v-bind="props"
|
||||
size="36"
|
||||
>
|
||||
<template #default>
|
||||
<v-icon size="20">mdi-message-text-outline</v-icon>
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="tpr-main-filter">
|
||||
<div class="tpr-title">
|
||||
<span title="刷新" @click="handleDebug">回复列表</span>
|
||||
<v-btn @click="showOverlay = false" icon="mdi-close" class="tpr-btn-close" size="32" />
|
||||
<v-btn class="tpr-btn-close" icon="mdi-close" size="32" @click="showOverlay = false" />
|
||||
</div>
|
||||
<div class="tpr-subtitle">
|
||||
<div class="tpr-switch" @click="switchOnlyLz()">
|
||||
@@ -40,14 +40,14 @@
|
||||
</div>
|
||||
<div class="tpr-select">
|
||||
<v-select
|
||||
:hide-details="true"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
v-model="orderType"
|
||||
:hide-details="true"
|
||||
:items="orderList"
|
||||
density="compact"
|
||||
item-title="label"
|
||||
item-value="value"
|
||||
label="排序方式"
|
||||
variant="outlined"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,14 +57,14 @@
|
||||
v-for="(item, index) in reply"
|
||||
:key="index"
|
||||
:modelValue="item"
|
||||
mode="main"
|
||||
:pinId="pinId"
|
||||
mode="main"
|
||||
/>
|
||||
<div v-if="isLast" class="tpr-list-item">
|
||||
<v-chip color="blue" label>没有更多了</v-chip>
|
||||
</div>
|
||||
<div v-else class="tpr-list-item">
|
||||
<v-btn @click="loadReply()" color="blue" :loading="loading">加载更多</v-btn>
|
||||
<v-btn :loading="loading" color="blue" @click="loadReply()">加载更多</v-btn>
|
||||
</div>
|
||||
</v-list>
|
||||
</div>
|
||||
@@ -73,6 +73,7 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import bbsEnum from "@enum/bbs.js";
|
||||
import postReq from "@req/postReq.js";
|
||||
import { emit } from "@tauri-apps/api/event";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
@@ -90,18 +91,6 @@ type TprMainProps = {
|
||||
postId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* 回复排序类型
|
||||
*/
|
||||
enum ReplyOrderType {
|
||||
/* 热门 */
|
||||
HOT = 0,
|
||||
/* 最新 */
|
||||
LATEST = 2,
|
||||
/* 最早 */
|
||||
OLDEST = 1,
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择项类型
|
||||
*/
|
||||
@@ -109,16 +98,21 @@ type SelectItem = {
|
||||
/* 文本 */
|
||||
label: string;
|
||||
/* 值 */
|
||||
value: ReplyOrderType;
|
||||
value: TGApp.BBS.Reply.ReplyOrderTypeEnum;
|
||||
};
|
||||
|
||||
const props = defineProps<TprMainProps>();
|
||||
|
||||
// 简单封装选项
|
||||
const genOrderItem = (order: TGApp.BBS.Reply.ReplyOrderTypeEnum): SelectItem => ({
|
||||
label: bbsEnum.post.replyOrderTypeDesc(order),
|
||||
value: order,
|
||||
});
|
||||
const orderList: Array<SelectItem> = [
|
||||
{ label: "热门", value: ReplyOrderType.HOT },
|
||||
{ label: "最新", value: ReplyOrderType.LATEST },
|
||||
{ label: "最早", value: ReplyOrderType.OLDEST },
|
||||
];
|
||||
bbsEnum.post.replyOrderType.HOT,
|
||||
bbsEnum.post.replyOrderType.LATEST,
|
||||
bbsEnum.post.replyOrderType.OLDEST,
|
||||
].map(genOrderItem);
|
||||
|
||||
const pinId = ref<string>("0");
|
||||
const lastId = ref<string>();
|
||||
@@ -126,11 +120,11 @@ const isLast = ref<boolean>(false);
|
||||
const loading = ref<boolean>(false);
|
||||
const showOverlay = ref<boolean>(false);
|
||||
const onlyLz = ref<boolean>(false);
|
||||
const orderType = ref<ReplyOrderType>(ReplyOrderType.HOT);
|
||||
const orderType = ref<TGApp.BBS.Reply.ReplyOrderTypeEnum>(bbsEnum.post.replyOrderType.HOT);
|
||||
const reply = shallowRef<Array<TGApp.BBS.Reply.ReplyFull>>([]);
|
||||
const isHot = computed<boolean>(() => orderType.value === ReplyOrderType.HOT);
|
||||
const replyOrder = computed<1 | 2 | undefined>(() => {
|
||||
if (orderType.value === ReplyOrderType.HOT) return undefined;
|
||||
const isHot = computed<boolean>(() => orderType.value === bbsEnum.post.replyOrderType.HOT);
|
||||
const replyOrder = computed<TGApp.BBS.Reply.ReplyOrderTypeEnum | undefined>(() => {
|
||||
if (orderType.value === bbsEnum.post.replyOrderType.HOT) return undefined;
|
||||
return orderType.value;
|
||||
});
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
v-for="post in results"
|
||||
:key="post.post.post_id"
|
||||
:post
|
||||
@onUserClick="toUserProfile"
|
||||
class="tops-item"
|
||||
@onUserClick="toUserProfile"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -38,6 +38,7 @@
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import TPostCard from "@comp/app/t-postcard.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import bbsEnum from "@enum/bbs.js";
|
||||
import { useBoxReachBottom } from "@hooks/reachBottom.js";
|
||||
import postReq from "@req/postReq.js";
|
||||
import useBBSStore from "@store/bbs.js";
|
||||
@@ -46,12 +47,19 @@ import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, useTemplateRef, watch } from "vue";
|
||||
|
||||
type ToPostSearchProps = { gid: number; keyword?: string };
|
||||
type SortSelect = { text: string; value: number };
|
||||
type SortSelect<T extends number = number> = { text: string; value: T };
|
||||
|
||||
const sortOrderList: Array<SortSelect> = [
|
||||
{ text: "最新", value: 2 },
|
||||
{ text: "最热", value: 1 },
|
||||
];
|
||||
// 简单封装选项
|
||||
const genSortItem = (
|
||||
sort: TGApp.BBS.Post.SearchSortTypeEnum,
|
||||
): SortSelect<TGApp.BBS.Post.SearchSortTypeEnum> => ({
|
||||
text: bbsEnum.post.searchSortTypeDesc(sort),
|
||||
value: sort,
|
||||
});
|
||||
const sortOrderList: ReadonlyArray<SortSelect<TGApp.BBS.Post.SearchSortTypeEnum>> = [
|
||||
bbsEnum.post.searchSortType.LATEST,
|
||||
bbsEnum.post.searchSortType.HOT,
|
||||
].map(genSortItem);
|
||||
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
|
||||
@@ -66,7 +74,7 @@ const lastId = ref<string>("");
|
||||
const gameId = ref<string>("2");
|
||||
const isLast = ref<boolean>(false);
|
||||
const load = ref<boolean>(false);
|
||||
const sortType = ref<number>(1);
|
||||
const sortType = ref<TGApp.BBS.Post.SearchSortTypeEnum>(bbsEnum.post.searchSortType.HOT);
|
||||
const results = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
|
||||
const label = computed<string>(() => {
|
||||
const gameFind = gameList.value.find((v) => v.id.toString() === gameId.value);
|
||||
|
||||
111
src/enum/bbs.ts
111
src/enum/bbs.ts
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 米游社相关枚举
|
||||
* @since Beta v0.7.9
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -73,6 +73,107 @@ function getPostNewsTypeDesc(newsType: TGApp.BBS.Post.NewsTypeEnum): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 话题排序类型
|
||||
* @since Beta v0.9.9
|
||||
* @see TGApp.BBS.Post.PostTopicSortType
|
||||
*/
|
||||
const PostTopicSortTypeEnum: typeof TGApp.BBS.Post.PostTopicSortType = {
|
||||
LATEST: 0,
|
||||
FEATURED: 1,
|
||||
HOT: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据话题排序类型获取描述
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
function getPostTopicSortTypeDesc(sortType: TGApp.BBS.Post.PostTopicSortTypeEnum): string {
|
||||
switch (sortType) {
|
||||
case PostTopicSortTypeEnum.LATEST:
|
||||
return "最新";
|
||||
case PostTopicSortTypeEnum.FEATURED:
|
||||
return "精选";
|
||||
case PostTopicSortTypeEnum.HOT:
|
||||
return "热门";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 论坛排序类型
|
||||
* @since Beta v0.9.9
|
||||
* @see TGApp.BBS.Post.ForumSortType
|
||||
*/
|
||||
const ForumSortTypeEnum: typeof TGApp.BBS.Post.ForumSortType = {
|
||||
LATEST_REPLY: 1,
|
||||
LATEST_POST: 2,
|
||||
HOT: 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据论坛排序类型获取描述
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
function getForumSortTypeDesc(sortType: TGApp.BBS.Post.ForumSortTypeEnum): string {
|
||||
switch (sortType) {
|
||||
case ForumSortTypeEnum.LATEST_REPLY:
|
||||
return "最新回复";
|
||||
case ForumSortTypeEnum.LATEST_POST:
|
||||
return "最新发布";
|
||||
case ForumSortTypeEnum.HOT:
|
||||
return "热门";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索排序类型
|
||||
* @since Beta v0.9.9
|
||||
* @see TGApp.BBS.Post.SearchSortType
|
||||
*/
|
||||
const SearchSortTypeEnum: typeof TGApp.BBS.Post.SearchSortType = {
|
||||
HOT: 1,
|
||||
LATEST: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据搜索排序类型获取描述
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
function getSearchSortTypeDesc(sortType: TGApp.BBS.Post.SearchSortTypeEnum): string {
|
||||
switch (sortType) {
|
||||
case SearchSortTypeEnum.HOT:
|
||||
return "最热";
|
||||
case SearchSortTypeEnum.LATEST:
|
||||
return "最新";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复排序类型
|
||||
* @since Beta v0.9.9
|
||||
* @see TGApp.BBS.Reply.ReplyOrderType
|
||||
*/
|
||||
const ReplyOrderTypeEnum: typeof TGApp.BBS.Reply.ReplyOrderType = {
|
||||
HOT: 0,
|
||||
OLDEST: 1,
|
||||
LATEST: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取回复排序类型描述
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
function getReplyOrderTypeDesc(replyType: TGApp.BBS.Reply.ReplyOrderTypeEnum): string {
|
||||
switch (replyType) {
|
||||
case ReplyOrderTypeEnum.HOT:
|
||||
return "热门";
|
||||
case ReplyOrderTypeEnum.OLDEST:
|
||||
return "最早";
|
||||
case ReplyOrderTypeEnum.LATEST:
|
||||
return "最新";
|
||||
}
|
||||
}
|
||||
|
||||
/** 米游社相关枚举 */
|
||||
const bbsEnum = {
|
||||
/** 用户信息相关枚举 */
|
||||
@@ -86,6 +187,14 @@ const bbsEnum = {
|
||||
newsType: PostNewsTypeEnum,
|
||||
newsTypeList: PostNewsTypeList,
|
||||
newsTypeDesc: getPostNewsTypeDesc,
|
||||
topicSortType: PostTopicSortTypeEnum,
|
||||
topicSortTypeDesc: getPostTopicSortTypeDesc,
|
||||
forumSortType: ForumSortTypeEnum,
|
||||
forumSortTypeDesc: getForumSortTypeDesc,
|
||||
searchSortType: SearchSortTypeEnum,
|
||||
searchSortTypeDesc: getSearchSortTypeDesc,
|
||||
replyOrderType: ReplyOrderTypeEnum,
|
||||
replyOrderTypeDesc: getReplyOrderTypeDesc,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
:hide-details="true"
|
||||
:clearable="true"
|
||||
:hide-details="true"
|
||||
append-inner-icon="mdi-magnify"
|
||||
class="post-switch-item"
|
||||
label="请输入帖子 ID 或搜索词"
|
||||
@@ -97,7 +97,7 @@
|
||||
</v-btn>
|
||||
</div>
|
||||
<template #extension>
|
||||
<TGameNav :mini="false" :gid="curGid" style="margin-left: 8px" />
|
||||
<TGameNav :gid="curGid" :mini="false" style="margin-left: 8px" />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
<div class="posts-grid">
|
||||
@@ -115,6 +115,7 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import VpOverlayUser from "@comp/viewPost/vp-overlay-user.vue";
|
||||
import bbsEnum from "@enum/bbs.js";
|
||||
import { usePageReachBottom } from "@hooks/reachBottom.js";
|
||||
import painterReq from "@req/painterReq.js";
|
||||
import useBBSStore from "@store/bbs.js";
|
||||
@@ -124,20 +125,26 @@ import { storeToRefs } from "pinia";
|
||||
import { computed, nextTick, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
type SortSelect = { text: string; value: number; icon: string };
|
||||
type SortSelect<T extends number = number> = { text: string; value: T; icon: string };
|
||||
type SortSelectForum = Omit<SortSelect<TGApp.BBS.Post.ForumSortTypeEnum>, "icon">;
|
||||
type SortSelectGame = { gid: number; forum: Array<SortSelect>; text: string; icon?: string };
|
||||
type PostRaw = { isLast: boolean; lastId: string; total: number };
|
||||
|
||||
const sortOrderList: Array<Omit<SortSelect, "icon">> = [
|
||||
{ text: "最新回复", value: 1 },
|
||||
{ text: "最新发布", value: 2 },
|
||||
{ text: "热门", value: 3 },
|
||||
];
|
||||
// 简单封装选项生成
|
||||
const genSortOrderItem = (order: TGApp.BBS.Post.ForumSortTypeEnum): SortSelectForum => ({
|
||||
text: bbsEnum.post.forumSortTypeDesc(order),
|
||||
value: order,
|
||||
});
|
||||
const sortOrderList: ReadonlyArray<SortSelectForum> = [
|
||||
bbsEnum.post.forumSortType.LATEST_REPLY,
|
||||
bbsEnum.post.forumSortType.LATEST_POST,
|
||||
bbsEnum.post.forumSortType.HOT,
|
||||
].map(genSortOrderItem);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const curGid = ref<number>(2);
|
||||
const curSortType = ref<number>(1);
|
||||
const curSortType = ref<TGApp.BBS.Post.ForumSortTypeEnum>(bbsEnum.post.forumSortType.LATEST_REPLY);
|
||||
const firstLoad = ref<boolean>(false);
|
||||
const isReq = ref<boolean>(false);
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
:hide-details="true"
|
||||
:clearable="true"
|
||||
:hide-details="true"
|
||||
append-inner-icon="mdi-magnify"
|
||||
class="post-switch-item"
|
||||
label="请输入帖子 ID 或搜索词"
|
||||
@@ -103,6 +103,7 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import VpOverlayUser from "@comp/viewPost/vp-overlay-user.vue";
|
||||
import bbsEnum from "@enum/bbs.js";
|
||||
import { usePageReachBottom } from "@hooks/reachBottom.js";
|
||||
import postReq from "@req/postReq.js";
|
||||
import topicReq from "@req/topicReq.js";
|
||||
@@ -113,10 +114,18 @@ import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
type SortSelect = { text: string; value: number };
|
||||
type SortSelect<T extends number = number> = { text: string; value: T };
|
||||
type PostMiniData = { isLast: boolean; lastId: string; total: number };
|
||||
type GameList = TGApp.BBS.Topic.GameInfo & { icon?: string };
|
||||
|
||||
// 简单封装选项生成
|
||||
const genSortOrderItem = (
|
||||
sort: TGApp.BBS.Post.PostTopicSortTypeEnum,
|
||||
): SortSelect<TGApp.BBS.Post.PostTopicSortTypeEnum> => ({
|
||||
text: bbsEnum.post.topicSortTypeDesc(sort),
|
||||
value: sort,
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -125,7 +134,7 @@ const { sidebar } = storeToRefs(useAppStore());
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
|
||||
const curGid = ref<number>(0);
|
||||
const curSortType = ref<0 | 1 | 2>(0);
|
||||
const curSortType = ref<TGApp.BBS.Post.PostTopicSortTypeEnum>(bbsEnum.post.topicSortType.LATEST);
|
||||
const curTopic = ref<string>("");
|
||||
|
||||
const search = ref<string>("");
|
||||
@@ -139,19 +148,19 @@ const postRaw = shallowRef<PostMiniData>({ isLast: false, lastId: "", total: 0 }
|
||||
const topicInfo = shallowRef<TGApp.BBS.Topic.InfoRes>();
|
||||
const posts = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
|
||||
const curGame = shallowRef<GameList>();
|
||||
const sortList = computed<Array<SortSelect>>(() => {
|
||||
const sortList = computed<Array<SortSelect<TGApp.BBS.Post.PostTopicSortTypeEnum>>>(() => {
|
||||
if (!topicInfo.value) return [];
|
||||
let sortArr: ReadonlyArray<TGApp.BBS.Post.PostTopicSortTypeEnum>;
|
||||
if (!topicInfo.value.good_post_exist) {
|
||||
return [
|
||||
{ text: "最新", value: 0 },
|
||||
{ text: "热门", value: 2 },
|
||||
sortArr = [bbsEnum.post.topicSortType.LATEST, bbsEnum.post.topicSortType.HOT];
|
||||
} else {
|
||||
sortArr = [
|
||||
bbsEnum.post.topicSortType.LATEST,
|
||||
bbsEnum.post.topicSortType.HOT,
|
||||
bbsEnum.post.topicSortType.FEATURED,
|
||||
];
|
||||
}
|
||||
return [
|
||||
{ text: "最新", value: 0 },
|
||||
{ text: "热门", value: 2 },
|
||||
{ text: "精选", value: 1 },
|
||||
];
|
||||
return sortArr.map(genSortOrderItem);
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* painter 下的请求
|
||||
* @since Beta v0.8.3
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
import bbsEnum from "@enum/bbs.js";
|
||||
import { getRequestHeader } from "@utils/getRequestHeader.js";
|
||||
@@ -73,7 +73,7 @@ async function getHotForumPostList(
|
||||
|
||||
/**
|
||||
* 获取最近版块帖子列表
|
||||
* @since Beta v0.8.3
|
||||
* @since Beta v0.9.9
|
||||
* @param forumId - 版块 ID
|
||||
* @param gid - 社区 ID
|
||||
* @param type - 排序方式: 1-最新回复,2-最新发布
|
||||
@@ -85,7 +85,7 @@ async function getHotForumPostList(
|
||||
async function getRecentForumPostList(
|
||||
forumId: number,
|
||||
gid: number,
|
||||
type: number = 1,
|
||||
type: TGApp.BBS.Post.ForumSortTypeEnum = bbsEnum.post.forumSortType.LATEST_REPLY,
|
||||
lastId?: string,
|
||||
pageSize: number = 20,
|
||||
cookie?: Record<string, string>,
|
||||
@@ -93,7 +93,7 @@ async function getRecentForumPostList(
|
||||
type ReqParams = {
|
||||
forum_id: number;
|
||||
gids: number;
|
||||
sort_type: number;
|
||||
sort_type: TGApp.BBS.Post.ForumSortTypeEnum;
|
||||
is_good: boolean;
|
||||
page_size: number;
|
||||
last_id?: string;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* 帖子相关的请求
|
||||
* @since Beta v0.9.1
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
import bbsEnum from "@enum/bbs.js";
|
||||
import { getRequestHeader } from "@utils/getRequestHeader.js";
|
||||
import TGHttp from "@utils/TGHttp.js";
|
||||
|
||||
@@ -54,7 +55,7 @@ async function getPostFullInCollection(
|
||||
|
||||
/**
|
||||
* 获取帖子回复信息
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.9.9
|
||||
* @param postId - 帖子 ID
|
||||
* @param gid - 社区 ID
|
||||
* @param isHot - 是否热门
|
||||
@@ -70,7 +71,7 @@ async function getPostReplies(
|
||||
isHot: boolean = true,
|
||||
lastId?: string,
|
||||
onlyMaster: boolean = false,
|
||||
orderType?: 1 | 2,
|
||||
orderType?: TGApp.BBS.Reply.ReplyOrderTypeEnum,
|
||||
size: number = 20,
|
||||
): Promise<TGApp.BBS.Reply.MainRes | TGApp.BBS.Response.Base> {
|
||||
type GprParam = {
|
||||
@@ -79,7 +80,7 @@ async function getPostReplies(
|
||||
is_hot: boolean;
|
||||
size: number;
|
||||
last_id?: string;
|
||||
order_type?: 1 | 2;
|
||||
order_type?: TGApp.BBS.Reply.ReplyOrderTypeEnum;
|
||||
only_master?: boolean;
|
||||
};
|
||||
const params: GprParam = { post_id: postId, gids: gid, is_hot: isHot, size: size };
|
||||
@@ -136,7 +137,7 @@ async function getSubReplies(
|
||||
|
||||
/**
|
||||
* 获取特定话题帖子列表
|
||||
* @since Beta v0.7.1
|
||||
* @since Beta v0.9.9
|
||||
* @param gid - 游戏分区 ID
|
||||
* @param topicId - 话题 ID
|
||||
* @param orderType - 排序方式
|
||||
@@ -147,7 +148,7 @@ async function getSubReplies(
|
||||
async function getTopicPostList(
|
||||
gid: number,
|
||||
topicId: string,
|
||||
orderType: number = 0,
|
||||
orderType: TGApp.BBS.Post.PostTopicSortTypeEnum = bbsEnum.post.topicSortType.LATEST,
|
||||
lastId?: string,
|
||||
size: number = 20,
|
||||
): Promise<TGApp.BBS.Topic.PostRes | TGApp.BBS.Response.Base> {
|
||||
@@ -192,7 +193,7 @@ async function getUserPost(
|
||||
|
||||
/**
|
||||
* 搜索帖子
|
||||
* @since Beta v0.8.7
|
||||
* @since Beta v0.9.9
|
||||
* @param gid - 游戏分区 ID
|
||||
* @param keyword - 关键词
|
||||
* @param lastId - 最后一条帖子 ID
|
||||
@@ -203,7 +204,7 @@ async function searchPosts(
|
||||
gid: string = "2",
|
||||
keyword: string,
|
||||
lastId: string,
|
||||
orderType: number,
|
||||
orderType: TGApp.BBS.Post.SearchSortTypeEnum,
|
||||
): Promise<TGApp.BBS.Post.SearchRes> {
|
||||
return (
|
||||
await TGHttp<TGApp.BBS.Post.SearchResp>(`${bapBu}searchPosts`, {
|
||||
|
||||
57
src/types/BBS/Post.d.ts
vendored
57
src/types/BBS/Post.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 帖子类型定义文件
|
||||
* @since Beta v0.9.8
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Post {
|
||||
@@ -63,6 +63,61 @@ declare namespace TGApp.BBS.Post {
|
||||
*/
|
||||
type NewsTypeEnum = (typeof NewsType)[keyof typeof NewsType];
|
||||
|
||||
/**
|
||||
* 话题排序类型
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
const PostTopicSortType = <const>{
|
||||
/** 最新 */
|
||||
LATEST: 0,
|
||||
/** 精选 */
|
||||
FEATURED: 1,
|
||||
/** 热门 */
|
||||
HOT: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* 话题排序类型枚举
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
type PostTopicSortTypeEnum = (typeof PostTopicSortType)[keyof typeof PostTopicSortType];
|
||||
|
||||
/**
|
||||
* 论坛排序类型
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
const ForumSortType = <const>{
|
||||
/** 最新回复 */
|
||||
LATEST_REPLY: 1,
|
||||
/** 最新发布 */
|
||||
LATEST_POST: 2,
|
||||
/** 热门 */
|
||||
HOT: 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* 论坛排序类型枚举
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
type ForumSortTypeEnum = (typeof ForumSortType)[keyof typeof ForumSortType];
|
||||
|
||||
/**
|
||||
* 搜索排序类型
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
const SearchSortType = <const>{
|
||||
/** 最热 */
|
||||
HOT: 1,
|
||||
/** 最新 */
|
||||
LATEST: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* 搜索排序类型枚举
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
type SearchSortTypeEnum = (typeof SearchSortType)[keyof typeof SearchSortType];
|
||||
|
||||
/**
|
||||
* 资讯返回响应
|
||||
* @since Beta v0.7.2
|
||||
|
||||
22
src/types/BBS/Reply.d.ts
vendored
22
src/types/BBS/Reply.d.ts
vendored
@@ -1,8 +1,28 @@
|
||||
/**
|
||||
* 回复数据类型定义文件
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Reply {
|
||||
/**
|
||||
* 回复排序类型
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
const ReplyOrderType = <const>{
|
||||
/* 热门 */
|
||||
HOT: 0,
|
||||
/* 最早 */
|
||||
OLDEST: 1,
|
||||
/* 最新 */
|
||||
LATEST: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* 回复排序类型枚举
|
||||
* @since Beta v0.9.9
|
||||
*/
|
||||
type ReplyOrderTypeEnum = (typeof ReplyOrderType)[keyof typeof ReplyOrderType];
|
||||
|
||||
/**
|
||||
* 帖子回复数据类型
|
||||
* @since Beta v0.7.1
|
||||
|
||||
Reference in New Issue
Block a user