This commit is contained in:
wood
2023-11-11 03:21:46 +08:00
parent 49ea44c65b
commit 96793c3e9c
7 changed files with 41 additions and 162 deletions

View File

@@ -327,7 +327,7 @@ const LogsTable = () => {
onClick={() => {
sortLog('created_time');
}}
width={3}
width={2}
>
时间
</Table.HeaderCell>
@@ -412,9 +412,9 @@ const LogsTable = () => {
onClick={() => {
sortLog('content');
}}
width={isAdminUser ? 3 : 5}
width={isAdminUser ? 4 : 6}
>
详情
详情(1=$0.002/1K tokens)
</Table.HeaderCell>
</Table.Row>
</Table.Header>

View File

@@ -7,31 +7,8 @@ const TopUp = () => {
const [redemptionCode, setRedemptionCode] = useState('');
const [topUpLink, setTopUpLink] = useState('');
const [userQuota, setUserQuota] = useState(0);
const [userGroup, setUserGroup] = useState('');
const [isSubmitting, setIsSubmitting] = useState(false);
// 升级用户组
const updateUserGroupIfNecessary = async (quota) => {
if (userGroup === 'vip') return; // 添加这一行
if (quota >= 5*500000) {
try {
const res = await API.post('/api/user/manage', {
username: localStorage.getItem('username'),
newGroup: 'vip'
});
const { success, message } = res.data;
if (success) {
showSuccess('已成功升级为 VIP 会员!');
} else {
showError('请右下角联系客服');
}
} catch (err) {
showError('请右下角联系客服');
}
}
};
const topUp = async () => {
if (redemptionCode === '') {
showInfo('请输入充值码!')
@@ -42,12 +19,15 @@ const TopUp = () => {
const res = await API.post('/api/user/topup', {
key: redemptionCode
});
const { success, message, data } = res.data;
const { success, message, data ,upgradedToVIP } = res.data;
if (success) {
showSuccess('充值成功!');
if (upgradedToVIP) { // 如果用户成功升级为 VIP
showSuccess('充值成功,升级为 VIP 会员');
} else {
showSuccess('充值成功');
}
setUserQuota((quota) => {
const newQuota = quota + data;
updateUserGroupIfNecessary(newQuota);
return newQuota;
});
setRedemptionCode('');
@@ -55,7 +35,7 @@ const TopUp = () => {
showError(message);
}
} catch (err) {
showError('请右下角联系客服');
showError('失败,请右下角联系客服');
} finally {
setIsSubmitting(false);
}
@@ -74,7 +54,7 @@ const TopUp = () => {
const { success, message, data } = res.data;
if (success) {
setUserQuota(data.quota);
setUserGroup(data.group); // 添加这一行
} else {
showError(message);
}