mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-04 07:05:07 +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);
|
||||
|
||||
Reference in New Issue
Block a user