From 9ee256c5208a22447d25bccfd8b0892ac29e3241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Fri, 16 Aug 2024 15:55:00 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=89=8D=E7=9E=BB=E5=85=91?= =?UTF-8?q?=E6=8D=A2=E7=A0=81=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/main/t-gamenav.vue | 43 ++++++++++++++- src/components/overlay/to-livecode.vue | 72 ++++++++++++++++++++++++++ src/pages/common/Test.vue | 64 +---------------------- src/types/BBS/Navigator.d.ts | 31 +++++++++++ src/web/request/TGRequest.ts | 4 ++ src/web/request/getCode.ts | 28 ++++++++++ 6 files changed, 178 insertions(+), 64 deletions(-) create mode 100644 src/components/overlay/to-livecode.vue create mode 100644 src/web/request/getCode.ts diff --git a/src/components/main/t-gamenav.vue b/src/components/main/t-gamenav.vue index 00d25c3e..96488d7e 100644 --- a/src/components/main/t-gamenav.vue +++ b/src/components/main/t-gamenav.vue @@ -4,19 +4,25 @@ navIcon {{ navItem.name }} +
+ +
+ + diff --git a/src/pages/common/Test.vue b/src/pages/common/Test.vue index 64798c68..d47da50f 100644 --- a/src/pages/common/Test.vue +++ b/src/pages/common/Test.vue @@ -13,65 +13,9 @@ -

数据请求测试

-
- 获取角色列表 - 获取角色详情 -
-
- -
- + diff --git a/src/types/BBS/Navigator.d.ts b/src/types/BBS/Navigator.d.ts index 48a59c99..91fa9b75 100644 --- a/src/types/BBS/Navigator.d.ts +++ b/src/types/BBS/Navigator.d.ts @@ -264,4 +264,35 @@ declare namespace TGApp.BBS.Navigator { user_status: unknown; }; } + + /** + * @description 兑换码接口返回数据 + * @interface CodeResponse + * @since Beta v0.5.3 + * @extends TGApp.BBS.Response.BaseWithData + * @property {CodeData[]} data.code_list - 兑换码数据 + * @return CodeResponse + */ + interface CodeResponse extends TGApp.BBS.Response.BaseWithData { + data: { + code_list: CodeData[]; + }; + } + + /** + * @description 兑换码数据 + * @interface CodeData + * @since Beta v0.5.3 + * @property {string} title - 兑换码标题,为html字符串 + * @property {string} code - 兑换码 + * @property {string} img - 兑换码图片 + * @property {string} to_get_time - 过期时间,时间戳(单位:秒) + * @return CodeData + */ + interface CodeData { + title: string; + code: string; + img: string; + to_get_time: string; + } } diff --git a/src/web/request/TGRequest.ts b/src/web/request/TGRequest.ts index 84fb19fd..52a58f36 100644 --- a/src/web/request/TGRequest.ts +++ b/src/web/request/TGRequest.ts @@ -9,6 +9,7 @@ import { getAbyss } from "./getAbyss.js"; import { getActionTicketBySToken } from "./getActionTicket.js"; import { getAnnoContent, getAnnoList } from "./getAnno.js"; import { getAvatarList, getAvatarDetail } from "./getAvatarDetail.js"; +import getCode from "./getCode.js"; import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken.js"; import { getDeviceFp } from "./getDeviceFp.js"; import { getGachaLog } from "./getGachaLog.js"; @@ -64,6 +65,9 @@ const TGRequest = { getSyncAvatarDetail, }, }, + Nav: { + getCode, + }, }; export default TGRequest; diff --git a/src/web/request/getCode.ts b/src/web/request/getCode.ts new file mode 100644 index 00000000..98e3301f --- /dev/null +++ b/src/web/request/getCode.ts @@ -0,0 +1,28 @@ +/** + * @file web/request/getCode.ts + * @description 获取兑换码相关请求 + * @since Beta v0.5.3 + */ + +import TGHttp from "../../utils/TGHttp.js"; + +/** + * @description 获取兑换码请求 + * @since Beta v0.5.3 + * @param {string} act_id - 活动 id + * @return {Promise} + */ +async function getCode( + act_id: string, +): Promise { + const url = "https://api-takumi-static.mihoyo.com/event/miyolive/refreshCode"; + const header = { "x-rpc-act_id": act_id }; + const res = await TGHttp(url, { + method: "GET", + headers: header, + }); + if (res.retcode !== 0) return res; + return res.data.code_list; +} + +export default getCode;