- 版本目标 → 收录版本(前后端用户可见字符串、能力描述、给模型的提示) - Agent 上游 / 上游 → 模型服务;界面上的 Agent / Agent 会话 → 智能体 / 智能体会话 - 身份歧义 / 识别有歧义 / 无法确定作品 → 没识别出作品;待识别(池) → 未识别 - 建档 → 加入媒体库;资产 → 文件;库根 → 媒体库目录;纳管 → 本工具 / 外部任务; 哨兵 → 标记文件 / 检查目录;站点快照 → 抓取;Feed / RSS 订阅 / 来源健康 → RSS - 代码标识符、API 字段名、迁移文件不改;glossary.md 同步;smoke 选择器跟随 Co-Authored-By: Claude Opus 5.5 <[email protected]>
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import type { LocalMediaHit, MediaKind, SearchInventoryState, SearchSiteStatus } from "@umt/contracts";
|
|
import { Compass, type LucideIcon, Zap } from "lucide-react";
|
|
import type { StatusTone } from "~/components/console/status-badge.tsx";
|
|
import { MEDIA_KIND } from "~/components/library/labels.ts";
|
|
|
|
// 搜索结果的展示口径
|
|
|
|
export const mediaKindLabel = (k: MediaKind) => MEDIA_KIND[k] ?? k;
|
|
|
|
/** 本地作品的一行摘要:订阅 / 版本 / 下载中 / 缺口 */
|
|
export function slotSummary(h: LocalMediaHit): string {
|
|
const c = h.slotCounts;
|
|
const parts: string[] = [];
|
|
if (h.subscribed) parts.push("已订阅");
|
|
if (h.versionCount) parts.push(`${h.versionCount} 个版本`);
|
|
if (h.downloadingCount) parts.push(`${h.downloadingCount} 个下载中`);
|
|
const gaps = c.empty + c.attention + c.upgrade_pending;
|
|
if (gaps) parts.push(`${gaps} 个收录版本未满足`);
|
|
return parts.join(" · ") || "未订阅";
|
|
}
|
|
|
|
export const actionIcon = (kind: "page" | "action"): LucideIcon => (kind === "page" ? Compass : Zap);
|
|
|
|
export const INVENTORY_STATE: Record<SearchInventoryState, { label: string; tone: StatusTone }> = {
|
|
downloading: { label: "下载中", tone: "warning" },
|
|
gap: { label: "有缺口", tone: "warning" },
|
|
owned: { label: "已有版本", tone: "success" },
|
|
subscribed: { label: "已订阅", tone: "neutral" },
|
|
none: { label: "本地无版本", tone: "neutral" },
|
|
};
|
|
|
|
export const SITE_STATUS: Record<SearchSiteStatus, string> = {
|
|
ok: "正常",
|
|
failed: "失败",
|
|
timeout: "超时",
|
|
skipped: "跳过",
|
|
};
|
|
|
|
export const SORT_OPTIONS = [
|
|
{ value: "default", label: "默认" },
|
|
{ value: "seeders", label: "做种数" },
|
|
{ value: "size", label: "大小" },
|
|
{ value: "uploadedAt", label: "发布时间" },
|
|
{ value: "site", label: "站点" },
|
|
] as const;
|
|
|
|
const PROMO: Record<string, string> = {
|
|
free: "免费",
|
|
"2xfree": "2x 免费",
|
|
"50%": "50%",
|
|
"2x50%": "2x 50%",
|
|
"30%": "30%",
|
|
"2x": "2x 上传",
|
|
};
|
|
/** 促销文案;none/unknown 返回 null */
|
|
export function promoLabel(type: string): string | null {
|
|
if (!type || type === "none" || type === "unknown") return null;
|
|
return PROMO[type] ?? type;
|
|
}
|
|
|
|
const GB = 1024 ** 3;
|
|
export const gbToBytes = (s: string): number | undefined => {
|
|
const n = Number(s);
|
|
return s.trim() && Number.isFinite(n) && n >= 0 ? Math.round(n * GB) : undefined;
|
|
};
|