mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-31 06:29:46 +08:00
🎨 代码格式化
This commit is contained in:
@@ -11,9 +11,11 @@ import {
|
||||
AvatarUpRateApi,
|
||||
AvatarUseRateApi,
|
||||
DataUploadApi,
|
||||
OverviewApi, TeamCombinationApi,
|
||||
OverviewApi,
|
||||
TeamCombinationApi,
|
||||
UidCheckApi,
|
||||
UidRankApi, WeaponCollocationApi,
|
||||
UidRankApi,
|
||||
WeaponCollocationApi,
|
||||
} from "./abyss";
|
||||
|
||||
const HutaoApi = {
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssAvatarCollocation[]>}
|
||||
*/
|
||||
async function getAvatarCollect (): Promise<TGApp.Plugins.Hutao.AbyssAvatarCollocation[]> {
|
||||
async function getAvatarCollect(): Promise<TGApp.Plugins.Hutao.AbyssAvatarCollocation[]> {
|
||||
const url = HutaoApi.Abyss.avatar.collect;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssAvatarCollocationResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssAvatarCollocationResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getAvatarCollect;
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<TGApp.Plugins.Hutao.AbyssAvatarHoldRate[]>}
|
||||
*/
|
||||
async function getAvatarHoldRate (): Promise<TGApp.Plugins.Hutao.AbyssAvatarHoldRate[]> {
|
||||
async function getAvatarHoldRate(): Promise<TGApp.Plugins.Hutao.AbyssAvatarHoldRate[]> {
|
||||
const url = HutaoApi.Abyss.avatar.holdRate;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssAvatarHoldRateResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssAvatarHoldRateResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getAvatarHoldRate;
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssAvatarUpRate[]>}
|
||||
*/
|
||||
async function getAvatarUpRate (): Promise<TGApp.Plugins.Hutao.AbyssAvatarUpRate[]> {
|
||||
async function getAvatarUpRate(): Promise<TGApp.Plugins.Hutao.AbyssAvatarUpRate[]> {
|
||||
const url = HutaoApi.Abyss.avatar.upRate;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssAvatarUpRateResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssAvatarUpRateResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getAvatarUpRate;
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssAvatarUseRate[]>}
|
||||
*/
|
||||
async function getAvatarUseRate (): Promise<TGApp.Plugins.Hutao.AbyssAvatarUseRate[]> {
|
||||
async function getAvatarUseRate(): Promise<TGApp.Plugins.Hutao.AbyssAvatarUseRate[]> {
|
||||
const url = HutaoApi.Abyss.avatar.useRate;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssAvatarUseRateResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssAvatarUseRateResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getAvatarUseRate;
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssOverview>}
|
||||
*/
|
||||
async function getOverview (): Promise<TGApp.Plugins.Hutao.AbyssOverview> {
|
||||
async function getOverview(): Promise<TGApp.Plugins.Hutao.AbyssOverview> {
|
||||
const url = HutaoApi.Abyss.overview;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssOverviewResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssOverviewResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getOverview;
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssTeamCombination[]>}
|
||||
*/
|
||||
async function getTeamCollect (): Promise<TGApp.Plugins.Hutao.AbyssTeamCombination[]> {
|
||||
async function getTeamCollect(): Promise<TGApp.Plugins.Hutao.AbyssTeamCombination[]> {
|
||||
const url = HutaoApi.Abyss.team;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssTeamCombinationResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssTeamCombinationResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getTeamCollect;
|
||||
|
||||
@@ -17,13 +17,15 @@ import HutaoApi from "../api";
|
||||
* @param {string} uid
|
||||
* @return {Promise<boolean>}
|
||||
*/
|
||||
export async function checkUid (uid: string): Promise<boolean> {
|
||||
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, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssRecordExistResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,11 +35,13 @@ export async function checkUid (uid: string): Promise<boolean> {
|
||||
* @param {string} uid
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssRecordRank>}
|
||||
*/
|
||||
export async function getUserData (uid: string): Promise<TGApp.Plugins.Hutao.AbyssRecordRank> {
|
||||
export async function getUserData(uid: string): Promise<TGApp.Plugins.Hutao.AbyssRecordRank> {
|
||||
const url = HutaoApi.Abyss.user.rank.replace("{uid}", uid);
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssRecordRankResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssRecordRankResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,13 +15,15 @@ import HutaoApi from "../api";
|
||||
* @since Alpha v0.2.0
|
||||
* @return {Promise<TGApp.Plugins.Hutao.AbyssWeaponCollocation[]>}
|
||||
*/
|
||||
async function getWeaponCollect (): Promise<TGApp.Plugins.Hutao.AbyssWeaponCollocation[]> {
|
||||
async function getWeaponCollect(): Promise<TGApp.Plugins.Hutao.AbyssWeaponCollocation[]> {
|
||||
const url = HutaoApi.Abyss.weapon;
|
||||
return await http.fetch<TGApp.Plugins.Hutao.AbyssWeaponCollocationResponse>(url, {
|
||||
method: "GET",
|
||||
}).then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
return await http
|
||||
.fetch<TGApp.Plugins.Hutao.AbyssWeaponCollocationResponse>(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
export default getWeaponCollect;
|
||||
|
||||
@@ -17,12 +17,14 @@ import HutaoApi from "../api";
|
||||
* @param {TGApp.Plugins.Hutao.AbyssRecordUpload} data 用户数据
|
||||
* @returns {Promise<unknown>} 上传结果
|
||||
*/
|
||||
async function uploadData (data: TGApp.Plugins.Hutao.AbyssRecordUpload): Promise<unknown> {
|
||||
async function uploadData(data: TGApp.Plugins.Hutao.AbyssRecordUpload): Promise<unknown> {
|
||||
const url = HutaoApi.Abyss.upload;
|
||||
return await http.fetch(url, {
|
||||
method: "POST",
|
||||
body: http.Body.json(data),
|
||||
}).then(res => res.data);
|
||||
return await http
|
||||
.fetch(url, {
|
||||
method: "POST",
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
||||
export default uploadData;
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
* @returns {MysResponse}
|
||||
*/
|
||||
export interface MysResponse {
|
||||
retcode: number
|
||||
message: string
|
||||
data: any
|
||||
retcode: number;
|
||||
message: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,8 +30,8 @@ export interface MysResponse {
|
||||
*/
|
||||
export interface MysObcResponse extends MysResponse {
|
||||
data: {
|
||||
list: MysObc[]
|
||||
}
|
||||
list: MysObc[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,13 +48,13 @@ export interface MysObcResponse extends MysResponse {
|
||||
* @returns {MysObc}
|
||||
*/
|
||||
export interface MysObc {
|
||||
id: number
|
||||
name: string
|
||||
parent_id: number
|
||||
depth: number
|
||||
ch_ext: string
|
||||
children: MysObc[]
|
||||
list: unknown[]
|
||||
id: number;
|
||||
name: string;
|
||||
parent_id: number;
|
||||
depth: number;
|
||||
ch_ext: string;
|
||||
children: MysObc[];
|
||||
list: unknown[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,8 @@ import { type MysResponse } from "./base";
|
||||
*/
|
||||
export interface GachaResponse extends MysResponse {
|
||||
data: {
|
||||
list: GachaData[]
|
||||
}
|
||||
list: GachaData[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,16 +39,16 @@ export interface GachaResponse extends MysResponse {
|
||||
* @returns {GachaData}
|
||||
*/
|
||||
export interface GachaData {
|
||||
id: string
|
||||
title: string
|
||||
activity_url: string
|
||||
content_before_act: string
|
||||
pool: GachaPool[]
|
||||
voice_icon: string
|
||||
voice_url: string
|
||||
voice_status: string
|
||||
start_time: string
|
||||
end_time: string
|
||||
id: string;
|
||||
title: string;
|
||||
activity_url: string;
|
||||
content_before_act: string;
|
||||
pool: GachaPool[];
|
||||
voice_icon: string;
|
||||
voice_url: string;
|
||||
voice_status: string;
|
||||
start_time: string;
|
||||
end_time: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,8 +60,8 @@ export interface GachaData {
|
||||
* @returns {GachaPool}
|
||||
*/
|
||||
export interface GachaPool {
|
||||
icon: string
|
||||
url: string
|
||||
icon: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,16 +82,16 @@ export interface GachaPool {
|
||||
* @returns {GachaCard}
|
||||
*/
|
||||
export interface GachaCard {
|
||||
title: string
|
||||
subtitle: string
|
||||
cover: string
|
||||
post_id: number
|
||||
characters: GachaPool[]
|
||||
voice: GachaPool
|
||||
title: string;
|
||||
subtitle: string;
|
||||
cover: string;
|
||||
post_id: number;
|
||||
characters: GachaPool[];
|
||||
voice: GachaPool;
|
||||
time: {
|
||||
start: string
|
||||
start_stamp: number
|
||||
end: string
|
||||
end_stamp: number
|
||||
}
|
||||
start: string;
|
||||
start_stamp: number;
|
||||
end: string;
|
||||
end_stamp: number;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ import { type UserInfoPost } from "./user";
|
||||
*/
|
||||
export interface LotteryResponse extends MysResponse {
|
||||
data: {
|
||||
show_lottery: LotteryData
|
||||
}
|
||||
show_lottery: LotteryData;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,21 +44,21 @@ export interface LotteryResponse extends MysResponse {
|
||||
* @returns {LotteryData}
|
||||
*/
|
||||
export interface LotteryData {
|
||||
id: string
|
||||
creator: UserInfoPost
|
||||
draw_time: string
|
||||
participant_way: string
|
||||
is_expect_unfocus_user: boolean
|
||||
is_expect_non_real_name_user: boolean
|
||||
user_rewards: LotteryReward[]
|
||||
status: string
|
||||
is_blocked: boolean
|
||||
user_status: string
|
||||
is_upload_address: boolean
|
||||
lottery_entity_summary: string
|
||||
entity_id: string
|
||||
entity_type: string
|
||||
now_time: string
|
||||
id: string;
|
||||
creator: UserInfoPost;
|
||||
draw_time: string;
|
||||
participant_way: string;
|
||||
is_expect_unfocus_user: boolean;
|
||||
is_expect_non_real_name_user: boolean;
|
||||
user_rewards: LotteryReward[];
|
||||
status: string;
|
||||
is_blocked: boolean;
|
||||
user_status: string;
|
||||
is_upload_address: boolean;
|
||||
lottery_entity_summary: string;
|
||||
entity_id: string;
|
||||
entity_type: string;
|
||||
now_time: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,12 +74,12 @@ export interface LotteryData {
|
||||
* @returns {LotteryReward}
|
||||
*/
|
||||
export interface LotteryReward {
|
||||
reward_name: string
|
||||
winner_number: number
|
||||
scheduled_winner_number: number
|
||||
is_send_by_post: boolean
|
||||
users: UserInfoPost[]
|
||||
id: string
|
||||
reward_name: string;
|
||||
winner_number: number;
|
||||
scheduled_winner_number: number;
|
||||
is_send_by_post: boolean;
|
||||
users: UserInfoPost[];
|
||||
id: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,12 +95,12 @@ export interface LotteryReward {
|
||||
* @returns {LotteryCard}
|
||||
*/
|
||||
export interface LotteryCard {
|
||||
id: string
|
||||
participantWay: string
|
||||
status: string
|
||||
creator: UserInfoPost
|
||||
drawTime: string
|
||||
rewards: LotteryRewardCard[]
|
||||
id: string;
|
||||
participantWay: string;
|
||||
status: string;
|
||||
creator: UserInfoPost;
|
||||
drawTime: string;
|
||||
rewards: LotteryRewardCard[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,8 @@ export interface LotteryCard {
|
||||
* @returns {LotteryRewardCard}
|
||||
*/
|
||||
export interface LotteryRewardCard {
|
||||
rewardName: string
|
||||
winnerNumber: number
|
||||
scheduledWinnerNumber: number
|
||||
users: UserInfoPost[]
|
||||
rewardName: string;
|
||||
winnerNumber: number;
|
||||
scheduledWinnerNumber: number;
|
||||
users: UserInfoPost[];
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { type ImageData, type HelpSys } from "./utils";
|
||||
* @returns {NewsResponse}
|
||||
*/
|
||||
export interface NewsResponse extends MysResponse {
|
||||
data: NewsData
|
||||
data: NewsData;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,9 +32,9 @@ export interface NewsResponse extends MysResponse {
|
||||
* @returns {NewsData}
|
||||
*/
|
||||
export interface NewsData {
|
||||
last_id: number
|
||||
is_last: boolean
|
||||
list: NewsItem[]
|
||||
last_id: number;
|
||||
is_last: boolean;
|
||||
list: NewsItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,27 +65,27 @@ export interface NewsData {
|
||||
* @returns {NewsItem}
|
||||
*/
|
||||
export interface NewsItem {
|
||||
post: Post
|
||||
forum: Forum
|
||||
topics: Topic[]
|
||||
user: UserInfoPost
|
||||
self_operation: SelfOperation
|
||||
stat: PostStat
|
||||
help_sys: HelpSys
|
||||
cover: ImageData
|
||||
image_list: ImageData[]
|
||||
is_official_master: boolean
|
||||
is_user_master: boolean
|
||||
hot_reply_exist: boolean
|
||||
vote_count: number
|
||||
last_modify_time: number
|
||||
recommend_type: string
|
||||
collection: unknown
|
||||
vod_list: unknown[]
|
||||
is_block_on: boolean
|
||||
forum_rank_info: unknown
|
||||
link_card_list: unknown[]
|
||||
news_meta: NewsMeta
|
||||
post: Post;
|
||||
forum: Forum;
|
||||
topics: Topic[];
|
||||
user: UserInfoPost;
|
||||
self_operation: SelfOperation;
|
||||
stat: PostStat;
|
||||
help_sys: HelpSys;
|
||||
cover: ImageData;
|
||||
image_list: ImageData[];
|
||||
is_official_master: boolean;
|
||||
is_user_master: boolean;
|
||||
hot_reply_exist: boolean;
|
||||
vote_count: number;
|
||||
last_modify_time: number;
|
||||
recommend_type: string;
|
||||
collection: unknown;
|
||||
vod_list: unknown[];
|
||||
is_block_on: boolean;
|
||||
forum_rank_info: unknown;
|
||||
link_card_list: unknown[];
|
||||
news_meta: NewsMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,9 +98,9 @@ export interface NewsItem {
|
||||
* @returns {NewsMeta}
|
||||
*/
|
||||
export interface NewsMeta {
|
||||
activity_status: number
|
||||
start_at_sec: string
|
||||
end_at_sec: string
|
||||
activity_status: number;
|
||||
start_at_sec: string;
|
||||
end_at_sec: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,11 +115,11 @@ export interface NewsMeta {
|
||||
* @returns {NewsCard}
|
||||
*/
|
||||
export interface NewsCard {
|
||||
title: string
|
||||
cover: string
|
||||
post_id: number
|
||||
subtitle: string
|
||||
status?: ActivityStatus
|
||||
title: string;
|
||||
cover: string;
|
||||
post_id: number;
|
||||
subtitle: string;
|
||||
status?: ActivityStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,6 +130,6 @@ export interface NewsCard {
|
||||
* @returns {ActivityStatus}
|
||||
*/
|
||||
export interface ActivityStatus {
|
||||
status: string
|
||||
colorCss: string
|
||||
status: string;
|
||||
colorCss: string;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import { type MysObcResponse, type MysObc } from "./base";
|
||||
*/
|
||||
export interface PositionResponse extends MysObcResponse {
|
||||
data: {
|
||||
list: PositionObc[]
|
||||
}
|
||||
list: PositionObc[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ export interface PositionResponse extends MysObcResponse {
|
||||
* @returns {PositionObc}
|
||||
*/
|
||||
export interface PositionObc extends MysObc {
|
||||
list: PositionData[]
|
||||
list: PositionData[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,19 +53,19 @@ export interface PositionObc extends MysObc {
|
||||
* @returns {PositionData}
|
||||
*/
|
||||
export interface PositionData {
|
||||
recommend_id: number
|
||||
content_id: number
|
||||
title: string
|
||||
ext: string
|
||||
type: number
|
||||
url: string
|
||||
icon: string
|
||||
abstract: string
|
||||
article_user_name: string
|
||||
avatar_url: string
|
||||
article_time: string
|
||||
create_time: string
|
||||
end_time: string
|
||||
recommend_id: number;
|
||||
content_id: number;
|
||||
title: string;
|
||||
ext: string;
|
||||
type: number;
|
||||
url: string;
|
||||
icon: string;
|
||||
abstract: string;
|
||||
article_user_name: string;
|
||||
avatar_url: string;
|
||||
article_time: string;
|
||||
create_time: string;
|
||||
end_time: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,14 +84,14 @@ export interface PositionData {
|
||||
* @returns {PositionCard}
|
||||
*/
|
||||
export interface PositionCard {
|
||||
title: string
|
||||
post_id: number
|
||||
icon: string
|
||||
abstract: string
|
||||
title: string;
|
||||
post_id: number;
|
||||
icon: string;
|
||||
abstract: string;
|
||||
time: {
|
||||
start: string
|
||||
start_stamp: number
|
||||
end: string
|
||||
end_stamp: number
|
||||
}
|
||||
start: string;
|
||||
start_stamp: number;
|
||||
end: string;
|
||||
end_stamp: number;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ import { type ImageData, type HelpSys } from "./utils";
|
||||
*/
|
||||
export interface PostResponse extends MysResponse {
|
||||
data: {
|
||||
post: PostData
|
||||
}
|
||||
post: PostData;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,27 +52,27 @@ export interface PostResponse extends MysResponse {
|
||||
* @returns {PostData}
|
||||
*/
|
||||
export interface PostData {
|
||||
post: Post
|
||||
forum: Forum
|
||||
topics: Topic[]
|
||||
user: UserInfoPost
|
||||
self_operation: SelfOperation
|
||||
stat: PostStat
|
||||
help_sys: HelpSys | null
|
||||
cover: ImageData | null
|
||||
image_list: ImageData[]
|
||||
is_official_master: boolean
|
||||
is_user_master: boolean
|
||||
hot_reply_exist: boolean
|
||||
vot_count: number
|
||||
last_modify_time: number
|
||||
recommend_type: string
|
||||
collection: unknown | null
|
||||
vod_list: unknown[]
|
||||
is_block_on: boolean
|
||||
forum_rank_info: unknown | null
|
||||
link_card_list: unknown[]
|
||||
news_meta: NewsMeta | null
|
||||
post: Post;
|
||||
forum: Forum;
|
||||
topics: Topic[];
|
||||
user: UserInfoPost;
|
||||
self_operation: SelfOperation;
|
||||
stat: PostStat;
|
||||
help_sys: HelpSys | null;
|
||||
cover: ImageData | null;
|
||||
image_list: ImageData[];
|
||||
is_official_master: boolean;
|
||||
is_user_master: boolean;
|
||||
hot_reply_exist: boolean;
|
||||
vot_count: number;
|
||||
last_modify_time: number;
|
||||
recommend_type: string;
|
||||
collection: unknown | null;
|
||||
vod_list: unknown[];
|
||||
is_block_on: boolean;
|
||||
forum_rank_info: unknown | null;
|
||||
link_card_list: unknown[];
|
||||
news_meta: NewsMeta | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,46 +121,46 @@ export interface PostData {
|
||||
* @returns {Post}
|
||||
*/
|
||||
export interface Post {
|
||||
game_id: number
|
||||
post_id: string
|
||||
f_forum_id: number
|
||||
uid: string
|
||||
subject: string
|
||||
content: string
|
||||
cover: string
|
||||
view_type: number
|
||||
created_at: number
|
||||
images: string[]
|
||||
game_id: number;
|
||||
post_id: string;
|
||||
f_forum_id: number;
|
||||
uid: string;
|
||||
subject: string;
|
||||
content: string;
|
||||
cover: string;
|
||||
view_type: number;
|
||||
created_at: number;
|
||||
images: string[];
|
||||
post_status: {
|
||||
is_top: boolean
|
||||
is_good: boolean
|
||||
is_official: boolean
|
||||
}
|
||||
topic_ids: number[]
|
||||
view_status: number
|
||||
max_floor: number
|
||||
is_original: number
|
||||
republish_authorization: number
|
||||
reply_time: string
|
||||
is_deleted: number
|
||||
is_interactive: boolean
|
||||
structured_content: string
|
||||
structured_content_rows: string[]
|
||||
review_id: number
|
||||
is_profit: boolean
|
||||
is_in_profit: boolean
|
||||
updated_at: number
|
||||
deleted_at: number
|
||||
pre_pub_status: number
|
||||
cate_id: number
|
||||
profit_post_status: number
|
||||
audit_status: number
|
||||
meta_content: string
|
||||
is_missing: boolean
|
||||
block_reply_img: number
|
||||
is_showing_missing: boolean
|
||||
block_latest_reply_time: number
|
||||
selected_comment: number
|
||||
is_top: boolean;
|
||||
is_good: boolean;
|
||||
is_official: boolean;
|
||||
};
|
||||
topic_ids: number[];
|
||||
view_status: number;
|
||||
max_floor: number;
|
||||
is_original: number;
|
||||
republish_authorization: number;
|
||||
reply_time: string;
|
||||
is_deleted: number;
|
||||
is_interactive: boolean;
|
||||
structured_content: string;
|
||||
structured_content_rows: string[];
|
||||
review_id: number;
|
||||
is_profit: boolean;
|
||||
is_in_profit: boolean;
|
||||
updated_at: number;
|
||||
deleted_at: number;
|
||||
pre_pub_status: number;
|
||||
cate_id: number;
|
||||
profit_post_status: number;
|
||||
audit_status: number;
|
||||
meta_content: string;
|
||||
is_missing: boolean;
|
||||
block_reply_img: number;
|
||||
is_showing_missing: boolean;
|
||||
block_latest_reply_time: number;
|
||||
selected_comment: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,11 +175,11 @@ export interface Post {
|
||||
* @returns {Forum}
|
||||
*/
|
||||
export interface Forum {
|
||||
id: number
|
||||
name: string
|
||||
icon: string
|
||||
game_id: number
|
||||
forum_cate: unknown | null
|
||||
id: number;
|
||||
name: string;
|
||||
icon: string;
|
||||
game_id: number;
|
||||
forum_cate: unknown | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,14 +197,14 @@ export interface Forum {
|
||||
* @returns {Topic}
|
||||
*/
|
||||
export interface Topic {
|
||||
id: number
|
||||
name: string
|
||||
cover: string
|
||||
is_top: boolean
|
||||
is_good: boolean
|
||||
is_interactive: boolean
|
||||
game_id: number
|
||||
content_type: number
|
||||
id: number;
|
||||
name: string;
|
||||
cover: string;
|
||||
is_top: boolean;
|
||||
is_good: boolean;
|
||||
is_interactive: boolean;
|
||||
game_id: number;
|
||||
content_type: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,11 +219,11 @@ export interface Topic {
|
||||
* @returns {PostStat}
|
||||
*/
|
||||
export interface PostStat {
|
||||
view_num: number
|
||||
reply_num: number
|
||||
like_num: number
|
||||
bookmark_num: number
|
||||
forward_num: number
|
||||
view_num: number;
|
||||
reply_num: number;
|
||||
like_num: number;
|
||||
bookmark_num: number;
|
||||
forward_num: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,8 +236,8 @@ export interface PostStat {
|
||||
* @returns {PostContent}
|
||||
*/
|
||||
export interface PostContent {
|
||||
describe: string
|
||||
imgs?: string[]
|
||||
describe: string;
|
||||
imgs?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,38 +271,37 @@ export interface PostContent {
|
||||
* @returns {PostStructuredContent}
|
||||
*/
|
||||
export interface PostStructuredContent {
|
||||
|
||||
insert:
|
||||
| {
|
||||
image?: string
|
||||
video?: string
|
||||
vod?: PostStructuredContentVod
|
||||
backup_text?: string
|
||||
lottery?: {
|
||||
id: string
|
||||
toast: string
|
||||
}
|
||||
fold?: {
|
||||
title: string
|
||||
content: string
|
||||
}
|
||||
link_card?: PostStructuredContentLinkCard
|
||||
divider?: string
|
||||
mention?: {
|
||||
uid: string
|
||||
nickname: string
|
||||
}
|
||||
}
|
||||
| string
|
||||
| {
|
||||
image?: string;
|
||||
video?: string;
|
||||
vod?: PostStructuredContentVod;
|
||||
backup_text?: string;
|
||||
lottery?: {
|
||||
id: string;
|
||||
toast: string;
|
||||
};
|
||||
fold?: {
|
||||
title: string;
|
||||
content: string;
|
||||
};
|
||||
link_card?: PostStructuredContentLinkCard;
|
||||
divider?: string;
|
||||
mention?: {
|
||||
uid: string;
|
||||
nickname: string;
|
||||
};
|
||||
}
|
||||
| string;
|
||||
attributes?: {
|
||||
height?: number
|
||||
width?: number
|
||||
size?: number
|
||||
ext?: string
|
||||
bold?: boolean
|
||||
color?: string
|
||||
link?: string
|
||||
}
|
||||
height?: number;
|
||||
width?: number;
|
||||
size?: number;
|
||||
ext?: string;
|
||||
bold?: boolean;
|
||||
color?: string;
|
||||
link?: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,22 +326,22 @@ export interface PostStructuredContent {
|
||||
* @returns {PostStructuredContentVod}
|
||||
*/
|
||||
export interface PostStructuredContentVod {
|
||||
id: number
|
||||
duration: number
|
||||
cover: string
|
||||
id: number;
|
||||
duration: number;
|
||||
cover: string;
|
||||
resolutions: Array<{
|
||||
url: string
|
||||
definition: string
|
||||
height: number
|
||||
width: number
|
||||
bitrate: number
|
||||
size: number
|
||||
format: string
|
||||
label: string
|
||||
}>
|
||||
view_num: number
|
||||
transcoding_status: number
|
||||
review_status: number
|
||||
url: string;
|
||||
definition: string;
|
||||
height: number;
|
||||
width: number;
|
||||
bitrate: number;
|
||||
size: number;
|
||||
format: string;
|
||||
label: string;
|
||||
}>;
|
||||
view_num: number;
|
||||
transcoding_status: number;
|
||||
review_status: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,15 +362,15 @@ export interface PostStructuredContentVod {
|
||||
* @returns {PostStructuredContentLinkCard}
|
||||
*/
|
||||
export interface PostStructuredContentLinkCard {
|
||||
link_type: number
|
||||
origin_url: string
|
||||
landing_url: string
|
||||
cover: string
|
||||
title: string
|
||||
card_id: string
|
||||
card_status: number
|
||||
market_price: string
|
||||
price: string
|
||||
button_text: string
|
||||
landing_url_type: number
|
||||
link_type: number;
|
||||
origin_url: string;
|
||||
landing_url: string;
|
||||
cover: string;
|
||||
title: string;
|
||||
card_id: string;
|
||||
card_status: number;
|
||||
market_price: string;
|
||||
price: string;
|
||||
button_text: string;
|
||||
landing_url_type: number;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { type MysResponse } from "./base";
|
||||
* @returns {UserResponse}
|
||||
*/
|
||||
export interface UserResponse extends MysResponse {
|
||||
data: UserInfoFull
|
||||
data: UserInfoFull;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,23 +41,23 @@ export interface UserResponse extends MysResponse {
|
||||
* @returns {UserInfoFull}
|
||||
*/
|
||||
export interface UserInfoFull {
|
||||
user_info: UserInfo
|
||||
follow_relation: unknown
|
||||
auth_relations: unknown[]
|
||||
is_in_blacklist: boolean
|
||||
is_has_collection: boolean
|
||||
is_creator: boolean
|
||||
user_info: UserInfo;
|
||||
follow_relation: unknown;
|
||||
auth_relations: unknown[];
|
||||
is_in_blacklist: boolean;
|
||||
is_has_collection: boolean;
|
||||
is_creator: boolean;
|
||||
custom_service: {
|
||||
is_customer_service_staff: boolean
|
||||
game_id: number
|
||||
}
|
||||
is_customer_service_staff: boolean;
|
||||
game_id: number;
|
||||
};
|
||||
audit_info: {
|
||||
is_nickname_in_audit: boolean
|
||||
nickname: string
|
||||
is_introduce_in_audit: boolean
|
||||
introduce: string
|
||||
nickname_status: number
|
||||
}
|
||||
is_nickname_in_audit: boolean;
|
||||
nickname: string;
|
||||
is_introduce_in_audit: boolean;
|
||||
introduce: string;
|
||||
nickname_status: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,21 +82,21 @@ export interface UserInfoFull {
|
||||
* @returns {UserInfo}
|
||||
*/
|
||||
export interface UserInfo {
|
||||
uid: string
|
||||
nickname: string
|
||||
introduce: string
|
||||
avatar: string
|
||||
gender: number
|
||||
certification: UserCertification
|
||||
level_exps: UserLevelExp[]
|
||||
archive: UserArchive
|
||||
community_info: UserCommunityInfo
|
||||
avatar_url: string
|
||||
certifications: UserCertification[]
|
||||
level_exp: UserLevelExp
|
||||
pendant: string
|
||||
is_logoff: boolean
|
||||
ip_region: string
|
||||
uid: string;
|
||||
nickname: string;
|
||||
introduce: string;
|
||||
avatar: string;
|
||||
gender: number;
|
||||
certification: UserCertification;
|
||||
level_exps: UserLevelExp[];
|
||||
archive: UserArchive;
|
||||
community_info: UserCommunityInfo;
|
||||
avatar_url: string;
|
||||
certifications: UserCertification[];
|
||||
level_exp: UserLevelExp;
|
||||
pendant: string;
|
||||
is_logoff: boolean;
|
||||
ip_region: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +108,8 @@ export interface UserInfo {
|
||||
* @returns {UserCertification}
|
||||
*/
|
||||
export interface UserCertification {
|
||||
type: number
|
||||
label: string
|
||||
type: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,9 +123,9 @@ export interface UserCertification {
|
||||
* @returns {UserLevelExp}
|
||||
*/
|
||||
export interface UserLevelExp {
|
||||
level: number
|
||||
exp: number
|
||||
game_id: number
|
||||
level: number;
|
||||
exp: number;
|
||||
game_id: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,15 +144,15 @@ export interface UserLevelExp {
|
||||
* @returns {UserArchive}
|
||||
*/
|
||||
export interface UserArchive {
|
||||
like_num: string
|
||||
post_num: string
|
||||
replypost_num: string
|
||||
follow_cnt: string
|
||||
followed_cnt: string
|
||||
topic_cnt: string
|
||||
new_follower_num: string
|
||||
good_post_num: string
|
||||
follow_collection_cnt: string
|
||||
like_num: string;
|
||||
post_num: string;
|
||||
replypost_num: string;
|
||||
follow_cnt: string;
|
||||
followed_cnt: string;
|
||||
topic_cnt: string;
|
||||
new_follower_num: string;
|
||||
good_post_num: string;
|
||||
follow_collection_cnt: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,36 +189,36 @@ export interface UserArchive {
|
||||
* @returns {UserCommunityInfo}
|
||||
*/
|
||||
export interface UserCommunityInfo {
|
||||
is_realname: boolean
|
||||
agree_status: boolean
|
||||
silent_end_time: number
|
||||
forbid_end_time: number
|
||||
info_upd_time: number
|
||||
is_realname: boolean;
|
||||
agree_status: boolean;
|
||||
silent_end_time: number;
|
||||
forbid_end_time: number;
|
||||
info_upd_time: number;
|
||||
privacy_invisible: {
|
||||
post: boolean
|
||||
collect: boolean
|
||||
watermark: boolean
|
||||
reply: boolean
|
||||
post_and_instant: boolean
|
||||
}
|
||||
post: boolean;
|
||||
collect: boolean;
|
||||
watermark: boolean;
|
||||
reply: boolean;
|
||||
post_and_instant: boolean;
|
||||
};
|
||||
notify_disable: {
|
||||
reply: boolean
|
||||
upvote: boolean
|
||||
follow: boolean
|
||||
system: boolean
|
||||
chat: boolean
|
||||
}
|
||||
has_initialized: boolean
|
||||
reply: boolean;
|
||||
upvote: boolean;
|
||||
follow: boolean;
|
||||
system: boolean;
|
||||
chat: boolean;
|
||||
};
|
||||
has_initialized: boolean;
|
||||
user_func_status: {
|
||||
enable_history_view: boolean
|
||||
enable_recommend: boolean
|
||||
enable_mention: boolean
|
||||
user_center_view: number
|
||||
}
|
||||
forum_silent_info: unknown[]
|
||||
last_login_ip: string
|
||||
last_login_time: number
|
||||
created_at: number
|
||||
enable_history_view: boolean;
|
||||
enable_recommend: boolean;
|
||||
enable_mention: boolean;
|
||||
user_center_view: number;
|
||||
};
|
||||
forum_silent_info: unknown[];
|
||||
last_login_ip: string;
|
||||
last_login_time: number;
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,20 +241,20 @@ export interface UserCommunityInfo {
|
||||
* @returns {UserInfoPost}
|
||||
*/
|
||||
export interface UserInfoPost {
|
||||
uid: string
|
||||
nickname: string
|
||||
introduce: string
|
||||
avatar: string
|
||||
gender: number
|
||||
certification: UserCertification
|
||||
uid: string;
|
||||
nickname: string;
|
||||
introduce: string;
|
||||
avatar: string;
|
||||
gender: number;
|
||||
certification: UserCertification;
|
||||
level_exp: {
|
||||
level: number
|
||||
exp: number
|
||||
}
|
||||
is_following: boolean
|
||||
is_follower: boolean
|
||||
avatar_url: string
|
||||
pendant: string
|
||||
level: number;
|
||||
exp: number;
|
||||
};
|
||||
is_following: boolean;
|
||||
is_follower: boolean;
|
||||
avatar_url: string;
|
||||
pendant: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,6 +266,6 @@ export interface UserInfoPost {
|
||||
* @returns {SelfOperation}
|
||||
*/
|
||||
export interface SelfOperation {
|
||||
attitude: number
|
||||
is_collected: boolean
|
||||
attitude: number;
|
||||
is_collected: boolean;
|
||||
}
|
||||
|
||||
@@ -41,23 +41,23 @@ export const OBC_CONTENT_API =
|
||||
* @returns {ImageData}
|
||||
*/
|
||||
export interface ImageData {
|
||||
url: string
|
||||
height: number
|
||||
width: number
|
||||
format: string
|
||||
size: string
|
||||
url: string;
|
||||
height: number;
|
||||
width: number;
|
||||
format: string;
|
||||
size: string;
|
||||
crop: {
|
||||
x: number
|
||||
y: number
|
||||
w: number
|
||||
h: number
|
||||
url: string
|
||||
} | null
|
||||
is_user_set_cover: boolean
|
||||
image_id: string
|
||||
entity_type: string
|
||||
entity_id: string
|
||||
is_deleted: boolean
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
url: string;
|
||||
} | null;
|
||||
is_user_set_cover: boolean;
|
||||
image_id: string;
|
||||
entity_type: string;
|
||||
entity_id: string;
|
||||
is_deleted: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ export interface ImageData {
|
||||
* @returns {HelpSys}
|
||||
*/
|
||||
export interface HelpSys {
|
||||
top_up: unknown | null
|
||||
top_n: unknown[]
|
||||
answer_num: number
|
||||
top_up: unknown | null;
|
||||
top_n: unknown[];
|
||||
answer_num: number;
|
||||
}
|
||||
|
||||
@@ -9,21 +9,22 @@ import { http } from "@tauri-apps/api";
|
||||
import { type GachaResponse, type GachaData } from "../interface/gacha";
|
||||
|
||||
// 卡池 API
|
||||
const GACHA_POOL_API = "https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc";
|
||||
const GACHA_POOL_API =
|
||||
"https://api-takumi.mihoyo.com/common/blackboard/ys_obc/v1/gacha_pool?app_sn=ys_obc";
|
||||
|
||||
/**
|
||||
* @description 获取卡池信息
|
||||
* @since Alpha
|
||||
* @return {Promise<GachaData[]>}
|
||||
*/
|
||||
export async function getGachaData (): Promise<GachaData[]> {
|
||||
export async function getGachaData(): Promise<GachaData[]> {
|
||||
return await http
|
||||
.fetch<GachaResponse>(GACHA_POOL_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
|
||||
@@ -9,7 +9,8 @@ import { http } from "@tauri-apps/api";
|
||||
import { type LotteryResponse, type LotteryData } from "../interface/lottery";
|
||||
|
||||
// 抽奖 API
|
||||
const LOTTERY_API = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?gids=2&id={lottery_id}";
|
||||
const LOTTERY_API =
|
||||
"https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?gids=2&id={lottery_id}";
|
||||
|
||||
/**
|
||||
* @description 获取抽奖信息
|
||||
@@ -17,14 +18,14 @@ const LOTTERY_API = "https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show
|
||||
* @param {string} lotteryId 抽奖 ID
|
||||
* @return {Promise<LotteryData>}
|
||||
*/
|
||||
export async function getLotteryData (lotteryId: string): Promise<LotteryData> {
|
||||
export async function getLotteryData(lotteryId: string): Promise<LotteryData> {
|
||||
return await http
|
||||
.fetch<LotteryResponse>(LOTTERY_API.replace("{lottery_id}", lotteryId), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.show_lottery;
|
||||
});
|
||||
|
||||
@@ -37,7 +37,11 @@ enum NewsType {
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNoticeList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
export async function getNoticeList(
|
||||
gid: string = "2",
|
||||
pageSize: number = 20,
|
||||
lastId: number = 0,
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", pageSize.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NOTICE)
|
||||
@@ -53,7 +57,11 @@ export async function getNoticeList (gid: string = "2", pageSize: number = 20, l
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getActivityList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
export async function getActivityList(
|
||||
gid: string = "2",
|
||||
pageSize: number = 20,
|
||||
lastId: number = 0,
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", pageSize.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.ACTIVITY)
|
||||
@@ -69,7 +77,11 @@ export async function getActivityList (gid: string = "2", pageSize: number = 20,
|
||||
* @param {number} lastId 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNewsList (gid: string = "2", pageSize: number = 20, lastId: number = 0): Promise<NewsData> {
|
||||
export async function getNewsList(
|
||||
gid: string = "2",
|
||||
pageSize: number = 20,
|
||||
lastId: number = 0,
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", pageSize.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NEWS)
|
||||
|
||||
@@ -10,21 +10,22 @@ import { type PositionResponse, type PositionData } from "../interface/position"
|
||||
import { dfs } from "../utils/position";
|
||||
|
||||
// 热点追踪 API
|
||||
const POSITION_API = "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc";
|
||||
const POSITION_API =
|
||||
"https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/home/position?app_sn=ys_obc";
|
||||
|
||||
/**
|
||||
* @description 获取热点追踪信息
|
||||
* @since Alpha v0.1.1
|
||||
* @return {Promise<PositionData[]>}
|
||||
*/
|
||||
export async function getPositionData (): Promise<PositionData[]> {
|
||||
export async function getPositionData(): Promise<PositionData[]> {
|
||||
const res = await http
|
||||
.fetch<PositionResponse>(POSITION_API, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.list;
|
||||
});
|
||||
|
||||
@@ -18,15 +18,15 @@ const POST_REFERER = "https://bbs.mihoyo.com/";
|
||||
* @param {number} postId 帖子 ID
|
||||
* @return {Promise<PostData>}
|
||||
*/
|
||||
export async function getPostData (postId: number): Promise<PostData> {
|
||||
export async function getPostData(postId: number): Promise<PostData> {
|
||||
return await http
|
||||
.fetch<PostResponse>(POST_API.replace("{post_id}", postId.toString()), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Referer: POST_REFERER,
|
||||
},
|
||||
})
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Referer: POST_REFERER,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
return res.data.data.post;
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ import { type GachaCard, type GachaData } from "../interface/gacha";
|
||||
* @param {Map<string>} poolCover 卡池封面
|
||||
* @returns {Promise<GachaCard[]>}
|
||||
*/
|
||||
export async function getGachaCard (
|
||||
export async function getGachaCard(
|
||||
gachaData: GachaData[],
|
||||
poolCover: Record<number, string> | undefined = undefined,
|
||||
): Promise<GachaCard[]> {
|
||||
|
||||
@@ -5,7 +5,12 @@
|
||||
* @since Alpha v0.1.1
|
||||
*/
|
||||
|
||||
import { type LotteryData, type LotteryCard, type LotteryRewardCard, type LotteryReward } from "../interface/lottery";
|
||||
import {
|
||||
type LotteryData,
|
||||
type LotteryCard,
|
||||
type LotteryRewardCard,
|
||||
type LotteryReward,
|
||||
} from "../interface/lottery";
|
||||
|
||||
/**
|
||||
* @description 根据抽奖信息转为渲染用的抽奖信息
|
||||
@@ -13,7 +18,7 @@ import { type LotteryData, type LotteryCard, type LotteryRewardCard, type Lotter
|
||||
* @param {LotteryData} lotteryData 抽奖信息
|
||||
* @returns {LotteryCard}
|
||||
*/
|
||||
export function getLotteryCard (lotteryData: LotteryData): LotteryCard {
|
||||
export function getLotteryCard(lotteryData: LotteryData): LotteryCard {
|
||||
return {
|
||||
id: lotteryData.id,
|
||||
participantWay: lotteryData.participant_way,
|
||||
@@ -32,7 +37,7 @@ export function getLotteryCard (lotteryData: LotteryData): LotteryCard {
|
||||
* @param {LotteryReward} lotteryReward 抽奖奖励信息
|
||||
* @returns {LotteryRewardCard}
|
||||
*/
|
||||
export function getLotteryRewardCard (lotteryReward: LotteryReward): LotteryRewardCard {
|
||||
export function getLotteryRewardCard(lotteryReward: LotteryReward): LotteryRewardCard {
|
||||
return {
|
||||
rewardName: lotteryReward.reward_name,
|
||||
winnerNumber: lotteryReward.winner_number,
|
||||
|
||||
@@ -5,7 +5,12 @@
|
||||
* @since Alpha v0.1.2
|
||||
*/
|
||||
|
||||
import { type NewsData, type NewsItem, type NewsCard, type ActivityStatus } from "../interface/news";
|
||||
import {
|
||||
type NewsData,
|
||||
type NewsItem,
|
||||
type NewsCard,
|
||||
type ActivityStatus,
|
||||
} from "../interface/news";
|
||||
|
||||
// 默认封面图
|
||||
const defaultCover = "/source/UI/defaultCover.webp";
|
||||
@@ -44,7 +49,7 @@ const EnumStatus = {
|
||||
* @param {number} status 活动状态码
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getActivityStatus (status: number): ActivityStatus {
|
||||
export function getActivityStatus(status: number): ActivityStatus {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return EnumStatus.STARTED;
|
||||
@@ -63,7 +68,7 @@ export function getActivityStatus (status: number): ActivityStatus {
|
||||
* @param {NewsData} noticeData 公告数据
|
||||
* @returns {NewsCard[]}
|
||||
*/
|
||||
export function getNoticeCard (noticeData: NewsData): NewsCard[] {
|
||||
export function getNoticeCard(noticeData: NewsData): NewsCard[] {
|
||||
const noticeCard: NewsCard[] = [];
|
||||
noticeData.list.map((item: NewsItem) => {
|
||||
return noticeCard.push({
|
||||
@@ -82,7 +87,7 @@ export function getNoticeCard (noticeData: NewsData): NewsCard[] {
|
||||
* @param {NewsData} activityData 活动数据
|
||||
* @returns {NewsCard[]}
|
||||
*/
|
||||
export function getActivityCard (activityData: NewsData): NewsCard[] {
|
||||
export function getActivityCard(activityData: NewsData): NewsCard[] {
|
||||
const activityCard: NewsCard[] = [];
|
||||
activityData.list.map((item: NewsItem) => {
|
||||
const startTime = new Date(Number(item.news_meta.start_at_sec) * 1000).toLocaleDateString();
|
||||
@@ -105,7 +110,7 @@ export function getActivityCard (activityData: NewsData): NewsCard[] {
|
||||
* @param {NewsData} newsData 新闻数据
|
||||
* @returns {NewsCard[]}
|
||||
*/
|
||||
export function getNewsCard (newsData: NewsData): NewsCard[] {
|
||||
export function getNewsCard(newsData: NewsData): NewsCard[] {
|
||||
const newsCard: NewsCard[] = [];
|
||||
newsData.list.map((item: NewsItem) => {
|
||||
return newsCard.push({
|
||||
|
||||
@@ -12,7 +12,7 @@ import { type PostData, type PostStructuredContent } from "../interface/post";
|
||||
* @param {string} hex 16进制颜色
|
||||
* @returns {object} RGB 颜色
|
||||
*/
|
||||
function hexToRgb (hex: string): { r: number, g: number, b: number } {
|
||||
function hexToRgb(hex: string): { r: number; g: number; b: number } {
|
||||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
if (result === null) {
|
||||
throw new Error("无法解析颜色");
|
||||
@@ -31,16 +31,20 @@ function hexToRgb (hex: string): { r: number, g: number, b: number } {
|
||||
* @param {string} colorFg 前景颜色
|
||||
* @returns {boolean} 是否相近
|
||||
*/
|
||||
function isColorSimilar (colorBg: string, colorFg: string): boolean {
|
||||
function isColorSimilar(colorBg: string, colorFg: string): boolean {
|
||||
const colorBgRGB = hexToRgb(colorBg);
|
||||
const colorFgRGB = hexToRgb(colorFg);
|
||||
const colorBgL = 0.2126 * colorBgRGB.r + 0.7152 * colorBgRGB.g + 0.0722 * colorBgRGB.b;
|
||||
const colorFgL = 0.2126 * colorFgRGB.r + 0.7152 * colorFgRGB.g + 0.0722 * colorFgRGB.b;
|
||||
const colorBgLum = colorBgL / 255;
|
||||
const colorFgLum = colorFgL / 255;
|
||||
const colorBgLumFinal = colorBgLum <= 0.03928 ? colorBgLum / 12.92 : Math.pow((colorBgLum + 0.055) / 1.055, 2.4);
|
||||
const colorFgLumFinal = colorFgLum <= 0.03928 ? colorFgLum / 12.92 : Math.pow((colorFgLum + 0.055) / 1.055, 2.4);
|
||||
const contrast = (Math.max(colorBgLumFinal, colorFgLumFinal) + 0.05) / (Math.min(colorBgLumFinal, colorFgLumFinal) + 0.05);
|
||||
const colorBgLumFinal =
|
||||
colorBgLum <= 0.03928 ? colorBgLum / 12.92 : Math.pow((colorBgLum + 0.055) / 1.055, 2.4);
|
||||
const colorFgLumFinal =
|
||||
colorFgLum <= 0.03928 ? colorFgLum / 12.92 : Math.pow((colorFgLum + 0.055) / 1.055, 2.4);
|
||||
const contrast =
|
||||
(Math.max(colorBgLumFinal, colorFgLumFinal) + 0.05) /
|
||||
(Math.min(colorBgLumFinal, colorFgLumFinal) + 0.05);
|
||||
return contrast <= 2.5;
|
||||
}
|
||||
|
||||
@@ -50,7 +54,7 @@ function isColorSimilar (colorBg: string, colorFg: string): boolean {
|
||||
* @param {string} url 链接
|
||||
* @returns {boolean} 是否是米游社帖子
|
||||
*/
|
||||
export function IsMysPost (url: string): boolean {
|
||||
export function IsMysPost(url: string): boolean {
|
||||
const regBBS = /^https:\/\/bbs\.mihoyo\.com\/\w+\/article\/\d+$/;
|
||||
const regMYS = /^https:\/\/www\.miyoushe\.com\/\w+\/article\/\d+$/;
|
||||
return regBBS.test(url) || regMYS.test(url);
|
||||
@@ -62,7 +66,7 @@ export function IsMysPost (url: string): boolean {
|
||||
* @param {string} url 链接
|
||||
* @returns {string} 帖子 id
|
||||
*/
|
||||
export function getPostId (url: string): string {
|
||||
export function getPostId(url: string): string {
|
||||
const postId: string | undefined = url.split("/").pop();
|
||||
if (postId === undefined) {
|
||||
throw new Error("无法获取帖子 id");
|
||||
@@ -77,7 +81,7 @@ export function getPostId (url: string): string {
|
||||
* @param {string} content 帖子内容
|
||||
* @returns {string} 解析后的内容
|
||||
*/
|
||||
export function contentParser (content: string): string {
|
||||
export function contentParser(content: string): string {
|
||||
const data = JSON.parse(content);
|
||||
const result: PostStructuredContent[] = [];
|
||||
// 遍历 data 属性,值
|
||||
@@ -114,7 +118,7 @@ export function contentParser (content: string): string {
|
||||
* @description 为了安全考虑,不会解析所有的属性,只会解析几个常用的属性
|
||||
* @returns {string} 解析后的HTML,可作为 v-html 使用
|
||||
*/
|
||||
export function PostParser (post: PostData): string {
|
||||
export function PostParser(post: PostData): string {
|
||||
const postContent = post.post.content;
|
||||
let parserData;
|
||||
if (postContent.startsWith("<")) {
|
||||
@@ -141,22 +145,22 @@ export function PostParser (post: PostData): string {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement | HTMLSpanElement} 解析后的中转
|
||||
*/
|
||||
function ParserTransfer (data: PostStructuredContent): HTMLDivElement | HTMLSpanElement {
|
||||
function ParserTransfer(data: PostStructuredContent): HTMLDivElement | HTMLSpanElement {
|
||||
if (typeof data.insert === "string") {
|
||||
return TextParser(data);
|
||||
} else if (data.insert.image) {
|
||||
return ImageParser(data);
|
||||
} else if (data.insert.vod) {
|
||||
} else if (data.insert.vod != null) {
|
||||
return VideoParser(data);
|
||||
} else if (data.insert.video) {
|
||||
return VideoParser(data);
|
||||
} else if (data.insert.backup_text) {
|
||||
return BackupTextParser(data);
|
||||
} else if (data.insert.link_card) {
|
||||
} else if (data.insert.link_card != null) {
|
||||
return LinkCardParser(data);
|
||||
} else if (data.insert.divider) {
|
||||
return DividerParser(data);
|
||||
} else if (data.insert.mention) {
|
||||
} else if (data.insert.mention != null) {
|
||||
return MentionParser(data);
|
||||
} else {
|
||||
return UnknownParser(data);
|
||||
@@ -169,7 +173,7 @@ function ParserTransfer (data: PostStructuredContent): HTMLDivElement | HTMLSpan
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的未知数据
|
||||
*/
|
||||
function UnknownParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function UnknownParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 创建 div
|
||||
const div = document.createElement("div");
|
||||
div.classList.add("mys-post-unknown");
|
||||
@@ -188,7 +192,7 @@ function UnknownParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLSpanElement} 解析后的文本
|
||||
*/
|
||||
function TextParser (data: PostStructuredContent): HTMLSpanElement {
|
||||
function TextParser(data: PostStructuredContent): HTMLSpanElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert !== "string") {
|
||||
throw new Error("data.insert is not a string");
|
||||
@@ -196,7 +200,7 @@ function TextParser (data: PostStructuredContent): HTMLSpanElement {
|
||||
// 创建文本
|
||||
const text = document.createElement("span");
|
||||
// 设置文本属性
|
||||
if (data.attributes) {
|
||||
if (data.attributes != null) {
|
||||
if (data.attributes.bold) text.style.fontWeight = "bold";
|
||||
if (data.attributes.color) {
|
||||
let colorGet = data.attributes.color;
|
||||
@@ -224,12 +228,12 @@ function TextParser (data: PostStructuredContent): HTMLSpanElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLSpanElement} 解析后的链接
|
||||
*/
|
||||
function LinkTextParser (data: PostStructuredContent): HTMLSpanElement {
|
||||
function LinkTextParser(data: PostStructuredContent): HTMLSpanElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert !== "string") {
|
||||
throw new Error("data.insert is not a string");
|
||||
}
|
||||
if (!data.attributes) {
|
||||
if (data.attributes == null) {
|
||||
throw new Error("data.attributes is not defined");
|
||||
}
|
||||
if (!data.attributes.link) {
|
||||
@@ -263,7 +267,7 @@ function LinkTextParser (data: PostStructuredContent): HTMLSpanElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的分割线
|
||||
*/
|
||||
function DividerParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function DividerParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 数据检查
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
@@ -286,7 +290,8 @@ function DividerParser (data: PostStructuredContent): HTMLDivElement {
|
||||
img.src =
|
||||
"https://mihoyo-community-web.oss-cn-shanghai.aliyuncs.com/upload/2021/01/05/e7047588e912d60ff87a975e037c7606.png";
|
||||
} else if (data.insert.divider === "line_4") {
|
||||
img.src = "https://mihoyo-community-web.oss-cn-shanghai.aliyuncs.com/upload/2022/07/13/line_4.png";
|
||||
img.src =
|
||||
"https://mihoyo-community-web.oss-cn-shanghai.aliyuncs.com/upload/2022/07/13/line_4.png";
|
||||
} else {
|
||||
console.error("Unknown divider type", data);
|
||||
return UnknownParser(data);
|
||||
@@ -303,7 +308,7 @@ function DividerParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的图片
|
||||
*/
|
||||
function ImageParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function ImageParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
@@ -340,18 +345,18 @@ function ImageParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的视频
|
||||
*/
|
||||
function VideoParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function VideoParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
}
|
||||
if (!data.insert.vod && !data.insert.video) {
|
||||
if (data.insert.vod == null && !data.insert.video) {
|
||||
throw new Error("data.insert.vod is not defined");
|
||||
}
|
||||
// 创建 div
|
||||
const div = document.createElement("div");
|
||||
div.classList.add("mys-post-div");
|
||||
if (data.insert.vod) {
|
||||
if (data.insert.vod != null) {
|
||||
// 创建视频
|
||||
const video = document.createElement("video");
|
||||
video.classList.add("mys-post-vod");
|
||||
@@ -390,7 +395,7 @@ function VideoParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的折叠内容
|
||||
*/
|
||||
function BackupTextParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function BackupTextParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
@@ -398,7 +403,7 @@ function BackupTextParser (data: PostStructuredContent): HTMLDivElement {
|
||||
if (data.insert.backup_text === "[抽奖]") {
|
||||
return LotteryParser(data);
|
||||
}
|
||||
if (!data.insert.fold) {
|
||||
if (data.insert.fold == null) {
|
||||
throw new Error("data.insert.fold is not defined");
|
||||
}
|
||||
// 转换
|
||||
@@ -436,7 +441,7 @@ function BackupTextParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的抽奖
|
||||
*/
|
||||
function LotteryParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function LotteryParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
@@ -447,7 +452,7 @@ function LotteryParser (data: PostStructuredContent): HTMLDivElement {
|
||||
if (data.insert.backup_text !== "[抽奖]") {
|
||||
throw new Error("data.insert.backup_text is not [抽奖]");
|
||||
}
|
||||
if (!data.insert.lottery) {
|
||||
if (data.insert.lottery == null) {
|
||||
throw new Error("data.insert.lottery is not defined");
|
||||
}
|
||||
// 创建 div
|
||||
@@ -474,12 +479,12 @@ function LotteryParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的链接卡片
|
||||
*/
|
||||
function LinkCardParser (data: PostStructuredContent): HTMLDivElement {
|
||||
function LinkCardParser(data: PostStructuredContent): HTMLDivElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
}
|
||||
if (!data.insert.link_card) {
|
||||
if (data.insert.link_card == null) {
|
||||
throw new Error("data.insert.link_card is not defined");
|
||||
}
|
||||
// 创建 div
|
||||
@@ -537,12 +542,12 @@ function LinkCardParser (data: PostStructuredContent): HTMLDivElement {
|
||||
* @param {PostStructuredContent} data Mys数据
|
||||
* @returns {HTMLAnchorElement} 解析后的 Mention
|
||||
*/
|
||||
function MentionParser (data: PostStructuredContent): HTMLAnchorElement {
|
||||
function MentionParser(data: PostStructuredContent): HTMLAnchorElement {
|
||||
// 检查数据
|
||||
if (typeof data.insert === "string") {
|
||||
throw new Error("data.insert is a string");
|
||||
}
|
||||
if (!data.insert.mention) {
|
||||
if (data.insert.mention == null) {
|
||||
throw new Error("data.insert.mention is not defined");
|
||||
}
|
||||
// 创建图标
|
||||
|
||||
@@ -13,7 +13,7 @@ import { type PositionObc, type PositionData, type PositionCard } from "../inter
|
||||
* @param {PositionObc[]} list 列表
|
||||
* @returns {PositionData[]} 返回列表
|
||||
*/
|
||||
export function dfs (list: PositionObc[]): PositionData[] {
|
||||
export function dfs(list: PositionObc[]): PositionData[] {
|
||||
const res: PositionData[] = [];
|
||||
for (const item of list) {
|
||||
if (item.name === "近期活动") {
|
||||
@@ -32,7 +32,7 @@ export function dfs (list: PositionObc[]): PositionData[] {
|
||||
* @param {PositionData[]} positionData 列表
|
||||
* @returns {PositionCard[]} 返回列表
|
||||
*/
|
||||
export function getPositionCard (positionData: PositionData[]): PositionCard[] {
|
||||
export function getPositionCard(positionData: PositionData[]): PositionCard[] {
|
||||
const res: PositionCard[] = [];
|
||||
positionData.map((position) => {
|
||||
let endStr: string;
|
||||
|
||||
@@ -50,9 +50,9 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async initDB (): Promise<void> {
|
||||
public async initDB(): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = [...initTableSql(), ...await initDataSql()];
|
||||
const sql = [...initTableSql(), ...(await initDataSql())];
|
||||
for (const item of sql) {
|
||||
await db.execute(item);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<TGApp.Sqlite.AppData.Item[]>}
|
||||
*/
|
||||
public async getAppData (): Promise<TGApp.Sqlite.AppData.Item[]> {
|
||||
public async getAppData(): Promise<TGApp.Sqlite.AppData.Item[]> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT * FROM AppData;";
|
||||
const res: TGApp.Sqlite.AppData.Item[] = await db.select(sql);
|
||||
@@ -77,7 +77,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<Record<string, string>>}
|
||||
*/
|
||||
public async getCookie (): Promise<Record<string, string>> {
|
||||
public async getCookie(): Promise<Record<string, string>> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT value FROM AppData WHERE key='cookie';";
|
||||
const res: Array<{ value: string }> = await db.select(sql);
|
||||
@@ -91,7 +91,7 @@ class Sqlite {
|
||||
* @param {TGApp.User.Account.Game[]} accounts
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async saveAccount (accounts: TGApp.User.Account.Game[]): Promise<void> {
|
||||
public async saveAccount(accounts: TGApp.User.Account.Game[]): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
for (const a of accounts) {
|
||||
const sql = insertGameAccountData(a);
|
||||
@@ -105,7 +105,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<TGApp.Sqlite.Account.Game|false>}
|
||||
*/
|
||||
public async getCurAccount (): Promise<TGApp.Sqlite.Account.Game | false> {
|
||||
public async getCurAccount(): Promise<TGApp.Sqlite.Account.Game | false> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT * FROM GameAccount WHERE isChosen=1;";
|
||||
const res: TGApp.Sqlite.Account.Game[] = await db.select(sql);
|
||||
@@ -120,7 +120,7 @@ class Sqlite {
|
||||
* @param {string} value
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async saveAppData (key: string, value: string): Promise<void> {
|
||||
public async saveAppData(key: string, value: string): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = insertAppData(key, value);
|
||||
await db.execute(sql);
|
||||
@@ -132,7 +132,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async update (): Promise<void> {
|
||||
public async update(): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sqlD = await initDataSql();
|
||||
for (const item of sqlD) {
|
||||
@@ -146,7 +146,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
public async check (): Promise<boolean> {
|
||||
public async check(): Promise<boolean> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
let isVerified = false;
|
||||
// 检测数据表是否都存在
|
||||
@@ -166,7 +166,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async reset (): Promise<void> {
|
||||
public async reset(): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
this.tables.map(async (item) => {
|
||||
const sql = `DROP TABLE IF EXISTS ${item};`;
|
||||
@@ -181,7 +181,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<TGApp.Sqlite.Achievement.SeriesTable[]>}
|
||||
*/
|
||||
public async getAchievementSeries (): Promise<TGApp.Sqlite.Achievement.SeriesTable[]> {
|
||||
public async getAchievementSeries(): Promise<TGApp.Sqlite.Achievement.SeriesTable[]> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT * FROM AchievementSeries ORDER BY `order`;";
|
||||
const res: TGApp.Sqlite.Achievement.SeriesTable[] = await db.select(sql);
|
||||
@@ -195,7 +195,7 @@ class Sqlite {
|
||||
* @param {number} seriesId 系列 ID
|
||||
* @returns {Promise<TGApp.Sqlite.NameCard.Item>}
|
||||
*/
|
||||
public async getNameCard (seriesId: number): Promise<TGApp.Sqlite.NameCard.SingleTable> {
|
||||
public async getNameCard(seriesId: number): Promise<TGApp.Sqlite.NameCard.SingleTable> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = `SELECT *
|
||||
FROM NameCard
|
||||
@@ -211,7 +211,7 @@ class Sqlite {
|
||||
* @param {number} [seriesId] 系列 ID
|
||||
* @returns {Promise<TGApp.Sqlite.Achievement.SingleTable[]>}
|
||||
*/
|
||||
public async getAchievements (seriesId?: number): Promise<TGApp.Sqlite.Achievement.SingleTable[]> {
|
||||
public async getAchievements(seriesId?: number): Promise<TGApp.Sqlite.Achievement.SingleTable[]> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
let sql;
|
||||
if (seriesId) {
|
||||
@@ -232,10 +232,13 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<{total:number,fin:number}>}
|
||||
*/
|
||||
public async getAchievementsOverview (): Promise<{ total: number, fin: number }> {
|
||||
public async getAchievementsOverview(): Promise<{
|
||||
total: number;
|
||||
fin: number;
|
||||
}> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT SUM(totalCount) AS total, SUM(finCount) AS fin FROM AchievementSeries;";
|
||||
const res: Array<{ total: number, fin: number }> = await db.select(sql);
|
||||
const res: Array<{ total: number; fin: number }> = await db.select(sql);
|
||||
await db.close();
|
||||
return res[0];
|
||||
}
|
||||
@@ -245,7 +248,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
public async getLatestAchievementVersion (): Promise<string> {
|
||||
public async getLatestAchievementVersion(): Promise<string> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT version FROM AchievementSeries ORDER BY version DESC LIMIT 1;";
|
||||
const res: Array<{ version: string }> = await db.select(sql);
|
||||
@@ -259,7 +262,9 @@ class Sqlite {
|
||||
* @param {string} keyword 关键词
|
||||
* @returns {Promise<TGApp.Sqlite.Achievement.SingleTable[]>}
|
||||
*/
|
||||
public async searchAchievements (keyword: string): Promise<TGApp.Sqlite.Achievement.SingleTable[]> {
|
||||
public async searchAchievements(
|
||||
keyword: string,
|
||||
): Promise<TGApp.Sqlite.Achievement.SingleTable[]> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
let sql;
|
||||
if (keyword.startsWith("v")) {
|
||||
@@ -286,7 +291,7 @@ class Sqlite {
|
||||
* @param {TGApp.Plugins.UIAF.Achievement[]} achievements UIAF 数据
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async mergeUIAF (achievements: TGApp.Plugins.UIAF.Achievement[]): Promise<void> {
|
||||
public async mergeUIAF(achievements: TGApp.Plugins.UIAF.Achievement[]): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = importUIAFData(achievements);
|
||||
for (const item of sql) {
|
||||
@@ -300,7 +305,7 @@ class Sqlite {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<TGApp.Plugins.UIAF.Achievement[]>}
|
||||
*/
|
||||
public async getUIAF (): Promise<TGApp.Plugins.UIAF.Achievement[]> {
|
||||
public async getUIAF(): Promise<TGApp.Plugins.UIAF.Achievement[]> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = "SELECT * FROM Achievements WHERE isCompleted = 1 OR progress > 0";
|
||||
const res: TGApp.Sqlite.Achievement.SingleTable[] = await db.select(sql);
|
||||
@@ -312,7 +317,8 @@ class Sqlite {
|
||||
achievements.push({
|
||||
id: item.id,
|
||||
status,
|
||||
timestamp: completed && item.completedTime ? new Date(item.completedTime).getTime() / 1000 : 0,
|
||||
timestamp:
|
||||
completed && item.completedTime ? new Date(item.completedTime).getTime() / 1000 : 0,
|
||||
current: item.progress,
|
||||
});
|
||||
}
|
||||
@@ -326,7 +332,7 @@ class Sqlite {
|
||||
* @param {TGApp.Game.Abyss.FullData} data 深渊数据
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async saveAbyss (uid: string, data: TGApp.Game.Abyss.FullData): Promise<void> {
|
||||
public async saveAbyss(uid: string, data: TGApp.Game.Abyss.FullData): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = insertAbyssData(uid, data);
|
||||
await db.execute(sql);
|
||||
@@ -339,7 +345,7 @@ class Sqlite {
|
||||
* @param {string} uid 游戏 UID
|
||||
* @returns {Promise<TGApp.Game.Abyss.FullData>}
|
||||
*/
|
||||
public async getAbyss (uid?: string): Promise<TGApp.Sqlite.Abyss.SingleTable[]> {
|
||||
public async getAbyss(uid?: string): Promise<TGApp.Sqlite.Abyss.SingleTable[]> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
let sql;
|
||||
if (uid) {
|
||||
@@ -358,7 +364,7 @@ class Sqlite {
|
||||
* @param {TGApp.Sqlite.Abyss.SingleTable[]} data 深渊数据
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async restoreAbyss (data: TGApp.Sqlite.Abyss.SingleTable[]): Promise<void> {
|
||||
public async restoreAbyss(data: TGApp.Sqlite.Abyss.SingleTable[]): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
for (const item of data) {
|
||||
const sql = importAbyssData(item);
|
||||
@@ -374,7 +380,7 @@ class Sqlite {
|
||||
* @param {string} uid 用户 uid
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async saveUserRecord (data: TGApp.Game.Record.FullData, uid: string): Promise<void> {
|
||||
public async saveUserRecord(data: TGApp.Game.Record.FullData, uid: string): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = insertRecordData(data, uid);
|
||||
await db.execute(sql);
|
||||
@@ -387,7 +393,7 @@ class Sqlite {
|
||||
* @param {string} uid 用户 uid
|
||||
* @returns {Promise<TGApp.Sqlite.Record.SingleTable|false>}
|
||||
*/
|
||||
public async getUserRecord (uid: string): Promise<TGApp.Sqlite.Record.SingleTable | false> {
|
||||
public async getUserRecord(uid: string): Promise<TGApp.Sqlite.Record.SingleTable | false> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = `SELECT * FROM UserRecord WHERE uid = '${uid}'`;
|
||||
const res: TGApp.Sqlite.Record.SingleTable[] = await db.select(sql);
|
||||
@@ -402,7 +408,7 @@ class Sqlite {
|
||||
* @param {number} id 角色 ID
|
||||
* @returns {Promise<TGApp.Sqlite.Character.AppData}> 角色数据
|
||||
*/
|
||||
public async getAppCharacter (id: number): Promise<TGApp.Sqlite.Character.AppData> {
|
||||
public async getAppCharacter(id: number): Promise<TGApp.Sqlite.Character.AppData> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = `SELECT * FROM AppCharacters WHERE id = ${id}`;
|
||||
const res: TGApp.Sqlite.Character.AppData[] = await db.select(sql);
|
||||
@@ -417,7 +423,10 @@ class Sqlite {
|
||||
* @param {TGApp.Game.Character.ListItem[]} data 角色数据
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async saveUserCharacter (uid: string, data: TGApp.Game.Character.ListItem[]): Promise<void> {
|
||||
public async saveUserCharacter(
|
||||
uid: string,
|
||||
data: TGApp.Game.Character.ListItem[],
|
||||
): Promise<void> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = insertRoleData(uid, data);
|
||||
await db.execute(sql);
|
||||
@@ -430,7 +439,7 @@ class Sqlite {
|
||||
* @param {string} uid 用户 uid
|
||||
* @returns {Promise<TGApp.Sqlite.Character.UserRole[]|false>}
|
||||
*/
|
||||
public async getUserCharacter (uid: string): Promise<TGApp.Sqlite.Character.UserRole[] | false> {
|
||||
public async getUserCharacter(uid: string): Promise<TGApp.Sqlite.Character.UserRole[] | false> {
|
||||
const db = await Database.load(this.dbPath);
|
||||
const sql = `SELECT * FROM UserCharacters WHERE uid = '${uid}'`;
|
||||
const res: TGApp.Sqlite.Character.UserRole[] = await db.select(sql);
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<string[]>} sql
|
||||
*/
|
||||
async function initAppData (): Promise<string[]> {
|
||||
async function initAppData(): Promise<string[]> {
|
||||
const sqlRes: string[] = [];
|
||||
const appVersion = await app.getVersion();
|
||||
const buildTime = getBuildTime();
|
||||
@@ -35,20 +35,17 @@ async function initAppData (): Promise<string[]> {
|
||||
sqlRes.push(`
|
||||
INSERT INTO AppData (key, value, updated)
|
||||
VALUES ('appVersion', '${appVersion}', datetime('now', 'localtime'))
|
||||
ON CONFLICT(key) DO UPDATE SET value = '${appVersion}', updated = datetime('now', 'localtime');`,
|
||||
);
|
||||
ON CONFLICT(key) DO UPDATE SET value = '${appVersion}', updated = datetime('now', 'localtime');`);
|
||||
// 初始化应用数据更新时间
|
||||
sqlRes.push(`
|
||||
INSERT INTO AppData (key, value, updated)
|
||||
VALUES ('dataUpdated', '${buildTime}', datetime('now', 'localtime'))
|
||||
ON CONFLICT(key) DO UPDATE SET value = '${buildTime}', updated = datetime('now', 'localtime');`,
|
||||
);
|
||||
ON CONFLICT(key) DO UPDATE SET value = '${buildTime}', updated = datetime('now', 'localtime');`);
|
||||
// 初始化 cookie
|
||||
sqlRes.push(`
|
||||
INSERT INTO AppData (key, value, updated)
|
||||
VALUES ('cookie', '{}', datetime('now', 'localtime'))
|
||||
ON CONFLICT(key) DO NOTHING;`,
|
||||
);
|
||||
ON CONFLICT(key) DO NOTHING;`);
|
||||
return sqlRes;
|
||||
}
|
||||
|
||||
@@ -57,7 +54,7 @@ async function initAppData (): Promise<string[]> {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {string[]} sql
|
||||
*/
|
||||
function initAchievementSeriesData (): string[] {
|
||||
function initAchievementSeriesData(): string[] {
|
||||
return AppAchievementSeriesData.map((item) => insertAchievementSeriesData(item));
|
||||
}
|
||||
|
||||
@@ -66,7 +63,7 @@ function initAchievementSeriesData (): string[] {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {string[]} sql
|
||||
*/
|
||||
function initAchievementData (): string[] {
|
||||
function initAchievementData(): string[] {
|
||||
return AppAchievementsData.map((item) => insertAchievementData(item));
|
||||
}
|
||||
|
||||
@@ -75,7 +72,7 @@ function initAchievementData (): string[] {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {string[]} sql
|
||||
*/
|
||||
function initNameCardData (): string[] {
|
||||
function initNameCardData(): string[] {
|
||||
return AppNameCardsData.map((item) => insertNameCardData(item));
|
||||
}
|
||||
|
||||
@@ -84,7 +81,7 @@ function initNameCardData (): string[] {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {string[]} sql
|
||||
*/
|
||||
function initCharacterData (): string[] {
|
||||
function initCharacterData(): string[] {
|
||||
return AppCharacterData.map((item) => insertCharacterData(item));
|
||||
}
|
||||
|
||||
@@ -93,9 +90,9 @@ function initCharacterData (): string[] {
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {Promise<string[]>} sql
|
||||
*/
|
||||
async function initDataSql (): Promise<string[]> {
|
||||
async function initDataSql(): Promise<string[]> {
|
||||
const sqlRes: string[] = [];
|
||||
sqlRes.push(...await initAppData());
|
||||
sqlRes.push(...(await initAppData()));
|
||||
sqlRes.push(...initAchievementSeriesData());
|
||||
sqlRes.push(...initAchievementData());
|
||||
sqlRes.push(...initNameCardData());
|
||||
|
||||
@@ -14,11 +14,8 @@ import createTrigger from "./createTrigger.sql?raw";
|
||||
* @since Alpha v0.2.0
|
||||
* @returns {string[]} sql
|
||||
*/
|
||||
function initTableSql (): string[] {
|
||||
return [
|
||||
createTable,
|
||||
createTrigger,
|
||||
];
|
||||
function initTableSql(): string[] {
|
||||
return [createTable, createTrigger];
|
||||
}
|
||||
|
||||
export default initTableSql;
|
||||
|
||||
@@ -17,7 +17,7 @@ import { transUserRecord } from "../utils/transUserRecord";
|
||||
* @param {TGApp.App.Achievement.Item} data 成就数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertAchievementData (data: TGApp.App.Achievement.Item): string {
|
||||
export function insertAchievementData(data: TGApp.App.Achievement.Item): string {
|
||||
return `
|
||||
INSERT INTO Achievements (id, series, "order", name, description, reward, completedTime, version, updated)
|
||||
VALUES (${data.id}, ${data.series}, ${data.order}, '${data.name}', '${data.description}', ${data.reward}, '',
|
||||
@@ -39,7 +39,7 @@ export function insertAchievementData (data: TGApp.App.Achievement.Item): string
|
||||
* @param {TGApp.App.Achievement.Series} data 成就系列数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertAchievementSeriesData (data: TGApp.App.Achievement.Series): string {
|
||||
export function insertAchievementSeriesData(data: TGApp.App.Achievement.Series): string {
|
||||
return `
|
||||
INSERT INTO AchievementSeries (id, "order", name, version, nameCard, updated)
|
||||
VALUES (${data.id}, ${data.order}, '${data.name}', '${data.version}', '${data.card}',
|
||||
@@ -60,7 +60,7 @@ export function insertAchievementSeriesData (data: TGApp.App.Achievement.Series)
|
||||
* @param {string} value 值
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertAppData (key: string, value: string): string {
|
||||
export function insertAppData(key: string, value: string): string {
|
||||
return `
|
||||
INSERT INTO AppData (key, value, updated)
|
||||
VALUES ('${key}', '${value}', datetime('now', 'localtime'))
|
||||
@@ -75,7 +75,7 @@ export function insertAppData (key: string, value: string): string {
|
||||
* @param {TGApp.User.Account.Game} data 游戏账号数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertGameAccountData (data: TGApp.User.Account.Game): string {
|
||||
export function insertGameAccountData(data: TGApp.User.Account.Game): string {
|
||||
const isChosen = data.is_chosen ? 1 : 0;
|
||||
const isOfficial = data.is_official ? 1 : 0;
|
||||
return `
|
||||
@@ -99,7 +99,7 @@ export function insertGameAccountData (data: TGApp.User.Account.Game): string {
|
||||
* @param {TGApp.App.NameCard.Item} data 名片数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertNameCardData (data: TGApp.App.NameCard.Item): string {
|
||||
export function insertNameCardData(data: TGApp.App.NameCard.Item): string {
|
||||
return `
|
||||
INSERT INTO NameCard (name, "desc", type, source, updated)
|
||||
VALUES ('${data.name}', '${data.desc}', '${data.type}', '${data.source}', datetime('now', 'localtime'))
|
||||
@@ -116,7 +116,7 @@ export function insertNameCardData (data: TGApp.App.NameCard.Item): string {
|
||||
* @param {TGApp.User.Character.Item} data 角色数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertCharacterData (data: TGApp.App.Character.WikiBriefInfo): string {
|
||||
export function insertCharacterData(data: TGApp.App.Character.WikiBriefInfo): string {
|
||||
return `
|
||||
INSERT INTO AppCharacters (id, name, star, element, weapon, nameCard, birthday, updated)
|
||||
VALUES (${data.id}, '${data.name}', ${data.star}, '${data.element}', '${data.weapon}',
|
||||
@@ -138,7 +138,7 @@ export function insertCharacterData (data: TGApp.App.Character.WikiBriefInfo): s
|
||||
* @param {TGApp.User.Abyss} data 深渊数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertAbyssData (uid: string, data: TGApp.Game.Abyss.FullData): string {
|
||||
export function insertAbyssData(uid: string, data: TGApp.Game.Abyss.FullData): string {
|
||||
const startTime = timeToSecond(data.start_time);
|
||||
const endTime = timeToSecond(data.end_time);
|
||||
const isUnlock = data.is_unlock ? 1 : 0;
|
||||
@@ -182,7 +182,7 @@ export function insertAbyssData (uid: string, data: TGApp.Game.Abyss.FullData):
|
||||
* @param {TGApp.Sqlite.Abyss.SingleTable} data 深渊数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function importAbyssData (data: TGApp.Sqlite.Abyss.SingleTable): string {
|
||||
export function importAbyssData(data: TGApp.Sqlite.Abyss.SingleTable): string {
|
||||
return `
|
||||
INSERT INTO SpiralAbyss (uid, id, startTime, endTime, totalBattleTimes, totalWinTimes,
|
||||
maxFloor, totalStar, isUnlock, revealRank, defeatRank, damageRank,
|
||||
@@ -218,7 +218,7 @@ export function importAbyssData (data: TGApp.Sqlite.Abyss.SingleTable): string {
|
||||
* @param {string} uid 用户 UID
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertRecordData (data: TGApp.Game.Record.FullData, uid: string): string {
|
||||
export function insertRecordData(data: TGApp.Game.Record.FullData, uid: string): string {
|
||||
const transData = transUserRecord(data);
|
||||
transData.uid = uid;
|
||||
return `
|
||||
@@ -242,8 +242,8 @@ export function insertRecordData (data: TGApp.Game.Record.FullData, uid: string)
|
||||
* @param {TGApp.User.Character.Item[]} data 角色数据
|
||||
* @returns {string} sql
|
||||
*/
|
||||
export function insertRoleData (uid: string, data: TGApp.Game.Character.ListItem[]): string {
|
||||
const sql = data.map(item => {
|
||||
export function insertRoleData(uid: string, data: TGApp.Game.Character.ListItem[]): string {
|
||||
const sql = data.map((item) => {
|
||||
const role = transUserRoles(item);
|
||||
return `
|
||||
INSERT INTO UserCharacters (uid, cid, name, img, name, fetter, level, element, star, weapon, reliquary,
|
||||
|
||||
@@ -11,14 +11,17 @@
|
||||
* @param {TGApp.Plugins.UIAF.Achievement[]} data
|
||||
* @returns {string[]} sql
|
||||
*/
|
||||
export function importUIAFData (data: TGApp.Plugins.UIAF.Achievement[]): string[] {
|
||||
export function importUIAFData(data: TGApp.Plugins.UIAF.Achievement[]): string[] {
|
||||
const sqlRes: string[] = [];
|
||||
data.map((achievement) => {
|
||||
let sql;
|
||||
// 获取完成状态
|
||||
const isCompleted = achievement.status === 2 || achievement.status === 3;
|
||||
if (isCompleted) {
|
||||
const completedTime = new Date(achievement.timestamp * 1000).toISOString().replace("T", " ").slice(0, 19);
|
||||
const completedTime = new Date(achievement.timestamp * 1000)
|
||||
.toISOString()
|
||||
.replace("T", " ")
|
||||
.slice(0, 19);
|
||||
sql = `
|
||||
UPDATE Achievements
|
||||
SET isCompleted = 1, completedTime = '${completedTime}', progress = ${achievement.current}, updated = datetime('now', 'localtime')
|
||||
|
||||
@@ -13,7 +13,7 @@ import { timeToSecond } from "./transTime";
|
||||
* @param {TGApp.Game.Abyss.CharacterData[]} data 深渊数据
|
||||
* @returns {string} 转换后的深渊数据
|
||||
*/
|
||||
export function transCharacterData (data: TGApp.Game.Abyss.CharacterData[]): string {
|
||||
export function transCharacterData(data: TGApp.Game.Abyss.CharacterData[]): string {
|
||||
const res = data.map((item) => {
|
||||
return {
|
||||
id: item.avatar_id,
|
||||
@@ -30,7 +30,7 @@ export function transCharacterData (data: TGApp.Game.Abyss.CharacterData[]): str
|
||||
* @param {TGApp.Game.Abyss.Floor} data 深渊数据
|
||||
* @returns {string} 转换后的深渊数据
|
||||
*/
|
||||
export function transFloorData (data: TGApp.Game.Abyss.Floor[]): string {
|
||||
export function transFloorData(data: TGApp.Game.Abyss.Floor[]): string {
|
||||
const floor = data.map((item) => {
|
||||
return {
|
||||
id: item.index,
|
||||
@@ -42,8 +42,12 @@ export function transFloorData (data: TGApp.Game.Abyss.Floor[]): string {
|
||||
id: level.index,
|
||||
winStar: level.star,
|
||||
maxStar: level.max_star,
|
||||
upBattle: transBattleData(level.battles.find((l) => l.index === 1) as TGApp.Game.Abyss.Battle),
|
||||
downBattle: transBattleData(level.battles.find((l) => l.index === 2) as TGApp.Game.Abyss.Battle),
|
||||
upBattle: transBattleData(
|
||||
level.battles.find((l) => l.index === 1) as TGApp.Game.Abyss.Battle,
|
||||
),
|
||||
downBattle: transBattleData(
|
||||
level.battles.find((l) => l.index === 2) as TGApp.Game.Abyss.Battle,
|
||||
),
|
||||
};
|
||||
}),
|
||||
};
|
||||
@@ -57,7 +61,7 @@ export function transFloorData (data: TGApp.Game.Abyss.Floor[]): string {
|
||||
* @param {TGApp.Game.Abyss.Battle} data 深渊数据
|
||||
* @returns {TGApp.Sqlite.Abyss.Battle} 转换后的深渊数据
|
||||
*/
|
||||
function transBattleData (data: TGApp.Game.Abyss.Battle): TGApp.Sqlite.Abyss.Battle {
|
||||
function transBattleData(data: TGApp.Game.Abyss.Battle): TGApp.Sqlite.Abyss.Battle {
|
||||
return {
|
||||
time: timeToSecond(data.timestamp),
|
||||
characters: data.avatars.map((item) => {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* @param {string} timestamp 时间戳 (秒)
|
||||
* @returns {string} 时间字符串,格式为 YYYY-MM-DD HH:mm:ss
|
||||
*/
|
||||
export function timeToSecond (timestamp: string): string {
|
||||
export function timeToSecond(timestamp: string): string {
|
||||
const date = new Date(Number(timestamp) * 1000);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* @param {TGApp.Game.Record.FullData} data 用户战绩数据
|
||||
* @returns {TGApp.Sqlite.Record.SingleTable} 转换后的用户战绩数据
|
||||
*/
|
||||
export function transUserRecord (data: TGApp.Game.Record.FullData): TGApp.Sqlite.Record.SingleTable {
|
||||
export function transUserRecord(data: TGApp.Game.Record.FullData): TGApp.Sqlite.Record.SingleTable {
|
||||
return {
|
||||
uid: "",
|
||||
role: transRole(data.role),
|
||||
@@ -29,7 +29,7 @@ export function transUserRecord (data: TGApp.Game.Record.FullData): TGApp.Sqlite
|
||||
* @param {TGApp.Game.Record.Role} data 角色信息
|
||||
* @returns {string} 转换后的角色信息
|
||||
*/
|
||||
function transRole (data: TGApp.Game.Record.Role): string {
|
||||
function transRole(data: TGApp.Game.Record.Role): string {
|
||||
const role: TGApp.Sqlite.Record.Role = {
|
||||
nickname: data.nickname,
|
||||
region: data.region,
|
||||
@@ -44,7 +44,7 @@ function transRole (data: TGApp.Game.Record.Role): string {
|
||||
* @param {TGApp.Game.Record.Avatar[]} data 角色列表
|
||||
* @returns {string} 转换后的角色列表
|
||||
*/
|
||||
function transAvatar (data: TGApp.Game.Record.Avatar[]): string {
|
||||
function transAvatar(data: TGApp.Game.Record.Avatar[]): string {
|
||||
const elementMap: Record<string, string> = {
|
||||
Anemo: "风",
|
||||
Geo: "岩",
|
||||
@@ -54,25 +54,27 @@ function transAvatar (data: TGApp.Game.Record.Avatar[]): string {
|
||||
Cryo: "冰",
|
||||
Dendro: "草",
|
||||
};
|
||||
const avatars: TGApp.Sqlite.Record.Avatar[] = data.map(item => {
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
element: elementMap[item.element],
|
||||
fetter: item.fetter,
|
||||
level: item.level,
|
||||
star: item.rarity === 105 ? 5 : item.rarity,
|
||||
constellation: item.actived_constellation_num,
|
||||
isShow: item.is_chosen ? 1 : 0,
|
||||
} as TGApp.Sqlite.Record.Avatar;
|
||||
}).sort((a, b) => {
|
||||
// 先按星级降序
|
||||
if (a.star !== b.star) {
|
||||
return b.star - a.star;
|
||||
}
|
||||
// 再按 id 降序
|
||||
return b.id - a.id;
|
||||
});
|
||||
const avatars: TGApp.Sqlite.Record.Avatar[] = data
|
||||
.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
element: elementMap[item.element],
|
||||
fetter: item.fetter,
|
||||
level: item.level,
|
||||
star: item.rarity === 105 ? 5 : item.rarity,
|
||||
constellation: item.actived_constellation_num,
|
||||
isShow: item.is_chosen ? 1 : 0,
|
||||
} as TGApp.Sqlite.Record.Avatar;
|
||||
})
|
||||
.sort((a, b) => {
|
||||
// 先按星级降序
|
||||
if (a.star !== b.star) {
|
||||
return b.star - a.star;
|
||||
}
|
||||
// 再按 id 降序
|
||||
return b.id - a.id;
|
||||
});
|
||||
return JSON.stringify(avatars);
|
||||
}
|
||||
|
||||
@@ -82,7 +84,7 @@ function transAvatar (data: TGApp.Game.Record.Avatar[]): string {
|
||||
* @param {TGApp.Game.Record.Stats} data 统计信息
|
||||
* @return {string} 转换后的统计信息
|
||||
*/
|
||||
function transStat (data: TGApp.Game.Record.Stats): string {
|
||||
function transStat(data: TGApp.Game.Record.Stats): string {
|
||||
const stats: TGApp.Sqlite.Record.Stats = {
|
||||
activeDays: data.active_day_number,
|
||||
achievementNumber: data.achievement_number,
|
||||
@@ -109,11 +111,11 @@ function transStat (data: TGApp.Game.Record.Stats): string {
|
||||
* @param {TGApp.Game.Record.WorldExplore[]} data 城市探索信息
|
||||
* @returns {string} 转换后的城市探索信息
|
||||
*/
|
||||
function transWorld (data: TGApp.Game.Record.WorldExplore[]): string {
|
||||
const worlds: TGApp.Sqlite.Record.WorldExplore[] = data.map(item => {
|
||||
function transWorld(data: TGApp.Game.Record.WorldExplore[]): string {
|
||||
const worlds: TGApp.Sqlite.Record.WorldExplore[] = data.map((item) => {
|
||||
let offerings;
|
||||
if (item.offerings !== undefined) {
|
||||
offerings = item.offerings.map(offering => {
|
||||
offerings = item.offerings.map((offering) => {
|
||||
return {
|
||||
name: offering.name,
|
||||
icon: offering.icon,
|
||||
@@ -142,8 +144,8 @@ function transWorld (data: TGApp.Game.Record.WorldExplore[]): string {
|
||||
* @param {TGApp.Game.Record.Home[]} data 住宅信息
|
||||
* @returns {string} 转换后的住宅信息
|
||||
*/
|
||||
function transHome (data: TGApp.Game.Record.Home[]): string {
|
||||
const homes: TGApp.Sqlite.Record.Home[] = data.map(item => {
|
||||
function transHome(data: TGApp.Game.Record.Home[]): string {
|
||||
const homes: TGApp.Sqlite.Record.Home[] = data.map((item) => {
|
||||
return {
|
||||
comfortIcon: item.comfort_level_icon,
|
||||
comfortName: item.comfort_level_name,
|
||||
|
||||
@@ -31,7 +31,9 @@ enum EnumElement {
|
||||
* @param {TGApp.Game.Character.ListItem} data 用户角色数据
|
||||
* @returns {TGApp.Sqlite.Character.UserRole} 转换后的用户角色数据
|
||||
*/
|
||||
export function transUserRoles (data: TGApp.Game.Character.ListItem): TGApp.Sqlite.Character.UserRole {
|
||||
export function transUserRoles(
|
||||
data: TGApp.Game.Character.ListItem,
|
||||
): TGApp.Sqlite.Character.UserRole {
|
||||
return {
|
||||
uid: -1,
|
||||
cid: data.id,
|
||||
@@ -57,7 +59,7 @@ export function transUserRoles (data: TGApp.Game.Character.ListItem): TGApp.Sqli
|
||||
* @param {EnumElementEn} data 角色元素
|
||||
* @returns {EnumElement} 转换后的角色元素
|
||||
*/
|
||||
function transElement (data: EnumElementEn): EnumElement {
|
||||
function transElement(data: EnumElementEn): EnumElement {
|
||||
switch (data) {
|
||||
case EnumElementEn.pyro:
|
||||
return EnumElement.pyro;
|
||||
@@ -84,7 +86,7 @@ function transElement (data: EnumElementEn): EnumElement {
|
||||
* @param {TGApp.Game.Character.LIWeapon} data 角色武器
|
||||
* @returns {string} 转换后的角色武器
|
||||
*/
|
||||
function transWeapon (data: TGApp.Game.Character.LIWeapon): string {
|
||||
function transWeapon(data: TGApp.Game.Character.LIWeapon): string {
|
||||
const weapon: TGApp.Sqlite.Character.RoleWeapon = {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
@@ -104,7 +106,7 @@ function transWeapon (data: TGApp.Game.Character.LIWeapon): string {
|
||||
* @param {TGApp.Game.Character.LIRelic[]} data 角色命座
|
||||
* @returns {string} 转换后的角色命座
|
||||
*/
|
||||
function transReliquary (data: TGApp.Game.Character.LIRelic[]): string {
|
||||
function transReliquary(data: TGApp.Game.Character.LIRelic[]): string {
|
||||
if (data.length === 0) {
|
||||
return "";
|
||||
}
|
||||
@@ -139,7 +141,7 @@ function transReliquary (data: TGApp.Game.Character.LIRelic[]): string {
|
||||
* @param {TGApp.Game.Character.LIConstellation[]} data 角色命座
|
||||
* @returns {string} 转换后的角色命座
|
||||
*/
|
||||
function transConstellation (data: TGApp.Game.Character.LIConstellation[]): string {
|
||||
function transConstellation(data: TGApp.Game.Character.LIConstellation[]): string {
|
||||
const constellation: TGApp.Sqlite.Character.RoleConstellation[] = [];
|
||||
for (const item of data) {
|
||||
constellation.push({
|
||||
|
||||
Reference in New Issue
Block a user