Skip to content

Commit

Permalink
🐛 修复公告cdn返回格式错误
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed Dec 16, 2024
1 parent fdb5438 commit e9cc62c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions logic/ceobe_operation_logic/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use persistence::{
use serde::{Deserialize, Serialize};
use tencent_cloud_server::cdn::purge_urls_cache::PurgeCachePath;
use typed_builder::TypedBuilder;
use url::Url;

use crate::error::LogicError;

Expand Down Expand Up @@ -73,8 +74,7 @@ impl TryInto<ToolLinkResp> for FrontendToolLink {
pub struct AnnouncementResp {
pub start_time: String,
pub over_time: String,
pub content: String,
pub img_url: String,
pub html: String,
pub notice: bool,
}

Expand All @@ -89,11 +89,16 @@ impl From<announcement::Model> for AnnouncementResp {
..
}: announcement::Model,
) -> Self {
let image = Url::parse(&img_url)
.map(|url| url.to_string())
.unwrap_or_else(|_| format!(r#"/assets/image/{img_url}.png"#));

Self {
start_time: naive_date_time_format(start_time),
over_time: naive_date_time_format(over_time),
content,
img_url,
html: format!(
r#"<div class="online-area"><img class="online-title-img radius" src="{image}"/><div>{content}</div></div>"#,
),
notice,
}
}
Expand Down

0 comments on commit e9cc62c

Please sign in to comment.