♻️ 类型重构完毕,开始修改数据源

This commit is contained in:
BTMuli
2023-05-22 22:00:26 +08:00
parent ac4a2e465a
commit c5b073909b
34 changed files with 2085 additions and 1957 deletions

44
src/types/BBS/Account.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
/**
* @file types BBS Account.d.ts
* @description BBS 账户相关类型定义文件
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.5
*/
declare namespace TGApp.BBS.Account {
/**
* @description stoken 验证获取的用户信息
* @interface VerifySTokenInfo
* @since Alpha v0.1.5
* @todo 添加 request 索引
* @property {string} aid 账号 id
* @property {string} mid mid
* @property {string} account_name 账号名称
* @property {string} email 邮箱
* @property {number} is_email_verify 是否验证邮箱 // 0 未验证 1 已验证
* @property {string} area_code 手机区号 // '+86'
* @property {string} safe_mobile 手机号 // 部分明文,中间隐藏
* @property {string} realname 真实姓名 // 最后一位明文,其他隐藏
* @property {string} identity_code 身份证号 // 头尾三位明文,其他隐藏
* @property {string} rebind_area_code 重新绑定手机区号
* @property {string} rebind_mobile 重新绑定手机号
* @property {string} rebind_mobile_time 重新绑定手机时间
* @property {unknown[]} links 账号绑定信息
* @return VerifySTokenInfo
*/
export interface VerifySTokenInfo {
aid: string
mid: string
account_name: string
email: string
is_email_verify: number
area_code: string
safe_mobile: string
realname: string
identity_code: string
rebind_area_code: string
rebind_mobile: string
rebind_mobile_time: string
links: unknown[]
}
}

167
src/types/BBS/Announcement.d.ts vendored Normal file
View File

@@ -0,0 +1,167 @@
/**
* @file types BBS Announcement.d.ts
* @description 从 BBS 获取到的游戏内公告类型定义文件
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.5
*/
declare namespace BTMuli.BBS.Announcement {
/**
* @description 公告列表返回响应类型
* @interface ListResponse
* @since Alpha v0.1.5
* @extends TGApp.BBS.Response.Base
* @property {ListData} data - 公告列表数据
* @return ListResponse
*/
export interface ListResponse extends TGApp.BBS.Response.Base {
data: ListData
}
/**
* @description 公告内容返回响应类型
* @interface ContentResponse
* @since Alpha v0.1.5
* @extends TGApp.BBS.Response.Base
* @property {ContentData} data - 公告内容数据
* @return ContentResponse
*/
export interface ContentResponse extends TGApp.BBS.Response.Base {
data: ContentData
}
/**
* @description 公告列表数据
* @interface ListData
* @since Alpha v0.1.5
* @property {ListItem[]} list - 公告列表
* @property {number} total - 公告总数
* @property {ListType[]} type_list - 公告类型列表
* @property {boolean} alert - 是否有紧急公告
* @property {number} time_zone - 时区
* @property {string} t - 时间戳,单位为秒
* @property {unknown[]} pic_list - 图片列表 todo: 未知类型
* @property {number} pic_total - 图片总数
* @property {unknown[]} pic_type_list - 图片类型列表 todo: 未知类型
* @property {boolean} pic_alert - 是否有紧急图片
* @property {number} pic_alert_id - 紧急图片 ID
* @property {unknown} static_sign - 静态签名 todo: 未知类型
* @return ListData
*/
export interface ListData {
list: ListItem[]
total: number
type_list: ListType[]
alert: boolean
time_zone: number
t: string
pic_list: unknown[]
pic_total: number
pic_type_list: unknown[]
pic_alert: boolean
pic_alert_id: number
static_sign: unknown
}
/**
* @description 公告内容数据
* @interface ContentData
* @since Alpha v0.1.5
* @property {ContentItem[]} list - 公告内容列表
* @property {number} total - 公告内容总数
* @property {unknown[]} pic_list - 图片列表 todo: 未知类型
* @property {number} pic_total - 图片总数
* @return ContentData
*/
export interface ContentData {
list: ContentItem[]
total: number
pic_list: unknown[]
pic_total: number
}
/**
* @description 公告列表项
* @interface ListItem
* @since Alpha v0.1.5
* @property {number} ann_id 公告 ID
* @property {string} title 公告标题
* @property {string} subtitle 公告副标题
* @property {string} banner 公告图片
* @property {unknown} content 公告内容
* @property {string} type_label 公告类型标签
* @property {string} tag_label 公告标签
* @property {string} tag_icon 公告标签图标
* @property {number} login_alert 是否登录提示
* @property {string} lang 公告语言
* @property {string} start_time 公告开始时间 // "2023-03-01 07:00:00"
* @property {string} end_time 公告结束时间 // "2023-04-12 06:00:00"
* @property {number} type 公告类型
* @property {number} remind 公告提醒
* @property {number} alert 公告紧急
* @property {string} tag_start_time 公告标签开始时间 // "2000-01-02 15:04:05"
* @property {string} tag_end_time 公告标签结束时间 // "2030-01-02 15:04:05"
* @property {number} remind_ver 公告提醒版本
* @property {boolean} has_content 是否有内容
* @property {boolean} extra_remind 是否有额外提醒
* @return ListItem
*/
export interface ListItem {
ann_id: number
title: string
subtitle: string
banner: string
content: unknown
type_label: string
tag_label: string
tag_icon: string
login_alert: number
lang: string
start_time: string
end_time: string
type: number
remind: number
alert: number
tag_start_time: string
tag_end_time: string
remind_ver: number
has_content: boolean
extra_remind: boolean
}
/**
* @description 公告类型列表项
* @interface ListType
* @since Alpha v0.1.5
* @property {number} id 公告类型 ID
* @property {string} name 公告类型名称
* @property {string} mi18n_name 公告类型国际化名称
* @return ListType
*/
export interface ListType {
id: number
name: string
mi18n_name: string
}
/**
* @description 公告内容列表项
* @interface ContentItem
* @since Alpha v0.1.5
* @property {number} ann_id 公告 ID
* @property {string} title 公告标题
* @property {string} subtitle 公告副标题
* @property {string} banner 公告图片
* @property {string} content 公告内容,为 html
* @property {string} lang 公告语言
* @return ContentItem
*/
export interface ContentItem {
ann_id: number
title: string
subtitle: string
banner: string
content: string
lang: string
}
}

