feat: model load balancing (#4926)

This commit is contained in:
Nite Knite
2024-06-05 00:13:29 +08:00
committed by GitHub
parent d1dbbc1e33
commit 37f292ea91
58 changed files with 1896 additions and 304 deletions

View File

@@ -1,16 +1,16 @@
import type { FC, MouseEventHandler } from 'react'
import React from 'react'
import type { FC, MouseEventHandler, PropsWithChildren } from 'react'
import React, { memo } from 'react'
import classNames from 'classnames'
import Spinner from '../spinner'
export type IButtonProps = {
export type IButtonProps = PropsWithChildren<{
type?: string
className?: string
disabled?: boolean
loading?: boolean
tabIndex?: number
children: React.ReactNode
onClick?: MouseEventHandler<HTMLDivElement>
}
}>
const Button: FC<IButtonProps> = ({
type,
@@ -21,22 +21,22 @@ const Button: FC<IButtonProps> = ({
loading = false,
tabIndex,
}) => {
let style = 'cursor-pointer'
let typeClassNames = 'cursor-pointer'
switch (type) {
case 'primary':
style = (disabled || loading) ? 'btn-primary-disabled' : 'btn-primary'
typeClassNames = (disabled || loading) ? 'btn-primary-disabled' : 'btn-primary'
break
case 'warning':
style = (disabled || loading) ? 'btn-warning-disabled' : 'btn-warning'
typeClassNames = (disabled || loading) ? 'btn-warning-disabled' : 'btn-warning'
break
default:
style = disabled ? 'btn-default-disabled' : 'btn-default'
typeClassNames = disabled ? 'btn-default-disabled' : 'btn-default'
break
}
return (
<div
className={`btn ${style} ${className && className}`}
className={classNames('btn', typeClassNames, className)}
tabIndex={tabIndex}
onClick={disabled ? undefined : onClick}
>
@@ -47,4 +47,4 @@ const Button: FC<IButtonProps> = ({
)
}
export default React.memo(Button)
export default memo(Button)