🏷️ fix(types): 精简 types,清除无用文件

This commit is contained in:
BTMuli
2023-04-09 23:09:13 +08:00
parent 20f3c8d00f
commit a238dc5eed
10 changed files with 72 additions and 267 deletions

View File

@@ -2,7 +2,7 @@
* @file plugins Mys index.ts
* @description Mys plugin index
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.1
* @since Alpha v0.1.2
*/
// Post
@@ -20,9 +20,6 @@ import { getNoticeCard, getActivityCard, getNewsCard } from "./utils/news";
// Lottery
import { getLotteryData } from "./request/lottery";
import { getLotteryCard, getLotteryRewardCard } from "./utils/lottery";
// Calendar
import { getCalendarData } from "./request/calendar";
import { getCalendarCard } from "./utils/calendar";
const MysOper = {
Post: {
@@ -56,10 +53,6 @@ const MysOper = {
reward: getLotteryRewardCard,
},
},
Calendar: {
get: getCalendarData,
card: getCalendarCard,
},
};
export default MysOper;

View File

@@ -1,107 +0,0 @@
/**
* @file plugins Mys interface calendar.ts
* @description Mys 插件日历接口
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.2
*/
import { type MysResponse } from "./base";
/**
* @description 日历返回数据
* @since Alpha v0.1.1
* @interface CalendarResponse
* @extends {MysResponse}
* @property {CalendarData[]} data.list 日历数据
* @returns {CalendarResponse}
*/
export interface CalendarResponse extends MysResponse {
data: {
list: CalendarData[]
}
}
/**
* @description 日历数据
* @since Alpha v0.1.1
* @interface CalendarData
* @property {string} id 日历 ID
* @property {string} title 日历标题
* @property {string} kind 日历数据类型1 为活动2 为角色/武器4 为角色生日
* @property {string} img_url 日历图片 URL
* @property {string} jump_type 日历跳转类型1 为帖子链接2 为观测枢链接
* @property {string} jump_url 日历跳转 URLjump_type 为 1 时不为空
* @property {string} content_id 日历内容 IDjump_type 为 2 时不为空
* @property {string} style 日历样式,// TODO: 未知
* @property {string} start_time 开始时间kind 为 2 时为 0
* @property {string} end_time 结束时间kind 为 2 时为 0
* @property {string} font_color 日历字体颜色kind 为 2 时为空
* @property {string} padding_color 日历背景颜色kind 为 2 时为空
* @property {string[]} drop_day 掉落日kind 为 2 时不为空
* @property {string} break_type 日历分割类型0 为活动/生日1 为武器, 2 为角色
* @property {CalendarContent[]} contentInfos 材料内容kind 为 2 时不为空
* @property {string} sort 排序kind 为 2 时不为空,反序列化后为 Map<number, number>,前者为星期,后者为排序
* @property {CalendarContent[]} contentSource 材料来源kind 为 2 时不为空
* @returns {CalendarData}
*/
export interface CalendarData {
id: string
title: string
kind: string
img_url: string
jump_type: string
jump_url: string
content_id: string
style: string
start_time: string
end_time: string
font_color: string
padding_color: string
drop_day: string[]
break_type: string
contentInfos: CalendarContent[]
sort: string
contentSource: CalendarContent[]
}
/**
* @description 日历内容
* @since Alpha v0.1.1
* @interface CalendarContent
* @property {string} id 内容 ID对应的是观测枢的 content_id
* @property {string} title 材料/秘境 名称
* @property {string} icon 材料/秘境 图片 URL
* @property {string} bbs_url 链接,一般为空
* @returns {CalendarContent}
*/
export interface CalendarContent {
id: string
title: string
icon: string
bbs_url: string
}
/**
* @description 渲染用的日历数据
* @since Alpha v0.1.2
* @interface CalendarCard
* @property {number} id 角色/武器 ID
* @property {number} type 角色/武器,角色为 2武器为 1
* @property {string} title 角色/武器 名称
* @property {string} cover 角色/武器 封面
* @property {string} url 跳转链接,一般为 content_id
* @property {string[]} drop_day 掉落日
* @property {Record<number, number>} sort_day 排序
* @property {CalendarContent[]} contentInfos 材料内容
* @returns {CalendarCard}
*/
export interface CalendarCard {
id: number
type: number
title: string
cover: string
url: string
drop_day: string[]
sort_day: Record<number, number>
contentInfos: CalendarContent[]
}

View File

@@ -1,31 +0,0 @@
/**
* @file plugins Mys request calendar.ts
* @description Mys 插件日历请求
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.1
*/
import { http } from "@tauri-apps/api";
import { type CalendarResponse, type CalendarData } from "../interface/calendar";
// 日历 API
const CALENDAR_API = "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/get_activity_calendar?app_sn=ys_obc";
/**
* @description 日历请求
* @since Alpha v0.1.1
* @return {Promise<CalendarData[]>}
*/
export async function getCalendarData (): Promise<CalendarData[]> {
const res = await http
.fetch<CalendarResponse>(CALENDAR_API, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then((res) => {
return res.data.data.list;
});
return res.filter((item) => item.kind === "2");
}

View File

@@ -1,31 +0,0 @@
/**
* @file plugins Mys utils calendar.ts
* @description Mys 插件日历工具
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.1
*/
import { type CalendarData, type CalendarCard } from "../interface/calendar";
/**
* @description 将日历数据转换为卡片数据
* @since Alpha v0.1.1
* @param {CalendarData[]} calendarData 日历数据
* @returns {CalendarCard[]}
*/
export function getCalendarCard (calendarData: CalendarData[]): CalendarCard[] {
const calendarCard: CalendarCard[] = [];
calendarData.forEach((data: CalendarData) => {
return calendarCard.push({
id: Number(data.id),
type: Number(data.break_type),
title: data.title,
cover: data.img_url,
url: data.jump_type === "1" ? data.jump_url : data.content_id,
drop_day: data.drop_day,
sort_day: JSON.parse(data.sort),
contentInfos: data.contentInfos,
});
});
return calendarCard;
}