mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-25 05:29:45 +08:00
♻️ 重构部分请求
This commit is contained in:
@@ -77,7 +77,21 @@ import { createPost } from "@/utils/TGWindow.js";
|
||||
|
||||
type TPostCardProps = { modelValue: TGApp.Plugins.Mys.Post.FullData; selectMode?: boolean };
|
||||
type TPostCardEmits = (e: "onSelected", v: string) => void;
|
||||
type TPostStatus = TGApp.Plugins.Mys.News.RenderStatus & { stat: ActStat };
|
||||
type TPostStatus = RenderStatus & { stat: ActStat };
|
||||
type RenderForum = { name: string; icon: string; id: number };
|
||||
type RenderStatus = { stat: number; label: string; color: string };
|
||||
type RenderData = { mark: number; forward: number; like: number; reply: number; view: number };
|
||||
export type RenderCard = {
|
||||
title: string;
|
||||
cover: string;
|
||||
postId: number;
|
||||
subtitle: string;
|
||||
user: TGApp.Plugins.Mys.User.Post | null;
|
||||
forum: RenderForum | null;
|
||||
data: RenderData | null;
|
||||
status?: RenderStatus;
|
||||
topics: Array<TGApp.BBS.Topic.Info>;
|
||||
};
|
||||
|
||||
enum ActStat {
|
||||
UNKNOWN,
|
||||
@@ -94,7 +108,7 @@ const stats: Readonly<Array<TPostStatus>> = [
|
||||
];
|
||||
const props = withDefaults(defineProps<TPostCardProps>(), { selectMode: false });
|
||||
const emits = defineEmits<TPostCardEmits>();
|
||||
const card = shallowRef<TGApp.Plugins.Mys.News.RenderCard>();
|
||||
const card = shallowRef<RenderCard>();
|
||||
|
||||
const cardBg = computed<string>(() => {
|
||||
if (card.value && card.value.status) return card.value.status.color;
|
||||
@@ -108,7 +122,7 @@ watch(
|
||||
async () => (card.value = getPostCard(props.modelValue)),
|
||||
);
|
||||
|
||||
function getActivityStatus(status: number): TGApp.Plugins.Mys.News.RenderStatus {
|
||||
function getActivityStatus(status: number): RenderStatus {
|
||||
if (status satisfies ActStat) {
|
||||
const stat: ActStat = status;
|
||||
return stats[stat];
|
||||
@@ -126,15 +140,9 @@ function getPostCover(item: TGApp.Plugins.Mys.Post.FullData): string {
|
||||
return `${cover}?x-oss-process=image/resize,m_fill,w_360,h_130,limit_0/format,png`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取公共属性
|
||||
* @since Beta v0.6.1
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} item 咨讯列表项
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard} 渲染用咨讯列表项
|
||||
*/
|
||||
function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys.News.RenderCard {
|
||||
let forumData: TGApp.Plugins.Mys.News.RenderForum | null = null;
|
||||
let statData: TGApp.Plugins.Mys.News.RenderData | null = null;
|
||||
function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): RenderCard {
|
||||
let forumData: RenderForum | null = null;
|
||||
let statData: RenderData | null = null;
|
||||
if (item.forum !== null) {
|
||||
forumData = { name: item.forum.name, icon: item.forum.icon, id: item.forum.id };
|
||||
}
|
||||
@@ -159,7 +167,7 @@ function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys
|
||||
};
|
||||
}
|
||||
|
||||
function getPostCard(item: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys.News.RenderCard {
|
||||
function getPostCard(item: TGApp.Plugins.Mys.Post.FullData): RenderCard {
|
||||
const commonCard = getCommonCard(item);
|
||||
if (
|
||||
item.news_meta !== undefined &&
|
||||
@@ -186,12 +194,12 @@ async function shareCard(): Promise<void> {
|
||||
await generateShareImg(fileName, shareDom, 2.5);
|
||||
}
|
||||
|
||||
async function toTopic(topic: TGApp.Plugins.Mys.Topic.Info): Promise<void> {
|
||||
async function toTopic(topic: TGApp.BBS.Topic.Info): Promise<void> {
|
||||
const gid = props.modelValue.post.game_id;
|
||||
await emit("active_deep_link", `router?path=/posts/topic/${gid}/${topic.id}`);
|
||||
}
|
||||
|
||||
async function toForum(forum: TGApp.Plugins.Mys.News.RenderForum): Promise<void> {
|
||||
async function toForum(forum: RenderForum): Promise<void> {
|
||||
const gid = props.modelValue.post.game_id;
|
||||
await emit("active_deep_link", `router?path=/posts/forum/${gid}/${forum.id}`);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { getRecentForumPostList } from "@Mys/request/painterReq.js";
|
||||
import { getPostFull } from "@Mys/request/postReq.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref, shallowRef } from "vue";
|
||||
|
||||
import { useUserStore } from "@/store/modules/user.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
import painterReq from "@/web/request/painterReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type ParseMission = {
|
||||
id: number;
|
||||
@@ -164,7 +164,7 @@ async function tryAuto(): Promise<void> {
|
||||
const viewFind = postFilter.find((i) => i.key === "view_post_0");
|
||||
if (viewFind) viewCnt = viewFind.process;
|
||||
await TGLogger.Script("[米游币任务]获取帖子列表");
|
||||
const listResp = await getRecentForumPostList(26, 2, 2, undefined, 20);
|
||||
const listResp = await painterReq.forum.recent(26, 2, 2, undefined, 20);
|
||||
for (const post of listResp.list) {
|
||||
if (!isShare) {
|
||||
await TGLogger.Script(`[米游币任务]正在分享帖子${post.post.post_id}`);
|
||||
@@ -178,7 +178,7 @@ async function tryAuto(): Promise<void> {
|
||||
}
|
||||
if (likeCnt < 5 || viewCnt < 3) {
|
||||
await TGLogger.Script(`[米游币任务]正在浏览帖子${post.post.post_id}`);
|
||||
const detailResp = await getPostFull(Number(post.post.post_id), ckPost);
|
||||
const detailResp = await postReq.post(post.post.post_id, ckPost);
|
||||
if ("retcode" in detailResp) {
|
||||
await TGLogger.Script(
|
||||
`[米游币任务]获取帖子${post.post.post_id}失败:${detailResp.retcode} ${detailResp.message}`,
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, ref, shallowRef, watch } from "vue";
|
||||
|
||||
@@ -70,6 +69,7 @@ import VpReplyDebug from "./vp-reply-debug.vue";
|
||||
import VpReplyItem from "./vp-reply-item.vue";
|
||||
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type TprMainProps = { gid: number; postId: string };
|
||||
type SelectItem = { label: string; value: string };
|
||||
@@ -90,7 +90,7 @@ const showOverlay = ref<boolean>(false);
|
||||
const showDebug = ref<boolean>(false);
|
||||
const onlyLz = ref<boolean>(false);
|
||||
const orderType = ref<"hot" | "latest" | "oldest">("hot");
|
||||
const reply = shallowRef<Array<TGApp.Plugins.Mys.Reply.ReplyFull>>([]);
|
||||
const reply = shallowRef<Array<TGApp.BBS.Reply.ReplyFull>>([]);
|
||||
const isHot = computed<boolean>(() => orderType.value === "hot");
|
||||
const replyOrder = computed<1 | 2 | undefined>(() => {
|
||||
if (orderType.value === "hot") return undefined;
|
||||
@@ -121,7 +121,7 @@ async function reloadReply(): Promise<void> {
|
||||
|
||||
async function loadReply(): Promise<void> {
|
||||
loading.value = true;
|
||||
const resp = await Mys.Post.getPostReplies(
|
||||
const resp = await postReq.reply.main(
|
||||
props.postId,
|
||||
props.gid,
|
||||
isHot.value,
|
||||
|
||||
@@ -48,11 +48,11 @@
|
||||
<script lang="ts" setup>
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { nextTick, onMounted, shallowRef, useTemplateRef, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import { timestampToDate } from "@/utils/toolFunc.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type TpoCollectionProps = { collection: TGApp.Plugins.Mys.Post.Collection };
|
||||
type TpoCollectionItem = {
|
||||
@@ -86,7 +86,7 @@ watch(
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
const collectionPosts = await Mys.Post.getPostFullInCollection(props.collection.collection_id);
|
||||
const collectionPosts = await postReq.collection(props.collection.collection_id);
|
||||
const tempArr: Array<TpoCollectionItem> = [];
|
||||
for (const postItem of collectionPosts) {
|
||||
const post: TpoCollectionItem = {
|
||||
@@ -107,7 +107,7 @@ async function toPost(postId: string, index: number): Promise<void> {
|
||||
showSnackbar.warn("已经在当前帖子");
|
||||
return;
|
||||
}
|
||||
await router.push({ name: "帖子详情", params: { post_id: postId } });
|
||||
router.push({ name: "帖子详情", params: { post_id: postId } });
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -44,17 +44,32 @@
|
||||
<script setup lang="ts">
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { onUnmounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import painterReq from "@/web/request/painterReq.js";
|
||||
|
||||
type TpoLotteryProps = { lottery: string | undefined };
|
||||
type RenderCard = {
|
||||
id: string;
|
||||
upWay: string;
|
||||
status: string;
|
||||
creator: TGApp.Plugins.Mys.User.Post;
|
||||
drawTime: string;
|
||||
rewards: Array<RenderReward>;
|
||||
};
|
||||
type RenderReward = {
|
||||
name: string;
|
||||
win: number;
|
||||
goal: number;
|
||||
users: TGApp.Plugins.Mys.User.Post[];
|
||||
};
|
||||
|
||||
const props = defineProps<TpoLotteryProps>();
|
||||
const visible = defineModel<boolean>();
|
||||
const timeStatus = ref<string>("未知");
|
||||
const upWay = ref<string>("未知");
|
||||
const card = shallowRef<TGApp.Plugins.Mys.Lottery.RenderCard>();
|
||||
const jsonData = shallowRef<TGApp.Plugins.Mys.Lottery.FullData>();
|
||||
const card = shallowRef<RenderCard>();
|
||||
const jsonData = shallowRef<TGApp.BBS.Lottery.FullData>();
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
let timer: NodeJS.Timeout | undefined = undefined;
|
||||
@@ -68,7 +83,7 @@ watch(
|
||||
async function load(): Promise<void> {
|
||||
if (!props.lottery) return;
|
||||
if (card.value) return;
|
||||
const cardGet = await Mys.Lottery.get(props.lottery);
|
||||
const cardGet = await painterReq.lottery(props.lottery);
|
||||
if ("retcode" in cardGet) {
|
||||
showSnackbar.error(`[${cardGet.retcode}] ${cardGet.message}`);
|
||||
return;
|
||||
@@ -82,7 +97,7 @@ async function load(): Promise<void> {
|
||||
}
|
||||
timer = setInterval(flushTimeStatus, 1000);
|
||||
}
|
||||
card.value = Mys.Lottery.card(cardGet);
|
||||
card.value = transLotteryCard(cardGet);
|
||||
upWay.value = getUpWay(card.value?.upWay);
|
||||
}
|
||||
|
||||
@@ -114,6 +129,26 @@ function flushTimeStatus(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function transLotteryReward(lotteryReward: TGApp.BBS.Lottery.Reward): RenderReward {
|
||||
return {
|
||||
name: lotteryReward.reward_name,
|
||||
win: lotteryReward.winner_number,
|
||||
goal: lotteryReward.scheduled_winner_number,
|
||||
users: lotteryReward.users,
|
||||
};
|
||||
}
|
||||
|
||||
function transLotteryCard(lotteryData: TGApp.BBS.Lottery.FullData): RenderCard {
|
||||
return {
|
||||
id: lotteryData.id,
|
||||
upWay: lotteryData.participant_way,
|
||||
status: lotteryData.status,
|
||||
creator: lotteryData.creator,
|
||||
drawTime: lotteryData.draw_time,
|
||||
rewards: lotteryData.user_rewards.map(transLotteryReward),
|
||||
};
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer !== undefined) {
|
||||
clearInterval(timer);
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import TPostCard from "@comp/app/t-postcard.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type ToPostSearchProps = { gid: string; keyword?: string };
|
||||
|
||||
@@ -106,7 +106,7 @@ async function searchPosts(): Promise<void> {
|
||||
load.value = false;
|
||||
return;
|
||||
}
|
||||
const res = await Mys.Post.searchPosts(game.value, search.value, lastId.value);
|
||||
const res = await postReq.search(game.value, search.value, lastId.value);
|
||||
if (lastId.value === "") results.value = res.posts;
|
||||
else results.value = results.value.concat(res.posts);
|
||||
lastId.value = res.last_id;
|
||||
|
||||
@@ -25,7 +25,7 @@ import TGLogger from "@/utils/TGLogger.js";
|
||||
|
||||
const visible = defineModel<boolean>();
|
||||
const filePath = ref<string>("");
|
||||
const replyData = shallowRef<TGApp.Plugins.Mys.Reply.ReplyFull | null>(null);
|
||||
const replyData = shallowRef<TGApp.BBS.Reply.ReplyFull | null>(null);
|
||||
|
||||
async function selectFile(): Promise<void> {
|
||||
const file = await open({
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
<script lang="ts" setup>
|
||||
import showDialog from "@comp/func/dialog.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { event, path } from "@tauri-apps/api";
|
||||
import type { Event, UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { save } from "@tauri-apps/plugin-dialog";
|
||||
@@ -114,10 +113,11 @@ import TpParser from "./tp-parser.vue";
|
||||
|
||||
import { generateShareImg } from "@/utils/TGShare.js";
|
||||
import { timestampToDate } from "@/utils/toolFunc.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type TprReplyProps =
|
||||
| { mode: "sub"; modelValue: TGApp.Plugins.Mys.Reply.ReplyFull }
|
||||
| { mode: "main"; modelValue: TGApp.Plugins.Mys.Reply.ReplyFull; pinId: string };
|
||||
| { mode: "sub"; modelValue: TGApp.BBS.Reply.ReplyFull }
|
||||
| { mode: "main"; modelValue: TGApp.BBS.Reply.ReplyFull; pinId: string };
|
||||
|
||||
const props = defineProps<TprReplyProps>();
|
||||
const replyId = `reply_${props.modelValue.reply.post_id}_${props.modelValue.reply.floor_id}_${props.modelValue.reply.reply_id}`;
|
||||
@@ -129,7 +129,7 @@ const showSub = ref<boolean>(false);
|
||||
const lastId = ref<string>();
|
||||
const isLast = ref<boolean>(false);
|
||||
const loading = ref<boolean>(false);
|
||||
const subReplies = shallowRef<Array<TGApp.Plugins.Mys.Reply.ReplyFull>>([]);
|
||||
const subReplies = shallowRef<Array<TGApp.BBS.Reply.ReplyFull>>([]);
|
||||
const levelColor = computed<string>(() => {
|
||||
const level = props.modelValue.user.level_exp.level;
|
||||
if (level < 5) return "var(--tgc-od-green)";
|
||||
@@ -189,7 +189,7 @@ async function showReply(): Promise<void> {
|
||||
|
||||
async function loadSub(): Promise<void> {
|
||||
loading.value = true;
|
||||
const resp = await Mys.Post.getSubReplies(
|
||||
const resp = await postReq.reply.sub(
|
||||
props.modelValue.reply.floor_id,
|
||||
props.modelValue.reply.game_id,
|
||||
props.modelValue.reply.post_id,
|
||||
|
||||
@@ -107,7 +107,7 @@ import { computed, onMounted, onUnmounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import { useUserStore } from "@/store/modules/user.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import BBSApi from "@/web/request/bbsReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
const { cookie, briefInfo } = storeToRefs(useUserStore());
|
||||
let collectListener: UnlistenFn | null = null;
|
||||
@@ -351,7 +351,7 @@ async function freshUser(uid?: string): Promise<void> {
|
||||
}
|
||||
const uidReal = uid || briefInfo.value.uid;
|
||||
await showLoading.start(`[${uidReal}]获取用户收藏`);
|
||||
let res = await BBSApi.lovePost(cookie.value, uidReal);
|
||||
let res = await postReq.userFavourite(cookie.value, uidReal);
|
||||
while (true) {
|
||||
if ("retcode" in res) {
|
||||
await showLoading.end();
|
||||
@@ -363,7 +363,7 @@ async function freshUser(uid?: string): Promise<void> {
|
||||
await mergePosts(posts, uid || briefInfo.value.uid);
|
||||
if (res.is_last) break;
|
||||
await showLoading.update(`[offset]${res.next_offset} [is_last]${res.is_last}`);
|
||||
res = await BBSApi.lovePost(cookie.value, uid || briefInfo.value.uid, res.next_offset);
|
||||
res = await postReq.userFavourite(cookie.value, uid || briefInfo.value.uid, res.next_offset);
|
||||
}
|
||||
await showLoading.end();
|
||||
showSnackbar.success("获取用户收藏成功,即将刷新页面");
|
||||
|
||||
@@ -127,13 +127,13 @@ import TPostCard from "@comp/app/t-postcard.vue";
|
||||
import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import ApiHubReq from "@/web/request/apiHubReq.js";
|
||||
import painterReq from "@/web/request/painterReq.js";
|
||||
|
||||
type SortSelect = { text: string; value: number; icon: string };
|
||||
type SortSelectGame = { gid: number; forum: Array<SortSelect>; text: string; icon?: string };
|
||||
@@ -249,22 +249,17 @@ function getSortLabel(value: number): string {
|
||||
async function getCurrentPosts(
|
||||
loadMore: boolean = false,
|
||||
forum: number,
|
||||
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||
): Promise<TGApp.BBS.Forum.PostForumRes> {
|
||||
const mod20 = postRaw.value.total % 20;
|
||||
const pageSize = mod20 === 0 ? 20 : 20 - mod20;
|
||||
if (curSortType.value === 3) {
|
||||
if (loadMore) {
|
||||
return await Mys.Painter.getHotForumPostList(
|
||||
forum,
|
||||
curGid.value,
|
||||
postRaw.value.lastId,
|
||||
pageSize,
|
||||
);
|
||||
return await painterReq.forum.hot(forum, curGid.value, postRaw.value.lastId, pageSize);
|
||||
}
|
||||
return await Mys.Painter.getHotForumPostList(forum, curGid.value);
|
||||
return await painterReq.forum.hot(forum, curGid.value);
|
||||
}
|
||||
if (loadMore) {
|
||||
return await Mys.Painter.getRecentForumPostList(
|
||||
return await painterReq.forum.recent(
|
||||
forum,
|
||||
curGid.value,
|
||||
curSortType.value,
|
||||
@@ -272,12 +267,12 @@ async function getCurrentPosts(
|
||||
pageSize,
|
||||
);
|
||||
}
|
||||
return await Mys.Painter.getRecentForumPostList(forum, curGid.value, curSortType.value);
|
||||
return await painterReq.forum.recent(forum, curGid.value, curSortType.value);
|
||||
}
|
||||
|
||||
async function freshPostData(): Promise<void> {
|
||||
if (!selectedForum.value) return;
|
||||
await router.push({
|
||||
router.push({
|
||||
name: "酒馆",
|
||||
params: route.params,
|
||||
query: { gid: curGid.value, forum: selectedForum.value.value },
|
||||
|
||||
@@ -61,7 +61,6 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import ToChannel from "@comp/pageNews/to-channel.vue";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import type { Ref } from "vue";
|
||||
import { computed, onMounted, reactive, ref, shallowRef } from "vue";
|
||||
@@ -71,6 +70,7 @@ import { type NewsType, NewsTypeEnum, useAppStore } from "@/store/modules/app.js
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import painterReq from "@/web/request/painterReq.js";
|
||||
|
||||
type PostData = { [key in NewsType]: Ref<Array<TGApp.Plugins.Mys.Post.FullData>> };
|
||||
type RawItem = { isLast: boolean; name: string; lastId: number };
|
||||
@@ -112,7 +112,7 @@ async function firstLoad(key: NewsType, refresh: boolean = false): Promise<void>
|
||||
}
|
||||
await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`);
|
||||
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
||||
const getData = await Mys.Painter.getNewsList(gid, NewsTypeEnum[key]);
|
||||
const getData = await painterReq.news(gid, NewsTypeEnum[key]);
|
||||
await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`);
|
||||
rawData[key] = { isLast: getData.is_last, name: rawData[key].name, lastId: getData.list.length };
|
||||
postData[key] = getData.list;
|
||||
@@ -123,7 +123,7 @@ async function firstLoad(key: NewsType, refresh: boolean = false): Promise<void>
|
||||
|
||||
async function switchAnno(): Promise<void> {
|
||||
await TGLogger.Info(`[News][${gid}][switchAnno] 切换公告`);
|
||||
await router.push("/announcements");
|
||||
router.push("/announcements");
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
@@ -137,12 +137,7 @@ async function loadMore(key: NewsType): Promise<void> {
|
||||
await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`);
|
||||
const mod = rawData[key].lastId % 20;
|
||||
const pageSize = mod === 0 ? 20 : 20 - mod;
|
||||
const getData = await Mys.Painter.getNewsList(
|
||||
gid,
|
||||
NewsTypeEnum[key],
|
||||
pageSize,
|
||||
rawData[key].lastId,
|
||||
);
|
||||
const getData = await painterReq.news(gid, NewsTypeEnum[key], pageSize, rawData[key].lastId);
|
||||
await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`);
|
||||
rawData[key].lastId = rawData[key].lastId + getData.list.length;
|
||||
rawData[key].isLast = getData.is_last;
|
||||
|
||||
@@ -90,16 +90,16 @@ import TPostCard from "@comp/app/t-postcard.vue";
|
||||
import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
import topicReq from "@/web/request/topicReq.js";
|
||||
|
||||
type SortSelect = { text: string; value: number };
|
||||
type PostMiniData = { isLast: boolean; lastId: string; total: number };
|
||||
type GameList = TGApp.Plugins.Mys.Topic.GameInfo & { icon?: string };
|
||||
type GameList = TGApp.BBS.Topic.GameInfo & { icon?: string };
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -110,7 +110,7 @@ const search = ref<string>("");
|
||||
const curTopic = ref<string>("");
|
||||
const allGames = shallowRef<Array<TGApp.BBS.Game.Item>>([]);
|
||||
const postRaw = shallowRef<PostMiniData>({ isLast: false, lastId: "", total: 0 });
|
||||
const topicInfo = shallowRef<TGApp.Plugins.Mys.Topic.InfoData>();
|
||||
const topicInfo = shallowRef<TGApp.BBS.Topic.InfoRes>();
|
||||
const posts = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]);
|
||||
const curGame = shallowRef<GameList>();
|
||||
const sortList = computed<Array<SortSelect>>(() => {
|
||||
@@ -138,7 +138,7 @@ onMounted(async () => {
|
||||
curTopic.value = topic;
|
||||
await showLoading.start(`正在加载话题${topic}信息`);
|
||||
allGames.value = await apiHubReq.game();
|
||||
const info = await Mys.Post.getTopicFullInfo(gid, topic);
|
||||
const info = await topicReq.info(gid, topic);
|
||||
if ("retcode" in info) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${info.retcode}] ${info.message}`);
|
||||
@@ -169,13 +169,13 @@ watch(
|
||||
|
||||
async function firstLoad(): Promise<void> {
|
||||
await showLoading.start(`正在加载话题${topicInfo.value?.topic.name}信息`);
|
||||
await router.push({
|
||||
router.push({
|
||||
name: "话题",
|
||||
params: route.params,
|
||||
query: { gid: curGid.value, topic: curTopic.value },
|
||||
});
|
||||
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
||||
const postList = await Mys.Post.getTopicPostList(curGid.value, curTopic.value, curSortType.value);
|
||||
const postList = await topicReq.posts(curGid.value, curTopic.value, curSortType.value);
|
||||
if ("retcode" in postList) {
|
||||
await showLoading.end();
|
||||
showSnackbar.error(`[${postList.retcode}] ${postList.message}`);
|
||||
@@ -200,7 +200,7 @@ async function freshPostData(): Promise<void> {
|
||||
await showLoading.start(`正在刷新${topicInfo.value?.topic.name}帖子列表`);
|
||||
const mod20 = postRaw.value.total % 20;
|
||||
const pageSize = mod20 === 0 ? 20 : 20 - mod20;
|
||||
const postList = await Mys.Post.getTopicPostList(
|
||||
const postList = await topicReq.posts(
|
||||
curGid.value,
|
||||
curTopic.value,
|
||||
curSortType.value,
|
||||
@@ -233,7 +233,7 @@ function searchPost(): void {
|
||||
else createPost(search.value);
|
||||
}
|
||||
|
||||
function getGameList(gameList: TGApp.Plugins.Mys.Topic.GameInfo[] | undefined): GameList[] {
|
||||
function getGameList(gameList: Array<TGApp.BBS.Topic.GameInfo> | undefined): Array<GameList> {
|
||||
if (!gameList) return [];
|
||||
return gameList.map((item) => {
|
||||
const game = allGames.value.find((i) => i.id === item.id);
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
/**
|
||||
* @file plugins/Mys/index.ts
|
||||
* @description Mys plugin index
|
||||
* @since Beta v0.6.8
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
import { doCaptchaLogin, getCaptcha } from "./request/doCaptchaLogin.js";
|
||||
import { getGachaData, getPositionData } from "./request/obcReq.js";
|
||||
import * as Painter from "./request/painterReq.js";
|
||||
import * as Post from "./request/postReq.js";
|
||||
import { getGachaCard } from "./utils/getGachaCard.js";
|
||||
import getLotteryCard from "./utils/getLotteryCard.js";
|
||||
import getPositionCard from "./utils/getPositionCard.js";
|
||||
|
||||
const Mys = {
|
||||
Post,
|
||||
Painter,
|
||||
Gacha: { get: getGachaData, card: getGachaCard },
|
||||
Position: { get: getPositionData, card: getPositionCard },
|
||||
Lottery: { get: Painter.lotteryUserShow, card: getLotteryCard },
|
||||
User: { getCaptcha, login: doCaptchaLogin },
|
||||
};
|
||||
|
||||
|
||||
67
src/plugins/Mys/types/Collection.d.ts
vendored
67
src/plugins/Mys/types/Collection.d.ts
vendored
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Collection.d.ts
|
||||
* @description Mys 插件合集类型声明
|
||||
* @since Beta v0.5.5
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 合集类型
|
||||
* @since Beta v0.5.5
|
||||
* @namespace TGApp.Plugins.Mys.Collection
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
declare namespace TGApp.Plugins.Mys.Collection {
|
||||
/**
|
||||
* @description 合集信息
|
||||
* @since Beta v0.3.9
|
||||
* @interface Info
|
||||
* @property {string} cover 封面
|
||||
* @property {string} desc 描述
|
||||
* @property {number} id 合集 ID
|
||||
* @property {boolean} is_delete 是否删除
|
||||
* @property {boolean} is_following 是否关注
|
||||
* @property {number} post_num 帖子数量
|
||||
* @property {number} post_updated_at 帖子更新时间(秒级时间戳)
|
||||
* @property {number} status 状态
|
||||
* @property {string} title 标题
|
||||
* @property {number} uid 用户 ID
|
||||
* @property {number} view_num 浏览量
|
||||
* @return Info
|
||||
*/
|
||||
interface Info {
|
||||
cover: string;
|
||||
desc: string;
|
||||
id: number;
|
||||
is_delete: boolean;
|
||||
is_following: boolean;
|
||||
post_num: number;
|
||||
post_updated_at: number;
|
||||
status: number;
|
||||
title: string;
|
||||
uid: number;
|
||||
view_num: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取合集帖子返回
|
||||
* @since Beta v0.3.9
|
||||
* @interface ResponsePosts
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {Data[]} data.list 合集帖子列表
|
||||
* @return ResponsePosts
|
||||
*/
|
||||
interface ResponsePosts extends TGApp.BBS.Response.BaseWithData {
|
||||
data: {
|
||||
posts: Data[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 合集帖子
|
||||
* @since Beta v0.3.9
|
||||
* @interface Data
|
||||
* @see TGApp.Plugins.Mys.Post.FullData
|
||||
* @return Data
|
||||
*/
|
||||
type Data = TGApp.Plugins.Mys.Post.FullData;
|
||||
}
|
||||
86
src/plugins/Mys/types/Forum.d.ts
vendored
86
src/plugins/Mys/types/Forum.d.ts
vendored
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Forum.d.ts
|
||||
* @description Mys 插件论坛类型定义文件
|
||||
* @since Beta v0.6.3
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 插件论坛类型
|
||||
* @since Beta v0.4.5
|
||||
* @namespace TGApp.Plugins.Mys.Forum
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
declare namespace TGApp.Plugins.Mys.Forum {
|
||||
/**
|
||||
* @description 特定论坛返回数据
|
||||
* @since Beta v0.3.7
|
||||
* @interface Response
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {FullData} data 特定论坛数据
|
||||
* @return Response
|
||||
*/
|
||||
interface Response extends TGApp.BBS.Response.BaseWithData {
|
||||
data: FullData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 特定论坛数据
|
||||
* @since Beta v0.6.3
|
||||
* @interface FullData
|
||||
* @property {string} last_id 最后一条帖子 ID
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {boolean} is_origin 是否原创
|
||||
* @property {number} page 页码
|
||||
* @property {unknown} databox 数据盒子
|
||||
* @property {TGApp.Plugins.Mys.Post.FullData[]} list 帖子列表
|
||||
* @return FullData
|
||||
*/
|
||||
interface FullData {
|
||||
last_id: string;
|
||||
is_last: boolean;
|
||||
is_origin: boolean;
|
||||
page: number;
|
||||
databox: unknown;
|
||||
list: TGApp.Plugins.Mys.Post.FullData[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 用于渲染的咨讯卡片
|
||||
* @since Beta v0.4.0
|
||||
* @interface RenderCard
|
||||
* @property {string} title 标题
|
||||
* @property {string} cover 封面图片 URL
|
||||
* @property {string} postId 帖子 ID
|
||||
* @property {string} subtitle 副标题
|
||||
* @property {TGApp.Plugins.Mys.User.Post} user 发帖用户
|
||||
* @property forum 版块
|
||||
* @property {string} forum.name 版块名称
|
||||
* @property {string} forum.icon 版块图标
|
||||
* @property {RenderStatus} status 活动状态,仅活动咨讯有
|
||||
* @property data 帖子统计
|
||||
* @property {number} data.mark 帖子收藏数
|
||||
* @property {number} data.forward 帖子转发数
|
||||
* @property {number} data.like 帖子点赞数
|
||||
* @property {number} data.reply 帖子回复数
|
||||
* @property {number} data.view 帖子浏览数
|
||||
* @return RenderCard
|
||||
*/
|
||||
interface RenderCard {
|
||||
title: string;
|
||||
cover: string;
|
||||
postId: string;
|
||||
subtitle: string;
|
||||
user: TGApp.Plugins.Mys.User.Post;
|
||||
forum: {
|
||||
name: string;
|
||||
icon: string;
|
||||
};
|
||||
data: {
|
||||
mark: number;
|
||||
forward: number;
|
||||
like: number;
|
||||
reply: number;
|
||||
view: number;
|
||||
};
|
||||
}
|
||||
}
|
||||
112
src/plugins/Mys/types/News.d.ts
vendored
112
src/plugins/Mys/types/News.d.ts
vendored
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/news.d.ts
|
||||
* @description Mys 插件咨讯类型定义文件
|
||||
* @since Beta v0.6.7
|
||||
*/
|
||||
|
||||
declare namespace TGApp.Plugins.Mys.News {
|
||||
/**
|
||||
* @description 咨讯返回数据
|
||||
* @since Alpha v0.2.1
|
||||
* @interface Response
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {FullData} data 咨讯数据
|
||||
* @return Response
|
||||
*/
|
||||
type Response = TGApp.BBS.Response.BaseWithData & { data: FullData };
|
||||
|
||||
/**
|
||||
* @description 咨讯数据
|
||||
* @since Beta v0.4.5
|
||||
* @interface FullData
|
||||
* @property {number} last_id 最后一条咨讯 ID
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {Item[]} list 咨讯列表
|
||||
* @return FullData
|
||||
*/
|
||||
type FullData = {
|
||||
last_id: number;
|
||||
is_last: boolean;
|
||||
list: Array<TGApp.Plugins.Mys.Post.FullData>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 咨讯元数据,只有活动咨讯才有
|
||||
* @since Alpha v0.2.1
|
||||
* @interface Meta
|
||||
* @property {number} activity_status 活动状态 // ActivityStatus
|
||||
* @property {string} start_at_sec 活动开始时间戳,单位秒
|
||||
* @property {string} end_at_sec 活动结束时间戳,单位秒
|
||||
* @return Meta
|
||||
*/
|
||||
type Meta = { activity_status: number; start_at_sec: string; end_at_sec: string };
|
||||
|
||||
/**
|
||||
* @description 用于渲染的咨讯卡片
|
||||
* @since Beta v0.6.3
|
||||
* @interface RenderCard
|
||||
* @property {string} title 标题
|
||||
* @property {string} cover 封面图片 URL
|
||||
* @property {number} postId 帖子 ID
|
||||
* @property {string} subtitle 副标题
|
||||
* @property {TGApp.Plugins.Mys.User.Post|null} user 发帖用户,可能为 null
|
||||
* @property forum 版块,可能为 null
|
||||
* @property {string} forum.name 版块名称
|
||||
* @property {string} forum.icon 版块图标
|
||||
* @property {RenderStatus} status 活动状态,仅活动咨讯有
|
||||
* @property data 帖子统计,可能为 null
|
||||
* @property {number} data.mark 帖子收藏数
|
||||
* @property {number} data.forward 帖子转发数
|
||||
* @property {number} data.like 帖子点赞数
|
||||
* @property {number} data.reply 帖子回复数
|
||||
* @property {number} data.view 帖子浏览数
|
||||
* @property {TGApp.Plugins.Mys.Topic.Info[]} topics 帖子话题
|
||||
* @return RenderCard
|
||||
*/
|
||||
interface RenderCard {
|
||||
title: string;
|
||||
cover: string;
|
||||
postId: number;
|
||||
subtitle: string;
|
||||
user: TGApp.Plugins.Mys.User.Post | null;
|
||||
forum: RenderForum | null;
|
||||
data: RenderData | null;
|
||||
status?: RenderStatus;
|
||||
topics: TGApp.Plugins.Mys.Topic.Info[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 用于渲染的咨讯状态
|
||||
* @since Beta v0.6.7
|
||||
* @interface RenderStatus
|
||||
* @property {number} stat 活动状态
|
||||
* @property {string} label 活动状态标签
|
||||
* @property {string} color 活动状态颜色
|
||||
* @return RenderStatus
|
||||
*/
|
||||
type RenderStatus = { stat: number; label: string; color: string };
|
||||
|
||||
/**
|
||||
* @description 用于渲染的咨讯信息
|
||||
* @since Beta v0.6.3
|
||||
* @interface RenderData
|
||||
* @property {number} mark 帖子收藏数
|
||||
* @property {number} forward 帖子转发数
|
||||
* @property {number} like 帖子点赞数
|
||||
* @property {number} reply 帖子回复数
|
||||
* @property {number} view 帖子浏览数
|
||||
* @return RenderData
|
||||
*/
|
||||
type RenderData = { mark: number; forward: number; like: number; reply: number; view: number };
|
||||
|
||||
/**
|
||||
* @description 用于渲染的版块信息
|
||||
* @since Beta v0.6.3
|
||||
* @interface RenderForum
|
||||
* @property {string} name 版块名称
|
||||
* @property {string} icon 版块图标
|
||||
* @property {string} id 版块 ID
|
||||
* @return RenderForum
|
||||
*/
|
||||
type RenderForum = { name: string; icon: string; id: number };
|
||||
}
|
||||
21
src/plugins/Mys/types/Post.d.ts
vendored
21
src/plugins/Mys/types/Post.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/post.d.ts
|
||||
* @description Mys 插件帖子类型定义文件
|
||||
* @since Beta v0.6.7
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
declare namespace TGApp.Plugins.Mys.Post {
|
||||
@@ -21,7 +21,7 @@ declare namespace TGApp.Plugins.Mys.Post {
|
||||
* @interface FullData
|
||||
* @property {Post} post 帖子信息
|
||||
* @property {Forum|null} forum 所属版块,可能为 null
|
||||
* @property {Topic[]} topics 所属话题
|
||||
* @property {Array<TGApp.BBS.Topic.Info>} topics 所属话题
|
||||
* @property {TGApp.Plugins.Mys.User.Post|null} user 发帖人,可能为 null
|
||||
* @property {TGApp.Plugins.Mys.User.SelfOperation} self_operation 当前用户操作
|
||||
* @property {Stat|null} stat 帖子统计,可能为 null
|
||||
@@ -39,13 +39,13 @@ declare namespace TGApp.Plugins.Mys.Post {
|
||||
* @property {boolean} is_block_on 是否被屏蔽
|
||||
* @property {unknown} forum_rank_info 版块排行信息,可能为 null
|
||||
* @property {LinkCard[]} link_card_list 链接卡片列表,可能为空
|
||||
* @property {TGApp.Plugins.Mys.News.Meta} news_meta 咨讯元数据,可能为 null
|
||||
* @property {NewsMeta} news_meta 咨讯元数据,可能为 null
|
||||
* @return FullData
|
||||
*/
|
||||
interface FullData {
|
||||
post: Post;
|
||||
forum: Forum | null;
|
||||
topics: TGApp.Plugins.Mys.Topic.Info[];
|
||||
topics: Array<TGApp.BBS.Topic.Info>;
|
||||
user: TGApp.Plugins.Mys.User.Post | null;
|
||||
self_operation: TGApp.Plugins.Mys.User.SelfOperation;
|
||||
stat: Stat | null;
|
||||
@@ -63,7 +63,7 @@ declare namespace TGApp.Plugins.Mys.Post {
|
||||
is_block_on: boolean;
|
||||
forum_rank_info: unknown | null;
|
||||
link_card_list: LinkCard[];
|
||||
news_meta: TGApp.Plugins.Mys.News.Meta | null | undefined;
|
||||
news_meta?: NewsMeta | null;
|
||||
recommend_reason: unknown | null;
|
||||
villa_card: unknown | null;
|
||||
is_mentor: boolean;
|
||||
@@ -378,6 +378,17 @@ declare namespace TGApp.Plugins.Mys.Post {
|
||||
brief_info: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 咨讯元数据,只有活动咨讯才有
|
||||
* @since Beta v0.7.1
|
||||
* @interface NewsMeta
|
||||
* @property {number} activity_status 活动状态 // ActivityStatus
|
||||
* @property {string} start_at_sec 活动开始时间戳,单位秒
|
||||
* @property {string} end_at_sec 活动结束时间戳,单位秒
|
||||
* @return NewsMeta
|
||||
*/
|
||||
type NewsMeta = { activity_status: number; start_at_sec: string; end_at_sec: string };
|
||||
|
||||
/**
|
||||
* @description 推荐理由
|
||||
* @since Beta v0.3.7
|
||||
|
||||
44
src/plugins/Mys/types/Search.d.ts
vendored
44
src/plugins/Mys/types/Search.d.ts
vendored
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Search.d.ts
|
||||
* @description Mys 插件搜索类型声明
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 搜索帖子返回
|
||||
* @since Beta v0.4.5
|
||||
* @namespace TGApp.Plugins.Mys.Search
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
declare namespace TGApp.Plugins.Mys.Search {
|
||||
/**
|
||||
* @description 搜索帖子返回
|
||||
* @since Beta v0.4.5
|
||||
* @interface PostsResponse
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {PostsResponseData} data 返回数据
|
||||
* @return PostsResponse
|
||||
*/
|
||||
interface PostsResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: PostsResponseData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 搜索帖子返回数据
|
||||
* @since Beta v0.4.5
|
||||
* @interface PostsResponseData
|
||||
* @property {TGApp.Plugins.Mys.Post.FullData[]} posts 帖子列表
|
||||
* @property {string} last_id 索引
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {string[]} token_list token 列表
|
||||
* @property {Record<string,string>} databox 数据盒
|
||||
* @return PostsResponseData
|
||||
*/
|
||||
interface PostsResponseData {
|
||||
posts: TGApp.Plugins.Mys.Post.FullData[];
|
||||
last_id: string;
|
||||
is_last: boolean;
|
||||
token_list: string[];
|
||||
databox: Record<string, string>;
|
||||
}
|
||||
}
|
||||
39
src/plugins/Mys/types/User.d.ts
vendored
39
src/plugins/Mys/types/User.d.ts
vendored
@@ -4,12 +4,6 @@
|
||||
* @since Beta v0.5.5
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 插件用户类型
|
||||
* @since Beta v0.5.5
|
||||
* @namespace TGApp.Plugins.Mys.User
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
declare namespace TGApp.Plugins.Mys.User {
|
||||
/**
|
||||
* @description 主页用户信息返回
|
||||
@@ -311,35 +305,6 @@ declare namespace TGApp.Plugins.Mys.User {
|
||||
avatar_url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description collection中的用户信息
|
||||
* @since Beta v0.3.9
|
||||
* @interface Collection
|
||||
* @property {string} avatar 用户头像
|
||||
* @property {string} avatar_url 用户头像链接
|
||||
* @property {Certification} certification 用户认证信息
|
||||
* @property {number} gender 用户性别
|
||||
* @property {string} introduce 用户简介
|
||||
* @property {boolean} is_followed 是否被关注
|
||||
* @property {boolean} is_following 是否关注
|
||||
* @property {string} nickname 用户昵称
|
||||
* @property {string} pendant 用户挂件 URL,可能为 ""
|
||||
* @property {number} uid 用户 ID
|
||||
* @return Collection
|
||||
*/
|
||||
interface Collection {
|
||||
avatar: string;
|
||||
avatar_url: string;
|
||||
certification: Certification;
|
||||
gender: number;
|
||||
introduce: string;
|
||||
is_followed: boolean;
|
||||
is_following: boolean;
|
||||
nickname: string;
|
||||
pendant: string;
|
||||
uid: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 帖子回复中的用户信息
|
||||
* @since Beta v0.5.5
|
||||
@@ -358,7 +323,7 @@ declare namespace TGApp.Plugins.Mys.User {
|
||||
* @property {boolean} is_followed 是否被关注
|
||||
* @property {AvatarExt} avatar_ext 用户头像扩展信息
|
||||
* @property {boolean} is_super_fan 是否是铁粉
|
||||
* @property {TGApp.Plugins.Mys.Reply.ReplyBubble} reply_bubble 回复气泡,可能为 null
|
||||
* @property {TGApp.BBS.Reply.Bubble} reply_bubble 回复气泡,可能为 null
|
||||
* @return Reply
|
||||
*/
|
||||
interface Reply {
|
||||
@@ -376,6 +341,6 @@ declare namespace TGApp.Plugins.Mys.User {
|
||||
is_followed: boolean;
|
||||
avatar_ext: AvatarExt;
|
||||
is_super_fan: boolean;
|
||||
reply_bubble: TGApp.Plugins.Mys.Reply.ReplyBubble | null;
|
||||
reply_bubble: TGApp.BBS.Reply.Bubble | null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { getPostFull } from "@Mys/request/postReq.js";
|
||||
|
||||
import { AppCharacterData } from "@/data/index.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
/**
|
||||
* @description 根据单个卡池信息转为渲染用的卡池信息
|
||||
@@ -26,7 +26,7 @@ async function getGachaItemCard(
|
||||
if (poolCover !== undefined) {
|
||||
cover = poolCover;
|
||||
} else {
|
||||
const postResp = await getPostFull(postId);
|
||||
const postResp = await postReq.post(postId);
|
||||
if ("retcode" in postResp) {
|
||||
showSnackbar.error(`[${postResp.retcode}] ${postResp.message}`);
|
||||
return null;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* @file plugins Mys utils getLotteryCard.ts
|
||||
* @description 抽奖工具类
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 根据抽奖奖励信息转为渲染用的抽奖奖励信息
|
||||
* @since Alpha v0.2.1
|
||||
* @param {TGApp.Plugins.Mys.Lottery.Reward} lotteryReward 抽奖奖励信息
|
||||
* @returns {TGApp.Plugins.Mys.Lottery.RenderReward}
|
||||
*/
|
||||
function getLotteryRewardCard(
|
||||
lotteryReward: TGApp.Plugins.Mys.Lottery.Reward,
|
||||
): TGApp.Plugins.Mys.Lottery.RenderReward {
|
||||
return {
|
||||
name: lotteryReward.reward_name,
|
||||
win: lotteryReward.winner_number,
|
||||
goal: lotteryReward.scheduled_winner_number,
|
||||
users: lotteryReward.users,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据抽奖信息转为渲染用的抽奖信息
|
||||
* @since Alpha v0.2.1
|
||||
* @param {TGApp.Plugins.Mys.Lottery.FullData} lotteryData 抽奖信息
|
||||
* @returns {TGApp.Plugins.Mys.Lottery.RenderCard}
|
||||
*/
|
||||
function getLotteryCard(
|
||||
lotteryData: TGApp.Plugins.Mys.Lottery.FullData,
|
||||
): TGApp.Plugins.Mys.Lottery.RenderCard {
|
||||
return {
|
||||
id: lotteryData.id,
|
||||
upWay: lotteryData.participant_way,
|
||||
status: lotteryData.status,
|
||||
creator: lotteryData.creator,
|
||||
drawTime: lotteryData.draw_time,
|
||||
rewards: lotteryData.user_rewards.map(getLotteryRewardCard),
|
||||
};
|
||||
}
|
||||
|
||||
export default getLotteryCard;
|
||||
44
src/types/BBS/Collection.d.ts
vendored
44
src/types/BBS/Collection.d.ts
vendored
@@ -1,40 +1,44 @@
|
||||
/**
|
||||
* @file types/BBS/Collection.d.ts
|
||||
* @description BBS 收藏相关类型定义文件
|
||||
* @since Beta v0.4.5
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description BBS 收藏命名空间
|
||||
* @since Beta v0.4.5
|
||||
* @namespace TGApp.BBS.Collection
|
||||
* @memberof TGApp.BBS
|
||||
*/
|
||||
declare namespace TGApp.BBS.Collection {
|
||||
/**
|
||||
* @description 用户收藏帖子数据返回
|
||||
* @since Beta v0.4.5
|
||||
* @interface PostResponse
|
||||
* @since Beta v0.7.1
|
||||
* @interface UserPostResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {PostRespData} data - 响应数据
|
||||
* @return PostResponse
|
||||
* @property {UserPostRes} data - 响应数据
|
||||
* @return UserPostResp
|
||||
*/
|
||||
interface PostResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: PostRespData;
|
||||
}
|
||||
type UserPostResp = TGApp.BBS.Response.BaseWithData<UserPostRes>;
|
||||
|
||||
/**
|
||||
* @description 合集帖子返回
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostsResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {PostsRes} data - 返回数据
|
||||
* @return PostsResp
|
||||
*/
|
||||
type PostsResp = TGApp.BBS.Response.BaseWithData & {
|
||||
data: { posts: Array<TGApp.Plugins.Mys.Post.FullData> };
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 用户收藏帖子响应数据
|
||||
* @since Beta v0.4.5
|
||||
* @interface PostRespData
|
||||
* @since Beta v0.7.1
|
||||
* @interface UserPostRes
|
||||
* @property {boolean} is_last - 是否最后一页
|
||||
* @property {string} next_offset - 下一页偏移量
|
||||
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} list - 帖子列表
|
||||
* @return PostRespData
|
||||
* @return UserPostRes
|
||||
*/
|
||||
interface PostRespData {
|
||||
type UserPostRes = {
|
||||
is_last: boolean;
|
||||
next_offset: string;
|
||||
list: TGApp.Plugins.Mys.Post.FullData[];
|
||||
}
|
||||
list: Array<TGApp.Plugins.Mys.Post.FullData>;
|
||||
};
|
||||
}
|
||||
|
||||
35
src/types/BBS/Forum.d.ts
vendored
35
src/types/BBS/Forum.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file types/BBS/Forum.d.ts
|
||||
* @description BBS 版块类型定义
|
||||
* @since Beta v0.6.8
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Forum {
|
||||
@@ -15,12 +15,22 @@ declare namespace TGApp.BBS.Forum {
|
||||
*/
|
||||
type GameForumResp = TGApp.BBS.Response.BaseWithData & { data: { list: Array<GameForum> } };
|
||||
|
||||
/**
|
||||
* @description 获取版块帖子列表返回
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostForumResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {PostForumRes} data 版块帖子列表
|
||||
* @return PostForumResp
|
||||
*/
|
||||
type PostForumResp = TGApp.BBS.Response.BaseWithData<PostForumRes>;
|
||||
|
||||
/**
|
||||
* @description 分区版块信息
|
||||
* @since Beta v0.6.8
|
||||
* @interface GameForum
|
||||
* @property {number} game_id 游戏 ID
|
||||
* @property {List<GameForumItem>} forums 版块信息
|
||||
* @property {Array<GameForumItem>} forums 版块信息
|
||||
* @return GameForum
|
||||
*/
|
||||
type GameForum = { game_id: number; forums: Array<GameForumItem> };
|
||||
@@ -100,4 +110,25 @@ declare namespace TGApp.BBS.Forum {
|
||||
* @return ForumCat
|
||||
*/
|
||||
type ForumCat = { id: number; name: string; forum_id: number; desc: string; remark: string };
|
||||
|
||||
/**
|
||||
* @description 版块帖子列表
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostForumRes
|
||||
* @property {string} last_id 最后一条帖子 ID
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {boolean} is_origin 是否原创
|
||||
* @property {number} page 页码
|
||||
* @property {unknown} databox 数据盒子
|
||||
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} list 帖子列表
|
||||
* @return PostForumRes
|
||||
*/
|
||||
type PostForumRes = {
|
||||
last_id: string;
|
||||
is_last: boolean;
|
||||
is_origin: boolean;
|
||||
page: number;
|
||||
databox: unknown;
|
||||
list: TGApp.Plugins.Mys.Post.FullData[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Lottery.d.ts
|
||||
* @description Mys 插件抽奖类型定义文件
|
||||
* @since Alpha v0.2.1
|
||||
* @file types/BBS/Lottery.d.ts
|
||||
* @description 米游社抽奖类型
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 插件抽奖类型
|
||||
* @since Alpha v0.2.1
|
||||
* @namespace TGApp.Plugins.Mys.Lottery
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
declare namespace TGApp.Plugins.Mys.Lottery {
|
||||
declare namespace TGApp.BBS.Lottery {
|
||||
/**
|
||||
* @description 抽奖返回数据
|
||||
* @since Alpha v0.2.1
|
||||
* @interface Response
|
||||
* @description 抽奖返回响应
|
||||
* @since Beta v0.7.1
|
||||
* @interface Resp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {FullData} data.show_lottery 抽奖数据
|
||||
* @return Response
|
||||
* @return Resp
|
||||
*/
|
||||
interface Response extends TGApp.BBS.Response.BaseWithData {
|
||||
data: {
|
||||
show_lottery: FullData;
|
||||
};
|
||||
}
|
||||
type Resp = TGApp.BBS.Response.BaseWithData & { data: { show_lottery: FullData } };
|
||||
|
||||
/**
|
||||
* @description 抽奖数据
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.7.1
|
||||
* @interface FullData
|
||||
* @property {string} id 抽奖 ID
|
||||
* @property {TGApp.Plugins.Mys.User.Post} creator 创建者
|
||||
@@ -35,7 +25,7 @@ declare namespace TGApp.Plugins.Mys.Lottery {
|
||||
* @property {string} participant_way 参与方式 // Forward: 转发
|
||||
* @property {boolean} is_expect_unfocus_user 是否限制未关注用户
|
||||
* @property {boolean} is_expect_non_real_name_user 是否限制未实名用户
|
||||
* @property {Reward[]} user_rewards 用户奖励
|
||||
* @property {Array<Reward>} user_rewards 用户奖励
|
||||
* @property {string} status 状态 // Settled: 已结算
|
||||
* @property {boolean} is_blocked 是否被屏蔽
|
||||
* @property {string} user_status 用户状态 // NotParticipant: 未参与
|
||||
@@ -46,14 +36,14 @@ declare namespace TGApp.Plugins.Mys.Lottery {
|
||||
* @property {string} now_time 当前时间
|
||||
* @return FullData
|
||||
*/
|
||||
interface FullData {
|
||||
type FullData = {
|
||||
id: string;
|
||||
creator: TGApp.Plugins.Mys.User.Post;
|
||||
draw_time: string;
|
||||
participant_way: string;
|
||||
is_expect_unfocus_user: boolean;
|
||||
is_expect_non_real_name_user: boolean;
|
||||
user_rewards: Reward[];
|
||||
user_rewards: Array<Reward>;
|
||||
status: string;
|
||||
is_blocked: boolean;
|
||||
user_status: string;
|
||||
@@ -62,64 +52,26 @@ declare namespace TGApp.Plugins.Mys.Lottery {
|
||||
entity_id: string;
|
||||
entity_type: string;
|
||||
now_time: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 抽奖奖励
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.7.1
|
||||
* @interface Reward
|
||||
* @property {string} reward_name 奖励名称
|
||||
* @property {number} winner_number 获奖人数
|
||||
* @property {number} scheduled_winner_number 预计获奖人数
|
||||
* @property {boolean} is_send_by_post 是否通过帖子发放
|
||||
* @property {TGApp.Plugins.Mys.User.Post[]} users 用户列表
|
||||
* @property {Array<>TGApp.Plugins.Mys.User.Post>} users 用户列表
|
||||
* @property {string} id 奖励 ID
|
||||
* @return Reward
|
||||
*/
|
||||
interface Reward {
|
||||
type Reward = {
|
||||
reward_name: string;
|
||||
winner_number: number;
|
||||
scheduled_winner_number: number;
|
||||
is_send_by_post: boolean;
|
||||
users: TGApp.Plugins.Mys.User.Post[];
|
||||
users: Array<TGApp.Plugins.Mys.User.Post>;
|
||||
id: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 渲染用的抽奖信息
|
||||
* @since Alpha v0.2.1
|
||||
* @interface RenderCard
|
||||
* @property {string} id 抽奖 ID
|
||||
* @property {string} upWay 参与方式
|
||||
* @property {string} status 状态
|
||||
* @property {TGApp.Plugins.Mys.User.Post} creator 创建者
|
||||
* @property {string} drawTime 开奖时间
|
||||
* @property {RenderReward[]} rewards 奖励列表
|
||||
* @return RenderCard
|
||||
*/
|
||||
interface RenderCard {
|
||||
id: string;
|
||||
upWay: string;
|
||||
status: string;
|
||||
creator: TGApp.Plugins.Mys.User.Post;
|
||||
drawTime: string;
|
||||
rewards: RenderReward[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 渲染用的奖励信息
|
||||
* @since Alpha v0.2.1
|
||||
* @interface RenderReward
|
||||
* @property {string} name 奖励名称
|
||||
* @property {number} win 获奖人数
|
||||
* @property {number} goal 预计获奖人数
|
||||
* @property {TGApp.Plugins.Mys.User.Post[]} users 用户列表
|
||||
* @return RenderReward
|
||||
*/
|
||||
interface RenderReward {
|
||||
name: string;
|
||||
win: number;
|
||||
goal: number;
|
||||
users: TGApp.Plugins.Mys.User.Post[];
|
||||
}
|
||||
};
|
||||
}
|
||||
32
src/types/BBS/News.d.ts
vendored
Normal file
32
src/types/BBS/News.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @file types/BBS/News.d.ts
|
||||
* @description BBS 咨讯类型定义
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.News {
|
||||
/**
|
||||
* @description 咨讯返回数据
|
||||
* @since Beta v0.7.1
|
||||
* @interface Resp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {Res} data 咨讯数据
|
||||
* @return Resp
|
||||
*/
|
||||
type Resp = TGApp.BBS.Response.BaseWithData<Res>;
|
||||
|
||||
/**
|
||||
* @description 咨讯数据
|
||||
* @since Beta v0.7.1
|
||||
* @interface Res
|
||||
* @property {number} last_id 最后一条咨讯 ID
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} list 咨讯列表
|
||||
* @return Res
|
||||
*/
|
||||
type Res = {
|
||||
last_id: number;
|
||||
is_last: boolean;
|
||||
list: Array<TGApp.Plugins.Mys.Post.FullData>;
|
||||
};
|
||||
}
|
||||
@@ -1,108 +1,93 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Reply.d.ts
|
||||
* @description Mys 插件帖子回复数据类型定义文件
|
||||
* @since Beta v0.5.5
|
||||
* @file types/BBS/Reply.d.ts
|
||||
* @description 回复数据类型定义文件
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 插件帖子回复数据类型定义
|
||||
* @since Beta v0.5.5
|
||||
* @namespace TGApp.Plugins.Mys.Reply
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
declare namespace TGApp.Plugins.Mys.Reply {
|
||||
declare namespace TGApp.BBS.Reply {
|
||||
/**
|
||||
* @description 帖子回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface Response
|
||||
* @since Beta v0.7.1
|
||||
* @interface MainResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {ReplyData} data - 回复数据
|
||||
* @return Response
|
||||
* @property {MainRes} data - 回复数据
|
||||
* @return MainResp
|
||||
*/
|
||||
interface Response extends TGApp.BBS.Response.BaseWithData {
|
||||
data: ReplyData;
|
||||
}
|
||||
type MainResp = TGApp.BBS.Response.BaseWithData<MainRes>;
|
||||
|
||||
/**
|
||||
* @description 子回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface SubResponse
|
||||
* @since Beta v0.7.1
|
||||
* @interface SubResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {SubData} data - 子回复数据
|
||||
* @return SubResponse
|
||||
* @property {SubRes} data - 子回复数据
|
||||
* @return SubResp
|
||||
*/
|
||||
interface SubResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: SubData;
|
||||
}
|
||||
type SubResp = TGApp.BBS.Response.BaseWithData<SubRes>;
|
||||
|
||||
/**
|
||||
* @description 子回复数据的根数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface SubRootResponse
|
||||
* @since Beta v0.7.1
|
||||
* @interface SubRootResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {SubRootData} data - 子回复数据
|
||||
* @return SubRootResponse
|
||||
* @property {SubRootRes} data - 子回复数据
|
||||
* @return SubRootResp
|
||||
*/
|
||||
interface SubRootResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: SubRootData;
|
||||
}
|
||||
type SubRootResp = TGApp.BBS.Response.BaseWithData<SubRootRes>;
|
||||
|
||||
/**
|
||||
* @description 子回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface SubRootData
|
||||
* @since Beta v0.7.1
|
||||
* @interface SubRootRes
|
||||
* @property {TGApp.Plugins.Mys.Post.FullData} post - 帖子数据
|
||||
* @property {ReplyFull} reply - 回复数据
|
||||
* @return SubRootData
|
||||
* @return SubRootRes
|
||||
*/
|
||||
interface SubRootData {
|
||||
post: TGApp.Plugins.Mys.Post.FullData;
|
||||
reply: ReplyFull;
|
||||
}
|
||||
type SubRootRes = { post: TGApp.Plugins.Mys.Post.FullData; reply: ReplyFull };
|
||||
|
||||
/**
|
||||
* @description 回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface ReplyData
|
||||
* @since Beta v0.7.1
|
||||
* @interface MainRes
|
||||
* @property {Array<ReplyFull>} list - 回复列表
|
||||
* @property {string} last_id - 最后 ID
|
||||
* @property {boolean} is_last - 是否最后
|
||||
* @property {string} post_owner_id - 帖子拥有者 ID
|
||||
* @property {string} pin_reply_id - 置顶回复 ID
|
||||
* @property {number} fold_reply_num - 折叠回复数
|
||||
* @return ReplyData
|
||||
* @return MainRes
|
||||
*/
|
||||
interface ReplyData {
|
||||
type MainRes = {
|
||||
list: Array<ReplyFull>;
|
||||
last_id: string;
|
||||
is_last: boolean;
|
||||
post_owner_id: string;
|
||||
pin_reply_id: string;
|
||||
fold_reply_num: number;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 子回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface SubData
|
||||
* @since Beta v0.7.1
|
||||
* @interface SubRes
|
||||
* @property {Array<ReplyFull>} list - 回复列表
|
||||
* @property {string} last_id - 最后 ID
|
||||
* @property {boolean} is_last - 是否最后
|
||||
* @property {boolean} has_previous - 是否有上一页
|
||||
* @property {string} post_owner_id - 帖子拥有者 ID
|
||||
* @return SubData
|
||||
* @return SubRes
|
||||
*/
|
||||
interface SubData {
|
||||
type SubRes = {
|
||||
list: Array<ReplyFull>;
|
||||
last_id: string;
|
||||
is_last: boolean;
|
||||
has_previous: boolean;
|
||||
post_owner_id: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @since Beta v0.7.1
|
||||
* @interface ReplyFull
|
||||
* @property {Reply} reply - 回复数据
|
||||
* @property {User} user - 用户数据
|
||||
@@ -119,7 +104,7 @@ declare namespace TGApp.Plugins.Mys.Reply {
|
||||
* @property {unknown} user_game_info - 未知数据
|
||||
* @return ReplyFull
|
||||
*/
|
||||
interface ReplyFull {
|
||||
type ReplyFull = {
|
||||
reply: Reply;
|
||||
user: TGApp.Plugins.Mys.User.Reply;
|
||||
stat: Stat;
|
||||
@@ -133,11 +118,11 @@ declare namespace TGApp.Plugins.Mys.Reply {
|
||||
r_reply: unknown;
|
||||
r_post: unknown;
|
||||
user_game_info: unknown;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 回复数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @since Beta v0.7.1
|
||||
* @interface Reply
|
||||
* @property {number} game_id - 游戏 ID
|
||||
* @property {string} post_id - 帖子 ID
|
||||
@@ -164,7 +149,7 @@ declare namespace TGApp.Plugins.Mys.Reply {
|
||||
* @property {number} view_status - 查看状态
|
||||
* @return Reply
|
||||
*/
|
||||
interface Reply {
|
||||
type Reply = {
|
||||
game_id: number;
|
||||
post_id: string;
|
||||
reply_id: string;
|
||||
@@ -188,28 +173,23 @@ declare namespace TGApp.Plugins.Mys.Reply {
|
||||
selected_comment_time: number;
|
||||
is_mentor: boolean;
|
||||
view_status: number;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 回复气泡数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @interface ReplyBubble
|
||||
* @since Beta v0.7.1
|
||||
* @interface Bubble
|
||||
* @property {string} assets_id - 资源 ID
|
||||
* @property {string} bg_color - 背景颜色
|
||||
* @property {string} url - 链接
|
||||
* @property {string} name - 名称
|
||||
* @return ReplyBubble
|
||||
* @return Bubble
|
||||
*/
|
||||
interface ReplyBubble {
|
||||
assets_id: string;
|
||||
bg_color: string;
|
||||
url: string;
|
||||
name: string;
|
||||
}
|
||||
type Bubble = { assets_id: string; bg_color: string; url: string; name: string };
|
||||
|
||||
/**
|
||||
* @description 点赞数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @since Beta v0.7.1
|
||||
* @interface Stat
|
||||
* @property {number} reply_num - 回复数
|
||||
* @property {number} like_num - 点赞数
|
||||
@@ -217,25 +197,17 @@ declare namespace TGApp.Plugins.Mys.Reply {
|
||||
* @property {number} dislike_num - 踩数
|
||||
* @return Stat
|
||||
*/
|
||||
interface Stat {
|
||||
reply_num: number;
|
||||
like_num: number;
|
||||
sub_num: number;
|
||||
dislike_num: number;
|
||||
}
|
||||
type Stat = { reply_num: number; like_num: number; sub_num: number; dislike_num: number };
|
||||
|
||||
/**
|
||||
* @description 自身操作数据类型
|
||||
* @since Beta v0.5.5
|
||||
* @since Beta v0.7.1
|
||||
* @interface SelfOperation
|
||||
* @property {number} attitude - 操作态度
|
||||
* @property {number} reply_vote_attitude - 回复投票态度
|
||||
* @return SelfOperation
|
||||
*/
|
||||
interface SelfOperation {
|
||||
attitude: number;
|
||||
reply_vote_attitude: number;
|
||||
}
|
||||
type SelfOperation = { attitude: number; reply_vote_attitude: number };
|
||||
|
||||
/**
|
||||
* @description 主楼状态数据类型
|
||||
@@ -245,8 +217,5 @@ declare namespace TGApp.Plugins.Mys.Reply {
|
||||
* @property {boolean} is_user_master - 是否用户
|
||||
* @return MasterStatus
|
||||
*/
|
||||
interface MasterStatus {
|
||||
is_official_master: boolean;
|
||||
is_user_master: boolean;
|
||||
}
|
||||
type MasterStatus = { is_official_master: boolean; is_user_master: boolean };
|
||||
}
|
||||
36
src/types/BBS/Search.d.ts
vendored
Normal file
36
src/types/BBS/Search.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file types/BBS/Search.d.ts
|
||||
* @description 米游社搜索类型声明
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Search {
|
||||
/**
|
||||
* @description 搜索帖子返回
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostsResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {PostsRes} data 返回数据
|
||||
* @return PostsResp
|
||||
*/
|
||||
type PostsResp = TGApp.BBS.Response.BaseWithData<PostsRes>;
|
||||
|
||||
/**
|
||||
* @description 搜索帖子返回数据
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostsRes
|
||||
* @property {TGApp.Plugins.Mys.Post.FullData[]} posts 帖子列表
|
||||
* @property {string} last_id 索引
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {string[]} token_list token 列表
|
||||
* @property {Record<string,string>} databox 数据盒
|
||||
* @return PostsRes
|
||||
*/
|
||||
type PostsRes = {
|
||||
posts: Array<TGApp.Plugins.Mys.Post.FullData>;
|
||||
last_id: string;
|
||||
is_last: boolean;
|
||||
token_list: string[];
|
||||
databox: Record<string, string>;
|
||||
};
|
||||
}
|
||||
@@ -1,81 +1,77 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Topic.d.ts
|
||||
* @description Mys 插件话题类型定义文件
|
||||
* @since Beta v0.6.3
|
||||
* @file types/BBS/Topic.d.ts
|
||||
* @description 米游社话题类型声明
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
declare namespace TGApp.Plugins.Mys.Topic {
|
||||
declare namespace TGApp.BBS.Topic {
|
||||
/**
|
||||
* @description 特定话题返回数据-话题信息
|
||||
* @since Beta v0.6.3
|
||||
* @interface InfoResponse
|
||||
* @since Beta v0.7.1
|
||||
* @interface InfoResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {InfoData} data 特定话题数据
|
||||
* @return InfoResponse
|
||||
* @property {InfoRes} data 特定话题数据
|
||||
* @return InfoResp
|
||||
*/
|
||||
interface InfoResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: InfoData;
|
||||
}
|
||||
type InfoResp = TGApp.BBS.Response.BaseWithData<InfoRes>;
|
||||
|
||||
/**
|
||||
* @description 特定话题返回数据-帖子列表
|
||||
* @since Beta v0.6.3
|
||||
* @interface PostResponse
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostResp
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {PostData} data 特定话题帖子列表数据
|
||||
* @return PostResponse
|
||||
* @property {PostRes} data 特定话题帖子列表数据
|
||||
* @return PostResp
|
||||
*/
|
||||
interface PostResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: PostData;
|
||||
}
|
||||
type PostResp = TGApp.BBS.Response.BaseWithData<PostRes>;
|
||||
|
||||
/**
|
||||
* @description 特定话题数据
|
||||
* @since Beta v0.6.3
|
||||
* @interface InfoData
|
||||
* @property {GameInfo[]} game_info_list 游戏信息列表
|
||||
* @since Beta v0.7.1
|
||||
* @interface InfoRes
|
||||
* @property {Array<GameInfo>} game_info_list 游戏信息列表
|
||||
* @property {boolean} good_exist 是否有精华帖
|
||||
* @property {number} good_post_cnt 精华帖数量
|
||||
* @property {boolean} good_post_exist 是否有精华帖
|
||||
* @property {number} hot_post_cnt 热帖数量
|
||||
* @property {unknown[]} related_forums 相关版块
|
||||
* @property {unknown[]} related_topics 相关话题
|
||||
* @property {unknown[]} top_posts 置顶帖
|
||||
* @property {Array<unknown>} related_forums 相关版块
|
||||
* @property {Array<unknown>} related_topics 相关话题
|
||||
* @property {Array<unknown>} top_posts 置顶帖
|
||||
* @property {Info} topic 话题信息
|
||||
* @return InfoData
|
||||
* @return InfoRes
|
||||
*/
|
||||
interface InfoData {
|
||||
game_info_list: GameInfo[];
|
||||
type InfoRes = {
|
||||
game_info_list: Array<GameInfo>;
|
||||
good_exist: boolean;
|
||||
good_post_cnt: number;
|
||||
good_post_exist: boolean;
|
||||
hot_post_cnt: number;
|
||||
related_forums: unknown[];
|
||||
related_topics: unknown[];
|
||||
top_posts: unknown[];
|
||||
related_forums: Array<unknown>;
|
||||
related_topics: Array<unknown>;
|
||||
top_posts: Array<unknown>;
|
||||
topic: Info;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 特定话题帖子列表数据
|
||||
* @since Beta v0.6.3
|
||||
* @interface PostData
|
||||
* @since Beta v0.7.1
|
||||
* @interface PostRes
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {boolean} is_origin 是否原创
|
||||
* @property {string} last_id 最后一条帖子 ID
|
||||
* @property {TGApp.Plugins.Mys.Post.FullData[]} posts 帖子列表
|
||||
* @return PostData
|
||||
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} posts 帖子列表
|
||||
* @return PostRes
|
||||
*/
|
||||
interface PostData {
|
||||
type PostRes = {
|
||||
is_last: boolean;
|
||||
is_origin: boolean;
|
||||
last_id: string;
|
||||
posts: TGApp.Plugins.Mys.Post.FullData[];
|
||||
}
|
||||
posts: Array<TGApp.Plugins.Mys.Post.FullData>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 游戏信息
|
||||
* @since Beta v0.6.3
|
||||
* @since Beta v0.7.1
|
||||
* @interface GameInfo
|
||||
* @property {number} id 游戏 ID
|
||||
* @property {string} name 游戏名称
|
||||
@@ -83,18 +79,13 @@ declare namespace TGApp.Plugins.Mys.Topic {
|
||||
* @property {boolean} has_hot 是否有热帖
|
||||
* @return GameInfo
|
||||
*/
|
||||
interface GameInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
has_good: boolean;
|
||||
has_hot: boolean;
|
||||
}
|
||||
type GameInfo = { id: number; name: string; has_good: boolean; has_hot: boolean };
|
||||
|
||||
/**
|
||||
* @description 话题信息
|
||||
* @since Beta v0.6.3
|
||||
* @since Beta v0.7.1
|
||||
* @interface Info
|
||||
* @property {string[]} alias 话题别名
|
||||
* @property {Array<string>} alias 话题别名
|
||||
* @property {number} content_type 内容类型
|
||||
* @property {string} cover 封面图片 URL
|
||||
* @property {number} created_at 创建时间(秒级时间戳)
|
||||
@@ -112,14 +103,14 @@ declare namespace TGApp.Plugins.Mys.Topic {
|
||||
* @property {number} order 排序
|
||||
* @property {unknown} related_forum_ids 相关版块 ID
|
||||
* @property {unknown} stat 话题统计-可能为null
|
||||
* @property {SortConfig[]} topic_sort_config 话题排序配置
|
||||
* @property {Array<SortConfig>} topic_sort_config 话题排序配置
|
||||
* @property {number} topic_type 话题类型
|
||||
* @property {string} updated_at 更新时间(秒级时间戳)
|
||||
* @property {number[]} view_type 查看类型
|
||||
* @property {Array<number>} view_type 查看类型
|
||||
* @return Info
|
||||
*/
|
||||
interface Info {
|
||||
alias: string[];
|
||||
type Info = {
|
||||
alias: Array<string>;
|
||||
content_type: number;
|
||||
cover: string;
|
||||
created_at: number;
|
||||
@@ -137,15 +128,15 @@ declare namespace TGApp.Plugins.Mys.Topic {
|
||||
order: number;
|
||||
related_forum_ids: unknown;
|
||||
stat: unknown;
|
||||
topic_sort_config: SortConfig[];
|
||||
topic_sort_config: Array<SortConfig>;
|
||||
topic_type: number;
|
||||
updated_at: string;
|
||||
view_type: number[];
|
||||
}
|
||||
view_type: Array<number>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 话题排序配置
|
||||
* @since Beta v0.6.3
|
||||
* @since Beta v0.7.1
|
||||
* @interface SortConfig
|
||||
* @property {string} name 排序名称
|
||||
* @property {number} type 排序类型
|
||||
@@ -154,11 +145,11 @@ declare namespace TGApp.Plugins.Mys.Topic {
|
||||
* @property {string} data_report_name 数据报告名称
|
||||
* @return SortConfig
|
||||
*/
|
||||
interface SortConfig {
|
||||
type SortConfig = {
|
||||
name: string;
|
||||
type: number;
|
||||
url: string;
|
||||
show_sort: number;
|
||||
data_report_name: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
* @since Beta v0.6.2
|
||||
*/
|
||||
|
||||
import type { RenderCard } from "@comp/app/t-postcard.vue";
|
||||
import { core, window as TauriWindow } from "@tauri-apps/api";
|
||||
import type { WindowOptions } from "@tauri-apps/api/window";
|
||||
|
||||
@@ -46,12 +47,12 @@ export async function createTGWindow(
|
||||
/**
|
||||
* @description 打开帖子
|
||||
* @since Beta v0.4.2
|
||||
* @param {TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard} item 帖子内容或ID
|
||||
* @param {RenderCard | string | number} item 帖子内容或ID
|
||||
* @param {string} title 帖子标题
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function createPost(
|
||||
item: TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard,
|
||||
item: RenderCard | string | number,
|
||||
title?: string,
|
||||
): Promise<void> {
|
||||
let postId: string, postTitle: string;
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
import TSwitchTheme from "@comp/app/t-switchTheme.vue";
|
||||
import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef } from "vue";
|
||||
import VueJsonPretty from "vue-json-pretty";
|
||||
@@ -61,6 +60,7 @@ import { useRoute } from "vue-router";
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import { useUserStore } from "@/store/modules/user.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
const { theme } = storeToRefs(useAppStore());
|
||||
const { cookie } = storeToRefs(useUserStore());
|
||||
@@ -78,7 +78,7 @@ onMounted(async () => {
|
||||
}
|
||||
let ck: Record<string, string> | undefined = undefined;
|
||||
if (cookie.value) ck = { ltoken: cookie.value.ltoken, ltuid: cookie.value.ltuid };
|
||||
const resp = await Mys.Post.getPostFull(postId, ck);
|
||||
const resp = await postReq.post(postId, ck);
|
||||
if ("retcode" in resp) {
|
||||
await showLoading.empty("获取数据失败", `[${resp.retcode}]${resp.message}`);
|
||||
showSnackbar.error(`[${resp.retcode}]${resp.message}`);
|
||||
|
||||
@@ -99,7 +99,6 @@ import TpParser from "@comp/viewPost/tp-parser.vue";
|
||||
import VpBtnCollect from "@comp/viewPost/vp-btn-collect.vue";
|
||||
import VpBtnReply from "@comp/viewPost/vp-btn-reply.vue";
|
||||
import VpOverlayCollection from "@comp/viewPost/vp-overlay-collection.vue";
|
||||
import Mys from "@Mys/index.js";
|
||||
import { app, webviewWindow } from "@tauri-apps/api";
|
||||
import { emit, listen, UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -113,6 +112,7 @@ import TGClient from "@/utils/TGClient.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createTGWindow } from "@/utils/TGWindow.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
const { cookie } = storeToRefs(useUserStore());
|
||||
const { incognito } = storeToRefs(useAppStore());
|
||||
@@ -152,7 +152,7 @@ onMounted(async () => {
|
||||
if (cookie.value && incognito.value === false) {
|
||||
ck = { ltoken: cookie.value.ltoken, ltuid: cookie.value.ltuid };
|
||||
}
|
||||
const resp = await Mys.Post.getPostFull(postId, ck);
|
||||
const resp = await postReq.post(postId, ck);
|
||||
if ("retcode" in resp) {
|
||||
await showLoading.empty("数据加载失败", `[${resp.retcode}]${resp.message}`);
|
||||
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
|
||||
@@ -296,7 +296,7 @@ async function toPost(): Promise<void> {
|
||||
await TGClient.open("web_thin", link);
|
||||
}
|
||||
|
||||
async function toTopic(topic: TGApp.Plugins.Mys.Topic.Info): Promise<void> {
|
||||
async function toTopic(topic: TGApp.BBS.Topic.Info): Promise<void> {
|
||||
const gid = postData.value?.post.game_id ?? topic.game_id;
|
||||
await emit("active_deep_link", `router?path=/posts/topic/${gid}/${topic.id}`);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ async function getUserFullInfo(
|
||||
|
||||
/**
|
||||
* @description 根据gid和id获取用户信息
|
||||
* @since Beta v0.6.7
|
||||
* @since Beta v0.7.1
|
||||
* @param {number} gid - gid
|
||||
* @param {string} userId - 用户 id
|
||||
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info>}
|
||||
@@ -46,41 +46,6 @@ async function getOtherUserInfo(
|
||||
return resp.data.user_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取用户发布帖子
|
||||
* @since Beta v0.6.7
|
||||
* @param {string} uid - 用户 uid
|
||||
* @param [string] offset - 偏移量
|
||||
* @returns {Promise<TGApp.BBS.Collection.PostRespData|TGApp.BBS.Response.Base>} 用户发布帖子
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 获取用户收藏帖子
|
||||
* @since Beta v0.6.3
|
||||
* @param {TGApp.App.Account.Cookie} cookie - 用户 cookie
|
||||
* @param {string} uid - 用户 uid
|
||||
* @param {string} offset - 偏移量
|
||||
* @returns {Promise<TGApp.BBS.Collection.PostRespData|TGApp.BBS.Response.Base>} 用户收藏帖子
|
||||
*/
|
||||
async function userFavouritePost(
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
uid: string,
|
||||
offset: string = "",
|
||||
): Promise<TGApp.BBS.Collection.PostRespData | TGApp.BBS.Response.Base> {
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const params = { size: "20", uid, offset };
|
||||
const resp = await TGHttp<TGApp.BBS.Collection.PostResponse | TGApp.BBS.Response.Base>(
|
||||
"https://bbs-api.miyoushe.com/post/wapi/userFavouritePost",
|
||||
{ method: "GET", headers: getRequestHeader(ck, "GET", params), query: params },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
const BBSApi = {
|
||||
userInfo: getUserFullInfo,
|
||||
otherUserInfo: getOtherUserInfo,
|
||||
lovePost: userFavouritePost,
|
||||
};
|
||||
const BBSApi = { userInfo: getUserFullInfo, otherUserInfo: getOtherUserInfo };
|
||||
|
||||
export default BBSApi;
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* @file plugins/Mys/request/painterReq.ts
|
||||
* @description painter下的请求
|
||||
* @since Beta v0.6.2
|
||||
* @file web/request/painterReq.ts
|
||||
* @description painter 下的请求
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
|
||||
// MysPainterApiBaseUrl => Mpabu
|
||||
const Mpabu: Readonly<string> = "https://bbs-api.miyoushe.com/painter/wapi/";
|
||||
// BBSApiPainterBaseUrl => bapBu
|
||||
const bapBu: Readonly<string> = "https://bbs-api.miyoushe.com/painter/wapi/";
|
||||
|
||||
/**
|
||||
* @description 获取 News 列表
|
||||
* @since Beta v0.6.2
|
||||
* @since Beta v0.7.1
|
||||
* @param {string} gid GID
|
||||
* @param {string} newsType 咨讯类型: 1 为公告,2 为活动,3 为咨讯
|
||||
* @param {number} pageSize 返回数量
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<TGApp.Plugins.Mys.News.FullData>}
|
||||
* @return {Promise<TGApp.BBS.News.Res>}
|
||||
*/
|
||||
export async function getNewsList(
|
||||
async function getNewsList(
|
||||
gid: string = "2",
|
||||
newsType: string = "1",
|
||||
pageSize: number = 20,
|
||||
lastId: number = 0,
|
||||
): Promise<TGApp.Plugins.Mys.News.FullData> {
|
||||
): Promise<TGApp.BBS.News.Res> {
|
||||
return (
|
||||
await TGHttp<TGApp.Plugins.Mys.News.Response>(`${Mpabu}getNewsList`, {
|
||||
await TGHttp<TGApp.BBS.News.Resp>(`${bapBu}getNewsList`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
query: { gids: gid, page_size: pageSize, type: newsType, last_id: lastId },
|
||||
@@ -34,19 +34,19 @@ export async function getNewsList(
|
||||
|
||||
/**
|
||||
* @description 获取最近版块热门帖子列表
|
||||
* @since Beta v0.6.7
|
||||
* @since Beta v0.7.1
|
||||
* @param {number} forumId 版块 ID
|
||||
* @param {number} gid 社区 ID
|
||||
* @param {number} pageSize 每页数量
|
||||
* @param {string} lastId 最后 ID
|
||||
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
||||
* @return {Promise<TGApp.BBS.Forum.PostForumRes>}
|
||||
*/
|
||||
export async function getHotForumPostList(
|
||||
async function getHotForumPostList(
|
||||
forumId: number,
|
||||
gid: number,
|
||||
lastId?: string,
|
||||
pageSize: number = 20,
|
||||
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||
): Promise<TGApp.BBS.Forum.PostForumRes> {
|
||||
type ReqParams = {
|
||||
forum_id: number;
|
||||
gids: number;
|
||||
@@ -62,7 +62,7 @@ export async function getHotForumPostList(
|
||||
};
|
||||
if (lastId) params.last_id = lastId;
|
||||
return (
|
||||
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getHotForumPostList`, {
|
||||
await TGHttp<TGApp.BBS.Forum.PostForumResp>(`${bapBu}getHotForumPostList`, {
|
||||
method: "GET",
|
||||
query: params,
|
||||
})
|
||||
@@ -71,21 +71,21 @@ export async function getHotForumPostList(
|
||||
|
||||
/**
|
||||
* @description 获取最近版块帖子列表
|
||||
* @since Beta v0.6.7
|
||||
* @since Beta v0.7.1
|
||||
* @param {number} forumId 版块 ID
|
||||
* @param {number} gid 社区 ID
|
||||
* @param {number} type 排序方式: 1-最新回复,2-最新发布
|
||||
* @param {string} lastId 最后 ID
|
||||
* @param {number} pageSize 每页数量
|
||||
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
|
||||
* @return {Promise<TGApp.BBS.Forum.PostForumRes>}
|
||||
*/
|
||||
export async function getRecentForumPostList(
|
||||
async function getRecentForumPostList(
|
||||
forumId: number,
|
||||
gid: number,
|
||||
type: number = 1,
|
||||
lastId?: string,
|
||||
pageSize: number = 20,
|
||||
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
|
||||
): Promise<TGApp.BBS.Forum.PostForumRes> {
|
||||
type ReqParams = {
|
||||
forum_id: number;
|
||||
gids: number;
|
||||
@@ -103,7 +103,7 @@ export async function getRecentForumPostList(
|
||||
};
|
||||
if (lastId) params.last_id = lastId;
|
||||
return (
|
||||
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getRecentForumPostList`, {
|
||||
await TGHttp<TGApp.BBS.Forum.PostForumResp>(`${bapBu}getRecentForumPostList`, {
|
||||
method: "GET",
|
||||
query: params,
|
||||
})
|
||||
@@ -112,15 +112,15 @@ export async function getRecentForumPostList(
|
||||
|
||||
/**
|
||||
* @description 获取抽奖信息
|
||||
* @since Beta v0.6.2
|
||||
* @since Beta v0.7.1
|
||||
* @param {string} lotteryId 抽奖 ID
|
||||
* @return {Promise<TGApp.BBS.Response.Base|TGApp.Plugins.Mys.Lottery.FullData>}
|
||||
* @return {Promise<TGApp.BBS.Response.Base|TGApp.BBS.Lottery.FullData>}
|
||||
*/
|
||||
export async function lotteryUserShow(
|
||||
async function lotteryUserShow(
|
||||
lotteryId: string,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.FullData> {
|
||||
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>(
|
||||
`${Mpabu}lottery/user/show`,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.Lottery.FullData> {
|
||||
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.BBS.Lottery.Resp>(
|
||||
`${bapBu}lottery/user/show`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -130,3 +130,14 @@ export async function lotteryUserShow(
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.show_lottery;
|
||||
}
|
||||
|
||||
const painterReq = {
|
||||
forum: {
|
||||
hot: getHotForumPostList,
|
||||
recent: getRecentForumPostList,
|
||||
},
|
||||
lottery: lotteryUserShow,
|
||||
news: getNewsList,
|
||||
};
|
||||
|
||||
export default painterReq;
|
||||
@@ -1,27 +1,24 @@
|
||||
/**
|
||||
* @file plugins/Mys/request/postReq.ts
|
||||
* @description 帖子相关的获取
|
||||
* @since Beta v0.7.0
|
||||
* @file web/request/postReq.ts
|
||||
* @description 帖子相关的请求
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
import { getRequestHeader } from "@/web/utils/getRequestHeader.js";
|
||||
|
||||
// MysPostApiBaseUrl => Mpabu
|
||||
const Mpabu: Readonly<string> = "https://bbs-api.mihoyo.com/post/wapi/";
|
||||
// MysTopicApiBaseUrl => Mtapu
|
||||
const Mtabu: Readonly<string> = "https://bbs-api.miyoushe.com/topic/wapi/";
|
||||
// BBSApiPostBaseUrl => bapBu
|
||||
const bapBu: Readonly<string> = "https://bbs-api.miyoushe.com/post/wapi/";
|
||||
const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
|
||||
|
||||
/**
|
||||
* @description 获取单个帖子信息
|
||||
* @since Beta v0.7.0
|
||||
* @param {number} postId 帖子 ID
|
||||
* @since Beta v0.7.1
|
||||
* @param {number|string} postId 帖子 ID
|
||||
* @param {Record<string, string>} cookie Cookie
|
||||
* @return {Promise<TGApp.Plugins.Mys.Post.FullData|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getPostFull(
|
||||
postId: number,
|
||||
async function getPostFull(
|
||||
postId: number | string,
|
||||
cookie?: Record<string, string>,
|
||||
): Promise<TGApp.Plugins.Mys.Post.FullData | TGApp.BBS.Response.Base> {
|
||||
const param = { post_id: postId, read: 1 };
|
||||
@@ -32,7 +29,7 @@ export async function getPostFull(
|
||||
"x-rpc-client_type": "2",
|
||||
};
|
||||
} else header = { referer: Referer };
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Post.Response>(`${Mpabu}getPostFull`, {
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Post.Response>(`${bapBu}getPostFull`, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: param,
|
||||
@@ -43,15 +40,15 @@ export async function getPostFull(
|
||||
|
||||
/**
|
||||
* @description 获取合集帖子
|
||||
* @since Beta v0.6.2
|
||||
* @since Beta v0.7.1
|
||||
* @param {string} collectionId 合集 ID
|
||||
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
|
||||
*/
|
||||
export async function getPostFullInCollection(
|
||||
async function getPostFullInCollection(
|
||||
collectionId: string,
|
||||
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
|
||||
): Promise<Array<TGApp.Plugins.Mys.Post.FullData>> {
|
||||
return (
|
||||
await TGHttp<TGApp.Plugins.Mys.Collection.ResponsePosts>(`${Mpabu}getPostFullInCollection`, {
|
||||
await TGHttp<TGApp.BBS.Collection.PostsResp>(`${bapBu}getPostFullInCollection`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json", referer: Referer },
|
||||
query: { collection_id: collectionId },
|
||||
@@ -61,7 +58,7 @@ export async function getPostFullInCollection(
|
||||
|
||||
/**
|
||||
* @description 获取帖子回复信息
|
||||
* @since Beta v0.6.4
|
||||
* @since Beta v0.7.1
|
||||
* @param {string} postId 帖子 ID
|
||||
* @param {number} gid 社区 ID
|
||||
* @param {boolean} isHot 是否热门
|
||||
@@ -69,9 +66,9 @@ export async function getPostFullInCollection(
|
||||
* @param {number} orderType 排序类型
|
||||
* @param {string} lastId 最后 ID
|
||||
* @param {number} size 每页大小
|
||||
* @return {Promise<TGApp.Plugins.Mys.Reply.ReplyData|TGApp.BBS.Response.Base>}
|
||||
* @return {Promise<TGApp.BBS.Reply.MainRes|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getPostReplies(
|
||||
async function getPostReplies(
|
||||
postId: string,
|
||||
gid: number,
|
||||
isHot: boolean = true,
|
||||
@@ -79,7 +76,7 @@ export async function getPostReplies(
|
||||
onlyMaster: boolean = false,
|
||||
orderType?: 1 | 2,
|
||||
size: number = 20,
|
||||
): Promise<TGApp.Plugins.Mys.Reply.ReplyData | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Reply.MainRes | TGApp.BBS.Response.Base> {
|
||||
type GprParam = {
|
||||
post_id: string;
|
||||
gids: number;
|
||||
@@ -97,7 +94,7 @@ export async function getPostReplies(
|
||||
params.only_master = onlyMaster;
|
||||
params.order_type = 1;
|
||||
}
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.Response>(`${Mpabu}getPostReplies`, {
|
||||
const resp = await TGHttp<TGApp.BBS.Reply.MainResp>(`${bapBu}getPostReplies`, {
|
||||
method: "GET",
|
||||
headers: { referer: Referer },
|
||||
query: params,
|
||||
@@ -108,21 +105,21 @@ export async function getPostReplies(
|
||||
|
||||
/**
|
||||
* @description 获取帖子子回复信息
|
||||
* @since Beta v0.6.2
|
||||
* @since Beta v0.7.1
|
||||
* @param {number} floorId 楼层 ID
|
||||
* @param {number} gid 社区 ID
|
||||
* @param {string} postId 帖子 ID
|
||||
* @param {string} lastId 最后 ID
|
||||
* @param {number} size 每页大小
|
||||
* @return {Promise<TGApp.Plugins.Mys.Reply.SubData|TGApp.BBS.Response.Base>}
|
||||
* @return {Promise<TGApp.BBS.Reply.SubRes|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getSubReplies(
|
||||
async function getSubReplies(
|
||||
floorId: number,
|
||||
gid: number,
|
||||
postId: string,
|
||||
lastId?: string,
|
||||
size: number = 20,
|
||||
): Promise<TGApp.Plugins.Mys.Reply.SubData | TGApp.BBS.Response.Base> {
|
||||
): Promise<TGApp.BBS.Reply.SubRes | TGApp.BBS.Response.Base> {
|
||||
type GsrParam = {
|
||||
floor_id: number;
|
||||
gids: number;
|
||||
@@ -132,7 +129,7 @@ export async function getSubReplies(
|
||||
};
|
||||
const params: GsrParam = { floor_id: floorId, gids: gid, post_id: postId, size: size };
|
||||
if (lastId) params.last_id = lastId;
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.SubResponse>(`${Mpabu}getSubReplies`, {
|
||||
const resp = await TGHttp<TGApp.BBS.Reply.SubResp>(`${bapBu}getSubReplies`, {
|
||||
method: "GET",
|
||||
headers: { referer: Referer },
|
||||
query: params,
|
||||
@@ -141,77 +138,57 @@ export async function getSubReplies(
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取特定话题信息
|
||||
* @since Beta v0.6.3
|
||||
* @param {string} gid 游戏分区 ID
|
||||
* @param {string} topicId 话题 ID
|
||||
* @return {Promise<TGApp.Plugins.Mys.Topic.InfoData|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getTopicFullInfo(
|
||||
gid: string,
|
||||
topicId: string,
|
||||
): Promise<TGApp.Plugins.Mys.Topic.InfoData | TGApp.BBS.Response.Base> {
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Topic.InfoResponse>(`${Mtabu}getTopicFullInfo`, {
|
||||
method: "GET",
|
||||
headers: { referer: Referer },
|
||||
query: { gids: gid, id: topicId },
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取特定话题帖子列表
|
||||
* @since Beta v0.6.3
|
||||
* @param {number} gid 游戏分区 ID
|
||||
* @param {string} topicId 话题 ID
|
||||
* @param {string} orderType 排序方式
|
||||
* @param {string} lastId 最后一条帖子 ID
|
||||
* @param {number} size 每页大小
|
||||
* @return {Promise<TGApp.Plugins.Mys.Topic.PostData|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getTopicPostList(
|
||||
gid: number,
|
||||
topicId: string,
|
||||
orderType: number = 0,
|
||||
lastId?: string,
|
||||
size: number = 20,
|
||||
): Promise<TGApp.Plugins.Mys.Topic.PostData | TGApp.BBS.Response.Base> {
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Topic.PostResponse>(`${Mpabu}getTopicPostList`, {
|
||||
method: "GET",
|
||||
headers: { referer: Referer },
|
||||
query: {
|
||||
gids: gid,
|
||||
game_id: gid,
|
||||
topic_id: topicId,
|
||||
list_type: orderType,
|
||||
last_id: lastId ?? "",
|
||||
page_size: size,
|
||||
},
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 搜索帖子
|
||||
* @since Beta v0.6.2
|
||||
* @since Beta v0.7.1
|
||||
* @param {string} gid 游戏分区 ID
|
||||
* @param {string} keyword 关键词
|
||||
* @param {string} lastId 最后一条帖子 ID
|
||||
* @return {Promise<TGApp.Plugins.Mys.Search.PostsResponseData>} 返回帖子列表
|
||||
* @return {Promise<TGApp.BBS.Search.PostsRes>} 返回帖子列表
|
||||
*/
|
||||
export async function searchPosts(
|
||||
async function searchPosts(
|
||||
gid: string = "2",
|
||||
keyword: string,
|
||||
lastId: string,
|
||||
): Promise<TGApp.Plugins.Mys.Search.PostsResponseData> {
|
||||
): Promise<TGApp.BBS.Search.PostsRes> {
|
||||
return (
|
||||
await TGHttp<TGApp.Plugins.Mys.Search.PostsResponse>(`${Mpabu}searchPosts`, {
|
||||
await TGHttp<TGApp.BBS.Search.PostsResp>(`${bapBu}searchPosts`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
query: { gids: gid, keyword, last_id: lastId, size: 20 },
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取用户收藏帖子
|
||||
* @since Beta v0.6.3
|
||||
* @param {TGApp.App.Account.Cookie} cookie - 用户 cookie
|
||||
* @param {string} uid - 用户 uid
|
||||
* @param {string} offset - 偏移量
|
||||
* @returns {Promise<TGApp.BBS.Collection.UserPostRes|TGApp.BBS.Response.Base>} 用户收藏帖子
|
||||
*/
|
||||
async function userFavouritePost(
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
uid: string,
|
||||
offset: string = "",
|
||||
): Promise<TGApp.BBS.Collection.UserPostRes | TGApp.BBS.Response.Base> {
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const params = { size: "20", uid, offset };
|
||||
const resp = await TGHttp<TGApp.BBS.Collection.UserPostResp | TGApp.BBS.Response.Base>(
|
||||
`${bapBu}/userFavouritePost`,
|
||||
{ method: "GET", headers: getRequestHeader(ck, "GET", params), query: params },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
const postReq = {
|
||||
collection: getPostFullInCollection,
|
||||
post: getPostFull,
|
||||
reply: { main: getPostReplies, sub: getSubReplies },
|
||||
search: searchPosts,
|
||||
userFavourite: userFavouritePost,
|
||||
};
|
||||
|
||||
export default postReq;
|
||||
67
src/web/request/topicReq.ts
Normal file
67
src/web/request/topicReq.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @file web/request/topicReq.ts
|
||||
* @description 话题相关的请求
|
||||
* @since Beta v0.7.1
|
||||
*/
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
|
||||
// BBSApiTopicBaseUrl => batBu
|
||||
const batBu: Readonly<string> = "https://bbs-api.miyoushe.com/topic/wapi/";
|
||||
const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
|
||||
|
||||
/**
|
||||
* @description 获取特定话题信息
|
||||
* @since Beta v0.7.1
|
||||
* @param {string} gid 游戏分区 ID
|
||||
* @param {string} topicId 话题 ID
|
||||
* @return {Promise<TGApp.BBS.Topic.InfoRes|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getTopicFullInfo(
|
||||
gid: string,
|
||||
topicId: string,
|
||||
): Promise<TGApp.BBS.Topic.InfoRes | TGApp.BBS.Response.Base> {
|
||||
const resp = await TGHttp<TGApp.BBS.Topic.InfoResp>(`${batBu}getTopicFullInfo`, {
|
||||
method: "GET",
|
||||
headers: { referer: Referer },
|
||||
query: { gids: gid, id: topicId },
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取特定话题帖子列表
|
||||
* @since Beta v0.7.1
|
||||
* @param {number} gid 游戏分区 ID
|
||||
* @param {string} topicId 话题 ID
|
||||
* @param {string} orderType 排序方式
|
||||
* @param {string} lastId 最后一条帖子 ID
|
||||
* @param {number} size 每页大小
|
||||
* @return {Promise<TGApp.BBS.Topic.PostRes|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getTopicPostList(
|
||||
gid: number,
|
||||
topicId: string,
|
||||
orderType: number = 0,
|
||||
lastId?: string,
|
||||
size: number = 20,
|
||||
): Promise<TGApp.BBS.Topic.PostRes | TGApp.BBS.Response.Base> {
|
||||
const resp = await TGHttp<TGApp.BBS.Topic.PostResp>(`${batBu}getTopicPostList`, {
|
||||
method: "GET",
|
||||
headers: { referer: Referer },
|
||||
query: {
|
||||
gids: gid,
|
||||
game_id: gid,
|
||||
topic_id: topicId,
|
||||
list_type: orderType,
|
||||
last_id: lastId ?? "",
|
||||
page_size: size,
|
||||
},
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
const topicReq = { info: getTopicFullInfo, posts: getTopicPostList };
|
||||
|
||||
export default topicReq;
|
||||
Reference in New Issue
Block a user