Files

44 lines
1.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AppShell } from "@/components/AppShell";
import { TemplatesManager } from "@/components/templates/TemplatesManager";
import { PageHeader } from "@/components/ui/PageHeader";
import { StatusNote } from "@/components/ui/StatusNote";
import { fetchTemplates, fetchToolbox } from "@/lib/api/server";
import type { TemplateResponse, ToolDescriptorView } from "@/lib/api/types";
// 提示词/模板库F3全局单用户本地版。Server Component 预取列表 + 工具描述符(供「关联工具」下拉);
// CRUD 在客户端组件。fetchToolbox 任何错误内部降级为空列表,不阻塞进页。
export default async function TemplatesPage() {
let initial: TemplateResponse[] = [];
let tools: ToolDescriptorView[] = [];
let loadError = false;
try {
const [templates, toolbox] = await Promise.all([
fetchTemplates(),
fetchToolbox(),
]);
initial = templates;
tools = toolbox.tools ?? [];
} catch {
loadError = true;
}
return (
<AppShell title="提示词 / 模板库">
<div className="mx-auto max-w-3xl px-8 py-10">
<PageHeader
title="提示词 / 模板库"
eyebrow="prompt templates"
description="保存常用提示词,复用时一键填入生成器的需求 / 原文输入。仅本地、单用户,不做分享。"
/>
{loadError ? (
<StatusNote variant="danger" title="无法连接后端服务">
<p> API </p>
</StatusNote>
) : (
<TemplatesManager initial={initial} tools={tools} />
)}
</div>
</AppShell>
);
}