import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'; import { useNavigate } from 'react-router-dom'; import { Alert, Button, Card, Collapse, Form, Input, InputNumber, Modal, Space, Switch, Table, Tag, Typography, message, } from 'antd'; import type { MockSmsCodeItem, SystemConfigFieldMeta, SystemConfigFormResponse } from '@dukang/shared-types'; import { request, type HqProfile } from '../lib/api'; import { ConfigImageField, ConfigImageListField } from '../components/ConfigMediaFields'; const { TextArea } = Input; function MockSmsCodePanel({ codes, loading }: { codes: MockSmsCodeItem[]; loading?: boolean }) { return (
最近 Mock 验证码(写入数据库,最新 50 条) size="small" rowKey="id" loading={loading} pagination={false} scroll={{ y: 240 }} locale={{ emptyText: '暂无记录,触发短信发送后将显示在此' }} columns={[ { title: '时间', dataIndex: 'createdAt', width: 168, render: (v: string) => new Date(v).toLocaleString(), }, { title: '手机号', dataIndex: 'phone', width: 120 }, { title: '场景', dataIndex: 'scene', width: 160 }, { title: '验证码', dataIndex: 'code', width: 88, render: (code: string) => ( {code} ), }, ]} dataSource={codes} />
); } function renderField( field: SystemConfigFieldMeta, configuredSecrets: string[], extra?: ReactNode, ) { const isConfiguredSecret = field.secret && configuredSecrets.includes(field.key); if (field.type === 'boolean') { return (
{field.label} {field.key} {field.requiresRestart ? 需重启 : 即时} } tooltip={field.description} valuePropName="checked" getValueFromEvent={(checked: boolean) => (checked ? 'true' : 'false')} getValueProps={(v: string) => ({ checked: v === 'true' || v === '1' })} > {extra}
); } if (field.type === 'image' || field.type === 'imageList') { return ( {field.label} {field.key} {field.requiresRestart ? 需重启 : 即时} } tooltip={field.description} trigger="onChange" getValueFromEvent={(v: unknown) => (typeof v === 'string' ? v : '')} normalize={(v) => (typeof v === 'string' ? v : '')} > {field.type === 'image' ? ( ) : ( )} ); } const input = field.type === 'textarea' ? (