import { txtLength } from "@/utils/utils" import { Button, Input, Space } from "antd" import { TextAreaProps } from "antd/lib/input/TextArea" import React, { useEffect, useState } from "react" import './index.less' interface Props extends TextAreaProps { length?: number isCurrent?: Array<'素材名称' | '落地页名' | '文案'> } /** * 广告名称 设置 组件 * @returns */ const InputName: React.FC = ({ isCurrent, value, onChange, length, ...props }) => { /******************************/ const [status, setStatus] = useState<{ status?: string }>({}) /******************************/ useEffect(() => { if (length && txtLength(value as any) > length) { setStatus({ status: 'error' }) } else { setStatus({}) } }, [value]) /** 插入通配符 */ const insertMatching = (matching: string) => { onChange?.(value + `-${matching}` as any) } return { onChange?.(e) }} /> {length && 0 ? { color: 'red' } : {}}>{txtLength(value as any)}/{length}} {isCurrent && isCurrent?.length > 0 &&
通配符: {isCurrent.includes('素材名称') && } {isCurrent.includes('落地页名') && } {isCurrent.includes('文案') && }
}
} export default React.memo(InputName)