diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js
index ea4e22a..c98f73f 100644
--- a/web/src/components/ChannelsTable.js
+++ b/web/src/components/ChannelsTable.js
@@ -49,9 +49,9 @@ function renderType(type) {
type2label[0] = { value: 0, text: '未知类型', color: 'grey' };
}
return (
-
- {type2label[type]?.text}
-
+
+ {type2label[type]?.text}
+
);
}
@@ -75,13 +75,13 @@ const ChannelsTable = () => {
dataIndex: 'group',
render: (text, record, index) => {
return (
-
-
- {text.split(',').map((item, index) => {
- return renderGroup(item);
- })}
-
-
+
+
+ {text.split(',').map((item, index) => {
+ return renderGroup(item);
+ })}
+
+
);
},
},
@@ -104,11 +104,11 @@ const ChannelsTable = () => {
let reason = otherInfo['status_reason'];
let time = otherInfo['status_time'];
return (
-
-
- {renderStatus(text)}
-
-
+
+
+ {renderStatus(text)}
+
+
);
} else {
return renderStatus(text);
@@ -127,27 +127,27 @@ const ChannelsTable = () => {
dataIndex: 'expired_time',
render: (text, record, index) => {
return (
-
-
-
-
- {renderQuota(record.used_quota)}
-
-
-
- {
- updateChannelBalance(record);
- }}
- >
- ${renderNumberWithPoint(record.balance)}
-
-
-
-
+
+
+
+
+ {renderQuota(record.used_quota)}
+
+
+
+ {
+ updateChannelBalance(record);
+ }}
+ >
+ ${renderNumberWithPoint(record.balance)}
+
+
+
+
);
},
},
@@ -156,19 +156,19 @@ const ChannelsTable = () => {
dataIndex: 'priority',
render: (text, record, index) => {
return (
-
- {
- manageChannel(record.id, 'priority', record, e.target.value);
- }}
- keepFocus={true}
- innerButtons
- defaultValue={record.priority}
- min={-999}
- />
-
+
+ {
+ manageChannel(record.id, 'priority', record, e.target.value);
+ }}
+ keepFocus={true}
+ innerButtons
+ defaultValue={record.priority}
+ min={-999}
+ />
+
);
},
},
@@ -177,19 +177,19 @@ const ChannelsTable = () => {
dataIndex: 'weight',
render: (text, record, index) => {
return (
-
- {
- manageChannel(record.id, 'weight', record, e.target.value);
- }}
- keepFocus={true}
- innerButtons
- defaultValue={record.weight}
- min={0}
- />
-
+
+ {
+ manageChannel(record.id, 'weight', record, e.target.value);
+ }}
+ keepFocus={true}
+ innerButtons
+ defaultValue={record.weight}
+ min={0}
+ />
+
);
},
},
@@ -197,95 +197,95 @@ const ChannelsTable = () => {
title: '',
dataIndex: 'operate',
render: (text, record, index) => (
-
-
+
+
+
-
- }
- >
-
-
- {/**/}
- {
- manageChannel(record.id, 'delete', record).then(() => {
- removeRecord(record.id);
- });
- }}
- >
-
-
- {record.status === 1 ? (
-
- ) : (
-
- )}
-
+
+
+ {/*
*/}
+
{
+ manageChannel(record.id, 'delete', record).then(() => {
+ removeRecord(record.id);
+ });
+ }}
+ >
+
- {
- copySelectedChannel(record.id);
- }}
+
+ {record.status === 1 ? (
+
-
+ 禁用
+
+ ) : (
+ {
+ manageChannel(record.id, 'enable', record);
+ }}
+ >
+ 启用
+
+ )}
+ {
+ setEditingChannel(record);
+ setShowEdit(true);
+ }}
+ >
+ 编辑
+
+ {
+ copySelectedChannel(record.id);
+ }}
+ >
+
+ 复制
+
+
+
),
},
];
@@ -301,7 +301,7 @@ const ChannelsTable = () => {
const [updatingBalance, setUpdatingBalance] = useState(false);
const [pageSize, setPageSize] = useState(ITEMS_PER_PAGE);
const [showPrompt, setShowPrompt] = useState(
- shouldShowPrompt('channel-test'),
+ shouldShowPrompt('channel-test'),
);
const [channelCount, setChannelCount] = useState(pageSize);
const [groupOptions, setGroupOptions] = useState([]);
@@ -357,7 +357,7 @@ const ChannelsTable = () => {
const loadChannels = async (startIdx, pageSize, idSort) => {
setLoading(true);
const res = await API.get(
- `/api/channel/?p=${startIdx}&page_size=${pageSize}&id_sort=${idSort}`,
+ `/api/channel/?p=${startIdx}&page_size=${pageSize}&id_sort=${idSort}`,
);
if (res === undefined) {
return;
@@ -379,7 +379,7 @@ const ChannelsTable = () => {
const copySelectedChannel = async (id) => {
const channelToCopy = channels.find(
- (channel) => String(channel.id) === String(id),
+ (channel) => String(channel.id) === String(id),
);
console.log(channelToCopy);
channelToCopy.name += '_复制';
@@ -412,14 +412,14 @@ const ChannelsTable = () => {
// console.log('default effect')
const localIdSort = localStorage.getItem('id-sort') === 'true';
const localPageSize =
- parseInt(localStorage.getItem('page-size')) || ITEMS_PER_PAGE;
+ parseInt(localStorage.getItem('page-size')) || ITEMS_PER_PAGE;
setIdSort(localIdSort);
setPageSize(localPageSize);
loadChannels(0, localPageSize, localIdSort)
- .then()
- .catch((reason) => {
- showError(reason);
- });
+ .then()
+ .catch((reason) => {
+ showError(reason);
+ });
fetchGroups().then();
loadChannelModels().then();
}, []);
@@ -476,27 +476,27 @@ const ChannelsTable = () => {
switch (status) {
case 1:
return (
-
- 已启用
-
+
+ 已启用
+
);
case 2:
return (
-
- 已禁用
-
+
+ 已禁用
+
);
case 3:
return (
-
- 自动禁用
-
+
+ 自动禁用
+
);
default:
return (
-
- 未知状态
-
+
+ 未知状态
+
);
}
};
@@ -506,33 +506,33 @@ const ChannelsTable = () => {
time = time.toFixed(2) + ' 秒';
if (responseTime === 0) {
return (
-
- 未测试
-
+
+ 未测试
+
);
} else if (responseTime <= 1000) {
return (
-
- {time}
-
+
+ {time}
+
);
} else if (responseTime <= 3000) {
return (
-
- {time}
-
+
+ {time}
+
);
} else if (responseTime <= 5000) {
return (
-
- {time}
-
+
+ {time}
+
);
} else {
return (
-
- {time}
-
+
+ {time}
+
);
}
};
@@ -546,7 +546,7 @@ const ChannelsTable = () => {
}
setSearching(true);
const res = await API.get(
- `/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}`,
+ `/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}`,
);
const { success, message, data } = res.data;
if (success) {
@@ -648,8 +648,8 @@ const ChannelsTable = () => {
};
let pageData = channels.slice(
- (activePage - 1) * pageSize,
- activePage * pageSize,
+ (activePage - 1) * pageSize,
+ activePage * pageSize,
);
const handlePageChange = (page) => {
@@ -665,10 +665,10 @@ const ChannelsTable = () => {
setPageSize(size);
setActivePage(1);
loadChannels(0, size, idSort)
- .then()
- .catch((reason) => {
- showError(reason);
- });
+ .then()
+ .catch((reason) => {
+ showError(reason);
+ });
};
const fetchGroups = async () => {
@@ -680,10 +680,10 @@ const ChannelsTable = () => {
return;
}
setGroupOptions(
- res.data.data.map((group) => ({
- label: group,
- value: group,
- })),
+ res.data.data.map((group) => ({
+ label: group,
+ value: group,
+ })),
);
} catch (error) {
showError(error.message);
@@ -707,226 +707,226 @@ const ChannelsTable = () => {
};
return (
- <>
-
-
-
+ <>
+
+
+
+
+
+ 使用ID排序
+ {
+ localStorage.setItem('id-sort', v + '');
+ setIdSort(v);
+ loadChannels(0, pageSize, v)
+ .then()
+ .catch((reason) => {
+ showError(reason);
+ });
+ }}
+ >
+
+
+
-
'',
- 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
- }
- />
- '',
+ 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
+ }
+ />
+
+
- {
+ setEditingChannel({
+ id: undefined,
+ });
+ setShowEdit(true);
+ }}
+ >
+ 添加渠道
+
+
+
+ 测试所有通道
+
+
+
+
+ 更新所有已启用通道余额
+
+
+
+
+ 删除禁用通道
+
+
+
+
+ 刷新
+
+
+ {/**/}
+
+ {/*
*/}
+
+
+
+ 开启批量删除
+ {
+ setEnableBatchDelete(v);
+ }}
+ >
+
{
- setEditingChannel({
- id: undefined,
- });
- setShowEdit(true);
- }}
+ disabled={!enableBatchDelete}
+ theme='light'
+ type='danger'
+ style={{ marginRight: 8 }}
>
- 添加渠道
+ 删除所选通道
-
-
- 测试所有通道
-
-
-
-
- 更新所有已启用通道余额
-
-
-
-
- 删除禁用通道
-
-
-
-
- 刷新
+
+
+
+ 修复数据库一致性
-
- {/*
*/}
-
- {/*
*/}
-
-
-
- 开启批量删除
- {
- setEnableBatchDelete(v);
- }}
- >
-
-
- 删除所选通道
-
-
-
-
- 修复数据库一致性
-
-
-
-
- >
+
+
+
+ >
);
};