♻️ Hutao 类型重构,优化目录结构

This commit is contained in:
BTMuli
2023-06-27 14:53:36 +08:00
parent c7c1b2a0a2
commit dc51257e6b
15 changed files with 204 additions and 173 deletions

View File

@@ -77,7 +77,7 @@ import { useUserStore } from "../../store/modules/user";
import TGRequest from "../../web/request/TGRequest";
import TGSqlite from "../../plugins/Sqlite";
import { generateShareImg } from "../../utils/TGShare";
import HutaoRequest from "../../plugins/Hutao";
import Hutao from "../../plugins/Hutao";
// store
const userStore = useUserStore();
@@ -155,7 +155,7 @@ async function uploadAbyss(): Promise<void> {
const abyssData = curAbyss.value;
loadingTitle.value = "正在转换深渊数据";
loading.value = true;
let transAbyss = HutaoRequest.Abyss.utils.transData(abyssData);
let transAbyss = Hutao.Abyss.utils.transData(abyssData);
loadingTitle.value = "正在获取角色数据";
const roles = await TGSqlite.getUserCharacter(user.value.gameUid);
if (!roles) {
@@ -163,9 +163,9 @@ async function uploadAbyss(): Promise<void> {
return;
}
loadingTitle.value = "正在转换角色数据";
transAbyss.avatars = HutaoRequest.Abyss.utils.transAvatars(roles);
transAbyss.avatars = Hutao.Abyss.utils.transAvatars(roles);
loadingTitle.value = "正在上传深渊数据";
const res = await HutaoRequest.Abyss.postData(transAbyss);
const res = await Hutao.Abyss.postData(transAbyss);
console.log(res);
loading.value = false;
}

View File

@@ -9,7 +9,7 @@
// vue
import { onMounted, ref } from "vue";
// utils
import HutaoRequest from "../../plugins/Hutao";
import Hutao from "../../plugins/Hutao";
import HtaOverlayOverview from "../../components/hutaoAbyss/hta-overlay-overview.vue";
const showDialog = ref(false);
@@ -18,7 +18,7 @@ const showDialog = ref(false);
const overview = ref({} as TGApp.Plugins.Hutao.AbyssOverview);
onMounted(async () => {
overview.value = await HutaoRequest.Abyss.getOverview();
overview.value = await Hutao.Abyss.getOverview();
});
function getUpdated() {

View File

@@ -16,7 +16,7 @@ import getWeaponCollect from "./request/getWeaponCollect";
import uploadData from "./request/uploadData";
import { transAvatars, transLocal } from "./utils/transLocal";
const HutaoRequest = {
const Hutao = {
Abyss: {
avatar: {
getCollect: getAvatarCollect,
@@ -39,4 +39,4 @@ const HutaoRequest = {
},
};
export default HutaoRequest;
export default Hutao;

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取角色搭配数据
* @since Alpha v0.2.0
* @return {Promise<TGApp.Plugins.Hutao.AbyssAvatarCollocation[]>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.AvatarCollocation[]>}
*/
async function getAvatarCollect(): Promise<TGApp.Plugins.Hutao.AbyssAvatarCollocation[]> {
async function getAvatarCollect(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarCollocation[]> {
const url = HutaoApi.Abyss.avatar.collect;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssAvatarCollocationResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarCollocationResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取角色持有率数据
* @since Alpha v0.2.0
* @returns {Promise<TGApp.Plugins.Hutao.AbyssAvatarHoldRate[]>}
* @returns {Promise<TGApp.Plugins.Hutao.Abyss.AvatarHold[]>}
*/
async function getAvatarHoldRate(): Promise<TGApp.Plugins.Hutao.AbyssAvatarHoldRate[]> {
async function getAvatarHoldRate(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarHold[]> {
const url = HutaoApi.Abyss.avatar.holdRate;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssAvatarHoldRateResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarHoldResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取角色上场率数据
* @since Alpha v0.2.0
* @return {Promise<TGApp.Plugins.Hutao.AbyssAvatarUpRate[]>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.AvatarUp[]>}
*/
async function getAvatarUpRate(): Promise<TGApp.Plugins.Hutao.AbyssAvatarUpRate[]> {
async function getAvatarUpRate(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarUp[]> {
const url = HutaoApi.Abyss.avatar.upRate;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssAvatarUpRateResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarUpResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取角色使用率
* @since Alpha v0.2.0
* @return {Promise<TGApp.Plugins.Hutao.AbyssAvatarUseRate[]>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.AvatarUse[]>}
*/
async function getAvatarUseRate(): Promise<TGApp.Plugins.Hutao.AbyssAvatarUseRate[]> {
async function getAvatarUseRate(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarUse[]> {
const url = HutaoApi.Abyss.avatar.useRate;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssAvatarUseRateResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarUseResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取深渊概览数据
* @since Alpha v0.2.0
* @return {Promise<TGApp.Plugins.Hutao.AbyssOverview>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.OverviewData>}
*/
async function getOverview(): Promise<TGApp.Plugins.Hutao.AbyssOverview> {
async function getOverview(): Promise<TGApp.Plugins.Hutao.Abyss.OverviewData> {
const url = HutaoApi.Abyss.overview;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssOverviewResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.OverviewResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取队伍搭配数据
* @since Alpha v0.2.0
* @return {Promise<TGApp.Plugins.Hutao.AbyssTeamCombination[]>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.TeamCombination[]>}
*/
async function getTeamCollect(): Promise<TGApp.Plugins.Hutao.AbyssTeamCombination[]> {
async function getTeamCollect(): Promise<TGApp.Plugins.Hutao.Abyss.TeamCombination[]> {
const url = HutaoApi.Abyss.team;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssTeamCombinationResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.TeamCombinationResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -20,7 +20,7 @@ import HutaoApi from "../api";
export async function checkUid(uid: string): Promise<boolean> {
const url = HutaoApi.Abyss.user.check.replace("{uid}", uid);
return await http
.fetch<TGApp.Plugins.Hutao.AbyssRecordExistResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.ExistResponse>(url, {
method: "GET",
})
.then((res) => {
@@ -33,12 +33,12 @@ export async function checkUid(uid: string): Promise<boolean> {
* @since Alpha v0.2.0
* @todo 未完成
* @param {string} uid
* @return {Promise<TGApp.Plugins.Hutao.AbyssRecordRank>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.RankData>}
*/
export async function getUserData(uid: string): Promise<TGApp.Plugins.Hutao.AbyssRecordRank> {
export async function getUserData(uid: string): Promise<TGApp.Plugins.Hutao.Abyss.RankData> {
const url = HutaoApi.Abyss.user.rank.replace("{uid}", uid);
return await http
.fetch<TGApp.Plugins.Hutao.AbyssRecordRankResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.RecordRankResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,12 +13,12 @@ import HutaoApi from "../api";
/**
* @description 获取武器搭配
* @since Alpha v0.2.0
* @return {Promise<TGApp.Plugins.Hutao.AbyssWeaponCollocation[]>}
* @return {Promise<TGApp.Plugins.Hutao.Abyss.WeaponCollocation[]>}
*/
async function getWeaponCollect(): Promise<TGApp.Plugins.Hutao.AbyssWeaponCollocation[]> {
async function getWeaponCollect(): Promise<TGApp.Plugins.Hutao.Abyss.WeaponCollocation[]> {
const url = HutaoApi.Abyss.weapon;
return await http
.fetch<TGApp.Plugins.Hutao.AbyssWeaponCollocationResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.WeaponCollocationResponse>(url, {
method: "GET",
})
.then((res) => {

View File

@@ -13,15 +13,15 @@ import HutaoApi from "../api";
/**
* @description 上传用户数据
* @since Alpha v0.2.1
* @param {TGApp.Plugins.Hutao.AbyssRecordUpload} data 用户数据
* @returns {Promise<TGApp.Plugins.Hutao.HutaoResponse>} 上传结果
* @param {TGApp.Plugins.Hutao.Abyss.RecordUpload} data 用户数据
* @returns {Promise<TGApp.Plugins.Hutao.Abyss.UploadResponse>} 上传结果
*/
async function uploadData(
data: TGApp.Plugins.Hutao.AbyssRecordUpload,
): Promise<TGApp.Plugins.Hutao.HutaoResponse> {
data: TGApp.Plugins.Hutao.Abyss.RecordUpload,
): Promise<TGApp.Plugins.Hutao.Abyss.UploadResponse> {
const url = HutaoApi.Abyss.upload;
return await http
.fetch<TGApp.Plugins.Hutao.HutaoResponse>(url, {
.fetch<TGApp.Plugins.Hutao.Abyss.UploadResponse>(url, {
method: "POST",
body: http.Body.json(data),
})

View File

@@ -1,49 +1,42 @@
/**
* @file types Plugins Hutao.d.ts
* @description Hutao API
* @see HutaoRequest
* @file src plugins Hutao types Abyss.d.ts
* @description Hutao
* @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.1
*/
declare namespace TGApp.Plugins.Hutao {
/**
* @description Hutao API
* @since Alpha v0.2.0
* @interface HutaoResponse
* @property {number} retcode -
* @property {string} message -
* @property {any} data -
*/
export interface HutaoResponse {
retcode?: number;
message?: string;
data?: any;
}
/**
* @description Hutao
* @since Alpha v0.2.1
* @namespace Abyss
* @exports TGApp.Plugins.Hutao.Abyss
* @return Abyss
*/
declare namespace TGApp.Plugins.Hutao.Abyss {
/**
* @description
* @since Alpha v0.2.0
* @since Alpha v0.2.1
* @see HutaoRequest.Abyss.postData
* @interface AbyssRecordUpload
* @interface RecordUpload
* @property {string} uid - UID
* @property {string} identity -
* @property {AbyssRecord} spiralAbyss -
* @property {AbyssAvatar[]} avatars -
* @property {RecordData} spiralAbyss -
* @property {Avatar[]} avatars -
* @property {string} reservedUserName -
* @return AbyssRecordUpload
* @return RecordUpload
*/
export interface AbyssRecordUpload {
export interface RecordUpload {
uid: string;
identity: string;
spiralAbyss: AbyssRecord;
avatars: AbyssAvatar[];
spiralAbyss: RecordData;
avatars: Avatar[];
reservedUserName: string;
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssRecord
* @interface RecordData
* @property {number} scheduleId -
* @property {number} totalBattleTimes -
* @property {number} totalWinTimes -
@@ -51,10 +44,10 @@ declare namespace TGApp.Plugins.Hutao {
* @property {number} damage.value -
* @property {number} takeDamage.avatarId - ID
* @property {number} takeDamage.value -
* @property {AbyssFloor[]} floors -
* @return AbyssRecord
* @property {Floor[]} floors -
* @return RecordData
*/
export interface AbyssRecord {
export interface RecordData {
scheduleId: number;
totalBattleTimes: number;
totalWinTimes: number;
@@ -66,35 +59,35 @@ declare namespace TGApp.Plugins.Hutao {
avatarId: number;
value: number;
};
floors: AbyssFloor[];
floors: Floor[];
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssFloor
* @interface Floor
* @property {number} index -
* @property {number} star -
* @property {AbyssLevel[]} levels -
* @return AbyssFloor
* @property {Level[]} levels -
* @return Floor
*/
export interface AbyssFloor {
export interface Floor {
index: number;
star: number;
levels: AbyssLevel[];
levels: Level[];
}
/**
* @description
* @description
* @since Alpha v0.2.0
* @interface AbyssLevel
* @interface Level
* @property {number} index -
* @property {number} star -
* @property {number} battles[].index -
* @property {number[]} battles[].avatars - ID
* @return AbyssLevel
* @return Level
*/
export interface AbyssLevel {
export interface Level {
index: number;
star: number;
battles: Array<{
@@ -106,14 +99,14 @@ declare namespace TGApp.Plugins.Hutao {
/**
* @description
* @since Alpha v0.2.1
* @interface AbyssAvatar
* @interface Avatar
* @property {number} avatarId - ID
* @property {number} weaponId - ID
* @property {number[]} reliquarySetIds - ID
* @property {number} activedConstellationNumber -
* @return AbyssAvatar
* @return Avatar
*/
export interface AbyssAvatar {
export interface Avatar {
avatarId: number;
weaponId: number;
reliquarySetIds: number[];
@@ -121,40 +114,49 @@ declare namespace TGApp.Plugins.Hutao {
}
/**
* @description uid
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.user.checkExist
* @interface AbyssRecordExistResponse
* @extends HutaoResponse
* @property {boolean} data -
* @return AbyssRecordExistResponse
* @description
* @since Alpha v0.2.1
* @see HutaoRequest.Abyss.postData
* @interface UploadResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @return UploadResponse
*/
export interface AbyssRecordExistResponse extends HutaoResponse {
export interface UploadResponse extends TGApp.Plugins.Hutao.Base.Response {}
/**
* @description
* @since Alpha v0.2.1
* @see HutaoRequest.Abyss.user.checkExist
* @interface ExistResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {boolean} data -
* @return ExistResponse
*/
export interface ExistResponse extends TGApp.Plugins.Hutao.Base.Response {
data: boolean;
}
/**
* @description
* @todo
* @since Alpha v0.2.0
* @since Alpha v0.2.1
* @see HutaoRequest.Abyss.user.getRecord
* @interface AbyssRecordRankResponse
* @extends HutaoResponse
* @property {AbyssRecordRank} data -
* @return AbyssRecordRankResponse
* @interface RecordRankResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {RankData} data -
* @return RecordRankResponse
*/
export interface AbyssRecordRankResponse extends HutaoResponse {
data: AbyssRecordRank;
export interface RecordRankResponse extends TGApp.Plugins.Hutao.Base.Response {
data: RankData;
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssRecordRank
* @since Alpha v0.2.1
* @interface RankData
* @todo
* @return AbyssRecordRank
* @return RankData
*/
export interface AbyssRecordRank {
export interface RankData {
// todo
}
@@ -162,19 +164,19 @@ declare namespace TGApp.Plugins.Hutao {
* @description
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.getOverview
* @interface AbyssOverviewResponse
* @extends HutaoResponse
* @property {AbyssOverview} data -
* @return AbyssOverviewResponse
* @interface OverviewResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {OverviewData} data -
* @return OverviewResponse
*/
export interface AbyssOverviewResponse extends HutaoResponse {
data: AbyssOverview;
export interface OverviewResponse extends TGApp.Plugins.Hutao.Base.Response {
data: OverviewData;
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssOverview
* @interface OverviewData
* @property {number} scheduleId -
* @property {number} recordTotal -
* @property {number} spiralAbyssTotal -
@@ -185,9 +187,9 @@ declare namespace TGApp.Plugins.Hutao {
* @property {number} timestamp -
* @property {number} timeTotal -
* @property {number} timeAverage -
* @return AbyssOverview
* @return OverviewData
*/
export interface AbyssOverview {
export interface OverviewData {
scheduleId: number;
recordTotal: number;
spiralAbyssTotal: number;
@@ -204,26 +206,25 @@ declare namespace TGApp.Plugins.Hutao {
* @description
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.avatar.getUpRate
* @method GET
* @interface AbyssAvatarUpRateResponse
* @extends HutaoResponse
* @property {AbyssAvatarUpRate[]} data -
* @return AbyssAvatarUpRateResponse
* @interface AvatarUpResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {AvatarUp[]} data -
* @return AvatarUpResponse
*/
export interface AbyssAvatarUpRateResponse extends HutaoResponse {
data: AbyssAvatarUpRate[];
export interface AvatarUpResponse extends TGApp.Plugins.Hutao.Base.Response {
data: AvatarUp[];
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssAvatarUpRate
* @interface AvatarUp
* @property {number} floor -
* @property {number} ranks[].item - ID
* @property {number} ranks[].rate -
* @return AbyssAvatarUpRate
* @return AvatarUp
*/
export interface AbyssAvatarUpRate {
export interface AvatarUp {
floor: number;
ranks: {
item: number;
@@ -235,25 +236,25 @@ declare namespace TGApp.Plugins.Hutao {
* @description 使
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.avatar.getUseRate
* @interface AbyssAvatarUseRateResponse
* @extends HutaoResponse
* @property {AbyssAvatarUseRate[]} data - 使
* @return AbyssAvatarUseRateResponse
* @interface AvatarUseResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {AvatarUse[]} data - 使
* @return AvatarUseResponse
*/
export interface AbyssAvatarUseRateResponse extends HutaoResponse {
data: AbyssAvatarUseRate[];
export interface AvatarUseResponse extends TGApp.Plugins.Hutao.Base.Response {
data: AvatarUse[];
}
/**
* @description 使
* @since Alpha v0.2.0
* @interface AbyssAvatarUseRate
* @interface AvatarUse
* @property {number} floor -
* @property {number} ranks[].item - ID
* @property {number} ranks[].rate - 使
* @return AbyssAvatarUseRate
* @return AvatarUse
*/
export interface AbyssAvatarUseRate {
export interface AvatarUse {
floor: number;
ranks: Array<{
item: number;
@@ -265,26 +266,26 @@ declare namespace TGApp.Plugins.Hutao {
* @description
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.avatar.getHoldRate
* @interface AbyssAvatarHoldRateResponse
* @extends HutaoResponse
* @property {AbyssAvatarHoldRate[]} data -
* @return AbyssAvatarHoldRateResponse
* @interface AvatarHoldResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {AvatarHold[]} data -
* @return AvatarHoldResponse
*/
export interface AbyssAvatarHoldRateResponse extends HutaoResponse {
data: AbyssAvatarHoldRate[];
export interface AvatarHoldResponse extends TGApp.Plugins.Hutao.Base.Response {
data: AvatarHold[];
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssAvatarHoldRate
* @interface AvatarHold
* @property {number} holdingRate -
* @property {number} constellations[].item - ID
* @property {number} constellations[].rate -
* @property {number} avatarId - ID
* @return AbyssAvatarHoldRate
* @return AvatarHold
*/
export interface AbyssAvatarHoldRate {
export interface AvatarHold {
holdingRate: number;
constellations: Array<{
item: number;
@@ -297,19 +298,19 @@ declare namespace TGApp.Plugins.Hutao {
* @description
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.avatar.getCollect
* @interface AbyssAvatarCollocationResponse
* @extends HutaoResponse
* @property {AbyssAvatarCollocation[]} data -
* @return AbyssAvatarCollocationResponse
* @interface AvatarCollocationResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {AvatarCollocation[]} data -
* @return AvatarCollocationResponse
*/
export interface AbyssAvatarCollocationResponse extends HutaoResponse {
data: AbyssAvatarCollocation[];
export interface AvatarCollocationResponse extends TGApp.Plugins.Hutao.Base.Response {
data: AvatarCollocation[];
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssAvatarCollocation
* @interface AvatarCollocation
* @property {number} avatarId - ID
* @property {number} avatars[].item - ID
* @property {number} avatars[].rate -
@@ -317,9 +318,9 @@ declare namespace TGApp.Plugins.Hutao {
* @property {number} reliquaries[].rate -
* @property {number} weapons[].item - ID
* @property {number} weapons[].rate -
* @return AbyssAvatarCollocation
* @return AvatarCollocation
*/
export interface AbyssAvatarCollocation {
export interface AvatarCollocation {
avatarId: number;
avatars: Array<{
item: number;
@@ -339,24 +340,24 @@ declare namespace TGApp.Plugins.Hutao {
* @description
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.weapon.getCollect
* @interface AbyssWeaponCollocationResponse
* @extends HutaoResponse
* @property {AbyssWeaponCollocation[]} data -
* @interface WeaponCollocationResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {WeaponCollocation[]} data -
*/
export interface AbyssWeaponCollocationResponse extends HutaoResponse {
data: AbyssWeaponCollocation[];
export interface WeaponCollocationResponse extends TGApp.Plugins.Hutao.Base.Response {
data: WeaponCollocation[];
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssWeaponCollocation
* @interface WeaponCollocation
* @property {number} weaponId - ID
* @property {number} avatars[].item - ID
* @property {number} avatars[].rate -
* @return AbyssWeaponCollocation
* @return WeaponCollocation
*/
export interface AbyssWeaponCollocation {
export interface WeaponCollocation {
weaponId: number;
avatars: Array<{
item: number;
@@ -368,27 +369,27 @@ declare namespace TGApp.Plugins.Hutao {
* @description
* @since Alpha v0.2.0
* @see HutaoRequest.Abyss.getTeamCollect
* @interface AbyssTeamCombinationResponse
* @extends HutaoResponse
* @property {AbyssTeamCombination[]} data -
* @return AbyssTeamCombinationResponse
* @interface TeamCombinationResponse
* @extends TGApp.Plugins.Hutao.Base.Response
* @property {TeamCombination[]} data -
* @return TeamCombinationResponse
*/
export interface AbyssTeamCombinationResponse extends HutaoResponse {
data: AbyssTeamCombination[];
export interface TeamCombinationResponse extends TGApp.Plugins.Hutao.Base.Response {
data: TeamCombination[];
}
/**
* @description
* @since Alpha v0.2.0
* @interface AbyssTeamCombination
* @interface TeamCombination
* @property {number} floor -
* @property {string} up[].item - ID // id,id,id,id
* @property {number} up[].rate -
* @property {string} down[].item - ID // id,id,id,id
* @property {number} down[].rate -
* @return AbyssTeamCombination
* @return TeamCombination
*/
export interface AbyssTeamCombination {
export interface TeamCombination {
floor: number;
up: Array<{
item: string;

30
src/plugins/Hutao/types/Base.d.ts vendored Normal file
View File

@@ -0,0 +1,30 @@
/**
* @file src plugins Hutao types Base.d.ts
* @description Hutao 插件基础类型定义文件
* @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.1
*/
/**
* @description Hutao 插件基础类型
* @since Alpha v0.2.1
* @namespace Base
* @exports TGApp.plugins.Hutao.Base
* @return Base
*/
declare namespace TGApp.Plugins.Hutao.Base {
/**
* @description Hutao Response 统一接口
* @since Alpha v0.2.1
* @interface Response
* @property {number} retcode 状态码
* @property {string} message 状态信息
* @property {any} data 数据
* @return Response
*/
export interface Response {
retcode?: number;
message?: string;
data?: any;
}
}

View File

@@ -9,11 +9,11 @@
* @description 将本地数据转为上传用的数据
* @since Alpha v0.2.1
* @param {TGApp.Sqlite.Abyss.SingleTable} data 本地数据
* @returns {TGApp.Plugins.Hutao.AbyssRecordUpload} 上传用的数据
* @returns {TGApp.Plugins.Hutao.Abyss.RecordUpload} 上传用的数据
*/
export function transLocal(
data: TGApp.Sqlite.Abyss.SingleTable,
): TGApp.Plugins.Hutao.AbyssRecordUpload {
): TGApp.Plugins.Hutao.Abyss.RecordUpload {
return {
uid: data.uid,
identity: "Tauri.Genshin",
@@ -27,9 +27,9 @@ export function transLocal(
* @description 转换深渊数据
* @since Alpha v0.2.1
* @param {TGApp.Sqlite.Abyss.SingleTable} data 本地数据
* @returns {TGApp.Plugins.Hutao.AbyssRecord} 上传用的数据
* @returns {TGApp.Plugins.Hutao.Abyss.RecordData} 上传用的数据
*/
function transAbyss(data: TGApp.Sqlite.Abyss.SingleTable): TGApp.Plugins.Hutao.AbyssRecord {
function transAbyss(data: TGApp.Sqlite.Abyss.SingleTable): TGApp.Plugins.Hutao.Abyss.RecordData {
const damage: TGApp.Sqlite.Abyss.Character = JSON.parse(data.damageRank)[0];
const takeDamage: TGApp.Sqlite.Abyss.Character = JSON.parse(data.takeDamageRank)[0];
return {
@@ -52,9 +52,9 @@ function transAbyss(data: TGApp.Sqlite.Abyss.SingleTable): TGApp.Plugins.Hutao.A
* @description 转换层数数据
* @since Alpha v0.2.1
* @param {TGApp.Sqlite.Abyss.Floor} data 本地数据
* @returns {TGApp.Plugins.Hutao.AbyssFloor} 上传用的数据
* @returns {TGApp.Plugins.Hutao.Abyss.Floor} 上传用的数据
*/
function transFloor(data: TGApp.Sqlite.Abyss.Floor): TGApp.Plugins.Hutao.AbyssFloor {
function transFloor(data: TGApp.Sqlite.Abyss.Floor): TGApp.Plugins.Hutao.Abyss.Floor {
return {
index: data.id,
star: data.winStar,
@@ -66,9 +66,9 @@ function transFloor(data: TGApp.Sqlite.Abyss.Floor): TGApp.Plugins.Hutao.AbyssFl
* @description 转换层-关卡数据
* @since Alpha v0.2.1
* @param {TGApp.Sqlite.Abyss.Level} data 本地数据
* @returns {TGApp.Plugins.Hutao.AbyssLevel} 上传用的数据
* @returns {TGApp.Plugins.Hutao.Abyss.Level} 上传用的数据
*/
function transLevel(data: TGApp.Sqlite.Abyss.Level): TGApp.Plugins.Hutao.AbyssLevel {
function transLevel(data: TGApp.Sqlite.Abyss.Level): TGApp.Plugins.Hutao.Abyss.Level {
const battles: Array<{ index: number; avatars: number[] }> = [];
battles.push({
index: 1,
@@ -89,11 +89,11 @@ function transLevel(data: TGApp.Sqlite.Abyss.Level): TGApp.Plugins.Hutao.AbyssLe
* @description 转换角色数据
* @since Alpha v0.2.1
* @param {TGApp.Sqlite.Character.UserRole[]} avatars 角色数据
* @returns {TGApp.Plugins.Hutao.AbyssAvatar[]} 上传用的数据
* @returns {TGApp.Plugins.Hutao.Abyss.Avatar[]} 上传用的数据
*/
export function transAvatars(
avatars: TGApp.Sqlite.Character.UserRole[],
): TGApp.Plugins.Hutao.AbyssAvatar[] {
): TGApp.Plugins.Hutao.Abyss.Avatar[] {
return avatars.map((avatar) => {
const weapon: TGApp.Sqlite.Character.RoleWeapon = JSON.parse(avatar.weapon);
let relics: number[];