- 统一调整 admin.ts 文件中的接口定义缩进格式 - 优化 animated-theme-toggler.tsx 组件的代码结构和缩进 - 规范 app-config-modal.tsx 中 JSX 元素的嵌套格式 - 整理 app-providers.tsx 中的组件层级缩进 - 标准化 app-theme.ts 中的对象属性缩进格式
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
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);
|
|
}
|