♻️ 动态获取版块

This commit is contained in:
目棃
2025-01-16 15:51:03 +08:00
parent e8a79fb409
commit 8ecaed05ea
10 changed files with 297 additions and 135 deletions

View File

@@ -14,7 +14,6 @@
import TMiImg from "@comp/app/t-mi-img.vue"; import TMiImg from "@comp/app/t-mi-img.vue";
import showDialog from "@comp/func/dialog.js"; import showDialog from "@comp/func/dialog.js";
import showSnackbar from "@comp/func/snackbar.js"; import showSnackbar from "@comp/func/snackbar.js";
import Mys from "@Mys/index.js";
import { emit } from "@tauri-apps/api/event"; import { emit } from "@tauri-apps/api/event";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { computed, onMounted, ref, shallowRef, watch } from "vue"; import { computed, onMounted, ref, shallowRef, watch } from "vue";
@@ -25,6 +24,7 @@ import { useAppStore } from "@/store/modules/app.js";
import TGClient from "@/utils/TGClient.js"; import TGClient from "@/utils/TGClient.js";
import TGLogger from "@/utils/TGLogger.js"; import TGLogger from "@/utils/TGLogger.js";
import { createPost } from "@/utils/TGWindow.js"; import { createPost } from "@/utils/TGWindow.js";
import ApiHubReq from "@/web/request/apiHubReq.js";
import OtherApi from "@/web/request/otherReq.js"; import OtherApi from "@/web/request/otherReq.js";
type TGameNavProps = { modelValue: number }; type TGameNavProps = { modelValue: number };
@@ -49,7 +49,7 @@ watch(
); );
async function loadNav(): Promise<void> { async function loadNav(): Promise<void> {
nav.value = await Mys.ApiHub.homeNew(props.modelValue); nav.value = await ApiHubReq.home(props.modelValue);
} }
async function tryGetCode(): Promise<void> { async function tryGetCode(): Promise<void> {
@@ -79,7 +79,7 @@ async function toNav(item: TGApp.BBS.Navigator.Navigator): Promise<void> {
return; return;
} }
await TGLogger.Info(`[TGameNav][toNav] 打开网页活动 ${item.name}`); await TGLogger.Info(`[TGameNav][toNav] 打开网页活动 ${item.name}`);
await TGLogger.Info(`[TGameNav}][toNav] ${item.app_path}`); await TGLogger.Info(`[TGameNav][toNav] ${item.app_path}`);
const link = new URL(item.app_path); const link = new URL(item.app_path);
const mysList = [ const mysList = [
"https://act.mihoyo.com", "https://act.mihoyo.com",
@@ -132,6 +132,7 @@ async function toBBS(link: URL): Promise<void> {
showSnackbar.warn(`不支持的链接:${link.href}`); showSnackbar.warn(`不支持的链接:${link.href}`);
} }
// todo 动态获取版块列表
function getLocalPath(forum?: string): string { function getLocalPath(forum?: string): string {
if (!forum) return ""; if (!forum) return "";
const forumLocalMap: Record<string, string> = { const forumLocalMap: Record<string, string> = {

View File

@@ -10,7 +10,7 @@
<v-progress-circular v-else indeterminate color="primary" size="25" /> <v-progress-circular v-else indeterminate color="primary" size="25" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, onUnmounted, ref } from "vue"; import { onMounted, onUnmounted, ref, watch } from "vue";
import { useAppStore } from "@/store/modules/app.js"; import { useAppStore } from "@/store/modules/app.js";
import { saveImgLocal } from "@/utils/TGShare.js"; import { saveImgLocal } from "@/utils/TGShare.js";
@@ -32,10 +32,21 @@ const appStore = useAppStore();
const localUrl = ref<string>(); const localUrl = ref<string>();
onMounted(async () => { onMounted(async () => {
if (!props.src) return;
const link = props.ori ? props.src : appStore.getImageUrl(props.src); const link = props.ori ? props.src : appStore.getImageUrl(props.src);
localUrl.value = await saveImgLocal(link); localUrl.value = await saveImgLocal(link);
}); });
watch(
() => props.src,
async () => {
if (!props.src) return;
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
const link = props.ori ? props.src : appStore.getImageUrl(props.src);
localUrl.value = await saveImgLocal(link);
},
);
onUnmounted(() => { onUnmounted(() => {
if (localUrl.value) URL.revokeObjectURL(localUrl.value); if (localUrl.value) URL.revokeObjectURL(localUrl.value);
}); });

View File

@@ -1 +0,0 @@
<!-- todo 角色云图 -->

View File

@@ -1,4 +1,4 @@
<!-- todo 优化增加筛选功能调整 typo --> <!-- todo 优化增加筛选功能 -->
<template> <template>
<div class="ua-gt-box"> <div class="ua-gt-box">
<v-data-table <v-data-table

View File

@@ -21,9 +21,10 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import Mys from "@Mys/index.js";
import { onMounted, shallowRef } from "vue"; import { onMounted, shallowRef } from "vue";
import ApiHubReq from "@/web/request/apiHubReq.js";
type TpVote = { insert: { vote: { id: string; uid: string } } }; type TpVote = { insert: { vote: { id: string; uid: string } } };
type TpVoteProps = { data: TpVote }; type TpVoteProps = { data: TpVote };
type TpVoteData = { title: string; count: number; percent: number }; type TpVoteData = { title: string; count: number; percent: number };
@@ -34,8 +35,8 @@ const votes = shallowRef<TpVoteInfo>();
onMounted(async () => { onMounted(async () => {
const vote = props.data.insert.vote; const vote = props.data.insert.vote;
const voteInfo = await Mys.ApiHub.getVotes(vote.id, vote.uid); const voteInfo = await ApiHubReq.vote.info(vote.id, vote.uid);
const voteResult = await Mys.ApiHub.getVoteResult(vote.id, vote.uid); const voteResult = await ApiHubReq.vote.result(vote.id, vote.uid);
votes.value = { votes.value = {
title: voteInfo.title, title: voteInfo.title,
count: voteResult.user_cnt, count: voteResult.user_cnt,

View File

@@ -15,16 +15,52 @@
item-value="gid" item-value="gid"
variant="outlined" variant="outlined"
label="分区" label="分区"
>
<template #selection="{ item }">
<div class="select-item main">
<img
v-if="item.raw.icon"
:src="item.raw.icon"
:alt="item.raw.text"
:title="item.raw.text"
class="icon"
/> />
<span>{{ item.raw.text }}</span>
</div>
</template>
<template #item="{ props, item }">
<div v-bind="props" class="select-item sub">
<img v-if="item.raw.icon" :src="item.raw.icon" :alt="item.raw.text" class="icon" />
<span>{{ item.raw.text }}</span>
</div>
</template>
</v-select>
<v-select <v-select
v-model="curForum" v-model="selectedForum"
class="post-switch-item" class="post-switch-item"
:items="getGameForums(curGid)" :items="getGameForums(curGid)"
item-title="text"
item-value="value"
variant="outlined" variant="outlined"
label="版块" label="版块"
>
<template #selection="{ item }">
<div class="select-item main">
<TMiImg
:src="item.raw.icon"
:alt="item.raw.text"
:ori="true"
:title="item.raw.text"
class="icon"
/> />
<span>{{ item.raw.text }}</span>
</div>
</template>
<template #item="{ props, item }">
<div v-bind="props" class="select-item sub" @click="selectedForum = item.raw">
<TMiImg :src="item.raw.icon" :alt="item.raw.text" :ori="true" class="icon" />
<span>{{ item.raw.text }}</span>
</div>
</template>
</v-select>
<v-select <v-select
v-model="curSortType" v-model="curSortType"
class="post-switch-item" class="post-switch-item"
@@ -69,6 +105,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import TGameNav from "@comp/app/t-gameNav.vue"; import TGameNav from "@comp/app/t-gameNav.vue";
import TMiImg from "@comp/app/t-mi-img.vue";
import TPostCard from "@comp/app/t-postcard.vue"; import TPostCard from "@comp/app/t-postcard.vue";
import showLoading from "@comp/func/loading.js"; import showLoading from "@comp/func/loading.js";
import showSnackbar from "@comp/func/snackbar.js"; import showSnackbar from "@comp/func/snackbar.js";
@@ -79,112 +116,61 @@ import { useRoute } from "vue-router";
import TGLogger from "@/utils/TGLogger.js"; import TGLogger from "@/utils/TGLogger.js";
import { createPost } from "@/utils/TGWindow.js"; import { createPost } from "@/utils/TGWindow.js";
import { getGameName } from "@/utils/toolFunc.js";
import { CHANNEL_LIST } from "@/web/constant/bbs.js";
import ApiHubReq from "@/web/request/apiHubReq.js";
type SortSelect = { text: string; value: number }; type SortSelect = { text: string; value: number; icon: string };
type SortSelectGame = { gid: number; forum: Array<SortSelect>; text: string }; type SortSelectGame = { gid: number; forum: Array<SortSelect>; text: string; icon?: string };
type PostRaw = { isLast: boolean; lastId: string; total: number }; type PostRaw = { isLast: boolean; lastId: string; total: number };
const sortOrderList: Array<SortSelect> = [ const sortOrderList: Array<Omit<SortSelect, "icon">> = [
{ text: "最新回复", value: 1 }, { text: "最新回复", value: 1 },
{ text: "最新发布", value: 2 }, { text: "最新发布", value: 2 },
{ text: "热门", value: 3 }, { text: "热门", value: 3 },
]; ];
const forumYsList: Array<SortSelect> = [
{ text: "酒馆", value: 26 },
{ text: "攻略", value: 43 },
{ text: "同人图", value: 29 },
{ text: "COS", value: 49 },
{ text: "硬核", value: 50 },
];
const forumSrList: Array<SortSelect> = [
{ text: "候车室", value: 52 },
{ text: "攻略", value: 61 },
{ text: "同人图", value: 56 },
{ text: "COS", value: 62 },
];
const forumBh3List: Array<SortSelect> = [
{ text: "甲板", value: 1 },
{ text: "攻略", value: 14 },
{ text: "同人图", value: 4 },
{ text: "同人文", value: 41 },
];
const forumBh2List: Array<SortSelect> = [
{ text: "学园", value: 30 },
{ text: "攻略", value: 51 },
{ text: "同人图", value: 40 },
];
const forumWdList: Array<SortSelect> = [
{ text: "律所", value: 37 },
{ text: "攻略", value: 60 },
{ text: "同人文", value: 42 },
{ text: "同人图", value: 38 },
];
const forumZzzList: Array<SortSelect> = [
{ text: "咖啡馆", value: 57 },
{ text: "攻略", value: 64 },
{ text: "同人图", value: 59 },
{ text: "COS", value: 65 },
];
const forumDbyList: Array<SortSelect> = [
{ text: "校园", value: 54 },
{ text: "ACG", value: 35 },
{ text: "生活", value: 34 },
{ text: "同人图", value: 39 },
{ text: "COS", value: 47 },
{ text: "脑洞", value: 48 },
{ text: "科技", value: 55 },
{ text: "公告", value: 36 },
];
const sortGameList: Readonly<Array<SortSelectGame>> = [
{ gid: 2, forum: forumYsList, text: "原神" },
{ gid: 6, forum: forumSrList, text: "崩坏:星穹铁道" },
{ gid: 8, forum: forumZzzList, text: "绝区零" },
{ gid: 1, forum: forumBh3List, text: "崩坏3" },
{ gid: 3, forum: forumBh2List, text: "崩坏2" },
{ gid: 4, forum: forumWdList, text: "未定事件簿" },
{ gid: 5, forum: forumDbyList, text: "大别野" },
];
const { gid, forum } = useRoute().params; const { gid, forum } = useRoute().params;
const curGid = ref<number>(2); const curGid = ref<number>(2);
const curSortType = ref<number>(1); const curSortType = ref<number>(1);
const curForum = ref<number>(26);
const curForumLabel = ref<string>("");
const search = ref<string>(""); const search = ref<string>("");
const showSearch = ref<boolean>(false); const showSearch = ref<boolean>(false);
const firstLoad = ref<boolean>(false); const firstLoad = ref<boolean>(false);
const selectedForum = ref<SortSelect>();
const sortGameList = shallowRef<Array<SortSelectGame>>([]);
const postRaw = shallowRef<PostRaw>({ isLast: false, lastId: "", total: 0 }); const postRaw = shallowRef<PostRaw>({ isLast: false, lastId: "", total: 0 });
const posts = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]); const posts = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]);
onMounted(async () => { onMounted(async () => {
await loadForums();
if (gid && typeof gid === "string") curGid.value = Number(gid); if (gid && typeof gid === "string") curGid.value = Number(gid);
if (forum && typeof forum === "string") curForum.value = Number(forum); if (forum && typeof forum === "string") {
selectedForum.value = getForum(curGid.value, Number(forum));
} else {
selectedForum.value = getGameForums(curGid.value)[0];
}
const gameLabel = getGameLabel(curGid.value); const gameLabel = getGameLabel(curGid.value);
const forumLabel = getForumLabel(curGid.value, curForum.value); await TGLogger.Info(`[Posts][${gameLabel}][onMounted][${selectedForum.value.text}] 打开帖子列表`);
await TGLogger.Info(`[Posts][${gameLabel}][onMounted][${forumLabel}] 打开帖子列表`);
await freshPostData(); await freshPostData();
curForumLabel.value = forumLabel;
firstLoad.value = true; firstLoad.value = true;
}); });
watch( watch(
() => curGid.value, () => curGid.value,
() => { () => {
if (!selectedForum.value) return;
const forums = getGameForums(curGid.value); const forums = getGameForums(curGid.value);
const forumFind = forums.find((item) => item.text === curForumLabel.value); const forumFind = forums.find((item) => item.text === selectedForum.value?.text);
if (!firstLoad.value) return; if (!firstLoad.value) return;
if (forumFind) curForum.value = forumFind.value; selectedForum.value = forumFind ?? forums[0];
else curForum.value = forums[0].value;
showSnackbar.success(`已将分区切换到 ${getGameLabel(curGid.value)}`); showSnackbar.success(`已将分区切换到 ${getGameLabel(curGid.value)}`);
}, },
); );
watch( watch(
() => curForum.value, () => selectedForum.value,
async () => { async () => {
if (!selectedForum.value) return;
await freshPostData(); await freshPostData();
const oldForumLabel = JSON.parse(JSON.stringify(curForumLabel.value)); showSnackbar.success(`已将版块切换到 ${selectedForum.value.text}`);
curForumLabel.value = getForumLabel(curGid.value, curForum.value);
if (oldForumLabel !== curForumLabel.value) {
showSnackbar.success(`已将版块切换到 ${curForumLabel.value}`);
}
}, },
); );
watch( watch(
@@ -196,22 +182,41 @@ watch(
}, },
); );
// 初始化
async function loadForums(): Promise<void> {
const allForums = await ApiHubReq.forum();
const gameList: Array<SortSelectGame> = [];
for (const gameForum of allForums) {
const miniFind = CHANNEL_LIST.find((i) => i.gid === gameForum.game_id.toString())?.mini;
const gameItem: SortSelectGame = {
gid: gameForum.game_id,
icon: miniFind ? `/platforms/mhy/${miniFind}.webp` : undefined,
forum: gameForum.forums
.sort((a, b) => a.order - b.order)
.map((i) => ({ text: i.name, value: i.id, icon: i.icon_pure })),
text: getGameName(gameForum.game_id),
};
gameList.push(gameItem);
}
sortGameList.value = gameList;
}
function getGameForums(gid: number): SortSelect[] { function getGameForums(gid: number): SortSelect[] {
const game = sortGameList.find((item) => item.gid === gid); const game = sortGameList.value.find((item) => item.gid === gid);
if (game) return game.forum; if (game) return game.forum;
return []; return [];
} }
function getGameLabel(gid: number): string { function getGameLabel(gid: number): string {
const game = sortGameList.find((item) => item.gid === gid); const game = sortGameList.value.find((item) => item.gid === gid);
if (game) return game.text; if (game) return game.text;
return ""; return "";
} }
function getForumLabel(gid: number, forum: number): string { function getForum(gid: number, forum: number): SortSelect {
const forums = getGameForums(gid); const forums = getGameForums(gid);
const forumItem = forums.find((item) => item.value === forum); const forumItem = forums.find((item) => item.value === forum);
return forumItem ? forumItem.text : ""; return forumItem ? forumItem : forums[0];
} }
function getSortLabel(value: number): string { function getSortLabel(value: number): string {
@@ -221,43 +226,45 @@ function getSortLabel(value: number): string {
async function getCurrentPosts( async function getCurrentPosts(
loadMore: boolean = false, loadMore: boolean = false,
forum: number,
): Promise<TGApp.Plugins.Mys.Forum.FullData> { ): Promise<TGApp.Plugins.Mys.Forum.FullData> {
const mod20 = postRaw.value.total % 20; const mod20 = postRaw.value.total % 20;
const pageSize = mod20 === 0 ? 20 : 20 - mod20; const pageSize = mod20 === 0 ? 20 : 20 - mod20;
if (curSortType.value === 3) { if (curSortType.value === 3) {
if (loadMore) { if (loadMore) {
return await Mys.Painter.getHotForumPostList( return await Mys.Painter.getHotForumPostList(
curForum.value, forum,
curGid.value, curGid.value,
postRaw.value.lastId, postRaw.value.lastId,
pageSize, pageSize,
); );
} }
return await Mys.Painter.getHotForumPostList(curForum.value, curGid.value); return await Mys.Painter.getHotForumPostList(forum, curGid.value);
} }
if (loadMore) { if (loadMore) {
return await Mys.Painter.getRecentForumPostList( return await Mys.Painter.getRecentForumPostList(
curForum.value, forum,
curGid.value, curGid.value,
curSortType.value, curSortType.value,
postRaw.value.lastId, postRaw.value.lastId,
pageSize, pageSize,
); );
} }
return await Mys.Painter.getRecentForumPostList(curForum.value, curGid.value, curSortType.value); return await Mys.Painter.getRecentForumPostList(forum, curGid.value, curSortType.value);
} }
async function freshPostData(): Promise<void> { async function freshPostData(): Promise<void> {
if (!selectedForum.value) return;
await showLoading.start(`正在刷新${getGameLabel(curGid.value)}帖子`); await showLoading.start(`正在刷新${getGameLabel(curGid.value)}帖子`);
const gameLabel = getGameLabel(curGid.value); const gameLabel = getGameLabel(curGid.value);
const forumLabel = getForumLabel(curGid.value, curForum.value); const forumLabel = getForum(curGid.value, selectedForum.value.value).text;
const sortLabel = getSortLabel(curSortType.value); const sortLabel = getSortLabel(curSortType.value);
await TGLogger.Info( await TGLogger.Info(
`[Posts][${gameLabel}][freshPostData][${forumLabel}][${sortLabel}] 刷新帖子列表`, `[Posts][${gameLabel}][freshPostData][${forumLabel}][${sortLabel}] 刷新帖子列表`,
); );
await showLoading.update(`版块:${forumLabel},排序:${sortLabel}`); await showLoading.update(`版块:${forumLabel},排序:${sortLabel}`);
document.documentElement.scrollTo({ top: 0, behavior: "smooth" }); document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
const postsGet = await getCurrentPosts(); const postsGet = await getCurrentPosts(false, selectedForum.value.value);
posts.value = postsGet.list; posts.value = postsGet.list;
postRaw.value = { postRaw.value = {
isLast: postsGet.is_last, isLast: postsGet.is_last,
@@ -269,14 +276,18 @@ async function freshPostData(): Promise<void> {
} }
async function loadMore(): Promise<void> { async function loadMore(): Promise<void> {
if (!selectedForum.value) {
showSnackbar.warn("请先选择一个版块");
return;
}
if (postRaw.value.isLast) { if (postRaw.value.isLast) {
showSnackbar.warn("没有更多帖子了"); showSnackbar.warn("没有更多帖子了");
return; return;
} }
await showLoading.start("正在加载更多帖子数据", `游戏:${getGameLabel(curGid.value)}`); await showLoading.start("正在加载更多帖子数据", `游戏:${getGameLabel(curGid.value)}`);
const postsGet = await getCurrentPosts(true); const postsGet = await getCurrentPosts(true, selectedForum.value.value);
await showLoading.update( await showLoading.update(
`版块:${curForumLabel.value},排序:${getSortLabel(curSortType.value)},数量:${postsGet.list.length}`, `版块:${selectedForum.value.text},排序:${getSortLabel(curSortType.value)},数量:${postsGet.list.length}`,
); );
posts.value = posts.value.concat(postsGet.list); posts.value = posts.value.concat(postsGet.list);
postRaw.value = { postRaw.value = {
@@ -357,4 +368,35 @@ function searchPost(): void {
font-family: var(--font-title); font-family: var(--font-title);
transition: all 0.3s linear; transition: all 0.3s linear;
} }
.select-item {
position: relative;
display: flex;
align-items: center;
column-gap: 4px;
&.main {
position: relative;
height: 24px;
font-family: var(--font-title);
font-size: 16px;
}
&.sub {
padding: 8px;
font-family: var(--font-title);
font-size: 16px;
&:hover {
border-radius: 5px;
background: var(--common-shadow-2);
}
}
.icon {
width: 28px;
height: 28px;
border-radius: 4px;
}
}
</style> </style>

View File

@@ -4,7 +4,6 @@
* @since Beta v0.6.8 * @since Beta v0.6.8
*/ */
import * as ApiHub from "./request/apiHubReq.js";
import { doCaptchaLogin, getCaptcha } from "./request/doCaptchaLogin.js"; import { doCaptchaLogin, getCaptcha } from "./request/doCaptchaLogin.js";
import { getGachaData, getPositionData } from "./request/obcReq.js"; import { getGachaData, getPositionData } from "./request/obcReq.js";
import * as Painter from "./request/painterReq.js"; import * as Painter from "./request/painterReq.js";
@@ -16,7 +15,6 @@ import getPositionCard from "./utils/getPositionCard.js";
const Mys = { const Mys = {
Post, Post,
Painter, Painter,
ApiHub,
Gacha: { get: getGachaData, card: getGachaCard }, Gacha: { get: getGachaData, card: getGachaCard },
Position: { get: getPositionData, card: getPositionCard }, Position: { get: getPositionData, card: getPositionCard },
Lottery: { get: Painter.lotteryUserShow, card: getLotteryCard }, Lottery: { get: Painter.lotteryUserShow, card: getLotteryCard },

103
src/types/BBS/Forum.d.ts vendored Normal file
View File

@@ -0,0 +1,103 @@
/**
* @file types/BBS/Forum.d.ts
* @description BBS 版块类型定义
* @since Beta v0.6.8
*/
declare namespace TGApp.BBS.Forum {
/**
* @description 获取所有版块信息返回
* @since Beta v0.6.8
* @interface GameForumResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {Array<GameForum>} data.list 所有版块信息
* @return GameForumResp
*/
type GameForumResp = TGApp.BBS.Response.BaseWithData & { data: { list: Array<GameForum> } };
/**
* @description 分区版块信息
* @since Beta v0.6.8
* @interface GameForum
* @property {number} game_id 游戏 ID
* @property {List<GameForumItem>} forums 版块信息
* @return GameForum
*/
type GameForum = { game_id: number; forums: Array<GameForumItem> };
/**
* @description 版块信息
* @since Beta v0.6.8
* @interface GameForumItem
* @property {number} id 版块 ID
* @property {number} game_id 游戏 ID
* @property {string} name 版块名称
* @property {number} order 排序
* @property {number} f_id 父版块 ID
* @property {number} visible 是否可见 // 1 可见 0 不可见
* @property {number} create_type 创建类型
* @property {number} post_limit 发帖限制
* @property {number} max_top 最大置顶数
* @property {string} post_order 发帖排序 // reply 最新回复
* @property {number} src_type 来源类型
* @property {string} icon 图标
* @property {string} header_image 头图
* @property {number} hot_score 热度
* @property {string} icon_pure 图标
* @property {string} des 描述
* @property {number} post_num 帖子数
* @property {number} today_post 今日帖子数
* @property {number} reply_type 回复类型
* @property {number} edit_post 编辑帖子
* @property {string} created_at 创建时间 // yyyy-MM-dd HH:mm:ss
* @property {string} updated_at 更新时间 // yyyy-MM-dd HH:mm:ss
* @property {number} show_type 显示类型
* @property {number} default_tab 默认标签
* @property {string} read_me 说明
* @property {Array<ForumCat>} forum_cate_list 分类列表
* @property {Array<ForumCat>} video_cat_list 视频分类列表
* @return GameForumItem
*/
type GameForumItem = {
id: number;
game_id: number;
name: string;
order: number;
f_id: number;
visible: number;
create_type: number;
post_limit: number;
max_top: number;
post_order: string;
src_type: number;
icon: string;
header_image: string;
hot_score: number;
icon_pure: string;
des: string;
post_num: number;
today_post: number;
reply_type: number;
edit_post: number;
created_at: string;
updated_at: string;
show_type: number;
default_tab: number;
read_me: string;
forum_cate_list: Array<ForumCat>;
video_cat_list: Array<ForumCat>;
};
/**
* @description 视频分类
* @since Beta v0.6.8
* @interface ForumCat
* @property {number} id 分类 ID
* @property {string} name 分类名称
* @property {number} forum_id 版块 ID
* @property {string} desc 描述
* @property {string} remark 备注
* @return ForumCat
*/
type ForumCat = { id: number; name: string; forum_id: number; desc: string; remark: string };
}

View File

@@ -1,43 +1,29 @@
/** /**
* @file plugins/Mys/types/Vote.d.ts * @file types/BBS/Vote.d.ts
* @description Mys * @description Mys
* @since Beta v0.3.9 * @since Beta v0.6.8
*/ */
/** declare namespace TGApp.BBS.Vote {
* @description Mys
* @since Beta v0.3.9
* @namespace TGApp.Plugins.Mys.Vote
* @memberof TGApp.Plugins.Mys
*/
declare namespace TGApp.Plugins.Mys.Vote {
/** /**
* @description * @description
* @since Beta v0.3.9 * @since Beta v0.3.9
* @interface InfoResponse * @interface InfoResp
* @extends TGApp.BBS.Response.BaseWithData * @extends TGApp.BBS.Response.BaseWithData
* @property {Info[]} data.data * @property {Info[]} data.data
* @return InfoResponse * @return InfoResponse
*/ */
interface InfoResponse extends TGApp.BBS.Response.BaseWithData { type InfoResp = TGApp.BBS.Response.BaseWithData & { data: { data: Array<Info> } };
data: {
data: Info[];
};
}
/** /**
* @description * @description
* @since Beta v0.3.9 * @since Beta v0.3.9
* @interface ResultResponse * @interface ResultResp
* @extends TGApp.BBS.Response.BaseWithData * @extends TGApp.BBS.Response.BaseWithData
* @property {Result[]} data.data * @property {Result[]} data.data
* @return ResultResponse * @return ResultResponse
*/ */
interface ResultResponse extends TGApp.BBS.Response.BaseWithData { type ResultResp = TGApp.BBS.Response.BaseWithData & { data: { data: Array<Result> } };
data: {
data: Result[];
};
}
/** /**
* @description * @description

View File

@@ -1,25 +1,41 @@
/** /**
* @file plugins/Mys/request/apiHubReq.ts * @file web/request/apiHubReq.ts
* @description apiHub下的请求 * @description apiHub下的请求
* @since Beta v0.6.2 * @since Beta v0.6.8
*/ */
import TGHttp from "@/utils/TGHttp.js"; import TGHttp from "@/utils/TGHttp.js";
// MysApiHubApiBaseUrl => Mahabu // MysApiHubApiBaseUrl => Mahabu
const Mahabu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/api/"; const Mahabu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/api/";
// MysApiHubWapiBaseUrl => Mahwbu
const Mahwbu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/wapi/";
const Referer: Readonly<string> = "https://bbs.mihoyo.com/"; const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
/**
* @description
* @since Beta v0.6.8
* @return {Promise<TGApp.Plugins.Mys.Forum.GamesResp>}
*/
async function getAllGamesForums(): Promise<Array<TGApp.BBS.Forum.GameForum>> {
return (
await TGHttp<TGApp.BBS.Forum.GameForumResp>(`${Mahwbu}getAllGamesForums`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
})
).data.list;
}
/** /**
* @description * @description
* @since Beta v0.6.2 * @since Beta v0.6.2
* @param {string} id ID * @param {string} id ID
* @param {string} uid ID * @param {string} uid ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>} * @return {Promise<TGApp.BBS.Vote.Info>}
*/ */
export async function getVotes(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> { async function getVotes(id: string, uid: string): Promise<TGApp.BBS.Vote.Info> {
return ( return (
await TGHttp<TGApp.Plugins.Mys.Vote.InfoResponse>(`${Mahabu}getVotes`, { await TGHttp<TGApp.BBS.Vote.InfoResp>(`${Mahabu}getVotes`, {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json", referer: Referer }, headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id }, query: { owner_uid: uid, vote_ids: id },
@@ -32,14 +48,11 @@ export async function getVotes(id: string, uid: string): Promise<TGApp.Plugins.M
* @since Beta v0.6.2 * @since Beta v0.6.2
* @param {string} id ID * @param {string} id ID
* @param {string} uid ID * @param {string} uid ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>} * @return {Promise<TGApp.BBS.Vote.Result>}
*/ */
export async function getVoteResult( async function getVoteResult(id: string, uid: string): Promise<TGApp.BBS.Vote.Result> {
id: string,
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
return ( return (
await TGHttp<TGApp.Plugins.Mys.Vote.ResultResponse>(`${Mahabu}getVotesResult`, { await TGHttp<TGApp.BBS.Vote.ResultResp>(`${Mahabu}getVotesResult`, {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json", referer: Referer }, headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id }, query: { owner_uid: uid, vote_ids: id },
@@ -53,7 +66,7 @@ export async function getVoteResult(
* @param {number} gid GID * @param {number} gid GID
* @return {Promise<TGApp.BBS.Navigator.Navigator[]>} * @return {Promise<TGApp.BBS.Navigator.Navigator[]>}
*/ */
export async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> { async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
return ( return (
await TGHttp<TGApp.BBS.Navigator.HomeResponse>(`${Mahabu}home/new`, { await TGHttp<TGApp.BBS.Navigator.HomeResponse>(`${Mahabu}home/new`, {
method: "GET", method: "GET",
@@ -62,3 +75,11 @@ export async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.Navi
}) })
).data.navigator; ).data.navigator;
} }
const apiHubReq = {
vote: { info: getVotes, result: getVoteResult },
home: homeNew,
forum: getAllGamesForums,
};
export default apiHubReq;