mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-28 15:37:45 +08:00
refactor(web): 调整付费授权列表布局与文案
This commit is contained in:
1 parent
d33aa4bddf
commit
1de27dd28c
11 files changed
+122
-165
No files matched your search
@@ -1,4 +1,10 @@
|
||||
import { useCallback, useEffect, useState, type FormEvent } from "react"
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useState,
|
||||
type FormEvent,
|
||||
type ReactNode,
|
||||
} from "react"
|
||||
import { Loading03Icon } from "@hugeicons/core-free-icons"
|
||||
import { HugeiconsIcon } from "@hugeicons/react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -22,14 +28,6 @@ import {
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import {
|
||||
Item,
|
||||
ItemActions,
|
||||
ItemContent,
|
||||
ItemDescription,
|
||||
ItemGroup,
|
||||
ItemTitle,
|
||||
} from "@/components/ui/item"
|
||||
import { api } from "@/lib/api"
|
||||
import { publishLicenseStatus, type LicenseInfo } from "@/lib/license"
|
||||
import { cn } from "@/lib/utils"
|
||||
@@ -38,6 +36,25 @@ type MachineCodeResponse = {
|
||||
machine_code: string
|
||||
}
|
||||
|
||||
function LicenseRow({
|
||||
label,
|
||||
children,
|
||||
valueClassName,
|
||||
}: {
|
||||
label: string
|
||||
children: ReactNode
|
||||
valueClassName?: string
|
||||
}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_minmax(0,3fr)] items-center gap-4 px-4 py-3 text-sm">
|
||||
<dt className="min-w-0 break-words text-foreground">{label}</dt>
|
||||
<dd className={cn("min-w-0 break-words text-end", valueClassName)}>
|
||||
{children}
|
||||
</dd>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function formatDate(value: number | undefined, locale: string) {
|
||||
if (value == null) return "—"
|
||||
const date = new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(
|
||||
@@ -109,21 +126,6 @@ export function PaidLicenseCard({ className }: { className?: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function copyMachineCode() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(machineCode)
|
||||
showToast({
|
||||
status: "success",
|
||||
title: t("pages.license.machineCodeCopied"),
|
||||
})
|
||||
} catch {
|
||||
showToast({
|
||||
status: "error",
|
||||
title: t("pages.license.copyFailed"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const unavailable = info?.state === "invalid"
|
||||
const expired = info?.state === "expired"
|
||||
const dangerClassName = "text-red-600 dark:text-red-400"
|
||||
@@ -201,110 +203,65 @@ export function PaidLicenseCard({ className }: { className?: string }) {
|
||||
{t("pages.license.loading")}
|
||||
</p>
|
||||
)}
|
||||
<ItemGroup>
|
||||
{info !== null && (
|
||||
<>
|
||||
<Item variant="outline">
|
||||
<ItemContent>
|
||||
<ItemTitle>
|
||||
{t("licenseCapabilities.cloudComputer")}
|
||||
</ItemTitle>
|
||||
<ItemDescription>
|
||||
{t(
|
||||
info.state === "valid" &&
|
||||
info.allow_cloud_computer === true
|
||||
? "licenseCapabilities.granted"
|
||||
: "licenseCapabilities.notGranted"
|
||||
)}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
</Item>
|
||||
<Item variant="outline">
|
||||
<ItemContent>
|
||||
<ItemTitle>
|
||||
{t("licenseCapabilities.customBranding")}
|
||||
</ItemTitle>
|
||||
<ItemDescription>
|
||||
{t(
|
||||
info.state === "valid" &&
|
||||
info.allow_custom_branding === true
|
||||
? "licenseCapabilities.granted"
|
||||
: "licenseCapabilities.notGranted"
|
||||
)}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
</Item>
|
||||
</>
|
||||
)}
|
||||
<dl className="divide-y rounded-lg border">
|
||||
{info !== null && info.state !== "missing" && (
|
||||
<>
|
||||
<Item variant="outline">
|
||||
<ItemContent>
|
||||
<ItemTitle>{t("pages.license.seats")}</ItemTitle>
|
||||
<ItemDescription
|
||||
className={cn(unavailable && dangerClassName)}
|
||||
>
|
||||
{unavailable
|
||||
? t("pages.license.unavailable")
|
||||
: info.max_members == null
|
||||
? "—"
|
||||
: t("pages.license.seatsAllowed", {
|
||||
count: info.max_members,
|
||||
})}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
</Item>
|
||||
<Item variant="outline">
|
||||
<ItemContent className="min-w-0">
|
||||
<ItemTitle>{t("pages.license.client")}</ItemTitle>
|
||||
<ItemDescription
|
||||
className={cn(
|
||||
"line-clamp-none break-all",
|
||||
unavailable && dangerClassName
|
||||
)}
|
||||
>
|
||||
{unavailable
|
||||
? t("pages.license.unavailable")
|
||||
: info.client_name || info.client_id || "—"}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
</Item>
|
||||
<Item variant="outline">
|
||||
<ItemContent>
|
||||
<ItemTitle>{t("pages.license.validityPeriod")}</ItemTitle>
|
||||
<ItemDescription
|
||||
className={cn(
|
||||
"line-clamp-none",
|
||||
(unavailable || expired) && dangerClassName
|
||||
)}
|
||||
>
|
||||
{unavailable
|
||||
? t("pages.license.unavailable")
|
||||
: `${formatDate(info.not_valid_before, i18n.language)} - ${formatDate(info.not_valid_after, i18n.language)}`}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
</Item>
|
||||
<LicenseRow
|
||||
label={t("pages.license.client")}
|
||||
valueClassName={unavailable ? dangerClassName : undefined}
|
||||
>
|
||||
{unavailable
|
||||
? t("pages.license.unavailable")
|
||||
: info.client_name || info.client_id || "—"}
|
||||
</LicenseRow>
|
||||
<LicenseRow
|
||||
label={t("pages.license.validityPeriod")}
|
||||
valueClassName={
|
||||
unavailable || expired ? dangerClassName : undefined
|
||||
}
|
||||
>
|
||||
{unavailable
|
||||
? t("pages.license.unavailable")
|
||||
: `${formatDate(info.not_valid_before, i18n.language)} - ${formatDate(info.not_valid_after, i18n.language)}`}
|
||||
</LicenseRow>
|
||||
<LicenseRow
|
||||
label={t("pages.license.seats")}
|
||||
valueClassName={unavailable ? dangerClassName : undefined}
|
||||
>
|
||||
{unavailable
|
||||
? t("pages.license.unavailable")
|
||||
: info.max_members == null
|
||||
? "—"
|
||||
: t("pages.license.seatsAllowed", {
|
||||
count: info.max_members,
|
||||
})}
|
||||
</LicenseRow>
|
||||
</>
|
||||
)}
|
||||
<Item variant="outline">
|
||||
<ItemContent className="min-w-0">
|
||||
<ItemTitle>{t("pages.license.machineTitle")}</ItemTitle>
|
||||
<ItemDescription className="line-clamp-none break-all font-mono">
|
||||
<bdi dir="ltr">{machineCode || "—"}</bdi>
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
<ItemActions>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => void copyMachineCode()}
|
||||
disabled={!machineCode}
|
||||
>
|
||||
{t("pages.license.copy")}
|
||||
</Button>
|
||||
</ItemActions>
|
||||
</Item>
|
||||
</ItemGroup>
|
||||
{info !== null && (
|
||||
<>
|
||||
<LicenseRow label={t("licenseCapabilities.cloudComputer")}>
|
||||
{t(
|
||||
info.state === "valid" && info.allow_cloud_computer === true
|
||||
? "licenseCapabilities.granted"
|
||||
: "licenseCapabilities.notGranted"
|
||||
)}
|
||||
</LicenseRow>
|
||||
<LicenseRow label={t("licenseCapabilities.customBranding")}>
|
||||
{t(
|
||||
info.state === "valid" && info.allow_custom_branding === true
|
||||
? "licenseCapabilities.granted"
|
||||
: "licenseCapabilities.notGranted"
|
||||
)}
|
||||
</LicenseRow>
|
||||
</>
|
||||
)}
|
||||
<LicenseRow label={t("pages.license.machineTitle")}>
|
||||
<bdi dir="ltr" className="break-all font-mono">
|
||||
{machineCode || "—"}
|
||||
</bdi>
|
||||
</LicenseRow>
|
||||
</dl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const ar = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "أجهزة الكمبيوتر السحابية",
|
||||
customBranding: "تخصيص العلامة التجارية",
|
||||
granted: "متاح",
|
||||
notGranted: "غير متاح",
|
||||
cloudComputer: "وضع الكمبيوتر السحابي",
|
||||
customBranding: "تطبيق عميل مخصص",
|
||||
granted: "مدعوم",
|
||||
notGranted: "غير مدعوم",
|
||||
cloudLocked: "إنشاء أجهزة كمبيوتر سحابية غير متاح حاليًا.",
|
||||
brandingLocked: "تخصيص العلامة التجارية غير متاح حاليًا.",
|
||||
},
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const deDE = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "Cloud-Computer",
|
||||
customBranding: "Eigenes Branding",
|
||||
granted: "Verfügbar",
|
||||
notGranted: "Nicht verfügbar",
|
||||
cloudComputer: "Cloud-Computer-Modus",
|
||||
customBranding: "Angepasster Client",
|
||||
granted: "Unterstützt",
|
||||
notGranted: "Nicht unterstützt",
|
||||
cloudLocked: "Derzeit können keine Cloud-Computer erstellt werden.",
|
||||
brandingLocked: "Eigenes Branding ist derzeit nicht verfügbar.",
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export const enUS = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "Cloud computers",
|
||||
customBranding: "Custom branding",
|
||||
granted: "Available",
|
||||
notGranted: "Unavailable",
|
||||
cloudComputer: "Cloud computer mode",
|
||||
customBranding: "Customized client",
|
||||
granted: "Supported",
|
||||
notGranted: "Not supported",
|
||||
cloudLocked: "Creating cloud computers is currently unavailable.",
|
||||
brandingLocked: "Custom branding is currently unavailable.",
|
||||
},
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const es419 = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "Computadoras en la nube",
|
||||
customBranding: "Marca personalizada",
|
||||
granted: "Disponible",
|
||||
notGranted: "No disponible",
|
||||
cloudComputer: "Modo de computadora en la nube",
|
||||
customBranding: "Cliente personalizado",
|
||||
granted: "Compatible",
|
||||
notGranted: "No compatible",
|
||||
cloudLocked: "Por ahora no se pueden crear computadoras en la nube.",
|
||||
brandingLocked: "La personalización de la marca no está disponible.",
|
||||
},
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const frFR = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "Ordinateurs cloud",
|
||||
customBranding: "Personnalisation de la marque",
|
||||
granted: "Disponible",
|
||||
notGranted: "Indisponible",
|
||||
cloudComputer: "Mode ordinateur cloud",
|
||||
customBranding: "Client personnalisé",
|
||||
granted: "Pris en charge",
|
||||
notGranted: "Non pris en charge",
|
||||
cloudLocked: "La création d’ordinateurs cloud est actuellement indisponible.",
|
||||
brandingLocked: "La personnalisation de la marque est actuellement indisponible.",
|
||||
},
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const jaJP = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "クラウド PC",
|
||||
customBranding: "ブランドのカスタマイズ",
|
||||
granted: "利用可能",
|
||||
notGranted: "利用不可",
|
||||
cloudComputer: "クラウド PC モード",
|
||||
customBranding: "カスタムクライアント",
|
||||
granted: "対応",
|
||||
notGranted: "非対応",
|
||||
cloudLocked: "現在、クラウド PC は作成できません。",
|
||||
brandingLocked: "現在、ブランドをカスタマイズできません。",
|
||||
},
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const koKR = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "클라우드 컴퓨터",
|
||||
customBranding: "사용자 지정 브랜드",
|
||||
granted: "사용 가능",
|
||||
notGranted: "사용 불가",
|
||||
cloudComputer: "클라우드 컴퓨터 모드",
|
||||
customBranding: "맞춤형 클라이언트",
|
||||
granted: "지원",
|
||||
notGranted: "미지원",
|
||||
cloudLocked: "현재 새 클라우드 컴퓨터를 만들 수 없습니다.",
|
||||
brandingLocked: "현재 브랜드를 변경할 수 없습니다.",
|
||||
},
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const ruRU = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "Облачные компьютеры",
|
||||
customBranding: "Настройка бренда",
|
||||
granted: "Доступно",
|
||||
notGranted: "Недоступно",
|
||||
cloudComputer: "Режим облачного компьютера",
|
||||
customBranding: "Индивидуальная версия клиента",
|
||||
granted: "Поддерживается",
|
||||
notGranted: "Не поддерживается",
|
||||
cloudLocked: "Создание облачных компьютеров сейчас недоступно.",
|
||||
brandingLocked: "Настройка бренда сейчас недоступна.",
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export const zhCN = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "云电脑",
|
||||
customBranding: "自定义品牌",
|
||||
granted: "可用",
|
||||
notGranted: "不可用",
|
||||
cloudComputer: "云电脑模式",
|
||||
customBranding: "定制客户端",
|
||||
granted: "支持",
|
||||
notGranted: "不支持",
|
||||
cloudLocked: "当前无法新建云电脑。",
|
||||
brandingLocked: "当前无法编辑自定义品牌。",
|
||||
},
|
||||
@@ -1027,7 +1027,7 @@ export const zhCN = {
|
||||
title: "付费授权",
|
||||
description: "用于查看和管理付费授权",
|
||||
seats: "授权席位",
|
||||
seatsAllowed: "允许最多 {{count}} 个用户使用",
|
||||
seatsAllowed: "最多允许 {{count}} 个成员使用",
|
||||
unavailable: "授权不可用",
|
||||
client: "授权客户",
|
||||
validityPeriod: "授权时间",
|
||||
|
||||
@@ -2,10 +2,10 @@ import { enUS } from "./en-US.ts"
|
||||
|
||||
export const zhTW = {
|
||||
licenseCapabilities: {
|
||||
cloudComputer: "雲端電腦",
|
||||
customBranding: "自訂品牌",
|
||||
granted: "可用",
|
||||
notGranted: "無法使用",
|
||||
cloudComputer: "雲端電腦模式",
|
||||
customBranding: "客製化用戶端",
|
||||
granted: "支援",
|
||||
notGranted: "不支援",
|
||||
cloudLocked: "目前無法建立雲端電腦。",
|
||||
brandingLocked: "目前無法編輯自訂品牌。",
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user