chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -39,7 +39,7 @@ export const ParamName = (props: {
const { groups } = useVariableContext();
const formApi = useFormApi();
// 使用 ref 缓存最后一次的有效值, Tree组件隐藏的时候会销毁组件Form表单的Field字段会删除所以需要缓存
// Use ref to cache the last valid value. When the Tree component is hidden, the component will be destroyed, and the Field field of the Form will be deleted, so it needs to be cached.
useCacheField(data);
return (

View File

@@ -25,24 +25,24 @@ export const requiredRules = {
};
/**
* 检查变量名称是否重复
* 1、检查变量名称在同组&同层级是否重复
* 2、检查变量名称在不同组的Root节点名称是否重复
* Check if variable names are duplicate
* 1. Check whether the variable names are duplicated in the same group & level
* 2. Check whether the variable names are duplicated in the root node names of different groups
*/
export const duplicateRules = {
validate: (value: Variable, groups: VariableGroup[]): boolean => {
if (!value.name) {
return true;
} // 如果名称为空则跳过检查
} // Skip check if name is empty
// 1. 检查同组同层级是否重复
// 1. Check whether the same group and level are duplicated
const currentGroup = groups.find(group => group.groupId === value.groupId);
if (!currentGroup) {
return true;
}
// 获取当前节点所在的所有同层级节点(包括嵌套在其他节点children中的)
// Get all nodes at the same level as the current node (including those nested in other node children)
const findSiblings = (
variables: Variable[],
targetParentId: string | null,
@@ -50,14 +50,14 @@ export const duplicateRules = {
let result: Variable[] = [];
for (const variable of variables) {
// 如果当前变量的parentId与目标parentId相同且不是自身则添加到结果中
// If the parentId of the current variable is the same as the target parentId and is not itself, it is added to the result
if (
variable.parentId === targetParentId &&
variable.variableId !== value.variableId
) {
result.push(variable);
}
// 递归检查children
// Check children recursively
if (variable.children?.length) {
result = result.concat(
findSiblings(variable.children, targetParentId),
@@ -74,8 +74,8 @@ export const duplicateRules = {
return false;
}
// 2. 检查是否与其他组的根节点重名
// 只有当前节点是根节点时才需要检查
// 2. Check if it has the same name as the root node of other groups
// Check only if the current node is the root node
if (!value.parentId) {
const otherGroupsRootNodes = groups
.filter(group => group.groupId !== value.groupId)

View File

@@ -49,28 +49,28 @@ export default function ParamOperator({
}: ParamOperatorProps) {
const isLimited = level >= 3;
// 是否可以添加子项
// Is it possible to add children?
const canAddChild = !readonly && ObjectLikeTypes.includes(data.type);
// 子项按钮是否可用
// Is the child button available?
const enableAddChildButton =
!readonly && hasObjectLike && canAddChild && needRenderAppendChild;
// 是否显示删除按钮
// Whether to display the delete button
const showDeleteButton = !readonly;
// 是否显示开启/关闭按钮
// Whether to display the on/off button
const enabledSwitch = level === 0;
const { variablePageCanEdit } = useVariableContext();
return (
<div className="flex items-center h-[24px] flex-shrink-0 justify-start gap-x-2 w-[130px]">
{/* 开启/关闭 */}
{/* Open/close */}
<Switch
size="small"
disabled={!variablePageCanEdit || !enabledSwitch}
checked={data.enabled}
onChange={onEnabledChange}
/>
{/* 添加子项 */}
{/* Add child item */}
{needRenderAppendChild ? (
<div className="flex items-center justify-center">
<Tooltip
@@ -89,7 +89,7 @@ export default function ParamOperator({
</Tooltip>
</div>
) : null}
{/* 删除 */}
{/* delete */}
<IconButton
data-testid={VariableE2e.VariableTreeDeleteBtn}
color="secondary"

View File

@@ -33,15 +33,15 @@ export const generateVariableOption = (
});
export interface VariableTypeOption {
// 类型的值, 非叶子节点时可能为空
// Value of type, possibly empty when not a leaf node
value: number | string;
// 选项的展示名称
// The display name of the option
label: ReactNode;
// 回显的展示名称
// Echoed display name
display?: string;
// 类型是否禁用
// Is the type disabled?
disabled?: boolean;
// 子类型
// subtype
children?: VariableTypeOption[];
}
@@ -72,7 +72,7 @@ const filterTypes = (
}
/**
* 1. 到达层级限制时禁用 ObjectLike 类型,避免嵌套过深
* 1. Disable the ObjectLike type when reaching the level limit to avoid too deep nesting
*/
const disabled = Boolean(
level &&
@@ -98,7 +98,7 @@ export const getVariableTypeList = options =>
filterTypes(allVariableTypeList, options);
/**
* 获取类型在选项列表中的路径,作为 cascader value
* Get the path of the type in the options list as the cascader value
*/
export const getCascaderVal = (
originalVal: ViewVariableType,

View File

@@ -24,7 +24,7 @@ export enum ChangeMode {
Replace,
}
// JSON类型
// JSON type
// eslint-disable-next-line @typescript-eslint/naming-convention
export const JSONLikeTypes = [
ViewVariableType.Object,

View File

@@ -63,20 +63,20 @@ export default function CustomTreeNode(props: CustomTreeNodeProps) {
onCollapse,
validateExistKeyword = false,
} = props;
// 当前值
// current value
const value = cloneDeep(data) as Variable;
const treeNodeRef = useRef<HTMLDivElement>(null);
// 删除时
// When deleting
const onDelete = () => {
onChange(ChangeMode.Delete, value);
};
// 新增子项时
// When adding a child
const onAppend = () => {
onChange(ChangeMode.Append, value);
};
// 类型切换时
// When switching types
const onSelectChange = (
val?: string | number | Array<unknown> | Record<string, unknown>,
) => {
@@ -86,7 +86,7 @@ export default function CustomTreeNode(props: CustomTreeNodeProps) {
if (!isNumber(val)) {
return;
}
// 清除默认值
// Clear default
value.defaultValue = '';
value.children = [];
onChange(ChangeMode.Update, { ...value, type: val as ViewVariableType });

View File

@@ -143,7 +143,7 @@ export const JSONEditor: FC<JSONEditorProps> = props => {
const isValid = useMemo(() => validate(value), [value]);
// 同步 value schema
// Synchronizing values and schemas
useEffect(() => {
const _schema = convert(value);
setSchema(_schema);
@@ -185,7 +185,7 @@ export const JSONEditor: FC<JSONEditorProps> = props => {
key={id}
value={value}
defaultLanguage="json"
/** 通过 css 样式覆盖 icube-dark 主题 */
/** Override icube-dark theme with css style */
className={lightStyles.light}
options={{
fontSize: 13,

View File

@@ -47,19 +47,19 @@ export const JSONImport: FC<JSONImportProps> = props => {
const [jsonString, setJsonString] = useState('');
const handleImport = (data: SchemaNode[]) => {
const allowDepth = MAX_LEVEL; // 最大深度限制
const allowNameLength = MAX_NAME_LENGTH; // 名称长度限制
const maxVariableCount = MAX_JSON_VARIABLE_COUNT; // 最大变量数量限制
const allowDepth = MAX_LEVEL; // Maximum depth limit
const allowNameLength = MAX_NAME_LENGTH; // Name length limit
const maxVariableCount = MAX_JSON_VARIABLE_COUNT; // Maximum number of variables limit
const variables = exportVariableService(
data,
{
groupId: treeData.groupId,
channel: treeData.channel,
},
treeData, // 传入原始变量以保持variableId
treeData, // Pass in the original variable to maintain the variableId.
);
// 裁切非法数据
// Crop illegal data
const dataCutoff = cutOffInvalidData({
data: variables,
allowDepth,
@@ -67,12 +67,12 @@ export const JSONImport: FC<JSONImportProps> = props => {
maxVariableCount,
});
// 先深拷贝原始数据
// First deep copy the original data source
const clonedTreeData = cloneDeep(treeData);
// 合并新旧数据
// Merge old and new data
const mergedData = merge(clonedTreeData, dataCutoff[0]);
// 更新数据
// update data
return onOk(mergedData);
};

View File

@@ -65,14 +65,14 @@ export const getEditorViewVariableJson = (treeData: TreeNodeCustomData) => {
);
}
// 如果没有name,返回空对象
// If there is no name, return an empty object
if (!name) {
return '{}';
}
const isArray = isArrayType(type);
// 递归处理children
// Recursive processing of children
const processChildren = (
nodes?: TreeNodeCustomData[],
parentType?: ViewVariableType,
@@ -87,7 +87,7 @@ export const getEditorViewVariableJson = (treeData: TreeNodeCustomData) => {
return [];
}
// 如果是数组类型,根据第一个子元素的类型生成默认值
// If it is an array type, generate a default value based on the type of the first child element
const result = {};
if (firstChild.children && firstChild.children.length > 0) {
result[firstChild.name] = processChildren(
@@ -117,7 +117,7 @@ export const getEditorViewVariableJson = (treeData: TreeNodeCustomData) => {
);
};
// 生成最终的JSON结构
// Generate the final JSON structure
const result = {
[name]: processChildren(children),
};

View File

@@ -23,10 +23,10 @@ import { type Variable } from '@/store';
import { type SchemaNode } from '../../../json-editor/service/convert-schema-service';
/**
* 将转换后的数据转换为Variable
* @param data 转换后的数据
* @param baseInfo 基础信息
* @param originalVariable 原始变量,用于保持variableId
* Converting Converted Data to Variables
* @param data converted data
* @param baseInfo
* @param originalVariable to hold variableId
* @returns Variable[]
*/
export const exportVariableService = (
@@ -44,7 +44,7 @@ export const exportVariableService = (
parentId = '',
originalNode?: Variable,
): Variable => {
// 使用store中的createVariable方法创建基础变量
// Create the underlying variable using the createVariable method in the store
const baseVariable = store.createVariable({
variableType: node.type as ViewVariableType,
groupId: baseInfo.groupId,
@@ -52,17 +52,17 @@ export const exportVariableService = (
channel: baseInfo.channel,
});
// 如果存在原始节点,保持其variableId
// If the original node exists, keep its variableId.
if (originalNode) {
baseVariable.variableId = originalNode.variableId;
baseVariable.description = originalNode.description;
}
// 更新变量的基本信息
// Update basic information about variables
baseVariable.name = node.name;
baseVariable.defaultValue = node.defaultValue;
// 递归处理子节点,尝试匹配原始子节点
// Recursively process the sub-node and try to match the original sub-node.
if (node.children?.length) {
baseVariable.children = node.children.map((child, index) => {
const originalChild = originalNode?.children?.[index];
@@ -75,7 +75,7 @@ export const exportVariableService = (
const variables = data.map(node => convertNode(node, '', originalVariable));
// 使用store中的updateMeta方法更新meta信息
// Update meta information using the updateMeta method in the store
store.updateMeta({ variables });
return variables;

View File

@@ -19,7 +19,7 @@ import { nanoid } from 'nanoid';
import type { TreeNodeCustomData } from '../../../type';
import { traverse, type TraverseContext } from './traverse';
/** 计算路径 */
/** Compute Path */
const getTreePath = (context: TraverseContext): string => {
const parents = context
.getParents()
@@ -32,14 +32,14 @@ const getTreePath = (context: TraverseContext): string => {
return parents.map(node => node.value.name).join('/');
};
/** 新旧数据保留 key 防止变量系统引用失效 */
/** Old and new data keep keys to prevent variable system references from invalidating */
export const mergeData = (params: {
newData: TreeNodeCustomData;
oldData: TreeNodeCustomData;
}): TreeNodeCustomData => {
const { newData, oldData } = params;
// 计算旧数据中路径与key的映射
// Compute the mapping of paths and keys in old data
const treeDataPathKeyMap = new Map<
string,
{
@@ -60,7 +60,7 @@ export const mergeData = (params: {
});
});
// 新数据复用旧数据的key失败则重新生成
// The new data reuses the key of the old data, and if it fails, it is regenerated.
const newDataWithKey = traverse(newData, context => {
if (
typeof context.node.value !== 'object' ||

View File

@@ -37,9 +37,9 @@ export interface TraverseContext {
export type TraverseHandler = (context: TraverseContext) => void;
/**
* 深度遍历对象,对每个值做处理
* @param value 遍历对象
* @param handle 处理函数
* Traverse the object in depth, processing each value
* @param value over object
* @param handling function
*/
export const traverse = <T extends TraverseValue = TraverseValue>(
value: T,
@@ -56,9 +56,9 @@ export const traverse = <T extends TraverseValue = TraverseValue>(
namespace TraverseUtils {
/**
* 深度遍历对象,对每个值做处理
* @param node 遍历节点
* @param handle 处理函数
* Traverse the object in depth, processing each value
* @param node traverse node
* @param handling function
*/
export const traverseNodes = (
node: TraverseNode,
@@ -66,11 +66,11 @@ namespace TraverseUtils {
): void => {
const { value } = node;
if (!value) {
// 异常处理
// exception handling
return;
}
if (Object.prototype.toString.call(value) === '[object Object]') {
// 对象,遍历对象的每个属性
// Object, iterate through each property of the object
Object.entries(value).forEach(([key, item]) =>
traverseNodes(
{
@@ -83,8 +83,8 @@ namespace TraverseUtils {
),
);
} else if (Array.isArray(value)) {
// 数组,遍历数组的每个元素
// 从数组的末尾开始遍历,这样即使中途移除了某个元素,也不会影响到未处理的元素的索引
// Array, iterate through each element of the array
// The iteration starts at the end of the array, so that even if an element is removed halfway through, it will not affect the index of the unprocessed element
for (let index = value.length - 1; index >= 0; index--) {
const item: string = value[index];
traverseNodes(
@@ -116,14 +116,14 @@ namespace TraverseUtils {
});
const setValue = (node: TraverseNode, value: unknown) => {
// 设置值函数
// 引用类型,需要借助父元素修改值
// 由于是递归遍历所以需要根据node来判断是给对象的哪个属性赋值还是给数组的哪个元素赋值
// Set Value Function
// Reference type, you need to modify the value with the help of the parent element
// Since it is a recursive traversal, it is necessary to determine which property of the object to assign a value to, or which element of the array to assign a value to, according to node
if (!value || !node) {
return;
}
node.value = value;
// 从上级作用域node中取出containerkeyindex
// Remove container, key, index from upper scope node
const { container, key, index } = node;
if (key && container) {
container[key] = value;
@@ -161,7 +161,7 @@ namespace TraverseUtils {
if (typeof pathItem === 'string') {
const re = /\W/g;
if (re.test(pathItem)) {
// 包含特殊字符
// Contains special characters
return `${stringifyPath}["${pathItem}"]`;
}
return `${stringifyPath}.${pathItem}`;

View File

@@ -16,17 +16,17 @@
/* eslint-disable @typescript-eslint/naming-convention */
/** 每一级树缩进宽度 */
/** Indent width of each level of tree */
export const TreeIndentWidth = 30;
/** 树节点展开收起按钮宽度 */
/** Tree Node Expand Collapse Button Width */
export const TreeCollapseWidth = 24;
// 名称最长50字符
// Name Maximum 50 characters
export const MAX_NAME_LENGTH = 50;
// 最大深度限制
// Maximum depth limit
export const MAX_LEVEL = 3;
// 最大变量数量限制
// Maximum number of variables limit
export const MAX_JSON_VARIABLE_COUNT = 1;
// 最大JSON长度限制30kb
// Maximum JSON length limit 30kb
export const MAX_JSON_LENGTH = 30 * 1024;

View File

@@ -51,7 +51,7 @@ export interface VariableTreeProps {
className?: string;
style?: React.CSSProperties;
showAddButton?: boolean;
/** 默认变量类型 */
/** Default variable type */
defaultVariableType?: ViewVariableType;
defaultCollapse?: boolean;
children?: React.ReactNode;
@@ -172,7 +172,7 @@ export function Index(
});
};
// 树节点的 change 方法
// Tree node change method
const onTreeNodeChange = (mode: ChangeMode, param: TreeNodeCustomData) => {
const findResult = findAndModifyVariable(
groupId,
@@ -194,7 +194,7 @@ export function Index(
});
addChildVariable(childVariable);
// 当前节点下新增节点 展开当前节点
// Add a new node under the current node and expand the current node
if (findResult?.variableId) {
expandTreeNode(findResult.variableId);
}
@@ -231,13 +231,13 @@ export function Index(
}
case ChangeMode.UpdateEnabled: {
findResult.enabled = param.enabled;
// 一键关闭所有子节点
// Close all sub-nodes with one click
traverse<TreeNodeCustomData>(findResult, node => {
if (!param.enabled) {
node.enabled = param.enabled;
}
});
// 子点开启,父节点也开启
// The child point is turned on, and the parent node is also turned on.
if (findResult.parentId && findResult.enabled) {
const parentData = findAndModifyVariable(
groupId,
@@ -284,11 +284,11 @@ export function Index(
<VariableTreeContext.Provider value={{ groupId, variables: flatTreeData }}>
<div
className={classNames(
// 基础容器样式
// basic container style
'relative h-full',
// 交互状态
// interaction state
!readonly && 'cursor-default',
// 自定义类名
// custom class name
className,
)}
style={style}
@@ -301,20 +301,20 @@ export function Index(
}}
disabled={readonly}
className={classNames(
// 基础滚动行为
// basic scrolling behavior
'overflow-x-auto',
// Tree 列表基础样式
// Tree list base style
[
// 列表容器样式
// list container style
'[&_.semi-tree-option-list]:overflow-visible',
'[&_.semi-tree-option-list]:p-0',
'[&_.semi-tree-option-list>div:first-child]:mt-0',
// 选项样式
// Option style
'[&_.semi-tree-option]:!pl-2',
].join(' '),
// 交互状态样式
// interaction state style
readonly
? '[&_.semi-tree-option-list-block_.semi-tree-option:hover]:bg-inherit'
: [
@@ -371,5 +371,5 @@ export function Index(
);
}
// 导出可调用ref方法的组件
// Export components that can call the ref method
export const VariableTree = React.forwardRef(Index);

View File

@@ -22,7 +22,7 @@ import { type ChangeMode } from './components/custom-tree-node/constants';
export interface RecursedParamDefinition {
name?: string;
/** Tree 组件要求每一个节点都有 key而 key 不适合用名称(前后缀)等任何方式赋值,最终确定由接口转换层一次性提供随机 key */
/** The Tree component requires each node to have a key, and the key is not suitable for assignment in any way such as name (before and after). Finally, the interface conversion layer provides a random key at one time. */
fieldRandomKey?: string;
desc?: string;
type: ViewVariableType;
@@ -35,14 +35,14 @@ export interface CustomTreeNodeFuncRef {
data: TreeNodeCustomData;
level: number;
readonly: boolean;
// 通用change方法
// General change method
onChange: (mode: ChangeMode, param: TreeNodeCustomData) => void;
// 定制的类型改变的change方法主要用于自定义render使用
// 添加子项
// Customized type change method, mainly used for custom rendering
// Add child item
onAppend: () => void;
// 删除该项
// Delete this item
onDelete: () => void;
// 类型改变时内部的调用方法主要用于从类Object类型转为其他类型时需要删除所有子项
// The internal call method when the type changes, mainly used to delete all children when converting from the class Object type to other types
onSelectChange: (
val?: string | number | Array<unknown> | Record<string, unknown>,
) => void;

View File

@@ -32,7 +32,7 @@ interface ChildrenFindResult {
export type FindDataResult = RootFindResult | ChildrenFindResult | null;
/**
* 根据target数组找到key在该项的值和位置主要是获取位置方便操作parent的children
* According to the target array, find the value and position of the key in the item, mainly to obtain the position, which is convenient for operating the children of the parent.
*/
export function findCustomTreeNodeDataResult(
target: Array<TreeNodeCustomData>,
@@ -40,7 +40,7 @@ export function findCustomTreeNodeDataResult(
): FindDataResult {
const dataInRoot = target.find(item => item.variableId === variableId);
if (dataInRoot) {
// 如果是根节点
// If it is the root node
return {
isRoot: true,
parentData: null,
@@ -81,7 +81,7 @@ export function findCustomTreeNodeDataResult(
return findDataInChildrenLoop(target);
}
// groupVariableMeta打平为viewVariableTreeNode[]
// Flatten groupVariableMeta to viewVariableTreeNode []
export function flatGroupVariableMeta(
groupVariableMeta: VariableGroup[],
maxDepth = Infinity,

View File

@@ -37,7 +37,7 @@ export const VariablesPage = () => {
type="text"
className={classNames(
'h-full flex flex-col',
// 滚动条位置调整到 tab 内容中
// Scroll bar position is adjusted to tab content
'[&_.semi-tabs-content]:p-0 [&_.semi-tabs-content]:grow [&_.semi-tabs-content]:overflow-hidden',
'[&_.semi-tabs-pane-active]:h-full',
'[&_.semi-tabs-pane-motion-overlay]:h-full [&_.semi-tabs-pane-motion-overlay]:overflow-auto',

View File

@@ -20,7 +20,7 @@ import { Toast } from '@coze-arch/coze-design';
import { useVariableGroupsStore } from '../../store';
/**
* 提交变量
* commit variable
* @param projectID
* @returns
*/
@@ -38,9 +38,9 @@ export async function submit(projectID: string) {
}
/**
* 检查并确保 projectID 是非空字符串
* @param projectID 可能为空的项目ID
* @returns projectID 是否为非空字符串
* Check and make sure projectID is a non-empty string
* @param projectID possibly empty project ID
* @Returns whether projectID is a non-empty string
*/
export const checkProjectID = (projectID: unknown): projectID is string =>
typeof projectID === 'string' && projectID.length > 0;

View File

@@ -85,27 +85,27 @@ export interface VariableGroupsAction {
parentId: string;
channel: VariableChannel;
}) => Variable;
// 更新变量, 根据groupIdvariableId更新
// Update variables, according to groupId and variableId
updateVariable: (newVariable: Variable) => void;
// 更新变量的meta信息
// Update the meta information of the variable
updateMeta: (params: {
variables: Variable[];
level?: number;
parentId?: string;
}) => void;
// 新增根节点变量
// Add root node variable
addRootVariable: (variable: Omit<Variable, 'channel'>) => void;
// 新增子节点变量
// Add sub-node variable
addChildVariable: (variable: Variable) => void;
// 删除变量
// Delete variable
deleteVariable: (variable: Variable) => void;
// 保存后作为历史变量对待
// After being preserved, it is treated as a historical variable
saveHistory: () => void;
// 获取DTO variable
// Get DTO variable
getDtoVariable: (variable: Variable) => ProjectMemory.Variable;
// 获取groups下所有的变量
// Get all the variables under groups
getAllRootVariables: () => Variable[];
// 获取groups下所有的变量
// Get all the variables under groups
getAllVariables: () => Variable[];
transformDto2Vo: (data: ProjectMemory.GroupVariableInfo[]) => VariableGroup[];
initStore: (data: {
@@ -113,7 +113,7 @@ export interface VariableGroupsAction {
canEdit: boolean;
}) => void;
clear: () => void;
// 在变量树中查找变量,并可选地修改或删除
// Locate variables in the variable tree and optionally modify or delete them
findAndModifyVariable: (
groupId: string,
predicate: (variable: Variable) => boolean,
@@ -328,7 +328,7 @@ export const useVariableGroupsStore = create<
},
transformDto2Vo: data => {
const transformedData = getGroupListByDto(data);
// 在数据转换完成后立即更新meta信息
// After the data conversion is completed, update the meta information immediately
transformedData.forEach(group => {
get().updateMeta({ variables: group.varInfoList });
});

View File

@@ -104,7 +104,7 @@ const getSubGroupListByDto = ({
subGroupList?.map(subGroup => ({
...getBaseGroupInfoByDto({
...subGroup,
DefaultChannel: group.DefaultChannel, // 服务端返回的 subGroup 没有 DefaultChannel需要手动设置
DefaultChannel: group.DefaultChannel, // The subGroup returned by the server level has no DefaultChannel and needs to be set manually
}),
groupId,
varInfoList: getGroupVariableListByDto({

View File

@@ -24,7 +24,7 @@ import { type VariableSchemaDTO, VariableTypeDTO } from '../types';
import { type Variable } from '../store';
/**
* 前端变量类型
* Front-end variable type
*/
export enum ViewVariableType {
String = 1,
@@ -32,7 +32,7 @@ export enum ViewVariableType {
Boolean,
Number,
Object = 6,
// 上面是 api 中定义的 InputType。下面是整合后的。从 99 开始,避免和后端定义撞车
// The above is the InputType defined in the api. The following is the integrated one. Start from 99 to avoid collisions with the backend definition.
ArrayString = 99,
ArrayInteger,
ArrayBoolean,
@@ -101,7 +101,7 @@ export const getDtoVariable = (
schema: '',
};
// 处理数组类型
// Working with array types
if (type === VariableTypeDTO.List && arrayItemType) {
if (arrayItemType === VariableTypeDTO.Object) {
schema.schema = {
@@ -118,7 +118,7 @@ export const getDtoVariable = (
}
}
// 处理对象类型
// Handling object types
if (type === VariableTypeDTO.Object) {
schema.schema = viewVariable.children?.map(child => {
const childDTO = getDtoVariable(child);

View File

@@ -34,7 +34,7 @@ export interface VariableSchemaDTO {
}
/**
* 前端变量类型
* Front-end variable type
*/
export enum ViewVariableType {
String = 1,
@@ -42,7 +42,7 @@ export enum ViewVariableType {
Boolean,
Number,
Object = 6,
// 上面是 api 中定义的 InputType。下面是整合后的。从 99 开始,避免和后端定义撞车
// The above is the InputType defined in the api. The following is the integrated one. Start from 99 to avoid collisions with the backend definition.
ArrayString = 99,
ArrayInteger,
ArrayBoolean,
@@ -73,7 +73,7 @@ export const VARIABLE_TYPE_ALIAS_MAP: Record<ViewVariableType, string> = {
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace ViewVariableType {
/**
* 获取所有变量类型的补集
* Get the complement of all variable types
* @param inputTypes
*/
export function getComplement(inputTypes: ViewVariableType[]) {