fix: connect remaining sms pages to real backend

This commit is contained in:
hectorzhao
2026-07-02 19:30:04 +08:00
parent 06562e42dd
commit 131f344ac4
50 changed files with 2074 additions and 6400 deletions
+8 -82
View File
@@ -103,85 +103,6 @@ const statusToneMap: Record<ChannelStatus, 'success' | 'neutral' | 'info' | 'dan
failed: 'danger',
};
const initialChannels: SmsChannel[] = [
{
id: '88827',
name: '行北-集市三甲医院-39',
carrier: 'mobile',
unitPrice: 3.9,
status: 'normal',
total: 1587451,
successRate: 88.2,
successCount: 1281035,
unknownRate: 29.1,
unknownCount: 31648,
failureRate: 8,
failureCount: 189,
gatewayHost: '10.10.39.8',
gatewayPort: '17890',
corpCode: 'CM88827',
account: 'acct88827',
accessNo: '10690088',
},
{
id: '77',
name: '移动-行北-上海甲医院-38',
carrier: 'mobile',
unitPrice: 3.8,
status: 'stopped',
total: 12867,
successRate: 68.2,
successCount: 9982,
unknownRate: 20.5,
unknownCount: 2671,
failureRate: 16.2,
failureCount: 189,
gatewayHost: '10.10.38.8',
gatewayPort: '17890',
corpCode: 'CM00077',
account: 'acct00077',
accessNo: '10690077',
},
{
id: '78',
name: '联通-行政-杭州甲医院-37',
carrier: 'unicom',
unitPrice: 3.7,
status: 'connecting',
total: 8123,
successRate: 78.2,
successCount: 0,
unknownRate: 1.2,
unknownCount: 12,
failureRate: 5.8,
failureCount: 0,
gatewayHost: '10.10.37.8',
gatewayPort: '17890',
corpCode: 'CU00078',
account: 'acct00078',
accessNo: '10690078',
},
{
id: '67',
name: '联通-行政-上海甲医院-34',
carrier: 'telecom',
unitPrice: 16.2,
status: 'failed',
total: 154,
successRate: 0,
successCount: 0,
unknownRate: 0,
unknownCount: 0,
failureRate: 100,
failureCount: 154,
gatewayHost: '10.10.34.8',
gatewayPort: '17890',
corpCode: 'CT00067',
account: 'acct00067',
accessNo: '10690067',
},
];
function mapApiChannel(channel: AdminChannel): SmsChannel {
const statusMap: Record<string, ChannelStatus> = {
active: 'normal',
@@ -400,7 +321,8 @@ function SmsTestModal({
export function AdminChannelsPage() {
const navigate = useNavigate();
const [channels, setChannels] = useState(initialChannels);
const [channels, setChannels] = useState<SmsChannel[]>([]);
const [error, setError] = useState('');
const [keyword, setKeyword] = useState('');
const [carrier, setCarrier] = useState('all');
const [status, setStatus] = useState('all');
@@ -411,8 +333,11 @@ export function AdminChannelsPage() {
useEffect(() => {
adminApi.listChannels()
.then((items) => setChannels(items.filter((item) => item.status !== 'deleted').map(mapApiChannel)))
.catch(() => undefined);
.then((items) => {
setChannels(items.filter((item) => item.status !== 'deleted').map(mapApiChannel));
setError('');
})
.catch((failure: Error) => setError(failure.message || '通道列表加载失败'));
}, []);
const filteredChannels = useMemo(
@@ -496,6 +421,7 @@ export function AdminChannelsPage() {
<Breadcrumb items={['短信通道管理']} />
<Button icon={<Plus size={16} />} onClick={() => setModal({ mode: 'create' })}></Button>
</div>
{error ? <p className="form-error">{error}</p> : null}
<div className="surface sms-channel-filter">
<div className="sms-channel-filter-grid">