2026-07-30 09:21:55 +08:00
|
|
|
import { CloudUpload, Download, FileCode2, Search } from "lucide-solid";
|
|
|
|
|
import { createMemo, For, Show } from "solid-js";
|
2026-07-30 15:16:02 +08:00
|
|
|
import { EmptyState } from "../../components/feedback/empty-state";
|
|
|
|
|
import { Page } from "../../components/layout/page";
|
|
|
|
|
import { PageHeading } from "../../components/layout/page-heading";
|
|
|
|
|
import { Button, IconLink } from "../../components/ui/button";
|
|
|
|
|
import { Card, CardHeader } from "../../components/ui/card";
|
|
|
|
|
import {
|
|
|
|
|
Table,
|
|
|
|
|
TableBody,
|
|
|
|
|
TableCell,
|
|
|
|
|
TableHead,
|
|
|
|
|
TableHeader,
|
|
|
|
|
TableRow,
|
|
|
|
|
} from "../../components/ui/table";
|
2026-07-30 09:21:55 +08:00
|
|
|
import { witPackageDownloadUrl } from "../../lib/api";
|
|
|
|
|
import type { PageProps } from "../types";
|
|
|
|
|
|
|
|
|
|
export default function WitPackagesPage(props: PageProps) {
|
|
|
|
|
const packages = createMemo(() => {
|
|
|
|
|
const state = props.state();
|
|
|
|
|
const query = state?.query.trim().toLowerCase() ?? "";
|
|
|
|
|
return (
|
|
|
|
|
state?.snapshot?.witPackages.filter(
|
|
|
|
|
(item) =>
|
|
|
|
|
!query ||
|
|
|
|
|
item.name.toLowerCase().includes(query) ||
|
|
|
|
|
item.version.toLowerCase().includes(query) ||
|
|
|
|
|
item.sha256.toLowerCase().includes(query),
|
|
|
|
|
) ?? []
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
2026-07-30 15:16:02 +08:00
|
|
|
<Page>
|
2026-07-30 09:21:55 +08:00
|
|
|
<PageHeading
|
|
|
|
|
eyebrow="INTERFACES"
|
|
|
|
|
title="WIT 包"
|
|
|
|
|
description="管理不可变、版本化的 Component 接口依赖。"
|
|
|
|
|
actions={
|
2026-07-30 15:16:02 +08:00
|
|
|
<Button variant="primary" onClick={() => props.command({ type: "open-wit-publish" })}>
|
2026-07-30 09:21:55 +08:00
|
|
|
<CloudUpload size={16} />
|
|
|
|
|
发布 WIT 包
|
2026-07-30 15:16:02 +08:00
|
|
|
</Button>
|
2026-07-30 09:21:55 +08:00
|
|
|
}
|
|
|
|
|
/>
|
2026-07-30 15:16:02 +08:00
|
|
|
<Card as="section">
|
|
|
|
|
<CardHeader>
|
2026-07-30 09:21:55 +08:00
|
|
|
<div>
|
|
|
|
|
<h2>Registry</h2>
|
|
|
|
|
<p>{packages().length} 个匹配包版本</p>
|
|
|
|
|
</div>
|
2026-07-30 15:16:02 +08:00
|
|
|
</CardHeader>
|
2026-07-30 09:21:55 +08:00
|
|
|
<Show
|
|
|
|
|
when={packages().length > 0}
|
|
|
|
|
fallback={
|
|
|
|
|
<EmptyState icon={Search} title="没有匹配的 WIT 包" detail="发布或调整搜索关键词。" />
|
|
|
|
|
}
|
|
|
|
|
>
|
2026-07-30 15:16:02 +08:00
|
|
|
<Table>
|
|
|
|
|
<TableHeader>
|
|
|
|
|
<TableRow>
|
|
|
|
|
<TableHead>包</TableHead>
|
|
|
|
|
<TableHead>版本</TableHead>
|
|
|
|
|
<TableHead>直接依赖</TableHead>
|
|
|
|
|
<TableHead>SHA-256</TableHead>
|
|
|
|
|
<TableHead>
|
|
|
|
|
<span class="sr-only">下载</span>
|
|
|
|
|
</TableHead>
|
|
|
|
|
</TableRow>
|
|
|
|
|
</TableHeader>
|
|
|
|
|
<TableBody>
|
|
|
|
|
<For each={packages()}>
|
|
|
|
|
{(item) => (
|
|
|
|
|
<TableRow>
|
|
|
|
|
<TableCell>
|
|
|
|
|
<span class="flex items-center gap-2">
|
|
|
|
|
<FileCode2 size={15} class="text-cyan-strong" />
|
|
|
|
|
<strong>{item.name}</strong>
|
|
|
|
|
</span>
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell class="font-mono text-xs">{item.version}</TableCell>
|
|
|
|
|
<TableCell class="text-xs text-muted">
|
|
|
|
|
{item.dependencies.length
|
|
|
|
|
? item.dependencies
|
|
|
|
|
.map((dependency) => `${dependency.name}@${dependency.version}`)
|
|
|
|
|
.join(", ")
|
|
|
|
|
: "无"}
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell
|
|
|
|
|
class="max-w-64 truncate font-mono text-xs text-muted"
|
|
|
|
|
title={item.sha256}
|
|
|
|
|
>
|
|
|
|
|
{item.sha256}
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell class="text-right">
|
|
|
|
|
<IconLink
|
|
|
|
|
aria-label={`下载 ${item.name}@${item.version}`}
|
|
|
|
|
title="下载"
|
|
|
|
|
href={witPackageDownloadUrl(props.state()?.apiBase ?? "", item)}
|
|
|
|
|
>
|
|
|
|
|
<Download size={15} />
|
|
|
|
|
</IconLink>
|
|
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
</TableBody>
|
|
|
|
|
</Table>
|
2026-07-30 09:21:55 +08:00
|
|
|
</Show>
|
2026-07-30 15:16:02 +08:00
|
|
|
</Card>
|
|
|
|
|
</Page>
|
2026-07-30 09:21:55 +08:00
|
|
|
);
|
|
|
|
|
}
|