mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 16:46:37 +08:00
模板系统
This commit is contained in:
@@ -4,6 +4,7 @@ import type {
|
||||
AuthSource,
|
||||
AuthSourceRequest,
|
||||
CreateSystemConfigRequest,
|
||||
CreateTemplateRequest,
|
||||
CreateUserRequest,
|
||||
DispatchTaskRequest,
|
||||
ListTaskExecutionsRequest,
|
||||
@@ -15,8 +16,10 @@ import type {
|
||||
TaskExecution,
|
||||
TaskMeta,
|
||||
TaskTypeResponse,
|
||||
Template,
|
||||
ToggleAuthSourceRequest,
|
||||
UpdateSystemConfigRequest,
|
||||
UpdateTemplateRequest,
|
||||
UpdateUserStatusRequest,
|
||||
} from './types';
|
||||
|
||||
@@ -362,4 +365,41 @@ export class AdminService extends BaseService {
|
||||
}> {
|
||||
return this.get('/logs', { cursor, limit });
|
||||
}
|
||||
|
||||
// ==================== 模板管理 ====================
|
||||
|
||||
/**
|
||||
* 获取模板列表
|
||||
*/
|
||||
static async listTemplates(): Promise<Template[]> {
|
||||
return this.get<Template[]>('/templates');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个模板
|
||||
*/
|
||||
static async getTemplate(key: string): Promise<Template> {
|
||||
return this.get<Template>(`/templates/${ key }`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模板
|
||||
*/
|
||||
static async createTemplate(request: CreateTemplateRequest): Promise<Template> {
|
||||
return this.post<Template>('/templates', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模板
|
||||
*/
|
||||
static async updateTemplate(key: string, request: UpdateTemplateRequest): Promise<Template> {
|
||||
return this.put<Template>(`/templates/${ key }`, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板
|
||||
*/
|
||||
static async deleteTemplate(key: string): Promise<void> {
|
||||
return this.delete<void>(`/templates/${ key }`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,3 +324,43 @@ export interface SystemStatus {
|
||||
last_pause: string;
|
||||
num_gc: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板配置信息
|
||||
*/
|
||||
export interface Template {
|
||||
id: string;
|
||||
key: string;
|
||||
name: string;
|
||||
type: string;
|
||||
subject: string;
|
||||
content: string;
|
||||
description: string;
|
||||
is_system: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模板请求参数
|
||||
*/
|
||||
export interface CreateTemplateRequest {
|
||||
key: string;
|
||||
name: string;
|
||||
type: string;
|
||||
subject: string;
|
||||
content: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模板请求参数
|
||||
*/
|
||||
export interface UpdateTemplateRequest {
|
||||
name: string;
|
||||
type: string;
|
||||
subject: string;
|
||||
content: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user