mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-18 17:51:28 +00:00
feat: able to set top up link now
This commit is contained in:
@@ -25,6 +25,7 @@ const SystemSetting = () => {
|
||||
TurnstileSecretKey: '',
|
||||
RegisterEnabled: '',
|
||||
QuotaForNewUser: 0,
|
||||
TopUpLink: ''
|
||||
});
|
||||
let originInputs = {};
|
||||
let [loading, setLoading] = useState(false);
|
||||
@@ -65,7 +66,7 @@ const SystemSetting = () => {
|
||||
}
|
||||
const res = await API.put('/api/option', {
|
||||
key,
|
||||
value,
|
||||
value
|
||||
});
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
@@ -88,7 +89,8 @@ const SystemSetting = () => {
|
||||
name === 'WeChatAccountQRCodeImageURL' ||
|
||||
name === 'TurnstileSiteKey' ||
|
||||
name === 'TurnstileSecretKey' ||
|
||||
name === 'QuotaForNewUser'
|
||||
name === 'QuotaForNewUser' ||
|
||||
name === 'TopUpLink'
|
||||
) {
|
||||
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
||||
} else {
|
||||
@@ -101,6 +103,15 @@ const SystemSetting = () => {
|
||||
await updateOption('ServerAddress', ServerAddress);
|
||||
};
|
||||
|
||||
const submitOperationConfig = async () => {
|
||||
if (originInputs['QuotaForNewUser'] !== inputs.QuotaForNewUser) {
|
||||
await updateOption('QuotaForNewUser', inputs.QuotaForNewUser);
|
||||
}
|
||||
if (originInputs['TopUpLink'] !== inputs.TopUpLink) {
|
||||
await updateOption('TopUpLink', inputs.TopUpLink);
|
||||
}
|
||||
}
|
||||
|
||||
const submitSMTP = async () => {
|
||||
if (originInputs['SMTPServer'] !== inputs.SMTPServer) {
|
||||
await updateOption('SMTPServer', inputs.SMTPServer);
|
||||
@@ -244,10 +255,17 @@ const SystemSetting = () => {
|
||||
min='0'
|
||||
placeholder='例如:100'
|
||||
/>
|
||||
<Form.Input
|
||||
label='充值链接'
|
||||
name='TopUpLink'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
value={inputs.TopUpLink}
|
||||
type='link'
|
||||
placeholder='例如发卡网站的购买链接'
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Button onClick={()=>{
|
||||
updateOption('QuotaForNewUser', inputs.QuotaForNewUser).then();
|
||||
}}>保存运营设置</Form.Button>
|
||||
<Form.Button onClick={submitOperationConfig}>保存运营设置</Form.Button>
|
||||
<Divider />
|
||||
<Header as='h3'>
|
||||
配置 SMTP
|
||||
|
@@ -37,6 +37,7 @@ const TokensTable = () => {
|
||||
const [showTopUpModal, setShowTopUpModal] = useState(false);
|
||||
const [targetTokenIdx, setTargetTokenIdx] = useState(0);
|
||||
const [redemptionCode, setRedemptionCode] = useState('');
|
||||
const [topUpLink, setTopUpLink] = useState('');
|
||||
|
||||
const loadTokens = async (startIdx) => {
|
||||
const res = await API.get(`/api/token/?p=${startIdx}`);
|
||||
@@ -71,6 +72,13 @@ const TokensTable = () => {
|
||||
.catch((reason) => {
|
||||
showError(reason);
|
||||
});
|
||||
let status = localStorage.getItem('status');
|
||||
if (status) {
|
||||
status = JSON.parse(status);
|
||||
if (status.top_up_link) {
|
||||
setTopUpLink(status.top_up_link);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
const manageToken = async (id, action, idx) => {
|
||||
@@ -342,6 +350,11 @@ const TokensTable = () => {
|
||||
<Modal.Content>
|
||||
<Modal.Description>
|
||||
{/*<Image src={status.wechat_qrcode} fluid />*/}
|
||||
{
|
||||
topUpLink && <p>
|
||||
<a target='_blank' href={topUpLink}>点击此处获取兑换码</a>
|
||||
</p>
|
||||
}
|
||||
<Form size='large'>
|
||||
<Form.Input
|
||||
fluid
|
||||
|
Reference in New Issue
Block a user