更新 Speed/CreateServerModal.tsx

This commit is contained in:
ste87 2026-03-14 16:16:49 +08:00
parent c453288a58
commit 72016cee81

View File

@ -68,7 +68,7 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
z.literal(''), z.literal(''),
z.preprocess(Number, z.number().min(0)), z.preprocess(Number, z.number().min(0)),
]), ]),
rateLimit: z.union([ // 新增 rateLimit: z.union([
z.literal(''), z.literal(''),
z.preprocess(Number, z.number().min(0)), z.preprocess(Number, z.number().min(0)),
]), ]),
@ -83,7 +83,7 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
nodeId: z.preprocess(Number, z.number()), nodeId: z.preprocess(Number, z.number()),
userId: z.preprocess(Number, z.number()), userId: z.preprocess(Number, z.number()),
vmid: z.union([ vmid: z.union([
z.preprocess(Number, z.number().min(100).max(999999999)), z.preprocess(Number, z.number().int().min(100).max(999999999)),
z.literal(''), z.literal(''),
]), ]),
hostname: hostname().max(191).nonempty(), hostname: hostname().max(191).nonempty(),
@ -103,6 +103,10 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
z.literal(''), z.literal(''),
z.preprocess(Number, z.number().min(0)), z.preprocess(Number, z.number().min(0)),
]), ]),
rateLimit: z.union([
z.literal(''),
z.preprocess(Number, z.number().min(0)),
]),
accountPassword: password(usKeyboardCharacters()).optional(), accountPassword: password(usKeyboardCharacters()).optional(),
shouldCreateServer: z.literal(false), shouldCreateServer: z.literal(false),
startOnCompletion: z.boolean(), startOnCompletion: z.boolean(),
@ -129,6 +133,7 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
snapshotLimit: '0', snapshotLimit: '0',
backupLimit: '', backupLimit: '',
bandwidthLimit: '', bandwidthLimit: '',
rateLimit: '',
accountPassword: '', accountPassword: '',
shouldCreateServer: true, shouldCreateServer: true,
startOnCompletion: false, startOnCompletion: false,
@ -148,6 +153,7 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
snapshotLimit, snapshotLimit,
backupLimit, backupLimit,
bandwidthLimit, bandwidthLimit,
rateLimit,
addressIds, addressIds,
accountPassword, accountPassword,
...data ...data
@ -165,6 +171,7 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
backups: backupLimit !== '' ? backupLimit : null, backups: backupLimit !== '' ? backupLimit : null,
bandwidth: bandwidth:
bandwidthLimit !== '' ? bandwidthLimit * 1048576 : null, bandwidthLimit !== '' ? bandwidthLimit * 1048576 : null,
rateLimit: rateLimit !== '' ? Number(rateLimit) : null,
addressIds, addressIds,
}, },
accountPassword: accountPassword ? accountPassword : null, accountPassword: accountPassword ? accountPassword : null,
@ -257,6 +264,14 @@ const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
} }
/> />
</div> </div>
<TextInputForm
name={'rateLimit'}
label={`${t('rate_limit')} (MiB/s)`}
placeholder={
t('limit_placeholder') ??
'Leave blank for no limit'
}
/>
<TextInputForm <TextInputForm
name={'accountPassword'} name={'accountPassword'}
label={tStrings('system_os_password')} label={tStrings('system_os_password')}