♻️ 请求重构,合并postWapi跟apiHub相关请求

This commit is contained in:
目棃
2024-10-24 23:08:34 +08:00
parent 41db04b7a2
commit 26041948ef
31 changed files with 399 additions and 594 deletions

View File

@@ -86,7 +86,7 @@ interface TPoolEmits {
const emits = defineEmits<TPoolEmits>(); const emits = defineEmits<TPoolEmits>();
function poolLastInterval(postId: number): TGApp.Plugins.Mys.Gacha.RenderCard { function poolLastInterval(postId: number): TGApp.Plugins.Mys.Gacha.RenderCard | undefined {
const pool = poolCards.value.find((pool) => pool.postId === postId); const pool = poolCards.value.find((pool) => pool.postId === postId);
if (!pool) return; if (!pool) return;
if (poolTimeGet.value[postId] === "未开始") { if (poolTimeGet.value[postId] === "未开始") {
@@ -162,7 +162,7 @@ function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]): boolean {
return false; return false;
} }
const cover = homeStore.poolCover; const cover = homeStore.poolCover;
if (cover === undefined) return false; if (cover.value === undefined) return false;
let checkList = data.length; let checkList = data.length;
Object.entries(cover).forEach(([key, value]: [string, unknown]) => { Object.entries(cover).forEach(([key, value]: [string, unknown]) => {
const pool = data.find((item: TGApp.Plugins.Mys.Gacha.Data) => item.id.toString() === key); const pool = data.find((item: TGApp.Plugins.Mys.Gacha.Data) => item.id.toString() === key);

View File

@@ -51,7 +51,7 @@ watch(
); );
async function loadNav(): Promise<void> { async function loadNav(): Promise<void> {
nav.value = await Mys.Posts.nav(props.modelValue); nav.value = await Mys.ApiHub.homeNew(props.modelValue);
} }
async function tryGetCode(): Promise<void> { async function tryGetCode(): Promise<void> {

View File

@@ -134,7 +134,7 @@ async function searchPosts() {
load.value = false; load.value = false;
return; return;
} }
const res = await Mys.Posts.search(game.value, search.value, lastId.value); const res = await Mys.Post.searchPosts(game.value, search.value, lastId.value);
if (lastId.value === "") { if (lastId.value === "") {
results.value = res.posts; results.value = res.posts;
} else { } else {

View File

@@ -55,8 +55,8 @@ const votes = ref<TpVoteInfo>();
onMounted(async () => { onMounted(async () => {
const vote = props.data.insert.vote; const vote = props.data.insert.vote;
const voteInfo = await Mys.Vote.get(vote.id, vote.uid); const voteInfo = await Mys.ApiHub.getVotes(vote.id, vote.uid);
const voteResult = await Mys.Vote.result(vote.id, vote.uid); const voteResult = await Mys.ApiHub.getVoteResult(vote.id, vote.uid);
votes.value = { votes.value = {
title: voteInfo.title, title: voteInfo.title,
count: voteResult.user_cnt, count: voteResult.user_cnt,

View File

@@ -99,7 +99,7 @@ watch(
); );
onMounted(async () => { onMounted(async () => {
const collectionPosts = await Mys.PostCollect(props.collection.collection_id); const collectionPosts = await Mys.Post.getPostFullInCollection(props.collection.collection_id);
const tempArr: TpoCollectionItem[] = []; const tempArr: TpoCollectionItem[] = [];
for (const postItem of collectionPosts) { for (const postItem of collectionPosts) {
const post: TpoCollectionItem = { const post: TpoCollectionItem = {

View File

@@ -125,7 +125,7 @@ async function reloadReply(): Promise<void> {
async function loadReply(): Promise<void> { async function loadReply(): Promise<void> {
loading.value = true; loading.value = true;
const resp = await Mys.Post.reply( const resp = await Mys.Post.getPostReplies(
props.postId, props.postId,
props.gid, props.gid,
isHot.value, isHot.value,

View File

@@ -207,17 +207,14 @@ async function showReply(): Promise<void> {
async function loadSub(): Promise<void> { async function loadSub(): Promise<void> {
loading.value = true; loading.value = true;
const resp = await Mys.Post.replySub( const resp = await Mys.Post.getSubReplies(
props.modelValue.reply.floor_id, props.modelValue.reply.floor_id,
props.modelValue.reply.game_id, props.modelValue.reply.game_id,
props.modelValue.reply.post_id, props.modelValue.reply.post_id,
lastId.value, lastId.value,
); );
if ("retcode" in resp) { if ("retcode" in resp) {
showSnackbar({ showSnackbar({ text: `[${resp.retcode}] ${resp.message}`, color: "error" });
text: `[${resp.retcode}] ${resp.message}`,
color: "error",
});
loading.value = false; loading.value = false;
return; return;
} }
@@ -225,12 +222,7 @@ async function loadSub(): Promise<void> {
lastId.value = resp.last_id; lastId.value = resp.last_id;
subReplies.value = subReplies.value.concat(resp.list); subReplies.value = subReplies.value.concat(resp.list);
loading.value = false; loading.value = false;
if (isLast.value) { if (isLast.value) showSnackbar({ text: "没有更多了", color: "info" });
showSnackbar({
text: "没有更多了",
color: "info",
});
}
} }
async function exportData(): Promise<void> { async function exportData(): Promise<void> {

View File

@@ -63,9 +63,9 @@
v-for="(item, index) in data?.talks" v-for="(item, index) in data?.talks"
:key="index" :key="index"
> >
<template #title <template #title>
><span class="twc-text-item-title">{{ item.Title }}</span></template <span class="twc-text-item-title">{{ item.Title }}</span>
> </template>
<template #text> <template #text>
<span class="twc-text-item-content" v-html="parseHtmlText(item.Context)" /> <span class="twc-text-item-content" v-html="parseHtmlText(item.Context)" />
</template> </template>
@@ -82,12 +82,12 @@
v-for="(item, index) in data.stories" v-for="(item, index) in data.stories"
:key="index" :key="index"
> >
<template #title <template #title>
><span class="twc-text-item-title">{{ item.Title }}</span></template <span class="twc-text-item-title">{{ item.Title }}</span>
> </template>
<template #text <template #text>
><span class="twc-text-item-content">{{ item.Context }}</span></template <span class="twc-text-item-content">{{ item.Context }}</span>
> </template>
</v-expansion-panel> </v-expansion-panel>
</v-expansion-panels> </v-expansion-panels>
</template> </template>
@@ -101,8 +101,7 @@ import { computed, onMounted, ref, watch } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { WikiCharacterData, AppNameCardsData, AppCharacterData } from "../../data/index.js"; import { WikiCharacterData, AppNameCardsData, AppCharacterData } from "../../data/index.js";
import Mys from "../../plugins/Mys/index.js"; import { createObc } from "../../utils/TGWindow.js";
import { createTGWindow } from "../../utils/TGWindow.js";
import { parseHtmlText } from "../../utils/toolFunc.js"; import { parseHtmlText } from "../../utils/toolFunc.js";
import showSnackbar from "../func/snackbar.js"; import showSnackbar from "../func/snackbar.js";
import TItembox, { TItemBoxData } from "../main/t-itembox.vue"; import TItembox, { TItemBoxData } from "../main/t-itembox.vue";
@@ -143,10 +142,7 @@ const nameCard = ref<TGApp.App.NameCard.Item>();
async function loadData(): Promise<void> { async function loadData(): Promise<void> {
const res = WikiCharacterData.find((item) => item.id === props.item.id); const res = WikiCharacterData.find((item) => item.id === props.item.id);
if (res === undefined) { if (res === undefined) {
showSnackbar({ showSnackbar({ text: `未获取到角色 ${props.item.name} 的 Wiki 数据`, color: "error" });
text: `未获取到角色 ${props.item.name} 的 Wiki 数据`,
color: "error",
});
return; return;
} }
data.value = res; data.value = res;
@@ -157,38 +153,22 @@ async function loadData(): Promise<void> {
} else { } else {
hasNc.value = false; hasNc.value = false;
} }
showSnackbar({ showSnackbar({ text: `成功获取角色 ${props.item.name} 的 Wiki 数据` });
text: `成功获取角色 ${props.item.name} 的 Wiki 数据`,
color: "success",
});
} }
watch( watch(
() => props.item, () => props.item,
async () => { async () => await loadData(),
await loadData();
},
); );
onMounted(async () => await loadData()); onMounted(async () => await loadData());
async function toWiki(): Promise<void> { async function toWiki(): Promise<void> {
if (props.item.contentId === 0) { if (props.item.contentId === 0) {
showSnackbar({ showSnackbar({ text: `角色 ${props.item.name} 暂无详情`, color: "warn" });
text: `角色 ${props.item.name} 暂无详情`,
color: "warn",
});
return; return;
} }
const url = Mys.Api.Obc.replace("{contentId}", props.item.contentId.toString()); await createObc(props.item.contentId, props.item.name);
await createTGWindow(
url,
"Sub_window",
`Content_${props.item.contentId} ${props.item.name}`,
1200,
800,
true,
);
} }
async function toBirth(date: string): Promise<void> { async function toBirth(date: string): Promise<void> {

View File

@@ -54,8 +54,7 @@
import { computed, onMounted, ref, watch } from "vue"; import { computed, onMounted, ref, watch } from "vue";
import { WikiWeaponData } from "../../data/index.js"; import { WikiWeaponData } from "../../data/index.js";
import Mys from "../../plugins/Mys/index.js"; import { createObc } from "../../utils/TGWindow.js";
import { createTGWindow } from "../../utils/TGWindow.js";
import { parseHtmlText } from "../../utils/toolFunc.js"; import { parseHtmlText } from "../../utils/toolFunc.js";
import showSnackbar from "../func/snackbar.js"; import showSnackbar from "../func/snackbar.js";
import TItembox, { TItemBoxData } from "../main/t-itembox.vue"; import TItembox, { TItemBoxData } from "../main/t-itembox.vue";
@@ -88,17 +87,11 @@ const selectItems = ref<number[]>([]);
async function loadData(): Promise<void> { async function loadData(): Promise<void> {
const res = WikiWeaponData.find((item) => item.id === props.item.id); const res = WikiWeaponData.find((item) => item.id === props.item.id);
if (res === undefined) { if (res === undefined) {
showSnackbar({ showSnackbar({ text: `未获取到武器 ${props.item.name} 的 Wiki 数据`, color: "error" });
text: `未获取到武器 ${props.item.name} 的 Wiki 数据`,
color: "error",
});
return; return;
} }
data.value = res; data.value = res;
showSnackbar({ showSnackbar({ text: `成功获取武器 ${props.item.name} 的 Wiki 数据` });
text: `成功获取武器 ${props.item.name} 的 Wiki 数据`,
color: "success",
});
if (data.value?.affix === undefined) return; if (data.value?.affix === undefined) return;
selectItems.value = data.value?.affix.Descriptions.map((item) => item.Level) ?? []; selectItems.value = data.value?.affix.Descriptions.map((item) => item.Level) ?? [];
} }
@@ -112,21 +105,10 @@ onMounted(async () => await loadData());
async function toWiki(): Promise<void> { async function toWiki(): Promise<void> {
if (props.item.contentId === 0) { if (props.item.contentId === 0) {
showSnackbar({ showSnackbar({ text: `武器 ${props.item.name} 暂无详情`, color: "warn" });
text: `武器 ${props.item.name} 暂无详情`,
color: "warn",
});
return; return;
} }
const url = Mys.Api.Obc.replace("{contentId}", props.item.contentId.toString()); await createObc(props.item.contentId, props.item.name);
await createTGWindow(
url,
"Sub_window",
`Content_${props.item.contentId} ${props.item.name}`,
1200,
800,
true,
);
} }
</script> </script>
<style lang="css" scoped> <style lang="css" scoped>

View File

@@ -32,8 +32,7 @@ import TwcCharacter from "../../components/wiki/twc-character.vue";
import TwcListItem from "../../components/wiki/twc-list-item.vue"; import TwcListItem from "../../components/wiki/twc-list-item.vue";
import TwoSelectC, { SelectedCValue } from "../../components/wiki/two-select-c.vue"; import TwoSelectC, { SelectedCValue } from "../../components/wiki/two-select-c.vue";
import { AppCharacterData } from "../../data/index.js"; import { AppCharacterData } from "../../data/index.js";
import Mys from "../../plugins/Mys/index.js"; import { createObc } from "../../utils/TGWindow.js";
import { createTGWindow } from "../../utils/TGWindow.js";
const id = useRoute().params.id.toString() ?? "0"; const id = useRoute().params.id.toString() ?? "0";
const showSelect = ref(false); const showSelect = ref(false);
@@ -55,18 +54,15 @@ const curItem = ref<TGApp.App.Character.WikiBriefInfo>({
onBeforeMount(() => { onBeforeMount(() => {
if (id === "0") { if (id === "0") {
curItem.value = cardsInfo.value[0]; curItem.value = cardsInfo.value[0];
} else { return;
const item = cardsInfo.value.find((item) => item.id.toString() === id);
if (item) {
curItem.value = item;
} else {
showSnackbar({
text: `角色 ${id} 不存在`,
color: "warn",
});
curItem.value = cardsInfo.value[0];
}
} }
const item = cardsInfo.value.find((item) => item.id.toString() === id);
if (item) {
curItem.value = item;
return;
}
showSnackbar({ text: `角色 ${id} 不存在`, color: "warn" });
curItem.value = cardsInfo.value[0];
}); });
watch(resetSelect, (val) => { watch(resetSelect, (val) => {
@@ -82,16 +78,10 @@ function handleSelect(val: SelectedCValue) {
return val.area.includes(item.area); return val.area.includes(item.area);
}); });
if (filterC.length === 0) { if (filterC.length === 0) {
showSnackbar({ showSnackbar({ text: "未找到符合条件的角色", color: "warn" });
text: "未找到符合条件的角色",
color: "warn",
});
return; return;
} }
showSnackbar({ showSnackbar({ text: `筛选出符合条件的角色 ${filterC.length}` });
text: `筛选出符合条件的角色 ${filterC.length}`,
color: "success",
});
cardsInfo.value = filterC; cardsInfo.value = filterC;
} }
@@ -106,10 +96,7 @@ async function switchC(item: TGApp.App.Character.WikiBriefInfo): Promise<void> {
async function toOuter(item?: TGApp.App.Character.WikiBriefInfo): Promise<void> { async function toOuter(item?: TGApp.App.Character.WikiBriefInfo): Promise<void> {
if (!item) return; if (!item) return;
if (item.contentId === 0) { if (item.contentId === 0) {
showSnackbar({ showSnackbar({ text: `角色 ${item.name} 暂无观测枢页面`, color: "warn" });
text: `角色 ${item.name} 暂无观测枢页面`,
color: "warn",
});
return; return;
} }
const confirm = await showConfirm({ const confirm = await showConfirm({
@@ -117,21 +104,10 @@ async function toOuter(item?: TGApp.App.Character.WikiBriefInfo): Promise<void>
text: "是否打开观测枢页面?", text: "是否打开观测枢页面?",
}); });
if (!confirm) { if (!confirm) {
showSnackbar({ showSnackbar({ text: "已取消", color: "cancel" });
text: "已取消",
color: "cancel",
});
return; return;
} }
const url = Mys.Api.Obc.replace("{contentId}", item.contentId.toString()); await createObc(item.contentId, item.name);
await createTGWindow(
url,
"Sub_window",
`Content_${item.contentId} ${item.name}`,
1200,
800,
true,
);
} }
</script> </script>
<style scoped> <style scoped>

View File

@@ -35,8 +35,7 @@ import TwcListItem from "../../components/wiki/twc-list-item.vue";
import TwcWeapon from "../../components/wiki/twc-weapon.vue"; import TwcWeapon from "../../components/wiki/twc-weapon.vue";
import TwoSelectW, { SelectedWValue } from "../../components/wiki/two-select-w.vue"; import TwoSelectW, { SelectedWValue } from "../../components/wiki/two-select-w.vue";
import { AppWeaponData } from "../../data/index.js"; import { AppWeaponData } from "../../data/index.js";
import Mys from "../../plugins/Mys/index.js"; import { createObc } from "../../utils/TGWindow.js";
import { createTGWindow } from "../../utils/TGWindow.js";
const id = useRoute().params.id.toString() ?? "0"; const id = useRoute().params.id.toString() ?? "0";
const showSelect = ref(false); const showSelect = ref(false);
@@ -55,18 +54,15 @@ const curItem = ref<TGApp.App.Weapon.WikiBriefInfo>({
onBeforeMount(() => { onBeforeMount(() => {
if (id === "0") { if (id === "0") {
curItem.value = cardsInfo.value[0]; curItem.value = cardsInfo.value[0];
} else { return;
const item = cardsInfo.value.find((item) => item.id.toString() === id);
if (item) {
curItem.value = item;
} else {
showSnackbar({
text: `武器 ${id} 不存在`,
color: "warn",
});
curItem.value = cardsInfo.value[0];
}
} }
const item = cardsInfo.value.find((item) => item.id.toString() === id);
if (item) {
curItem.value = item;
return;
}
showSnackbar({ text: `武器 ${id} 不存在`, color: "warn" });
curItem.value = cardsInfo.value[0];
}); });
function handleSelectW(val: SelectedWValue) { function handleSelectW(val: SelectedWValue) {
@@ -79,15 +75,10 @@ function handleSelectW(val: SelectedWValue) {
return val.weapon.includes(match[1]); return val.weapon.includes(match[1]);
}); });
if (filterW.length === 0) { if (filterW.length === 0) {
showSnackbar({ showSnackbar({ text: "未找到符合条件的武器", color: "warn" });
text: "未找到符合条件的武器",
color: "warn",
});
return; return;
} }
showSnackbar({ showSnackbar({ text: `找到 ${filterW.length} 件符合条件的武器` });
text: `找到 ${filterW.length} 件符合条件的武器`,
});
cardsInfo.value = filterW; cardsInfo.value = filterW;
} }
@@ -98,10 +89,7 @@ async function switchW(item: TGApp.App.Weapon.WikiBriefInfo): Promise<void> {
async function toOuter(item?: TGApp.App.Weapon.WikiBriefInfo): Promise<void> { async function toOuter(item?: TGApp.App.Weapon.WikiBriefInfo): Promise<void> {
if (!item) return; if (!item) return;
if (item.contentId === 0) { if (item.contentId === 0) {
showSnackbar({ showSnackbar({ text: `武器 ${item.name} 暂无观测枢页面`, color: "warn" });
text: `武器 ${item.name} 暂无观测枢页面`,
color: "warn",
});
return; return;
} }
const confirm = await showConfirm({ const confirm = await showConfirm({
@@ -109,21 +97,10 @@ async function toOuter(item?: TGApp.App.Weapon.WikiBriefInfo): Promise<void> {
text: "是否打开观测枢页面?", text: "是否打开观测枢页面?",
}); });
if (!confirm) { if (!confirm) {
showSnackbar({ showSnackbar({ text: "已取消", color: "cancel" });
text: "已取消",
color: "cancel",
});
return; return;
} }
const url = Mys.Api.Obc.replace("{contentId}", item.contentId.toString()); await createObc(item.contentId, item.name);
await createTGWindow(
url,
"Sub_window",
`Content_${item.contentId} ${item.name}`,
1200,
800,
true,
);
} }
</script> </script>
<style scoped> <style scoped>

View File

@@ -151,7 +151,7 @@ async function firstLoad(key: NewsKey, refresh: boolean = false): Promise<void>
} }
loadingTitle.value = `正在获取${rawData.value[key].name}数据...`; loadingTitle.value = `正在获取${rawData.value[key].name}数据...`;
loading.value = true; loading.value = true;
const getData = await Mys.News(gid, NewsType[key]); const getData = await Mys.Post.getNewsList(gid, NewsType[key]);
rawData.value[key].isLast = getData.is_last; rawData.value[key].isLast = getData.is_last;
rawData.value[key].lastId = getData.list.length; rawData.value[key].lastId = getData.list.length;
postData.value[key] = getData.list; postData.value[key] = getData.list;

View File

@@ -1,6 +1,13 @@
<template> <template>
<ToLoading v-model="loading" :title="loadingTitle" /> <ToLoading v-model="loading" :title="loadingTitle" />
<div class="posts-box"> <v-app-bar>
<template #prepend>
<div class="posts-top">
<img src="/source/UI/posts.png" alt="posts" />
<span>帖子</span>
<!-- todo 提供话题入口 -->
</div>
</template>
<div class="posts-switch"> <div class="posts-switch">
<v-select <v-select
v-model="curGid" v-model="curGid"
@@ -45,11 +52,13 @@
<span>刷新</span> <span>刷新</span>
</v-btn> </v-btn>
</div> </div>
<TGameNav :model-value="curGid" /> <template #extension>
<div class="posts-grid"> <TGameNav :model-value="curGid" />
<div v-for="post in posts" :key="post.post.post_id"> </template>
<TPostCard :model-value="post" v-if="post" /> </v-app-bar>
</div> <div class="posts-grid">
<div v-for="post in posts" :key="post.post.post_id">
<TPostCard :model-value="post" v-if="post" />
</div> </div>
</div> </div>
<ToPostSearch :gid="curGid.toString()" v-model="showSearch" :keyword="search" /> <ToPostSearch :gid="curGid.toString()" v-model="showSearch" :keyword="search" />
@@ -212,12 +221,8 @@ const search = ref<string>("");
const showSearch = ref<boolean>(false); const showSearch = ref<boolean>(false);
onBeforeMount(async () => { onBeforeMount(async () => {
if (gid && typeof gid === "string") { if (gid && typeof gid === "string") curGid.value = Number(gid);
curGid.value = Number(gid); if (forum && typeof forum === "string") curForum.value = Number(forum);
}
if (forum && typeof forum === "string") {
curForum.value = Number(forum);
}
}); });
onMounted(async () => { onMounted(async () => {
@@ -247,7 +252,6 @@ watch(
}); });
}, },
); );
watch( watch(
() => curForum.value, () => curForum.value,
async () => { async () => {
@@ -262,8 +266,6 @@ watch(
} }
}, },
); );
// 监听排序变化
watch( watch(
() => curSortType.value, () => curSortType.value,
async (newVal) => { async (newVal) => {
@@ -285,7 +287,7 @@ async function freshPostData(): Promise<void> {
); );
loading.value = true; loading.value = true;
loadingTitle.value = `正在加载 ${gameLabel}-${forumLabel}-${sortLabel} 数据`; loadingTitle.value = `正在加载 ${gameLabel}-${forumLabel}-${sortLabel} 数据`;
const postsGet = await Mys.Posts.get(curForum.value, curSortType.value, 12); const postsGet = await Mys.Post.getForumPostList(curForum.value, curSortType.value, 12);
posts.value = postsGet.list; posts.value = postsGet.list;
await nextTick(); await nextTick();
loading.value = false; loading.value = false;
@@ -309,22 +311,34 @@ function searchPost(): void {
} }
</script> </script>
<style lang="css" scoped> <style lang="css" scoped>
.posts-box { .posts-top {
display: flex; display: flex;
flex-direction: column; align-items: center;
row-gap: 10px; justify-content: center;
gap: 10px;
img {
width: 32px;
height: 32px;
}
span {
color: var(--common-text-title);
font-family: var(--font-title);
font-size: 20px;
}
} }
.posts-switch { .posts-switch {
display: flex; display: flex;
align-items: flex-end; align-items: flex-end;
justify-content: flex-start; justify-content: center;
padding: 5px; margin: 0 10px;
column-gap: 10px; gap: 10px;
} }
.post-switch-item { .post-switch-item {
width: fit-content; width: 250px;
height: 50px; height: 50px;
} }

View File

@@ -1,12 +0,0 @@
/**
* @file plugins/Mys/api/index.ts
* @description Mys API
* @since Beta v0.4.5
*/
const MysApi = {
Obc: "https://bbs.mihoyo.com/ys/obc/content/{contentId}/detail?bbs_presentation_style=no_header",
PostReferer: "https://bbs.mihoyo.com/",
};
export default MysApi;

View File

@@ -1,41 +1,23 @@
/** /**
* @file plugins/Mys/index.ts * @file plugins/Mys/index.ts
* @description Mys plugin index * @description Mys plugin index
* @since Beta v0.5.5 * @since Beta v0.6.2
*/ */
import MysApi from "./api/index.js"; import * as ApiHub from "./request/apiHubReq.js";
import { getCaptcha, doCaptchaLogin } from "./request/doCaptchaLogin.js"; import { getCaptcha, doCaptchaLogin } from "./request/doCaptchaLogin.js";
import { getLoginQr, getLoginStatus } from "./request/doGameLogin.js"; import { getLoginQr, getLoginStatus } from "./request/doGameLogin.js";
import { getCollectionPosts } from "./request/getCollectionData.js";
import getForumList from "./request/getForumList.js";
import getGachaData from "./request/getGachaData.js"; import getGachaData from "./request/getGachaData.js";
import getHomeNavigator from "./request/getHomeNavigator.js";
import getLotteryData from "./request/getLotteryData.js";
import getNewsList from "./request/getNewsList.js";
import { getPositionData } from "./request/getPositionData.js"; import { getPositionData } from "./request/getPositionData.js";
import getPostData from "./request/getPostData.js"; import * as Painter from "./request/painterReq.js";
import { getPostReply, getPostSubRoot, getPostSubReply } from "./request/getPostReply.js"; import * as Post from "./request/postReq.js";
import { getVoteInfo, getVoteResult } from "./request/getVoteData.js";
import searchPosts from "./request/searchPost.js";
import { getGachaCard } from "./utils/getGachaCard.js"; import { getGachaCard } from "./utils/getGachaCard.js";
import getLotteryCard from "./utils/getLotteryCard.js"; import getLotteryCard from "./utils/getLotteryCard.js";
import getPositionCard from "./utils/getPositionCard.js"; import getPositionCard from "./utils/getPositionCard.js";
const Mys = { const Mys = {
Api: MysApi, Post,
Post: { ApiHub,
get: getPostData,
reply: getPostReply,
replySubRoot: getPostSubRoot,
replySub: getPostSubReply,
},
PostCollect: getCollectionPosts,
Posts: {
get: getForumList,
nav: getHomeNavigator,
search: searchPosts,
},
Gacha: { Gacha: {
get: getGachaData, get: getGachaData,
card: getGachaCard, card: getGachaCard,
@@ -44,9 +26,8 @@ const Mys = {
get: getPositionData, get: getPositionData,
card: getPositionCard, card: getPositionCard,
}, },
News: getNewsList,
Lottery: { Lottery: {
get: getLotteryData, get: Painter.lotteryUserShow,
card: getLotteryCard, card: getLotteryCard,
}, },
User: { User: {
@@ -55,10 +36,6 @@ const Mys = {
getCaptcha, getCaptcha,
login: doCaptchaLogin, login: doCaptchaLogin,
}, },
Vote: {
get: getVoteInfo,
result: getVoteResult,
},
}; };
export default Mys; export default Mys;

View File

@@ -0,0 +1,64 @@
/**
* @file plugins/Mys/request/apiHubReq.ts
* @description apiHub下的请求
* @since Beta v0.6.2
*/
import TGHttp from "../../../utils/TGHttp.js";
// MysApiHubApiBaseUrl => Mahabu
const Mahabu = "https://bbs-api.miyoushe.com/apihub/api/";
const Referer = "https://bbs.mihoyo.com/";
/**
* @description 获取投票信息
* @since Beta v0.6.2
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>}
*/
export async function getVotes(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
return (
await TGHttp<TGApp.Plugins.Mys.Vote.InfoResponse>(`${Mahabu}getVotes`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
})
).data.data[0];
}
/**
* @description 获取投票结果
* @since Beta v0.6.2
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>}
*/
export async function getVoteResult(
id: string,
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
return (
await TGHttp<TGApp.Plugins.Mys.Vote.ResultResponse>(`${Mahabu}getVotesResult`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
})
).data.data[0];
}
/**
* @description 获取首页导航列表
* @since Beta v0.6.2
* @param {number} gid GID
* @return {Promise<TGApp.BBS.Navigator.Navigator[]>}
*/
export async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
return (
await TGHttp<TGApp.BBS.Navigator.HomeResponse>(`${Mahabu}home/new`, {
method: "GET",
headers: { "x-rpc-client_type": "2" },
query: { gids: gid },
})
).data.navigator;
}

View File

@@ -1,27 +0,0 @@
/**
* @file plugins/Mys/request/getCollectionPosts.ts
* @description Mys 获取合集帖子
* @since Beta v0.5.5
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取合集帖子
* @since Beta v0.5.0
* @param {string} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
*/
export async function getCollectionPosts(
collectionId: string,
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getPostFullInCollection";
const params = { collection_id: collectionId };
const resp = await TGHttp<TGApp.Plugins.Mys.Collection.ResponsePosts>(url, {
method: "GET",
query: params,
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
});
return resp.data.posts;
}

View File

@@ -1,35 +0,0 @@
/**
* @file plugins/Mys/request/getForumList.ts
* @description Mys 插件特定论坛请求
* @since Beta v0.5.1
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取特定论坛列表
* @since Beta v0.5.1
* @param {number} forumId 特定论坛 ID
* @param {number} type 排序方式: 0-按热度排序1-最新回复2-按时间排序
* @param {number} page_size 每页数量
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
*/
async function getForumList(
forumId: number,
type: number = 0,
page_size: number = 20,
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
const url = "https://bbs-api.miyoushe.com/post/wapi/getForumPostList";
const params = {
forum_id: forumId.toString(),
sort_type: type.toString(),
page_size: page_size.toString(),
};
const resp = await TGHttp<TGApp.Plugins.Mys.Forum.Response>(url, {
method: "GET",
query: params,
});
return resp.data;
}
export default getForumList;

View File

@@ -1,27 +0,0 @@
/**
* @file plugins/Mys/request/getHomeNavigator.ts
* @description Mys 插件首页导航请求
* @since Beta v0.5.1
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取首页导航列表
* @since Beta v0.5.1
* @param {number} gid GID
* @return {Promise<TGApp.BBS.Navigator.Navigator[]>}
*/
async function getHomeNavigator(gid: number = 2): Promise<TGApp.BBS.Navigator.Navigator[]> {
const url = "https://bbs-api.miyoushe.com/apihub/api/home/new";
const params = { gids: gid.toString() };
const header = { "x-rpc-client_type": "2" };
const resp = await TGHttp<TGApp.BBS.Navigator.HomeResponse>(url, {
method: "GET",
headers: header,
query: params,
});
return resp.data.navigator;
}
export default getHomeNavigator;

View File

@@ -1,39 +0,0 @@
/**
* @file plugins/Mys/request/getNewsList.ts
* @description Mys 插件咨讯请求
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 获取 News 列表
* @since Beta v0.5.0
* @param {string} gid GID
* @param {string} newsType 咨讯类型: 1 为公告2 为活动3 为咨讯
* @param {number} pageSize 返回数量
* @param {number} lastId 上一次请求的最后一条数据的 id
* @return {Promise<TGApp.Plugins.Mys.News.FullData>}
*/
async function getNewsList(
gid: string = "2",
newsType: string = "1",
pageSize: number = 20,
lastId: number = 0,
): Promise<TGApp.Plugins.Mys.News.FullData> {
const url = "https://bbs-api.mihoyo.com/post/wapi/getNewsList";
const params = {
gids: gid,
page_size: pageSize.toString(),
type: newsType,
last_id: lastId.toString(),
};
const resp = await TGHttp<TGApp.Plugins.Mys.News.Response>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data;
}
export default getNewsList;

View File

@@ -1,27 +0,0 @@
/**
* @file plugins Mys request getPostData.ts
* @description Mys帖子请求
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取帖子信息
* @since Beta v0.5.0
* @param {number} postId 帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Post.FullData>}
*/
async function getPostData(postId: number): Promise<TGApp.Plugins.Mys.Post.FullData> {
const url = "https://bbs-api.mihoyo.com/post/wapi/getPostFull";
const params = { post_id: postId.toString() };
const resp = await TGHttp<TGApp.Plugins.Mys.Post.Response>(url, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
return resp.data.post;
}
export default getPostData;

View File

@@ -1,115 +0,0 @@
/**
* @file plugins/Mys/request/getPostReply.ts
* @description Mys 插件帖子回复请求
* @since Beta v0.5.5
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取帖子回复信息
* @since Beta v0.5.5
* @param {string} postId 帖子 ID
* @param {number} gid 社区 ID
* @param {boolean} isHot 是否热门
* @param {boolean} onlyMaster 是否只看楼主
* @param {number} orderType 排序类型
* @param {string} lastId 最后 ID
* @param {number} size 每页大小
* @return {Promise<TGApp.Plugins.Mys.Reply.ReplyData|TGApp.BBS.Response.Base>}
*/
export async function getPostReply(
postId: string,
gid: number,
isHot: boolean = true,
lastId?: string,
onlyMaster: boolean = false,
orderType?: 1 | 2,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.ReplyData | TGApp.BBS.Response.Base> {
const params: Record<string, string | number | boolean> = {
post_id: postId,
gids: gid,
is_hot: isHot,
size: size,
};
if (lastId) {
params["last_id"] = lastId;
}
if (orderType) {
params["order_type"] = orderType;
}
if (onlyMaster) {
params["is_hot"] = false;
params["only_master"] = onlyMaster;
}
const link = "https://bbs-api.miyoushe.com/post/wapi/getPostReplies";
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.Response>(link, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取帖子子回复根信息
* @since Beta v0.5.5
* @param {number} gid 社区 ID
* @param {string} postId 帖子 ID
* @param {string} replyId 回复 ID
* @return {Promise<TGApp.Plugins.Mys.Reply.SubRootData|TGApp.BBS.Response.Base>}
*/
export async function getPostSubRoot(
gid: number,
postId: string,
replyId: string,
): Promise<TGApp.Plugins.Mys.Reply.SubRootData | TGApp.BBS.Response.Base> {
const link = "https://bbs-api.miyoushe.com/post/wapi/getRootReplyInfo";
const params = { gids: gid, post_id: postId, reply_id: replyId };
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.SubRootResponse>(link, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取帖子子回复信息
* @since Beta v0.5.5
* @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>}
*/
export async function getPostSubReply(
floorId: number,
gid: number,
postId: string,
lastId?: string,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.SubData | TGApp.BBS.Response.Base> {
const params: Record<string, string | number> = {
floor_id: floorId,
gids: gid,
post_id: postId,
size: size,
};
if (lastId) {
params["last_id"] = lastId;
}
const link = "https://bbs-api.miyoushe.com/post/wapi/getSubReplies";
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.SubResponse>(link, {
method: "GET",
headers: { referer: MysApi.PostReferer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}

View File

@@ -1,47 +0,0 @@
/**
* @file plugins/Mys/request/getVoteData.ts
* @description Mys 插件投票请求
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
import MysApi from "../api/index.js";
/**
* @description 获取投票信息
* @since Beta v0.5.0
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>}
*/
export async function getVoteInfo(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotes";
const params = { owner_uid: uid, vote_ids: id };
const resp = await TGHttp<TGApp.Plugins.Mys.Vote.InfoResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.data[0];
}
/**
* @description 获取投票结果
* @since Beta v0.5.0
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>}
*/
export async function getVoteResult(
id: string,
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotesResult";
const params = { owner_uid: uid, vote_ids: id };
const resp = await TGHttp<TGApp.Plugins.Mys.Vote.ResultResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
});
return resp.data.data[0];
}

View File

@@ -1,29 +1,30 @@
/** /**
* @file plugins/Mys/request/getLotteryData.ts * @file plugins/Mys/request/painterReq.ts
* @description Mys * @description painter下的请求
* @since Beta v0.5.0 * @since Beta v0.6.2
*/ */
import TGHttp from "../../../utils/TGHttp.js"; import TGHttp from "../../../utils/TGHttp.js";
// MysPainterApiBaseUrl => Mpabu
const Mpabu = "https://bbs-api.miyoushe.com/painter/wapi/";
/** /**
* @description * @description
* @since Beta v0.5.0 * @since Beta v0.6.2
* @param {string} lotteryId ID * @param {string} lotteryId ID
* @return {Promise<TGApp.BBS.Response.Base|TGApp.Plugins.Mys.Lottery.FullData>} * @return {Promise<TGApp.BBS.Response.Base|TGApp.Plugins.Mys.Lottery.FullData>}
*/ */
async function getLotteryData( export async function lotteryUserShow(
lotteryId: string, lotteryId: string,
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.FullData> { ): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.FullData> {
const url = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show"; const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>(
const params = { id: lotteryId }; `${Mpabu}lottery/user/show`,
const resp = await TGHttp<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.Lottery.Response>(url, { {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
query: params, query: { id: lotteryId },
}); },
);
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp; if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.show_lottery; return resp.data.show_lottery;
} }
export default getLotteryData;

View File

@@ -0,0 +1,193 @@
/**
* @file plugins/Mys/request/postReq.ts
* @description 帖子相关的获取
* @since Beta v0.6.2
*/
import TGHttp from "../../../utils/TGHttp.js";
// MysPostApiBaseUrl => Mpabu
const Mpabu = "https://bbs-api.mihoyo.com/post/wapi/";
const Referer = "https://bbs.mihoyo.com/";
/**
* @description 获取特定论坛列表
* @since Beta v0.6.2
* @param {number} forumId 特定论坛 ID
* @param {number} type 排序方式: 0-按热度排序1-最新回复2-按时间排序
* @param {number} page_size 每页数量
* @return {Promise<TGApp.Plugins.Mys.Forum.FullData>}
*/
export async function getForumPostList(
forumId: number,
type: number = 0,
page_size: number = 20,
): Promise<TGApp.Plugins.Mys.Forum.FullData> {
return (
await TGHttp<TGApp.Plugins.Mys.Forum.Response>(`${Mpabu}getForumPostList`, {
method: "GET",
query: { forum_id: forumId, sort_type: type, page_size: page_size },
})
).data;
}
/**
* @description 获取 News 列表
* @since Beta v0.6.2
* @param {string} gid GID
* @param {string} newsType 咨讯类型: 1 为公告2 为活动3 为咨讯
* @param {number} pageSize 返回数量
* @param {number} lastId 上一次请求的最后一条数据的 id
* @return {Promise<TGApp.Plugins.Mys.News.FullData>}
*/
export async function getNewsList(
gid: string = "2",
newsType: string = "1",
pageSize: number = 20,
lastId: number = 0,
): Promise<TGApp.Plugins.Mys.News.FullData> {
return (
await TGHttp<TGApp.Plugins.Mys.News.Response>(`${Mpabu}getNewsList`, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: { gids: gid, page_size: pageSize, type: newsType, last_id: lastId },
})
).data;
}
/**
* @description 获取单个帖子信息
* @since Beta v0.6.2
* @param {number} postId 帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Post.FullData>}
*/
export async function getPostFull(postId: number): Promise<TGApp.Plugins.Mys.Post.FullData> {
return (
await TGHttp<TGApp.Plugins.Mys.Post.Response>(`${Mpabu}getPostFull`, {
method: "GET",
headers: { referer: Referer },
query: { post_id: postId },
})
).data.post;
}
/**
* @description 获取合集帖子
* @since Beta v0.6.2
* @param {string} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
*/
export async function getPostFullInCollection(
collectionId: string,
): Promise<TGApp.Plugins.Mys.Collection.Data[]> {
return (
await TGHttp<TGApp.Plugins.Mys.Collection.ResponsePosts>(`${Mpabu}getPostFullInCollection`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { collection_id: collectionId },
})
).data.posts;
}
/**
* @description 获取帖子回复信息
* @since Beta v0.6.2
* @param {string} postId 帖子 ID
* @param {number} gid 社区 ID
* @param {boolean} isHot 是否热门
* @param {boolean} onlyMaster 是否只看楼主
* @param {number} orderType 排序类型
* @param {string} lastId 最后 ID
* @param {number} size 每页大小
* @return {Promise<TGApp.Plugins.Mys.Reply.ReplyData|TGApp.BBS.Response.Base>}
*/
export async function getPostReplies(
postId: string,
gid: number,
isHot: boolean = true,
lastId?: string,
onlyMaster: boolean = false,
orderType?: 1 | 2,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.ReplyData | TGApp.BBS.Response.Base> {
type GprParam = {
post_id: string;
gids: number;
is_hot: boolean;
size: number;
last_id?: string;
order_type?: 1 | 2;
only_master?: boolean;
};
const params: GprParam = { post_id: postId, gids: gid, is_hot: isHot, size: size };
if (lastId) params.last_id = lastId;
if (orderType) params.order_type = orderType;
if (onlyMaster) {
params.is_hot = false;
params.only_master = onlyMaster;
}
const resp = await TGHttp<TGApp.Plugins.Mys.Reply.Response>(`${Mpabu}getPostReplies`, {
method: "GET",
headers: { referer: Referer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 获取帖子子回复信息
* @since Beta v0.6.2
* @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>}
*/
export async function getSubReplies(
floorId: number,
gid: number,
postId: string,
lastId?: string,
size: number = 20,
): Promise<TGApp.Plugins.Mys.Reply.SubData | TGApp.BBS.Response.Base> {
type GsrParam = {
floor_id: number;
gids: number;
post_id: string;
size: number;
last_id?: string;
};
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`, {
method: "GET",
headers: { referer: Referer },
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* @description 搜索帖子
* @since Beta v0.6.2
* @param {string} gid 游戏分区 ID
* @param {string} keyword 关键词
* @param {string} lastId 最后一条帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Search.PostsResponseData>} 返回帖子列表
*/
export async function searchPosts(
gid: string = "2",
keyword: string,
lastId: string,
): Promise<TGApp.Plugins.Mys.Search.PostsResponseData> {
return (
await TGHttp<TGApp.Plugins.Mys.Search.PostsResponse>(`${Mpabu}searchPosts`, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: { gids: gid, keyword, last_id: lastId, size: 20 },
})
).data;
}

View File

@@ -1,32 +0,0 @@
/**
* @file plugins/Mys/request/searchPost.ts
* @description 帖子搜索
* @since Beta v0.5.0
*/
import TGHttp from "../../../utils/TGHttp.js";
/**
* @description 搜索帖子
* @since Beta v0.5.0
* @param {string} gid 游戏分区 ID
* @param {string} keyword 关键词
* @param {string} last_id 最后一条帖子 ID
* @return {Promise<TGApp.Plugins.Mys.Search.PostsResponseData>} 返回帖子列表
*/
async function searchPosts(
gid: string = "2",
keyword: string,
last_id: string,
): Promise<TGApp.Plugins.Mys.Search.PostsResponseData> {
const url = "https://bbs-api.miyoushe.com/post/wapi/searchPosts";
const params = { gids: gid, keyword, last_id, size: "20" };
const resp = await TGHttp<TGApp.Plugins.Mys.Search.PostsResponse>(url, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: params,
});
return resp.data;
}
export default searchPosts;

View File

@@ -1,15 +1,15 @@
/** /**
* @file plugins/Mys/utils/getGachaCard.ts * @file plugins/Mys/utils/getGachaCard.ts
* @description Mys 插件抽卡工具 * @description Mys 插件抽卡工具
* @since Beta v0.5.0 * @since Beta v0.6.2
*/ */
import { AppCharacterData } from "../../../data/index.js"; import { AppCharacterData } from "../../../data/index.js";
import getPostData from "../request/getPostData.js"; import { getPostFull } from "../request/postReq.js";
/** /**
* @description 根据单个卡池信息转为渲染用的卡池信息 * @description 根据单个卡池信息转为渲染用的卡池信息
* @since Beta v0.5.0 * @since Beta v0.6.2
* @param {TGApp.Plugins.Mys.Gacha.Data} data 卡池信息 * @param {TGApp.Plugins.Mys.Gacha.Data} data 卡池信息
* @param {string} poolCover 卡池封面 * @param {string} poolCover 卡池封面
* @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard>} * @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard>}
@@ -28,7 +28,7 @@ async function getGachaItemCard(
} else { } else {
try { try {
console.log("调用 getPostData"); console.log("调用 getPostData");
const post = await getPostData(postId); const post = await getPostFull(postId);
cover = post.cover?.url ?? post.post.images[0]; cover = post.cover?.url ?? post.post.images[0];
} catch (error) { } catch (error) {
console.error(error); console.error(error);

View File

@@ -1,14 +1,12 @@
/** /**
* @file plugins/Mys/utils/getPositionCard.ts * @file plugins/Mys/utils/getPositionCard.ts
* @description Mys 插件热点追踪工具 * @description Mys 插件热点追踪工具
* @since Beta v0.5.3 * @since Beta v0.6.2
*/ */
import Mys from "../index.js";
/** /**
* @description 根据热点追踪信息转为渲染用的数据 * @description 根据热点追踪信息转为渲染用的数据
* @since Beta v0.5.3 * @since Beta v0.6.2
* @param {TGApp.Plugins.Mys.Position.Data[]} positionData 列表 * @param {TGApp.Plugins.Mys.Position.Data[]} positionData 列表
* @returns {TGApp.Plugins.Mys.Position.RenderCard[]} 返回列表 * @returns {TGApp.Plugins.Mys.Position.RenderCard[]} 返回列表
*/ */
@@ -25,7 +23,7 @@ function getPositionCard(
} }
let link = position.url; let link = position.url;
if (position.url === "" && position.content_id !== 0) { if (position.url === "" && position.content_id !== 0) {
link = Mys.Api.Obc.replace("{contentId}", position.content_id.toString()); link = `https://bbs.mihoyo.com/ys/obc/content/${position.content_id}/detail?bbs_presentation_style=no_header`;
} }
const card: TGApp.Plugins.Mys.Position.RenderCard = { const card: TGApp.Plugins.Mys.Position.RenderCard = {
title: position.title, title: position.title,

View File

@@ -1,7 +1,7 @@
/** /**
* @file utils/TGWindow.ts * @file utils/TGWindow.ts
* @description 窗口创建相关工具函数 * @description 窗口创建相关工具函数
* @since Beta v0.5.0 * @since Beta v0.6.2
*/ */
import { core, window as TauriWindow } from "@tauri-apps/api"; import { core, window as TauriWindow } from "@tauri-apps/api";
@@ -70,3 +70,15 @@ export async function createPost(
console.error(err); console.error(err);
}); });
} }
/**
* @description 打开观测枢
* @since Beta 0.6.2
* @param {string} contentId
* @param {string} label
* @returns {Promise<void>}
*/
export async function createObc(contentId: number, label: string): Promise<void> {
const obcUrl = `https://bbs.mihoyo.com/ys/obc/content/${contentId}/detail?bbs_presentation_style=no_header`;
await createTGWindow(obcUrl, "Sub_window", `Content_${contentId}_${label}`, 1200, 800, true);
}

View File

@@ -37,7 +37,7 @@ onMounted(async () => {
} }
loadingTitle.value = "正在获取数据..."; loadingTitle.value = "正在获取数据...";
try { try {
jsonData = await Mys.Post.get(postId); jsonData = await Mys.Post.getPostFull(postId);
} catch (e) { } catch (e) {
loadingTitle.value = "获取数据失败"; loadingTitle.value = "获取数据失败";
loadingEmpty.value = true; loadingEmpty.value = true;

View File

@@ -147,7 +147,7 @@ onMounted(async () => {
// 获取数据 // 获取数据
loadingTitle.value = "正在获取数据..."; loadingTitle.value = "正在获取数据...";
try { try {
postData.value = await Mys.Post.get(postId); postData.value = await Mys.Post.getPostFull(postId);
loadingTitle.value = "正在渲染数据..."; loadingTitle.value = "正在渲染数据...";
renderPost.value = getRenderPost(postData.value); renderPost.value = getRenderPost(postData.value);
shareTitle.value = `Post_${postId}`; shareTitle.value = `Post_${postId}`;