feat: 完成渠道界面
This commit is contained in:
parent
034ea8dfcc
commit
61a9f8001b
@ -56,23 +56,23 @@ const ChannelsTable = () => {
|
||||
title: '名称',
|
||||
dataIndex: 'name'
|
||||
},
|
||||
{
|
||||
title: '分组',
|
||||
dataIndex: 'group',
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<div>
|
||||
<Space spacing={2}>
|
||||
{
|
||||
text.split(',').map((item, index) => {
|
||||
return (renderGroup(item));
|
||||
})
|
||||
}
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
// {
|
||||
// title: '分组',
|
||||
// dataIndex: 'group',
|
||||
// render: (text, record, index) => {
|
||||
// return (
|
||||
// <div>
|
||||
// <Space spacing={2}>
|
||||
// {
|
||||
// text.split(',').map((item, index) => {
|
||||
// return (renderGroup(item));
|
||||
// })
|
||||
// }
|
||||
// </Space>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
@ -147,33 +147,33 @@ const ChannelsTable = () => {
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '权重',
|
||||
dataIndex: 'weight',
|
||||
render: (text, record, index) => {
|
||||
return (
|
||||
<div>
|
||||
<InputNumber
|
||||
style={{ width: 70 }}
|
||||
name="weight"
|
||||
onBlur={e => {
|
||||
manageChannel(record.id, 'weight', record, e.target.value);
|
||||
}}
|
||||
keepFocus={true}
|
||||
innerButtons
|
||||
defaultValue={record.weight}
|
||||
min={0}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
// {
|
||||
// title: '权重',
|
||||
// dataIndex: 'weight',
|
||||
// render: (text, record, index) => {
|
||||
// return (
|
||||
// <div>
|
||||
// <InputNumber
|
||||
// style={{ width: 70 }}
|
||||
// name="weight"
|
||||
// onBlur={e => {
|
||||
// manageChannel(record.id, 'weight', record, e.target.value);
|
||||
// }}
|
||||
// keepFocus={true}
|
||||
// innerButtons
|
||||
// defaultValue={record.weight}
|
||||
// min={0}
|
||||
// />
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
{
|
||||
title: '',
|
||||
dataIndex: 'operate',
|
||||
render: (text, record, index) => (
|
||||
<div>
|
||||
<SplitButtonGroup style={{ marginRight: 1 }} aria-label="测试操作项目组">
|
||||
{/* <SplitButtonGroup style={{ marginRight: 1 }} aria-label="测试操作项目组">
|
||||
<Button theme="light" onClick={() => {
|
||||
testChannel(record, '');
|
||||
}}>测试</Button>
|
||||
@ -181,8 +181,8 @@ const ChannelsTable = () => {
|
||||
>
|
||||
<Button style={{ padding: '8px 4px' }} type="primary" icon={<IconTreeTriangleDown />}></Button>
|
||||
</Dropdown>
|
||||
</SplitButtonGroup>
|
||||
{/*<Button theme='light' type='primary' style={{marginRight: 1}} onClick={()=>testChannel(record)}>测试</Button>*/}
|
||||
</SplitButtonGroup> */}
|
||||
<Button theme='light' type='primary' style={{ marginRight: 1 }} onClick={() => testChannel(record)}>测试</Button>
|
||||
<Popconfirm
|
||||
title="确定是否要删除此渠道?"
|
||||
content="此修改将不可逆"
|
||||
@ -443,11 +443,11 @@ const ChannelsTable = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const testAllChannels = async () => {
|
||||
const res = await API.get(`/api/channel/test`);
|
||||
const testChannels = async (scope) => {
|
||||
const res = await API.get(`/api/channel/test?scope=${scope}`);
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showInfo('已成功开始测试所有通道,请刷新页面查看结果。');
|
||||
showInfo('已成功开始测试通道,请刷新页面查看结果。');
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
@ -576,6 +576,7 @@ const ChannelsTable = () => {
|
||||
return (
|
||||
<>
|
||||
<EditChannel refresh={refresh} visible={showEdit} handleClose={closeEdit} editingChannel={editingChannel} />
|
||||
<div style={{ display: "flex", placeItems: "center", justifyContent: "space-between" }}>
|
||||
<Form onSubmit={() => {
|
||||
searchChannels(searchKeyword, searchGroup, searchModel);
|
||||
}} labelPosition="left">
|
||||
@ -583,7 +584,7 @@ const ChannelsTable = () => {
|
||||
<Space>
|
||||
<Form.Input
|
||||
field="search_keyword"
|
||||
label="搜索渠道关键词"
|
||||
label="搜索"
|
||||
placeholder="ID,名称和密钥 ..."
|
||||
value={searchKeyword}
|
||||
loading={searching}
|
||||
@ -591,7 +592,7 @@ const ChannelsTable = () => {
|
||||
setSearchKeyword(v.trim());
|
||||
}}
|
||||
/>
|
||||
<Form.Input
|
||||
{/* <Form.Input
|
||||
field="search_model"
|
||||
label="模型"
|
||||
placeholder="模型关键字"
|
||||
@ -604,49 +605,12 @@ const ChannelsTable = () => {
|
||||
<Form.Select field="group" label="分组" optionList={groupOptions} onChange={(v) => {
|
||||
setSearchGroup(v);
|
||||
searchChannels(searchKeyword, v, searchModel);
|
||||
}} />
|
||||
}} /> */}
|
||||
<Button label="查询" type="primary" htmlType="submit" className="btn-margin-right"
|
||||
style={{ marginRight: 8 }}>查询</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Form>
|
||||
<div style={{ marginTop: 10, display: 'flex' }}>
|
||||
<Space>
|
||||
<Space>
|
||||
<Typography.Text strong>使用ID排序</Typography.Text>
|
||||
<Switch checked={idSort} label="使用ID排序" uncheckedText="关" aria-label="是否用ID排序" onChange={(v) => {
|
||||
localStorage.setItem('id-sort', v + '');
|
||||
setIdSort(v);
|
||||
loadChannels(0, pageSize, v)
|
||||
.then()
|
||||
.catch((reason) => {
|
||||
showError(reason);
|
||||
});
|
||||
}}></Switch>
|
||||
</Space>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<Table className={'channel-table'} style={{ marginTop: 15 }} columns={columns} dataSource={pageData} pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: channelCount,
|
||||
pageSizeOpts: [10, 20, 50, 100],
|
||||
showSizeChanger: true,
|
||||
formatPageText: (page) => '',
|
||||
onPageSizeChange: (size) => {
|
||||
handlePageSizeChange(size).then();
|
||||
},
|
||||
onPageChange: handlePageChange
|
||||
}} loading={loading} onRow={handleRow} rowSelection={
|
||||
enableBatchDelete ?
|
||||
{
|
||||
onChange: (selectedRowKeys, selectedRows) => {
|
||||
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
||||
setSelectedChannels(selectedRows);
|
||||
}
|
||||
} : null
|
||||
} />
|
||||
<div style={{
|
||||
display: isMobile() ? '' : 'flex',
|
||||
marginTop: isMobile() ? 0 : -45,
|
||||
@ -662,22 +626,30 @@ const ChannelsTable = () => {
|
||||
});
|
||||
setShowEdit(true);
|
||||
}
|
||||
}>添加渠道</Button>
|
||||
}>添加新的渠道</Button>
|
||||
<Popconfirm
|
||||
title="确定?"
|
||||
okType={'warning'}
|
||||
onConfirm={testAllChannels}
|
||||
onConfirm={() => { testChannels("all") }}
|
||||
position={isMobile() ? 'top' : 'top'}
|
||||
>
|
||||
<Button theme="light" type="warning" style={{ marginRight: 8 }}>测试所有通道</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
title="确定?"
|
||||
okType={'warning'}
|
||||
onConfirm={() => { testChannels("disabled") }}
|
||||
position={isMobile() ? 'top' : 'top'}
|
||||
>
|
||||
<Button theme="light" type="warning" style={{ marginRight: 8 }}>测试禁用渠道</Button>
|
||||
</Popconfirm>
|
||||
{/* <Popconfirm
|
||||
title="确定?"
|
||||
okType={'secondary'}
|
||||
onConfirm={updateAllChannelsBalance}
|
||||
>
|
||||
<Button theme="light" type="secondary" style={{ marginRight: 8 }}>更新所有已启用通道余额</Button>
|
||||
</Popconfirm>
|
||||
</Popconfirm> */}
|
||||
<Popconfirm
|
||||
title="确定是否要删除禁用通道?"
|
||||
content="此修改将不可逆"
|
||||
@ -693,7 +665,7 @@ const ChannelsTable = () => {
|
||||
|
||||
{/*</div>*/}
|
||||
</div>
|
||||
<div style={{ marginTop: 20 }}>
|
||||
{/* <div style={{ marginTop: 20 }}>
|
||||
<Space>
|
||||
<Typography.Text strong>开启批量删除</Typography.Text>
|
||||
<Switch label="开启批量删除" uncheckedText="关" aria-label="是否开启批量删除" onChange={(v) => {
|
||||
@ -721,6 +693,43 @@ const ChannelsTable = () => {
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</div>
|
||||
<div style={{ marginTop: 10, display: 'flex' }}>
|
||||
<Space>
|
||||
<Space>
|
||||
<Typography.Text strong>使用ID排序</Typography.Text>
|
||||
<Switch checked={idSort} label="使用ID排序" uncheckedText="关" aria-label="是否用ID排序" onChange={(v) => {
|
||||
localStorage.setItem('id-sort', v + '');
|
||||
setIdSort(v);
|
||||
loadChannels(0, pageSize, v)
|
||||
.then()
|
||||
.catch((reason) => {
|
||||
showError(reason);
|
||||
});
|
||||
}}></Switch>
|
||||
</Space>
|
||||
</Space>
|
||||
</div> */}
|
||||
</div>
|
||||
<Table className={'channel-table'} style={{ marginTop: 15 }} columns={columns} dataSource={pageData} pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: channelCount,
|
||||
pageSizeOpts: [10, 20, 50, 100],
|
||||
showSizeChanger: true,
|
||||
formatPageText: (page) => '',
|
||||
onPageSizeChange: (size) => {
|
||||
handlePageSizeChange(size).then();
|
||||
},
|
||||
onPageChange: handlePageChange
|
||||
}} loading={loading} onRow={handleRow} rowSelection={
|
||||
enableBatchDelete ?
|
||||
{
|
||||
onChange: (selectedRowKeys, selectedRows) => {
|
||||
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
||||
setSelectedChannels(selectedRows);
|
||||
}
|
||||
} : null
|
||||
} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user