💄 当即将切换卡池时提供 switch btn

This commit is contained in:
BTMuli
2023-10-17 17:45:40 +08:00
parent 6af3461168
commit a8bf9e3c3b
4 changed files with 91 additions and 28 deletions

View File

@@ -1,13 +1,12 @@
/**
* @file plugins Mys types Gacha.d.ts
* @description Mys 插件卡池类型定义文件
* @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.1
* @since Beta v0.3.3
*/
/**
* @description Mys 卡池类型定义
* @since Alpha v0.2.1
* @since Beta v0.3.3
* @namespace Gacha
* @return Gacha
*/
@@ -20,7 +19,7 @@ declare namespace TGApp.Plugins.Mys.Gacha {
* @property {Data[]} data.list 卡池数据
* @return Response
*/
export interface Response extends TGApp.Plugins.Mys.Base.Response {
interface Response extends TGApp.Plugins.Mys.Base.Response {
data: {
list: Data[];
};
@@ -43,7 +42,7 @@ declare namespace TGApp.Plugins.Mys.Gacha {
* @property {string} end_time 卡池结束时间
* @return Data
*/
export interface Data {
interface Data {
id: string;
title: string;
activity_url: string;
@@ -64,14 +63,14 @@ declare namespace TGApp.Plugins.Mys.Gacha {
* @property {string} url 链接
* @return MiniItem
*/
export interface MiniItem {
interface MiniItem {
icon: string;
url: string;
}
/**
* @description 用于渲染的卡池数据
* @since Alpha v0.2.1
* @since Beta v0.3.3
* @interface RenderCard
* @property {string} title 卡池标题
* @property {string} subtitle 卡池副标题
@@ -79,13 +78,12 @@ declare namespace TGApp.Plugins.Mys.Gacha {
* @property {number} postId 卡池对应帖子ID
* @property {MiniItem[]} characters 卡池包含的角色
* @property {MiniItem} voice 卡池角色语音
* @property {string} time.start 卡池开始时间
* @property {string} time.str 卡池时间字符串
* @property {string} time.startStamp 卡池开始时间戳
* @property {string} time.end 卡池结束时间
* @property {string} time.endStamp 卡池结束时间戳
* @return RenderCard
*/
export interface RenderCard {
interface RenderCard {
title: string;
subtitle: string;
cover: string;
@@ -93,9 +91,8 @@ declare namespace TGApp.Plugins.Mys.Gacha {
characters: MiniItem[];
voice: MiniItem;
time: {
start: string;
str: string;
startStamp: number;
end: string;
endStamp: number;
};
}

View File

@@ -1,15 +1,14 @@
/**
* @file plugins Mys utils getGachaCard.ts
* @description Mys 插件抽卡工具
* @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.1
* @since Beta v0.3.3
*/
import getPostData from "../request/getPostData";
/**
* @description 根据卡池信息转为渲染用的卡池信息
* @since Alpha v0.2.1
* @since Beta v0.3.3
* @param {TGApp.Plugins.Mys.Gacha.Data[]} gachaData 卡池信息
* @param {Record<number, string>} poolCover 卡池封面
* @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard[]>}
@@ -37,6 +36,7 @@ async function getGachaCard(
console.error(error);
}
}
const timeStr = `${data.start_time} ~ ${data.end_time}`;
return gachaCard.push({
title: data.title,
subtitle: data.content_before_act,
@@ -51,9 +51,8 @@ async function getGachaCard(
url: data.voice_url,
},
time: {
start: data.start_time,
str: timeStr,
startStamp: new Date(data.start_time).getTime(),
end: data.end_time,
endStamp: new Date(data.end_time).getTime(),
},
});