perf: 模板参数: 去除\n \t等

dev/code-splitting
Lei OT 2 years ago
parent fccb129992
commit 538bc40f3c

@ -423,6 +423,11 @@ export const debounce = (func, wait, immediate) => {
};
}
export const removeFormattingChars = (str) => {
const regex = /[\r\n\t\v\f]/g;
return str.replace(regex, ' ');
}
export const olog = (text, ...args) => {
console.log(
`%c ${text} `,

@ -3,7 +3,7 @@ import { App, Popover, Flex, Button, List, Input } from 'antd';
import { MessageOutlined, SendOutlined } from '@ant-design/icons';
import useAuthStore from '@/stores/AuthStore';
import useConversationStore from '@/stores/ConversationStore';
import { cloneDeep, getNestedValue, objectMapper, sortArrayByOrder } from '@/utils/commons';
import { cloneDeep, getNestedValue, objectMapper, removeFormattingChars, sortArrayByOrder } from '@/utils/commons';
import { replaceTemplateString } from '@/channel/whatsappUtils';
import { isEmpty } from '@/utils/commons';
@ -97,8 +97,9 @@ const InputTemplate = ({ mobile, disabled = false, invokeSendMessage }) => {
const [activeInput, setActiveInput] = useState({});
const onInput = (tempItem, key, val, initObj) => {
const _val = removeFormattingChars(val);
setActiveInput((prev) => {
return { ...prev, [tempItem.name]: { ...initObj, ...prev[tempItem.name], [key]: val } };
return { ...prev, [tempItem.name]: { ...initObj, ...prev[tempItem.name], [key]: _val } };
});
};

Loading…
Cancel
Save