feat: 完善广场功能
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import type {
|
||||
ICommonResponse,
|
||||
IImageGenerateData,
|
||||
IImageGenerateRequest
|
||||
IImageGenerateRequest,
|
||||
IImageHistoryListData,
|
||||
IImagePublicStateData,
|
||||
IPlazaPostListData
|
||||
} from "#shared/types";
|
||||
|
||||
export class ImageService {
|
||||
public static basePath = "/api/images";
|
||||
|
||||
/** 发起生图请求,成功后返回当前可展示的图片地址。 */
|
||||
public static GenerateImage(request: IImageGenerateRequest) {
|
||||
return $fetch<ICommonResponse<IImageGenerateData>>(
|
||||
`${ImageService.basePath}/generate`,
|
||||
@@ -16,4 +20,52 @@ export class ImageService {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** 分页读取当前登录用户的生图历史记录。 */
|
||||
public static GetImageHistory(page = 1, size = 10) {
|
||||
return $fetch<ICommonResponse<IImageHistoryListData>>(
|
||||
`${ImageService.basePath}/history`,
|
||||
{
|
||||
method: "GET",
|
||||
query: {
|
||||
page,
|
||||
size
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** 分页读取广场中所有用户可见的公开图片。 */
|
||||
public static GetPlazaPosts(page = 1, size = 20) {
|
||||
return $fetch<ICommonResponse<IPlazaPostListData>>(
|
||||
`${ImageService.basePath}/plaza`,
|
||||
{
|
||||
method: "GET",
|
||||
query: {
|
||||
page,
|
||||
size
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** 将当前用户的一条生图历史发布到广场。 */
|
||||
public static PublishHistoryImage(recordId: string) {
|
||||
return $fetch<ICommonResponse<IImagePublicStateData>>(
|
||||
`${ImageService.basePath}/history/${recordId}/public`,
|
||||
{
|
||||
method: "POST"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** 取消公开当前用户的一条广场图片,服务端会软隐藏发布记录。 */
|
||||
public static HideHistoryImage(recordId: string) {
|
||||
return $fetch<ICommonResponse<IImagePublicStateData>>(
|
||||
`${ImageService.basePath}/history/${recordId}/public`,
|
||||
{
|
||||
method: "DELETE"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user