🐛 修复banner为空时的渲染异常

This commit is contained in:
目棃
2024-10-11 17:53:20 +08:00
parent 67aa3b7363
commit 631fbfc29c
2 changed files with 17 additions and 9 deletions

View File

@@ -1,12 +1,9 @@
/**
* @file web utils transAnno.ts
* @description 公告数据转换工具
* @since Beta v0.4.4
* @since Beta v0.6.1
*/
// 默认封面图
const defaultCover = "/source/UI/defaultCover.webp";
/**
* @description 获取公告标签
* @since Beta v0.4.4
@@ -31,7 +28,7 @@ function getAnnoTag(tag: string): string {
/**
* @description 将获取到的数据转为渲染用的卡片
* @since Beta v0.4.3
* @since Beta v0.6.1
* @param {TGApp.BBS.Announcement.ListData[]} data 公告数据
* @returns {TGApp.App.Announcement.ListCard[]} 渲染用的卡片
*/
@@ -48,7 +45,7 @@ export function getAnnoCard(
id: anno.ann_id,
title: anno.title,
subtitle: anno.subtitle.replace(/<br \/>/g, " "),
banner: anno.banner || defaultCover,
banner: anno.banner,
typeLabel: anno.type === 2 ? "游戏公告" : "活动公告",
tagIcon: anno.tag_icon,
tagLabel: getAnnoTag(anno.tag_label),