开发: 添加表情匹配, 添加客群中心页面,修复弹框关闭

This commit is contained in:
zhengw
2023-04-20 17:38:19 +08:00
parent 21c1790dc4
commit 2156976a8c
19 changed files with 1135 additions and 123 deletions

View File

@@ -0,0 +1,32 @@
import { emoji } from '@/services/config';
import React from 'react';
type IProps = {
content: string;
};
export const EmojiFormat: React.FC<IProps> = (props) => {
const format = () => {
let txt = props.content;
emoji.forEach((item) => {
const reg = new RegExp(`\\[${item}\\]`, 'g');
txt = txt.replace(
reg,
`<img style="width: 24px;height:24px" src="/api/assets/wechat/emoji/${item}.png" alt="" />`,
);
});
return txt;
};
return (
<>
{typeof props.content === 'string' ? (
<span
style={{ display: 'inline-flex', flexWrap: 'wrap' }}
dangerouslySetInnerHTML={{ __html: format() }}
></span>
) : (
props.content
)}
</>
);
};