mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
♻️ showSnackbar重构
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
/**
|
||||
* @file plugins/Mys/index.ts
|
||||
* @description Mys plugin index
|
||||
* @since Beta v0.6.2
|
||||
* @since Beta v0.6.3
|
||||
*/
|
||||
|
||||
import * as ApiHub from "./request/apiHubReq.js";
|
||||
import { getCaptcha, doCaptchaLogin } from "./request/doCaptchaLogin.js";
|
||||
import { getLoginQr, getLoginStatus } from "./request/doGameLogin.js";
|
||||
import getGachaData from "./request/getGachaData.js";
|
||||
import { getPositionData } from "./request/getPositionData.js";
|
||||
import { getPositionData, getGachaData } from "./request/obcReq.js";
|
||||
import * as Painter from "./request/painterReq.js";
|
||||
import * as Post from "./request/postReq.js";
|
||||
import { getGachaCard } from "./utils/getGachaCard.js";
|
||||
|
||||
@@ -28,10 +28,7 @@ encrypt.setPublicKey(PUB_KEY_STR);
|
||||
function rsaEncrypt(data: string): string {
|
||||
const res = encrypt.encrypt(data.toString());
|
||||
if (res === false) {
|
||||
showSnackbar({
|
||||
text: "RSA 加密失败",
|
||||
color: "error",
|
||||
});
|
||||
showSnackbar.error("RSA 加密失败");
|
||||
return "";
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/request/getGachaData.ts
|
||||
* @description Mys 抽卡请求
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
import TGHttp from "../../../utils/TGHttp.js";
|
||||
|
||||
/**
|
||||
* @description 获取卡池信息
|
||||
* @since Beta v0.5.0
|
||||
* @return {Promise<TGApp.Plugins.Mys.Gacha.Data[]>}
|
||||
*/
|
||||
async function getGachaData(): Promise<TGApp.Plugins.Mys.Gacha.Data[]> {
|
||||
const url = "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc";
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Gacha.Response>(url, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
return resp.data.list;
|
||||
}
|
||||
|
||||
export default getGachaData;
|
||||
@@ -1,11 +1,42 @@
|
||||
/**
|
||||
* @file plugins/Mys/request/getPositionData.ts
|
||||
* @description Mys 插件热点追踪请求
|
||||
* @since Beta v0.5.0
|
||||
* @file plugins/Mys/request/obcReq.ts
|
||||
* @description 观测枢相关请求
|
||||
* @since Beta v0.6.3
|
||||
*/
|
||||
|
||||
import TGHttp from "../../../utils/TGHttp.js";
|
||||
|
||||
const obcApi = "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/";
|
||||
|
||||
/**
|
||||
* @description 获取卡池信息
|
||||
* @since Beta v0.6.3
|
||||
* @return {Promise<TGApp.Plugins.Mys.Gacha.Data[]>}
|
||||
*/
|
||||
export async function getGachaData(): Promise<TGApp.Plugins.Mys.Gacha.Data[]> {
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Gacha.Response>(`${obcApi}gacha_pool`, {
|
||||
method: "GET",
|
||||
query: { app_sn: "ys_obc" },
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
return resp.data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取热点追踪信息
|
||||
* @since Beta v0.6.3
|
||||
* @return {Promise<TGApp.Plugins.Mys.Position.Data[]>}
|
||||
*/
|
||||
export async function getPositionData(): Promise<TGApp.Plugins.Mys.Position.Data[]> {
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Position.Response>(`${obcApi}home/position`, {
|
||||
method: "GET",
|
||||
query: { app_sn: "ys_obc" },
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
const data = resp.data.list;
|
||||
return DfsObc(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 深度优先遍历
|
||||
* @since Alpha v0.2.1
|
||||
@@ -24,19 +55,3 @@ function DfsObc(list: TGApp.Plugins.Mys.Position.ObcItem[]): TGApp.Plugins.Mys.P
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取热点追踪信息
|
||||
* @since Beta v0.5.0
|
||||
* @return {Promise<TGApp.Plugins.Mys.Position.Data[]>}
|
||||
*/
|
||||
export async function getPositionData(): Promise<TGApp.Plugins.Mys.Position.Data[]> {
|
||||
const url =
|
||||
"https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc";
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.Position.Response>(url, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
const data = resp.data.list;
|
||||
return DfsObc(data);
|
||||
}
|
||||
Reference in New Issue
Block a user