mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-06 14:23:41 +08:00
feat: 无可选分组时关闭令牌分组功能 #485
This commit is contained in:
@@ -273,150 +273,150 @@ const EditToken = (props) => {
|
|||||||
>
|
>
|
||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
<Input
|
<Input
|
||||||
style={{marginTop: 20}}
|
style={{ marginTop: 20 }}
|
||||||
label='名称'
|
label='名称'
|
||||||
name='name'
|
name='name'
|
||||||
placeholder={'请输入名称'}
|
placeholder={'请输入名称'}
|
||||||
onChange={(value) => handleInputChange('name', value)}
|
onChange={(value) => handleInputChange('name', value)}
|
||||||
value={name}
|
value={name}
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
required={!isEdit}
|
required={!isEdit}
|
||||||
/>
|
/>
|
||||||
<Divider/>
|
<Divider />
|
||||||
<DatePicker
|
<DatePicker
|
||||||
label='过期时间'
|
label='过期时间'
|
||||||
name='expired_time'
|
name='expired_time'
|
||||||
placeholder={'请选择过期时间'}
|
placeholder={'请选择过期时间'}
|
||||||
onChange={(value) => handleInputChange('expired_time', value)}
|
onChange={(value) => handleInputChange('expired_time', value)}
|
||||||
value={expired_time}
|
value={expired_time}
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
type='dateTime'
|
type='dateTime'
|
||||||
/>
|
/>
|
||||||
<div style={{marginTop: 20}}>
|
<div style={{ marginTop: 20 }}>
|
||||||
<Space>
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
type={'tertiary'}
|
type={'tertiary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setExpiredTime(0, 0, 0, 0);
|
setExpiredTime(0, 0, 0, 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
永不过期
|
永不过期
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type={'tertiary'}
|
type={'tertiary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setExpiredTime(0, 0, 1, 0);
|
setExpiredTime(0, 0, 1, 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
一小时
|
一小时
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type={'tertiary'}
|
type={'tertiary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setExpiredTime(1, 0, 0, 0);
|
setExpiredTime(1, 0, 0, 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
一个月
|
一个月
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type={'tertiary'}
|
type={'tertiary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setExpiredTime(0, 1, 0, 0);
|
setExpiredTime(0, 1, 0, 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
一天
|
一天
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider/>
|
<Divider />
|
||||||
<Banner
|
<Banner
|
||||||
type={'warning'}
|
type={'warning'}
|
||||||
description={
|
description={
|
||||||
'注意,令牌的额度仅用于限制令牌本身的最大额度使用量,实际的使用受到账户的剩余额度限制。'
|
'注意,令牌的额度仅用于限制令牌本身的最大额度使用量,实际的使用受到账户的剩余额度限制。'
|
||||||
}
|
}
|
||||||
></Banner>
|
></Banner>
|
||||||
<div style={{marginTop: 20}}>
|
<div style={{ marginTop: 20 }}>
|
||||||
<Typography.Text>{`额度${renderQuotaWithPrompt(remain_quota)}`}</Typography.Text>
|
<Typography.Text>{`额度${renderQuotaWithPrompt(remain_quota)}`}</Typography.Text>
|
||||||
</div>
|
</div>
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
style={{marginTop: 8}}
|
style={{ marginTop: 8 }}
|
||||||
name='remain_quota'
|
name='remain_quota'
|
||||||
placeholder={'请输入额度'}
|
placeholder={'请输入额度'}
|
||||||
onChange={(value) => handleInputChange('remain_quota', value)}
|
onChange={(value) => handleInputChange('remain_quota', value)}
|
||||||
value={remain_quota}
|
value={remain_quota}
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
type='number'
|
type='number'
|
||||||
// position={'top'}
|
// position={'top'}
|
||||||
data={[
|
data={[
|
||||||
{value: 500000, label: '1$'},
|
{ value: 500000, label: '1$' },
|
||||||
{value: 5000000, label: '10$'},
|
{ value: 5000000, label: '10$' },
|
||||||
{value: 25000000, label: '50$'},
|
{ value: 25000000, label: '50$' },
|
||||||
{value: 50000000, label: '100$'},
|
{ value: 50000000, label: '100$' },
|
||||||
{value: 250000000, label: '500$'},
|
{ value: 250000000, label: '500$' },
|
||||||
{value: 500000000, label: '1000$'},
|
{ value: 500000000, label: '1000$' },
|
||||||
]}
|
]}
|
||||||
disabled={unlimited_quota}
|
disabled={unlimited_quota}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!isEdit && (
|
{!isEdit && (
|
||||||
<>
|
<>
|
||||||
<div style={{marginTop: 20}}>
|
<div style={{ marginTop: 20 }}>
|
||||||
<Typography.Text>新建数量</Typography.Text>
|
<Typography.Text>新建数量</Typography.Text>
|
||||||
</div>
|
</div>
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
style={{marginTop: 8}}
|
style={{ marginTop: 8 }}
|
||||||
label='数量'
|
label='数量'
|
||||||
placeholder={'请选择或输入创建令牌的数量'}
|
placeholder={'请选择或输入创建令牌的数量'}
|
||||||
onChange={(value) => handleTokenCountChange(value)}
|
onChange={(value) => handleTokenCountChange(value)}
|
||||||
onSelect={(value) => handleTokenCountChange(value)}
|
onSelect={(value) => handleTokenCountChange(value)}
|
||||||
value={tokenCount.toString()}
|
value={tokenCount.toString()}
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
type='number'
|
type='number'
|
||||||
data={[
|
data={[
|
||||||
{value: 10, label: '10个'},
|
{ value: 10, label: '10个' },
|
||||||
{value: 20, label: '20个'},
|
{ value: 20, label: '20个' },
|
||||||
{value: 30, label: '30个'},
|
{ value: 30, label: '30个' },
|
||||||
{value: 100, label: '100个'},
|
{ value: 100, label: '100个' },
|
||||||
]}
|
]}
|
||||||
disabled={unlimited_quota}
|
disabled={unlimited_quota}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
style={{marginTop: 8}}
|
style={{ marginTop: 8 }}
|
||||||
type={'warning'}
|
type={'warning'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setUnlimitedQuota();
|
setUnlimitedQuota();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{unlimited_quota ? '取消无限额度' : '设为无限额度'}
|
{unlimited_quota ? '取消无限额度' : '设为无限额度'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<Divider/>
|
<Divider />
|
||||||
<div style={{marginTop: 10}}>
|
<div style={{ marginTop: 10 }}>
|
||||||
<Typography.Text>IP白名单(请勿过度信任此功能)</Typography.Text>
|
<Typography.Text>IP白名单(请勿过度信任此功能)</Typography.Text>
|
||||||
</div>
|
</div>
|
||||||
<TextArea
|
<TextArea
|
||||||
label='IP白名单'
|
label='IP白名单'
|
||||||
name='allow_ips'
|
name='allow_ips'
|
||||||
placeholder={'允许的IP,一行一个'}
|
placeholder={'允许的IP,一行一个'}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
handleInputChange('allow_ips', value);
|
handleInputChange('allow_ips', value);
|
||||||
}}
|
}}
|
||||||
value={inputs.allow_ips}
|
value={inputs.allow_ips}
|
||||||
style={{fontFamily: 'JetBrains Mono, Consolas'}}
|
style={{ fontFamily: 'JetBrains Mono, Consolas' }}
|
||||||
/>
|
/>
|
||||||
<div style={{marginTop: 10, display: 'flex'}}>
|
<div style={{ marginTop: 10, display: 'flex' }}>
|
||||||
<Space>
|
<Space>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
name='model_limits_enabled'
|
name='model_limits_enabled'
|
||||||
checked={model_limits_enabled}
|
checked={model_limits_enabled}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
handleInputChange('model_limits_enabled', e.target.checked)
|
handleInputChange('model_limits_enabled', e.target.checked)
|
||||||
}
|
}
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
<Typography.Text>
|
<Typography.Text>
|
||||||
启用模型限制(非必要,不建议启用)
|
启用模型限制(非必要,不建议启用)
|
||||||
@@ -425,26 +425,26 @@ const EditToken = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
style={{marginTop: 8}}
|
style={{ marginTop: 8 }}
|
||||||
placeholder={'请选择该渠道所支持的模型'}
|
placeholder={'请选择该渠道所支持的模型'}
|
||||||
name='models'
|
name='models'
|
||||||
required
|
required
|
||||||
multiple
|
multiple
|
||||||
selection
|
selection
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
handleInputChange('model_limits', value);
|
handleInputChange('model_limits', value);
|
||||||
}}
|
}}
|
||||||
value={inputs.model_limits}
|
value={inputs.model_limits}
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
optionList={models}
|
optionList={models}
|
||||||
disabled={!model_limits_enabled}
|
disabled={!model_limits_enabled}
|
||||||
/>
|
/>
|
||||||
|
<div style={{ marginTop: 10 }}>
|
||||||
<div style={{marginTop: 10}}>
|
|
||||||
<Typography.Text>令牌分组,默认为用户的分组</Typography.Text>
|
<Typography.Text>令牌分组,默认为用户的分组</Typography.Text>
|
||||||
</div>
|
</div>
|
||||||
<Select
|
{groups.length > 0 ?
|
||||||
style={{marginTop: 8}}
|
<Select
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
placeholder={'令牌分组,默认为用户的分组'}
|
placeholder={'令牌分组,默认为用户的分组'}
|
||||||
name='gruop'
|
name='gruop'
|
||||||
required
|
required
|
||||||
@@ -455,7 +455,14 @@ const EditToken = (props) => {
|
|||||||
value={inputs.group}
|
value={inputs.group}
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
optionList={groups}
|
optionList={groups}
|
||||||
/>
|
/>:
|
||||||
|
<Select
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
|
placeholder={'管理员未设置用户可选分组'}
|
||||||
|
name='gruop'
|
||||||
|
disabled={true}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</Spin>
|
</Spin>
|
||||||
</SideSheet>
|
</SideSheet>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user