diff --git a/web/src/views/Channel/component/TableRow.js b/web/src/views/Channel/component/TableRow.js
index cedc5911..84c35b74 100644
--- a/web/src/views/Channel/component/TableRow.js
+++ b/web/src/views/Channel/component/TableRow.js
@@ -1,7 +1,8 @@
import PropTypes from 'prop-types';
import { useState } from 'react';
-import { showInfo } from 'utils/common';
+import { showInfo, showError } from 'utils/common';
+import { API } from 'utils/api';
import { CHANNEL_OPTIONS } from 'constants/ChannelConstants';
import {
@@ -19,6 +20,7 @@ import {
DialogContent,
DialogContentText,
DialogTitle,
+ Tooltip,
Button
} from '@mui/material';
@@ -36,6 +38,7 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
const [statusSwitch, setStatusSwitch] = useState(item.status);
const [priorityValve, setPriority] = useState(item.priority);
const [responseTimeData, setResponseTimeData] = useState({ test_time: item.test_time, response_time: item.response_time });
+ const [itemBalance, setItemBalance] = useState(item.balance);
const handleDeleteOpen = () => {
handleCloseMenu();
@@ -77,6 +80,18 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
}
};
+ const updateChannelBalance = async () => {
+ const res = await API.get(`/api/channel/update_balance/${item.id}`);
+ const { success, message, balance } = res.data;
+ if (success) {
+ setItemBalance(balance);
+
+ showInfo(`余额更新成功!`);
+ } else {
+ showError(message);
+ }
+ };
+
const handleDelete = async () => {
handleCloseMenu();
await manageChannel(item.id, 'delete', '');
@@ -116,7 +131,11 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
handle_action={handleResponseTime}
/>
- {item.balance}
+
+
+ {renderBalance(itemBalance)}
+
+
优先级
@@ -192,3 +211,24 @@ ChannelTableRow.propTypes = {
handleOpenModal: PropTypes.func,
setModalChannelId: PropTypes.func
};
+
+function renderBalance(type, balance) {
+ switch (type) {
+ case 1: // OpenAI
+ return ${balance.toFixed(2)};
+ case 4: // CloseAI
+ return ¥{balance.toFixed(2)};
+ case 8: // 自定义
+ return ${balance.toFixed(2)};
+ case 5: // OpenAI-SB
+ return ¥{(balance / 10000).toFixed(2)};
+ case 10: // AI Proxy
+ return {renderNumber(balance)};
+ case 12: // API2GPT
+ return ¥{balance.toFixed(2)};
+ case 13: // AIGC2D
+ return {renderNumber(balance)};
+ default:
+ return 不支持;
+ }
+}