diff --git a/src/pages/User/Characters.vue b/src/pages/User/Characters.vue
index 809392de..00e1c033 100644
--- a/src/pages/User/Characters.vue
+++ b/src/pages/User/Characters.vue
@@ -1,7 +1,49 @@
角色数据获取、展示、详情
+
+ 获取角色列表
+
+ {{ roleList }}
diff --git a/src/types/Game/Character.d.ts b/src/types/Game/Character.d.ts
new file mode 100644
index 00000000..27120ec3
--- /dev/null
+++ b/src/types/Game/Character.d.ts
@@ -0,0 +1,191 @@
+/**
+ * @file types Game Character.d.ts
+ * @description 游戏角色相关类型定义文件
+ * @todo v0.1.5 不使用
+ * @author BTMuli
+ * @since Alpha v0.2.0
+ */
+
+declare namespace TGApp.Game.Character {
+ /**
+ * @description 角色列表数据返回类型
+ * @interface ListResponse
+ * @since Alpha v0.2.0
+ * @see todo 请求也得重构一下
+ * @extends TGApp.BBS.Response.Base
+ * @property {ListItem[]} data.avatars - 角色列表
+ * @property {ListRole} data.role - 角色信息
+ * @return ListResponse
+ */
+ export interface ListResponse extends TGApp.BBS.Response.Base {
+ data: {
+ avatars: ListItem[]
+ role: ListRole
+ }
+ }
+
+ /**
+ * @description 角色列表数据类型
+ * @interface ListItem
+ * @since Alpha v0.2.0
+ * @property {number} id - 角色 ID
+ * @property {string} image - 角色全身像
+ * @property {string} icon - 角色头像
+ * @property {string} name - 角色名称
+ * @property {TGApp.Game.Constant.EnumElementEn} element - 角色元素
+ * @property {number} fetter - 角色好感等级
+ * @property {number} level - 角色等级
+ * @property {number} rarity - 角色稀有度
+ * @property {LIWeapon} weapon - 角色武器
+ * @property {LIRelic[]} reliquaries - 角色圣遗物
+ * @property {LIConstellation[]} constellations - 角色命座
+ * @property {number} actived_constellation_num - 角色已激活命座数量
+ * @property {LICostume[]} costumes - 角色时装
+ * @property {number} constellation_level - 角色命座等级
+ * @property {unknown} external - todo:未知
+ * @return ListItem
+ */
+ export interface ListItem {
+ id: number
+ image: string
+ icon: string
+ name: string
+ element: TGApp.Game.Constant.EnumElementEn
+ fetter: number
+ level: number
+ rarity: number
+ weapon: LIWeapon
+ reliquaries: LIReliquary[]
+ constellations: LIConstellation[]
+ actived_constellation_num: number
+ costumes: LICostume[]
+ constellation_level: number
+ external: unknown
+ }
+
+ /**
+ * @description 角色信息
+ * @interface ListRole
+ * @since Alpha v0.2.0
+ * @property {string} AvatarUrl - 角色头像 // 大部分情况下是空的
+ * @property {string} nickname - 角色昵称
+ * @property {string} region - 角色所在地区
+ * @property {number} level - 角色等级
+ * @return ListRole
+ */
+ export interface ListRole {
+ AvatarUrl: string
+ nickname: string
+ region: string
+ level: number
+ }
+
+ /**
+ * @description 角色武器数据类型
+ * @interface LIWeapon
+ * @since Alpha v0.2.0
+ * @property {number} id - 武器 ID
+ * @property {string} name - 武器名称
+ * @property {string} icon - 武器图标
+ * @property {number} type - 武器类型 // todo: 不同的武器类型对应的数值
+ * @property {number} rarity - 武器稀有度
+ * @property {number} level - 武器等级
+ * @property {number} promote_level - 武器等级对应的突破等级
+ * @property {string} type_name - 武器类型名称
+ * @property {string} desc - 武器描述
+ * @property {number} affix_level - 武器精炼等级
+ * @return LIWeapon
+ */
+ export interface LIWeapon {
+ id: number
+ name: string
+ icon: string
+ type: number
+ rarity: number
+ level: number
+ promote_level: number
+ type_name: string
+ desc: string
+ affix_level: number
+ }
+
+ /**
+ * @description 角色圣遗物数据类型
+ * @interface LIRelic
+ * @since Alpha v0.2.0
+ * @property {number} id - 圣遗物 ID
+ * @property {string} name - 圣遗物名称
+ * @property {string} icon - 圣遗物图标
+ * @property {number} pos - 圣遗物位置
+ * @property {number} rarity - 圣遗物稀有度
+ * @property {number} level - 圣遗物等级
+ * @property {RelicSet} set - 圣遗物套装
+ * @property {TGApp.Game.Constant.EnumRelic} pos_name - 圣遗物位置名称
+ * @return LIRelic
+ */
+ export interface LIRelic {
+ id: number
+ name: string
+ icon: string
+ pos: number
+ rarity: number
+ level: number
+ set: RelicSet
+ pos_name: TGApp.Game.Constant.EnumRelic
+ }
+
+ /**
+ * @description 圣遗物套装数据类型
+ * @interface RelicSet
+ * @since Alpha v0.2.0
+ * @property {number} id - 圣遗物套装 ID
+ * @property {string} name - 圣遗物套装名称
+ * @property {number} affixes[].activation_number - 圣遗物套装激活数量
+ * @property {string} affixes[].effect - 圣遗物套装效果
+ * @return RelicSet
+ */
+ export interface RelicSet {
+ id: number
+ name: string
+ affixes: Array<{
+ activation_number: number
+ effect: string
+ }>
+ }
+
+ /**
+ * @description 角色命座数据类型
+ * @interface LIConstellation
+ * @since Alpha v0.2.0
+ * @property {number} id - 命座 ID
+ * @property {string} name - 命座名称
+ * @property {string} icon - 命座图标
+ * @property {string} effect - 命座效果
+ * @property {boolean} is_actived - 命座是否激活
+ * @property {number} pos - 命座位置
+ * @return LIConstellation
+ */
+ export interface LIConstellation {
+ id: number
+ name: string
+ icon: string
+ effect: string
+ is_actived: boolean
+ pos: number
+ }
+
+ /**
+ * @description 角色时装数据类型
+ * @interface LICostume
+ * @since Alpha v0.2.0
+ * @property {number} id - 时装 ID
+ * @property {string} name - 时装名称
+ * @property {string} icon - 时装图标
+ * @return LICostume
+ */
+ export interface LICostume {
+ id: number
+ name: string
+ icon: string
+ }
+}
diff --git a/src/types/Game/Constant.d.ts b/src/types/Game/Constant.d.ts
index 01dd3566..566140db 100644
--- a/src/types/Game/Constant.d.ts
+++ b/src/types/Game/Constant.d.ts
@@ -28,6 +28,28 @@ declare namespace TGApp.Game.Constant {
dendro = "草元素",
}
+ /**
+ * @description 七元素-英文
+ * @since Alpha v0.2.0
+ * @enum {string}
+ * @property {string} pyro - 火元素
+ * @property {string} hydro - 水元素
+ * @property {string} anemo - 风元素
+ * @property {string} electro - 雷元素
+ * @property {string} cryo - 冰元素
+ * @property {string} geo - 岩元素
+ * @property {string} dendro - 草元素
+ */
+ export enum EnumElementEn {
+ pyro = "Pyro",
+ hydro = "Hydro",
+ anemo = "Anemo",
+ electro = "Electro",
+ cryo = "Cryo",
+ geo = "Geo",
+ dendro = "Dendro",
+ }
+
/**
* @description 武器类型
* @since Alpha v0.1.5
@@ -45,6 +67,24 @@ declare namespace TGApp.Game.Constant {
bow = "弓",
catalyst = "法器",
}
+
+ /**
+ * @description 圣遗物位置
+ * @since Alpha v0.2.0
+ * @enum {string}
+ * @property {string} flower - 生之花
+ * @property {string} feather - 死之羽
+ * @property {string} sands - 时之沙
+ * @property {string} goblet - 空之杯
+ * @property {string} circlet - 理之冠
+ */
+ export enum EnumRelic {
+ flower = "生之花",
+ feather = "死之羽",
+ sands = "时之沙",
+ goblet = "空之杯",
+ circlet = "理之冠",
+ }
}
// /**
diff --git a/src/web/request/TGRequest.ts b/src/web/request/TGRequest.ts
index 39fb34e1..5fd8386b 100644
--- a/src/web/request/TGRequest.ts
+++ b/src/web/request/TGRequest.ts
@@ -2,7 +2,7 @@
* @file web request TGRequest.ts
* @description 应用用到的请求函数
* @author BTMuli
- * @since Alpha v0.2.0
+ * @since Alpha v0.1.5
*/
import { getAbyss } from "./getAbyss";
@@ -11,7 +11,7 @@ import { getCookieTokenBySToken } from "./getCookieToken";
// import * from "./getEnkaData.ts";
import { getGameAccountsBySToken, getGameAccountsByCookie } from "./getGameAccounts";
import { getLTokenBySToken } from "./getLToken";
-// import * from "./getRoleList.ts";
+import { getGameRoleListByLToken } from "./getRoleList";
// import * from "./getTickets.ts";
import { getTokensByLoginTicket } from "./getTokens";
import { getUserInfoByCookie } from "./getUserInfo";
@@ -36,6 +36,7 @@ const TGRequest = {
},
byLToken: {
verify: verifyLToken,
+ getRoleList: getGameRoleListByLToken,
},
bySToken: {
getAccounts: getGameAccountsBySToken,
diff --git a/src/web/request/getRoleList.ts b/src/web/request/getRoleList.ts
new file mode 100644
index 00000000..92cc5d02
--- /dev/null
+++ b/src/web/request/getRoleList.ts
@@ -0,0 +1,35 @@
+/**
+ * @file web request getRoleList.ts
+ * @description 获取游戏角色列表的请求方法
+ * @author BTMuli
+ * @since Alpha v0.2.0
+ */
+
+// tauri
+import { http } from "@tauri-apps/api";
+// utils
+import TGApi from "../api/TGApi";
+import TGUtils from "../utils/TGUtils";
+
+/**
+ * @description 通过 Cookie 获取用户角色列表
+ * @since Alpha v0.2.0
+ * @param {Record} cookie Cookie
+ * @param {TGApp.Sqlite.Account.Game} account 游戏账号
+ * @returns {Promise} 用户角色列表
+ */
+export async function getGameRoleListByLToken (cookie: Record, account: TGApp.Sqlite.Account.Game): Promise {
+ const url = TGApi.GameData.byCookie.getCharacter;
+ const uid = account.gameUid;
+ // eslint-disable-next-line camelcase
+ const data = { role_id: uid, server: TGUtils.Tools.getServerByUid(uid) };
+ const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(data), "common");
+ return await http.fetch(url, {
+ method: "POST",
+ headers: header,
+ body: http.Body.json(data),
+ }).then((res) => {
+ if (res.data.retcode !== 0) return res.data;
+ return res.data.data.avatars;
+ });
+}