mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-16 04:03:17 +08:00
👽️ 公告添加千星奇域分类
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/enum/anno.ts
|
||||
* @description 游戏内公告相关枚举
|
||||
* @since Beta v0.8.0
|
||||
* @since Beta v0.8.4
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -37,17 +37,18 @@ export function getAnnoLangDesc(lang: TGApp.BBS.Announcement.AnnoLangEnum): stri
|
||||
|
||||
/**
|
||||
* @description 公告类型
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.4
|
||||
* @const AnnoTypeEnum
|
||||
*/
|
||||
export const AnnoTypeEnum: typeof TGApp.BBS.Announcement.AnnoType = {
|
||||
ACTIVITY: "activity",
|
||||
GAME: "game",
|
||||
UGC: "ugc",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 获取公告类型描述
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.4
|
||||
* @param {TGApp.BBS.Announcement.AnnoTypeEnum} type 公告类型
|
||||
* @return {string} 公告类型描述
|
||||
*/
|
||||
@@ -57,5 +58,7 @@ export function getAnnoTypeDesc(type: TGApp.BBS.Announcement.AnnoTypeEnum): stri
|
||||
return "活动公告";
|
||||
case AnnoTypeEnum.GAME:
|
||||
return "游戏公告";
|
||||
case AnnoTypeEnum.UGC:
|
||||
return "千星奇域";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,13 +89,14 @@ const langList: ReadonlyArray<AnnoSelect<TGApp.BBS.Announcement.AnnoLangEnum>> =
|
||||
const tabList: ReadonlyArray<AnnoSelect<TGApp.BBS.Announcement.AnnoTypeEnum>> = [
|
||||
AnnoTypeEnum.ACTIVITY,
|
||||
AnnoTypeEnum.GAME,
|
||||
AnnoTypeEnum.UGC,
|
||||
].map((i) => ({ text: getAnnoTypeDesc(i), value: i }));
|
||||
|
||||
const { server, lang } = storeToRefs(useAppStore());
|
||||
const router = useRouter();
|
||||
|
||||
const tab = ref<TGApp.BBS.Announcement.AnnoTypeEnum>(AnnoTypeEnum.ACTIVITY);
|
||||
const annoCards = shallowRef<AnnoList>({ activity: [], game: [] });
|
||||
const annoCards = shallowRef<AnnoList>({ activity: [], game: [], ugc: [] });
|
||||
const isReq = ref<boolean>(false);
|
||||
|
||||
watch(
|
||||
@@ -134,6 +135,7 @@ async function loadData(): Promise<void> {
|
||||
const detailResp = await hk4eReq.anno.detail(server.value, AnnoLangEnum.CHS);
|
||||
const actCards: Array<AnnoCard> = [];
|
||||
const gameCards: Array<AnnoCard> = [];
|
||||
const ugcCards: Array<AnnoCard> = [];
|
||||
for (const list of listResp.list) {
|
||||
for (const item of list.list) {
|
||||
const detail = detailResp.find((i) => i.ann_id === item.ann_id);
|
||||
@@ -143,13 +145,15 @@ async function loadData(): Promise<void> {
|
||||
actCards.push(card);
|
||||
} else if (card.typeLabel === "game") {
|
||||
gameCards.push(card);
|
||||
} else if (card.typeLabel === "ugc") {
|
||||
ugcCards.push(card);
|
||||
}
|
||||
} else {
|
||||
await TGLogger.Warn(`[Announcements][loadData] 未找到公告详情:${item.ann_id}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
annoCards.value = { activity: actCards, game: gameCards };
|
||||
annoCards.value = { activity: actCards, game: gameCards, ugc: ugcCards };
|
||||
await showLoading.end();
|
||||
isReq.value = false;
|
||||
}
|
||||
@@ -177,12 +181,17 @@ function getAnnoCard(
|
||||
const timeStart = anno.start_time.split(" ")[0];
|
||||
const timeEnd = anno.end_time.split(" ")[0];
|
||||
const time = `${timeStart} ~ ${timeEnd}`;
|
||||
const labelMap: Record<string, TGApp.BBS.Announcement.AnnoTypeEnum> = {
|
||||
1: AnnoTypeEnum.ACTIVITY,
|
||||
2: AnnoTypeEnum.GAME,
|
||||
26: AnnoTypeEnum.UGC,
|
||||
};
|
||||
return {
|
||||
id: anno.ann_id,
|
||||
title: anno.title,
|
||||
subtitle: anno.subtitle.replace(/<br \/>/g, " "),
|
||||
banner: anno.banner,
|
||||
typeLabel: anno.type === 2 ? "game" : "activity",
|
||||
typeLabel: labelMap[anno.type],
|
||||
tagIcon: anno.tag_icon,
|
||||
tagLabel: getAnnoTag(anno.tag_label),
|
||||
timeStr: time,
|
||||
@@ -233,7 +242,7 @@ async function switchNews(): Promise<void> {
|
||||
display: grid;
|
||||
font-family: var(--font-title);
|
||||
grid-auto-rows: auto;
|
||||
grid-gap: 8px;
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
|
||||
}
|
||||
</style>
|
||||
|
||||
6
src/types/BBS/Announcement.d.ts
vendored
6
src/types/BBS/Announcement.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file types/BBS/Announcement.d.ts
|
||||
* @description 从 BBS 获取到的游戏内公告类型定义文件
|
||||
* @since Beta v0.8.0
|
||||
* @since Beta v0.8.4
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Announcement {
|
||||
@@ -30,14 +30,16 @@ declare namespace TGApp.BBS.Announcement {
|
||||
|
||||
/**
|
||||
* @description 公告类型
|
||||
* @since Beta v0.7.7
|
||||
* @since Beta v0.8.4
|
||||
* @const AnnoType
|
||||
* @property {string} "activity" - 活动公告
|
||||
* @property {string} "game" - 游戏公告
|
||||
* @property {string} "ugc" - 千星奇域公告
|
||||
*/
|
||||
const AnnoType = <const>{
|
||||
ACTIVITY: "activity",
|
||||
GAME: "game",
|
||||
UGC: "ugc",
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user