48
src/types/BBS/Constant.d.ts vendored Normal file
View File

@@ -0,0 +1,48 @@
/**
* @file types BBS Constant.d.ts
* @description BBS 常量相关类型定义文件
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.5
*/
declare namespace TGApp.BBS.Constant {
/**
* @description 用户 Cookie 类型
* @interface Cookie
* @since Alpha v0.1.5
* @description 这边只写了需要的,其他的可以自行添加
* @description login_ticket 与 login_uid 一起使用
* @see TGRequest.User.byLoginTicket.getTokens
* @property {string} login_ticket 登录凭证
* @property {string} login_uid 登录 uid
* @description account_id 与 cookie_token 一起使用
* @see TGRequest.User.byCookie.getAccounts
* @property {string} account_id 账号 id
* @property {string} cookie_token cookie token
* @description ltoken 与 ltuid 一起使用
* @see TGRequest.User.byLToken.verify
* @property {string} ltoken ltoken
* @property {string} ltuid ltoken 对应的 uid
* @description stoken 与 stuid 一起使用,这是旧版本的 token
* @see TGRequest.User.bySToken.getCookieToken
* @property {string} stoken stoken
* @property {string} stuid stoken 对应的 uid
* @description stoken_v2 与 mid 一起使用,这是新版本的 token
* @see https://github.com/BTMuli/Tauri.Genshin/issues/18
* @property {string} stoken_v2 stoken_v2
* @property {string} mid mid
* @return Cookie
*/
export interface Cookie {
login_ticket: string
login_uid: string
account_id: string
cookie_token: string
ltoken: string
ltuid: string
mid: string
stoken: string
stuid: string
stoken_v2?: string
}
}

94
src/types/BBS/Response.d.ts vendored Normal file
View File

@@ -0,0 +1,94 @@
/**
* @file types BBS Tokens.d.ts
* @description BBS 返回数据类型定义文件
* @todo 视情况看看要不要拆分
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.5
*/
declare namespace TGApp.BBS.Response {
/**
* @description 基础返回类型,设计米游社接口请求都是这个类型
* @interface Base
* @since Alpha v0.1.5
* @property {number} retcode - 响应代码
* @property {string} message - 响应消息
* @property {any} data - 响应数据
* @return Base
*/
export interface Base {
retcode: number
message: string
data: any
}
/**
* @description 获取 ltoken 跟 stoken 的响应数据
* @interface getTokens
* @since Alpha v0.1.5
* @todo 添加 request 索引
* @extends Base
* @property {string} data.list[].name - token 名称
* @property {string} data.list[].token - token 值
* @return getTokens
*/
export interface getTokens extends Base {
data: {
list: Array<{
name: string
token: string
}>
}
}
/**
* @description 根据 stoken 获取 ltoken 的响应数据
* @interface getLTokenBySToken
* @since Alpha v0.1.5
* @todo 添加 request 索引
* @extends Base
* @property {string} data.ltoken - ltoken 值
* @return getLTokenBySToken
*/
export interface getLTokenBySToken extends Base {
data: {
ltoken: string
}
}
/**
* @description 根据 stoken 获取 cookie_token 的响应数据
* @interface getCookieTokenBySToken
* @since Alpha v0.1.5
* @todo 添加 request 索引
* @extends Base
* @property {string} data.uid - 用户 uid
* @property {string} data.cookie_token - cookie_token 值
* @return getCookieTokenBySToken
*/
export interface getCookieTokenBySToken extends Base {
data: {
uid: string
cookie_token: string
}
}
/**
* @description 通过 stoken 验证用户信息的返回类型
* @interface verifyUserInfoBySToken
* @since Alpha v0.1.5
* @todo 添加 request 索引
* @extends Base
* @property {TGApp.BBS.Account.VerifySTokenInfo} data.user_info - 用户信息
* @property {unknown} data.realname_info - 实名信息 // todo: 未知类型
* @property {boolean} data.need_realperson - 是否需要实名认证
* @return verifyUserInfoBySToken
*/
export interface verifyUserInfoBySToken extends Base {
data: {
user_info: TGApp.BBS.Account.VerifySTokenInfo
realname_info: unknown
need_realperson: boolean
}
}
}