♻️ 请求重构,合并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>();
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);
if (!pool) return;
if (poolTimeGet.value[postId] === "未开始") {
@@ -162,7 +162,7 @@ function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]): boolean {
return false;
}
const cover = homeStore.poolCover;
if (cover === undefined) return false;
if (cover.value === undefined) return false;
let checkList = data.length;
Object.entries(cover).forEach(([key, value]: [string, unknown]) => {
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> {
nav.value = await Mys.Posts.nav(props.modelValue);
nav.value = await Mys.ApiHub.homeNew(props.modelValue);
}
async function tryGetCode(): Promise<void> {

View File

@@ -134,7 +134,7 @@ async function searchPosts() {
load.value = false;
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 === "") {
results.value = res.posts;
} else {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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