♻️ 动态获取版块

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

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

View File

@@ -1,64 +0,0 @@
/**
* @file plugins/Mys/request/apiHubReq.ts
* @description apiHub下的请求
* @since Beta v0.6.2
*/
import TGHttp from "@/utils/TGHttp.js";
// MysApiHubApiBaseUrl => Mahabu
const Mahabu: Readonly<string> = "https://bbs-api.miyoushe.com/apihub/api/";
const Referer: Readonly<string> = "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,83 +0,0 @@
/**
* @file plugins/Mys/types/Vote.d.ts
* @description Mys 插件投票类型定义文件
* @since Beta v0.3.9
*/
/**
* @description Mys 插件投票类型
* @since Beta v0.3.9
* @namespace TGApp.Plugins.Mys.Vote
* @memberof TGApp.Plugins.Mys
*/
declare namespace TGApp.Plugins.Mys.Vote {
/**
* @description 投票信息返回
* @since Beta v0.3.9
* @interface InfoResponse
* @extends TGApp.BBS.Response.BaseWithData
* @property {Info[]} data.data 投票信息
* @return InfoResponse
*/
interface InfoResponse extends TGApp.BBS.Response.BaseWithData {
data: {
data: Info[];
};
}
/**
* @description 投票结果返回
* @since Beta v0.3.9
* @interface ResultResponse
* @extends TGApp.BBS.Response.BaseWithData
* @property {Result[]} data.data 投票结果
* @return ResultResponse
*/
interface ResultResponse extends TGApp.BBS.Response.BaseWithData {
data: {
data: Result[];
};
}
/**
* @description 投票信息
* @since Beta v0.3.9
* @interface Info
* @property {string} vote_id 投票 ID
* @property {string} uid 用户 ID
* @property {number} vote_limit 投票限制
* @property {number} end_time 投票结束时间(秒级时间戳)
* @property {string} title 投票标题
* @property {string[]} vote_option_indexes 投票选项索引
* @property {string} created_at 投票创建时间(秒级时间戳)
* @return Info
*/
interface Info {
vote_id: string;
uid: string;
vote_limit: number;
end_time: number;
title: string;
vote_option_indexes: string[];
created_at: string;
}
/**
* @description 投票结果
* @since Beta v0.3.9
* @interface Result
* @property {string} vote_id 投票 ID
* @property {boolean} is_over 是否已结束
* @property {Record<string, number>} option_stats 投票选项统计
* @property {number} user_cnt 投票人数
* @property {unknown[]} vote_option_indexes 投票选项索引
* @return Result
*/
interface Result {
vote_id: string;
is_over: boolean;
option_stats: Record<string, number>;
user_cnt: number;
vote_option_indexes: unknown[];
}
}