fix: harden admin and CMPP delivery workflows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Edit3, Eye, Plus, Search, Trash2 } from 'lucide-react';
|
||||
import { adminApi, type ClientSmsApplication, type ClientSmsSignature, type ClientSmsTemplate, type TenantOption } from '@/api/adminApi';
|
||||
import { formatDateTime } from '@/utils/dateTime';
|
||||
@@ -84,6 +84,7 @@ function TemplateFormModal({
|
||||
}) {
|
||||
const [customVariable, setCustomVariable] = useState('');
|
||||
const [variablesOpen, setVariablesOpen] = useState(false);
|
||||
const contentRef = useRef<HTMLTextAreaElement>(null);
|
||||
const [form, setForm] = useState<TemplateFormState>({
|
||||
tenantId: item?.tenantId ?? '',
|
||||
applicationId: item?.applicationId ?? '',
|
||||
@@ -110,7 +111,15 @@ function TemplateFormModal({
|
||||
if (!normalized) {
|
||||
return;
|
||||
}
|
||||
setContent(`${form.content}\${${normalized}}`);
|
||||
const token = `\${${normalized}}`;
|
||||
const textarea = contentRef.current;
|
||||
const start = textarea?.selectionStart ?? form.content.length;
|
||||
const end = textarea?.selectionEnd ?? start;
|
||||
setContent(`${form.content.slice(0, start)}${token}${form.content.slice(end)}`);
|
||||
requestAnimationFrame(() => {
|
||||
contentRef.current?.focus();
|
||||
contentRef.current?.setSelectionRange(start + token.length, start + token.length);
|
||||
});
|
||||
}
|
||||
|
||||
function updateVariableExample(name: string, example: string) {
|
||||
@@ -170,6 +179,7 @@ function TemplateFormModal({
|
||||
placeholder="例如:尊敬的${name},您的验证码为${code}。"
|
||||
required
|
||||
rows={8}
|
||||
ref={contentRef}
|
||||
value={form.content}
|
||||
/>
|
||||
<div className="template-form-meta">
|
||||
|
||||
Reference in New Issue
Block a user