修复任务参数类型转换

This commit is contained in:
ryan
2026-06-11 08:26:30 +08:00
parent 5241055030
commit 8964054fd8
7 changed files with 138 additions and 29 deletions
+4 -1
View File
@@ -18,6 +18,7 @@ import type {
SystemStatus,
TaskExecution,
TaskMeta,
TaskParamType,
TaskTypeResponse,
Template,
ToggleAuthSourceRequest,
@@ -187,7 +188,9 @@ export class AdminService extends BaseService {
params: (item.Params || item.params || []).map(p => ({
name: p.Name || p.name || '',
label: p.Label || p.label || '',
type: p.Type || p.type || '',
// Cast to TaskParamType: backend only emits 'string' | 'text' | 'number'.
// Unknown future values fall through safely to the string branch.
type: (p.Type || p.type || 'string') as TaskParamType,
required: p.Required ?? p.required ?? false,
placeholder: p.Placeholder || p.placeholder || '',
description: p.Description || p.description || '',
+6 -4
View File
@@ -1,19 +1,19 @@
/**
* 管理员服务模块
*
*
* @description
* 提供系统配置、用户与任务管理功能,包括:
* - 系统配置管理(创建、查询、更新、删除)
* - 异步任务配置及下发
* - 用户账号状态管理
*
*
* @remarks
* 所有接口都需要管理员权限
*
*
* @example
* ```typescript
* import { AdminService } from '@/lib/services';
*
*
* // 获取系统配置列表
* const configs = await AdminService.listSystemConfigs();
* ```
@@ -29,6 +29,8 @@ export type {
AuthSourceRequest,
ToggleAuthSourceRequest,
TaskMeta,
TaskParam,
TaskParamType,
TaskExecution,
TaskExecutionStatus,
ListTaskExecutionsRequest,
+9 -1
View File
@@ -92,13 +92,21 @@ export interface TaskTypeResponse {
params?: TaskParamResponse[];
}
/**
* 任务参数的数据类型
* - string → 单行文本输入,JSON 中序列化为 string
* - text → 多行文本输入,JSON 中序列化为 string
* - number → 数字输入,JSON 中序列化为 number(而非 string)
*/
export type TaskParamType = 'string' | 'text' | 'number';
/**
* 任务参数定义
*/
export interface TaskParam {
name: string;
label: string;
type: string;
type: TaskParamType;
required: boolean;
placeholder: string;
description: string;
+2
View File
@@ -99,6 +99,8 @@ export type {
CreateUserRequest,
UpdateSystemConfigRequest,
TaskMeta,
TaskParam,
TaskParamType,
TaskExecution,
TaskExecutionStatus,
ListTaskExecutionsRequest,