diff --git a/src/pages/llmodels/components/compatible-alert.tsx b/src/pages/llmodels/components/compatible-alert.tsx index 06208be8..b7c81f57 100644 --- a/src/pages/llmodels/components/compatible-alert.tsx +++ b/src/pages/llmodels/components/compatible-alert.tsx @@ -7,7 +7,7 @@ import { } from '@ant-design/icons'; import { Button } from 'antd'; import { isArray } from 'lodash'; -import React, { useMemo } from 'react'; +import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; interface CompatibilityAlertProps { @@ -49,11 +49,27 @@ const MessageWrapper = styled.div` font-size: var(--font-size-small); gap: 4px; `; +const linkReg = /(.*?)<\/a>/g; +const replaceReg = /]*\btarget=)([^>]*)>/gi; const CompatibilityAlert: React.FC = (props) => { const { warningStatus, contentStyle, showClose, onClose } = props; const { title, show, message, isHtml, type = 'warning' } = warningStatus; + const handleLinkMessage = useCallback((msg: string) => { + const link = msg?.match(linkReg); + if (link) { + return ( + ') + }} + > + ); + } + return msg || null; + }, []); + const renderMessage = useMemo(() => { if (!message || !show) { return ''; @@ -68,19 +84,19 @@ const CompatibilityAlert: React.FC = (props) => { ); } if (typeof message === 'string') { - return message; + return handleLinkMessage(message); } if (isArray(message)) { return ( {message.map((item, index) => ( -
{item}
+
{handleLinkMessage(item)}
))}
); } return ''; - }, [message, show]); + }, [message, show, handleLinkMessage]); const renderIcon = useMemo(() => { if (type === 'transition') {