- 新增节点库相关接口和类型定义,支持获取节点库列表 - 更新界面,添加节点库展示和动态表单功能,允许用户根据节点类型动态生成表单项 - 修改按钮事件名称以提高代码可读性
129 lines
2.6 KiB
TypeScript
129 lines
2.6 KiB
TypeScript
import request, { type RequestOptions } from '/@/utils/request';
|
|
|
|
export interface CreationListParams {
|
|
pageNum: number;
|
|
pageSize: number;
|
|
keyword?: string;
|
|
}
|
|
|
|
export interface NodeLibraryFormItem {
|
|
field: string;
|
|
label: string;
|
|
type: 'input' | 'number' | 'textarea' | 'switch' | string;
|
|
required: boolean;
|
|
default?: string | number | boolean;
|
|
}
|
|
|
|
export interface NodeLibraryItem {
|
|
nodeCode: string;
|
|
nodeName: string;
|
|
form: NodeLibraryFormItem[];
|
|
}
|
|
|
|
export interface NodeLibraryGroup {
|
|
group: string;
|
|
label: string;
|
|
items: NodeLibraryItem[];
|
|
}
|
|
|
|
export interface NodeLibraryListResponse {
|
|
code: number;
|
|
message: string;
|
|
data: {
|
|
groups: NodeLibraryGroup[];
|
|
};
|
|
}
|
|
|
|
export interface CreationImageItem {
|
|
name: string;
|
|
url: string;
|
|
}
|
|
|
|
export interface CreationTitleItem {
|
|
title: string;
|
|
htmlFileUrl: string;
|
|
imageUrls: CreationImageItem[] | null;
|
|
}
|
|
|
|
export interface CreationThemeItem {
|
|
theme: string;
|
|
titles: CreationTitleItem[];
|
|
}
|
|
|
|
export interface CreationContentTypeItem {
|
|
contentType: string;
|
|
themes: CreationThemeItem[];
|
|
}
|
|
|
|
export interface CreationTreeItem {
|
|
createdDate: string;
|
|
contentTypes: CreationContentTypeItem[];
|
|
}
|
|
|
|
export interface CreationListData {
|
|
list: unknown[] | null;
|
|
total: number;
|
|
Tree: CreationTreeItem[];
|
|
imgAddressPrefix: string;
|
|
}
|
|
|
|
export interface CreationListResponse {
|
|
code: number;
|
|
message: string;
|
|
data: CreationListData;
|
|
}
|
|
|
|
export interface CreationSubmitParams {
|
|
mode: string;
|
|
content_type: string;
|
|
theme: string;
|
|
title: string;
|
|
description?: string;
|
|
style: string;
|
|
count: number;
|
|
image_per_post: number;
|
|
image_ratio: string;
|
|
}
|
|
|
|
export interface DownloadToFileParams {
|
|
fileURL: string;
|
|
}
|
|
|
|
// requestOptions 用来声明“这个接口的错误提示由谁负责”。
|
|
export function getCreationList(params: CreationListParams, requestOptions?: RequestOptions) {
|
|
return request({
|
|
url: '/black-deacon/creation/info/list',
|
|
method: 'get',
|
|
params,
|
|
requestOptions,
|
|
}) as Promise<CreationListResponse>;
|
|
}
|
|
|
|
export function getNodeLibraryList(requestOptions?: RequestOptions) {
|
|
return request({
|
|
url: '/black-deacon/node/library/list',
|
|
method: 'get',
|
|
requestOptions,
|
|
}) as Promise<NodeLibraryListResponse>;
|
|
}
|
|
|
|
export function createCreation(data: CreationSubmitParams, requestOptions?: RequestOptions) {
|
|
return request({
|
|
url: '/black-deacon/creation/info/creation',
|
|
method: 'post',
|
|
data,
|
|
timeout: 0,
|
|
requestOptions,
|
|
});
|
|
}
|
|
|
|
export function downloadToFile(data: DownloadToFileParams, requestOptions?: RequestOptions) {
|
|
return request({
|
|
url: '/oss/file/downloadToBrowser',
|
|
method: 'post',
|
|
data,
|
|
responseType: 'blob',
|
|
requestOptions,
|
|
});
|
|
}
|