mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-01 06:39:45 +08:00
👽️ 完善类型,改用常量枚举,适配typescript 6
This commit is contained in:
@@ -122,7 +122,6 @@
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
"@types/node": "^25.5.0",
|
||||
"@typescript-eslint/parser": "^8.57.2",
|
||||
"@typescript/native-preview": "7.0.0-dev.20260321.1",
|
||||
"@vitejs/plugin-vue": "^6.0.5",
|
||||
"app-root-path": "^3.1.0",
|
||||
"concurrently": "^9.2.1",
|
||||
|
||||
73
pnpm-lock.yaml
generated
73
pnpm-lock.yaml
generated
@@ -159,9 +159,6 @@ importers:
|
||||
'@typescript-eslint/parser':
|
||||
specifier: ^8.57.2
|
||||
version: 8.57.2(eslint@9.39.2(jiti@2.6.1))(typescript@6.0.2)
|
||||
'@typescript/native-preview':
|
||||
specifier: 7.0.0-dev.20260321.1
|
||||
version: 7.0.0-dev.20260321.1
|
||||
'@vitejs/plugin-vue':
|
||||
specifier: ^6.0.5
|
||||
version: 6.0.5(vite@8.0.2(@types/node@25.5.0)(esbuild@0.27.4)(jiti@2.6.1)(sass-embedded@1.98.0)(sass@1.98.0)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.3))(vue@3.5.30(typescript@6.0.2))
|
||||
@@ -1855,45 +1852,6 @@ packages:
|
||||
resolution: {integrity: sha512-zhahknjobV2FiD6Ee9iLbS7OV9zi10rG26odsQdfBO/hjSzUQbkIYgda+iNKK1zNiW2ey+Lf8MU5btN17V3dUw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@typescript/native-preview-darwin-arm64@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-3LQP363bDCF/pmXqzhSCSkKXr1PpNl2elC167YFRPKRyJdrETiIwj3YAB8A6esn9D30pas5VLzfmeK/tUOf+6g==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@typescript/native-preview-darwin-x64@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-gCoKiv415CROgl0K8hEV8Lw/zvbYriWWmD7VxvpiQiTRqQmHppVXhLtb2OrGaPcsqpoBdYeCJQHN4wnohAkNLA==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@typescript/native-preview-linux-arm64@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-15z7UWt0PG870ktcUbaa0NogAjXIYT4pSFWlsc95u8+1aITrBTMQgqRih5qUH8bHke3eeYwbpjfXaU4gNmexvw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@typescript/native-preview-linux-arm@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-QuAFR9eFQzuqtKTIaJ5XkNR4i5Q55b1SE7fUcIAS528aY9j+5P1cMpvJa8aOBCuRKxfMgV5UtamolZKGWWzaMw==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@typescript/native-preview-linux-x64@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-8yuzwkxQnNSpXjXK43Y5Pn6rBfNbJVIcd3Qh9n3Tzhgtr+lcoGgwgMvn8axnqaazkxIUB3PZuiGRcqr6XIq3LA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@typescript/native-preview-win32-arm64@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-fCUk/VElUjMFmE6iFAtsy5r7kLxeLggEHOTWuR0HGYIUQze6EyAdDFqMPFFxvbzpUyFQFpRfUa0I/Fa5tqKh8g==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@typescript/native-preview-win32-x64@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-CWGyck7+sbNwOhcL+ObHhtKZe2/+Y6OZlEdWX2mHjpv8ef7ohUbPCdS94p+e7jbVY56w8NAce2Xx7ppn/C1Ucg==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@typescript/native-preview@7.0.0-dev.20260321.1':
|
||||
resolution: {integrity: sha512-uScJZRWRxyi1l4EWwOtuO88Gh8sUTi0itcI4oKlyNtXkqik4Y7EHfs1sfYPDuAEJO3cvW6bqohHjGx3mcXSZzQ==}
|
||||
hasBin: true
|
||||
|
||||
'@vitejs/plugin-vue@6.0.5':
|
||||
resolution: {integrity: sha512-bL3AxKuQySfk1iGcBsQnoRVexTPJq0Z/ixFVM8OhVJAP6ZXXXLtM7NFKWhLl30Kg7uTBqIaPXbh+nuQCuBDedg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
@@ -6066,37 +6024,6 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.57.2
|
||||
eslint-visitor-keys: 5.0.1
|
||||
|
||||
'@typescript/native-preview-darwin-arm64@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview-darwin-x64@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview-linux-arm64@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview-linux-arm@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview-linux-x64@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview-win32-arm64@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview-win32-x64@7.0.0-dev.20260321.1':
|
||||
optional: true
|
||||
|
||||
'@typescript/native-preview@7.0.0-dev.20260321.1':
|
||||
optionalDependencies:
|
||||
'@typescript/native-preview-darwin-arm64': 7.0.0-dev.20260321.1
|
||||
'@typescript/native-preview-darwin-x64': 7.0.0-dev.20260321.1
|
||||
'@typescript/native-preview-linux-arm': 7.0.0-dev.20260321.1
|
||||
'@typescript/native-preview-linux-arm64': 7.0.0-dev.20260321.1
|
||||
'@typescript/native-preview-linux-x64': 7.0.0-dev.20260321.1
|
||||
'@typescript/native-preview-win32-arm64': 7.0.0-dev.20260321.1
|
||||
'@typescript/native-preview-win32-x64': 7.0.0-dev.20260321.1
|
||||
|
||||
'@vitejs/plugin-vue@6.0.5(vite@8.0.2(@types/node@25.5.0)(esbuild@0.27.4)(jiti@2.6.1)(sass-embedded@1.98.0)(sass@1.98.0)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.3))(vue@3.5.30(typescript@6.0.2))':
|
||||
dependencies:
|
||||
'@rolldown/pluginutils': 1.0.0-rc.2
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,34 +4,28 @@
|
||||
"useDefineForClassFields": true,
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["DOM", "ESNext"],
|
||||
"skipLibCheck": true,
|
||||
"types": ["vite/client", "node", "js-md5", "uuid"],
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"composite": true,
|
||||
"erasableSyntaxOnly": false,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"],
|
||||
"@styles/*": ["src/assets/styles/*"],
|
||||
"@comp/*": ["src/components/*"],
|
||||
"@enum/*": ["src/enum/*"],
|
||||
"@hooks/*": ["src/hooks/*"],
|
||||
"@Bili/*": ["src/plugins/Bili/*"],
|
||||
"@Hutao/*": ["src/plugins/Hutao/*"],
|
||||
"@Mys/*": ["src/plugins/Mys/*"],
|
||||
"@Sql/*": ["src/plugins/Sqlite/*"],
|
||||
"@Sqlm/*": ["src/plugins/Sqlite/modules/*"],
|
||||
"@req/*": ["src/request/*"],
|
||||
"@store/*": ["src/store/modules/*"],
|
||||
"@utils/*": ["src/utils/*"]
|
||||
"@/*": ["./src/*"],
|
||||
"@styles/*": ["./src/assets/styles/*"],
|
||||
"@comp/*": ["./src/components/*"],
|
||||
"@enum/*": ["./src/enum/*"],
|
||||
"@hooks/*": ["./src/hooks/*"],
|
||||
"@Bili/*": ["./src/plugins/Bili/*"],
|
||||
"@Hutao/*": ["./src/plugins/Hutao/*"],
|
||||
"@Mys/*": ["./src/plugins/Mys/*"],
|
||||
"@Sql/*": ["./src/plugins/Sqlite/*"],
|
||||
"@Sqlm/*": ["./src/plugins/Sqlite/modules/*"],
|
||||
"@req/*": ["./src/request/*"],
|
||||
"@store/*": ["./src/store/modules/*"],
|
||||
"@utils/*": ["./src/utils/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
|
||||
Reference in New Issue
Block a user