import type { FormEvent } from 'react'
import {
CheckCircle2,
KeySquare,
Link2,
Loader2,
RefreshCw,
XCircle,
} from 'lucide-react'
import type { LicenseStatus } from '../api/license'
export function LicenseHeader() {
return (
)
}
export function LicenseBindPanel({
bindKey,
binding,
onBind,
onBindKeyChange,
}: {
bindKey: string
binding: boolean
onBind: (event: FormEvent) => void
onBindKeyChange: (value: string) => void
}) {
return (
绑定许可证
输入从授权服务器获取的许可证密钥,激活后按授权额度开放更多平台用户。
)
}
export function LicenseStatusPanel({
status,
loadingStatus,
active,
isExpired,
onRefresh,
onHeartbeat,
}: {
status: LicenseStatus | null
loadingStatus: boolean
active: boolean
isExpired: boolean
onRefresh: () => void
onHeartbeat: () => void
}) {
const activation = status?.activation
if (loadingStatus) {
return (
)
}
return (
{active && !isExpired ? (
) : (
)}
当前状态
{active && (
)}
{!active && (
)}
{active && activation && (
)}
{isExpired && (
此许可证已过期,部分功能可能受限。请获取新的许可证密钥。
)}
)
}
export function LicenseInactiveTip({ active, loadingStatus }: { active: boolean; loadingStatus: boolean }) {
if (active || loadingStatus) return null
return (
需要获取许可证?请联系管理员获取 MediaStationGo 授权密钥。
授权服务器地址可在系统设置中配置
)
}
function StatusBadge({
label,
value,
mono,
className,
}: {
label: string
value: string
mono?: boolean
className?: string
}) {
return (
)
}
function fmtDate(iso: string | null | undefined): string {
if (!iso) return '永久'
return new Date(iso).toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
}
function fmtDateTime(iso: string | null | undefined): string {
if (!iso) return '—'
return new Date(iso).toLocaleString('zh-CN')
}
function fmtUserLimit(maxUsers: number | null | undefined, unlimited?: boolean): string {
if (unlimited || maxUsers == null) return '不限制'
return `${maxUsers} 人`
}