/* Copyright (c) 2025 Tethys Plex This file is part of Veloera. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import React from 'react'; import { Layout, Typography, Button, Space, Card, Tag, Divider, Tooltip } from '@douyinfe/semi-ui'; import { IconArrowLeft } from '@douyinfe/semi-icons'; import { marked } from 'marked'; import { useTranslation } from 'react-i18next'; const { Title, Text } = Typography; const MessageDetail = ({ message, onBack }) => { const { t } = useTranslation(); const formatTimestamp = (timestamp) => { const date = new Date(timestamp); return date.toLocaleString(); }; const renderContent = (content, format) => { if (!content) return null; if (format === 'html') { return (
); } else if (format === 'markdown') { // Configure marked options for security and styling marked.setOptions({ breaks: true, gfm: true, sanitize: false, // We trust admin content, but in production you might want to sanitize }); const htmlContent = marked(content); return (
); } else { // Plain text return (
{content}
); } }; return (

{t('消息详情')}

{/* Message Header */}
{message.title} {message.format && message.format !== 'markdown' && ( {message.format.toUpperCase()} )}
{t('发送时间')}: {formatTimestamp(message.created_at)} {message.read_at && ( <> {t('阅读时间')}: {formatTimestamp(message.read_at)} )}
{/* Message Content */}
{renderContent(message.content, message.format)}
{/* Add some CSS for markdown content styling */}
); }; export default MessageDetail;