first commit

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
HouYunFei
2026-05-19 07:53:53 +08:00
commit 472bf8b732
133 changed files with 16869 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import { apiGet, compactApiParams } from "@/services/api/request";
export type Prompt = {
id: string;
title: string;
coverUrl: string;
prompt: string;
tags: string[];
category: string;
githubUrl: string;
preview: string;
createdAt: string;
updatedAt: string;
};
export const ALL_PROMPTS_OPTION = "全部";
export type PromptListResponse = {
items: Prompt[];
tags: string[];
categories: string[];
total: number;
};
export async function fetchPrompts({ keyword = "", tag = [], category = ALL_PROMPTS_OPTION, page, pageSize }: { keyword?: string; tag?: string[]; category?: string; page?: number; pageSize?: number } = {}) {
return apiGet<PromptListResponse>("/api/prompts", compactApiParams({
...(keyword ? { keyword } : {}),
...(tag.length ? { tag } : {}),
...(category !== ALL_PROMPTS_OPTION ? { category } : {}),
...(page ? { page } : {}),
...(pageSize ? { pageSize } : {}),
}));
}
export function formatPromptDate(value: string) {
const date = new Date(value);
return Number.isNaN(date.getTime()) ? "" : new Intl.DateTimeFormat("zh-CN", { year: "numeric", month: "2-digit", day: "2-digit" }).format(date);
}