chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -35,7 +35,7 @@ export const useTrace = () => {
|
||||
|
||||
const fetch = useMemoizedFn(async (logId: string) => {
|
||||
setLoading(true);
|
||||
/** 查询日志时,开始结束时间必传,由于用户可查范围为 7 天内,所以直接伪造 7 天时间间隔即可 */
|
||||
/** When querying the log, the start and end time must be passed. Since the user can check the range within 7 days, he can directly fake the 7-day time interval. */
|
||||
const now = dayjs().endOf('day').valueOf();
|
||||
const end = dayjs()
|
||||
.subtract(MAX_TRACE_TIME, 'day')
|
||||
|
||||
@@ -80,9 +80,9 @@ export const useOptions = (workflowId: string) => {
|
||||
next.unshift(first);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @coze-arch/no-empty-catch -- 无需报错
|
||||
// eslint-disable-next-line @coze-arch/no-empty-catch -- no error required
|
||||
} catch {
|
||||
// 无需报错
|
||||
// No error required
|
||||
}
|
||||
}
|
||||
next.forEach(s => {
|
||||
@@ -91,7 +91,7 @@ export const useOptions = (workflowId: string) => {
|
||||
}
|
||||
});
|
||||
setOptions(next);
|
||||
// 如果没有初始化,就初始化一次
|
||||
// If it is not initialized, it is initialized once
|
||||
if (!ready && !span && maybeInitialSpan) {
|
||||
patch({ span: maybeInitialSpan });
|
||||
}
|
||||
@@ -103,7 +103,7 @@ export const useOptions = (workflowId: string) => {
|
||||
const handleDateChange = useCallback(
|
||||
(next: [Date, Date]) => {
|
||||
const [start, end] = next;
|
||||
// 时间选择器选择的日期是当天 0 点,需要转化为当天 11 点 59 分 59 秒
|
||||
// The date selected by the time selector is 0:00 on the day, which needs to be converted to 11:59:59 on the day.
|
||||
setDate([start, dayjs(end).endOf('day').toDate()] as [Date, Date]);
|
||||
},
|
||||
[setDate],
|
||||
|
||||
@@ -20,5 +20,5 @@ export enum TraceChartsMode {
|
||||
}
|
||||
|
||||
export const MAX_TRACE_LENGTH = 50;
|
||||
/** 日志最多查询 7 天 */
|
||||
/** Log query for up to 7 days */
|
||||
export const MAX_TRACE_TIME = 7;
|
||||
|
||||
@@ -24,14 +24,14 @@ export interface TraceListState {
|
||||
spaceId: string;
|
||||
workflowId: string;
|
||||
isInOp?: boolean;
|
||||
/** 初次打开时需要先请求列表,然后选中第一项 */
|
||||
/** When opening it for the first time, you need to request the list first, and then select the first item. */
|
||||
ready: boolean;
|
||||
/** 当前选中的 span */
|
||||
/** Currently selected span */
|
||||
span: Span | null;
|
||||
}
|
||||
|
||||
export interface TraceListAction {
|
||||
/** 更新状态 */
|
||||
/** update status */
|
||||
patch: (next: Partial<TraceListState>) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ export const defaultLabelStyle: LabelStyle = {
|
||||
export const defaultLabelText: LabelText = (datum, element, params) =>
|
||||
`${datum.start}-${datum.end}`;
|
||||
|
||||
// xScale的padding(解决hover后rect边框被截断问题)
|
||||
// padding of xScale (solve the problem of rect border being truncated after hover)
|
||||
export const scrollbarMargin = 10;
|
||||
export const datazoomHeight = 20;
|
||||
export const datazoomDecimals = 0;
|
||||
|
||||
@@ -130,7 +130,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
[_globalLabelStyle],
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- 计算需要
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- calculation required
|
||||
const topOffset = datazoomHeight + datazoomPaddingBottom + 8;
|
||||
|
||||
const globalStyle: GlobalStyle = useMemo(
|
||||
@@ -146,7 +146,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
return rowCount * rowHeight;
|
||||
}, [flamethreadData]);
|
||||
|
||||
// 此参数含义: 可视窗口Height / 火焰图Height
|
||||
// Meaning of this parameter: Visual Window Height/Flame Map Height
|
||||
const yScaleRangeFactor = useMemo(() => {
|
||||
const rowCount = uniqWith(
|
||||
flamethreadData,
|
||||
@@ -187,7 +187,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
const tickData = scale.tickData(visibleColumnCount);
|
||||
const dx =
|
||||
tickData.length > 1
|
||||
? // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- 计算需要
|
||||
? // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- calculation required
|
||||
(range[1] - range[0]) / (tickData.length - 1) / 2
|
||||
: 0;
|
||||
|
||||
@@ -202,7 +202,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
style: { dx: -dx },
|
||||
formatMethod: (_value: string) => {
|
||||
const value = Number(_value);
|
||||
// 特化逻辑: 隐藏0刻度
|
||||
// Specialized logic: hide 0 ticks
|
||||
if (dx > 0 && value === 0) {
|
||||
return '';
|
||||
}
|
||||
@@ -218,7 +218,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
{
|
||||
type: GrammarMarkType.component,
|
||||
componentType: ComponentEnum.grid,
|
||||
tickCount: visibleColumnCount, // vgrammer库的类型写的不严谨,实际是可用的
|
||||
tickCount: visibleColumnCount, // The types of the vgrammer library are not strictly written, but are actually usable
|
||||
scale: 'xScale',
|
||||
gridType: 'line',
|
||||
gridShape: 'line',
|
||||
@@ -277,7 +277,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
lineWidth,
|
||||
lineDash,
|
||||
visible: true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- 尺寸计算,无须处理
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- size calculation, no processing required
|
||||
distance: lineWidth / 2,
|
||||
};
|
||||
},
|
||||
@@ -297,7 +297,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
lineWidth,
|
||||
lineDash,
|
||||
visible: true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- 尺寸计算,无须定义常量
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- size calculation, no need to define constants
|
||||
distance: lineWidth / 2,
|
||||
};
|
||||
},
|
||||
@@ -318,7 +318,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
lineWidth,
|
||||
lineDash,
|
||||
visible: true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- 尺寸计算,无须定义常量
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- size calculation, no need to define constants
|
||||
distance: lineWidth / 2,
|
||||
};
|
||||
},
|
||||
@@ -344,7 +344,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
},
|
||||
encode: {
|
||||
update: {
|
||||
pickable: false, // vgrammer库的类型写的不严谨,实际是可用的
|
||||
pickable: false, // The types of the vgrammer library are not strictly written, but are actually usable
|
||||
text: labelText ?? defaultLabelText,
|
||||
fill: (datum, _element, _params) => datum?.labelStyle.fill,
|
||||
},
|
||||
@@ -551,7 +551,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
[selectedKey],
|
||||
);
|
||||
|
||||
// 创建/更新view
|
||||
// Create/update view
|
||||
useLayoutEffect(() => {
|
||||
const initializeYScale = (view: IView) => {
|
||||
const yScale = view?.getScaleById('yScale');
|
||||
@@ -565,7 +565,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
|
||||
const registerEvent = (view: IView) => {
|
||||
const rectElm = view?.getMarkById('rect');
|
||||
// rect点击事件
|
||||
// Rect click event
|
||||
rectElm?.addEventListener('click', ((event, element) => {
|
||||
onClick?.(event, element);
|
||||
}) as InteractionEventHandler);
|
||||
@@ -574,7 +574,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
onClick?.(event, element);
|
||||
}) as InteractionEventHandler);
|
||||
|
||||
// rect hover高亮
|
||||
// Rect hover highlight
|
||||
view?.interaction('element-highlight', {
|
||||
selector: 'rect',
|
||||
highlightState: 'hover2',
|
||||
@@ -594,7 +594,7 @@ export const Flamethread: FC<FlamethreadProps> = props => {
|
||||
});
|
||||
}
|
||||
|
||||
// rect hover显示tooltip
|
||||
// Rect hover tooltip
|
||||
if (tooltip) {
|
||||
view?.interaction('tooltip', {
|
||||
selector: 'rect',
|
||||
|
||||
@@ -51,7 +51,7 @@ export interface RectNode {
|
||||
end: number;
|
||||
rectStyle?: RectStyle;
|
||||
labelStyle?: Pick<LabelStyle, 'fill'>;
|
||||
// 其他字段,会透传
|
||||
// Other fields will be passed through
|
||||
extra?: unknown;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export interface FlamethreadProps {
|
||||
rectStyle?: RectStyle;
|
||||
labelStyle?: LabelStyle;
|
||||
labelText?: LabelText;
|
||||
// 结构太复杂,直接暴漏即可
|
||||
// The structure is too complicated, just leak it directly
|
||||
tooltip?: Tooltip;
|
||||
globalStyle?: GlobalStyle;
|
||||
rowHeight?: number;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-magic-numbers -- 本组件中会有很多位置计算的数字,无须处理*/
|
||||
/* eslint-disable @typescript-eslint/no-magic-numbers -- there will be many numbers calculated in this component, no need to deal with them*/
|
||||
import { type FC, useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import { isFunction, mergeWith } from 'lodash-es';
|
||||
@@ -68,8 +68,8 @@ export const Tree: FC<TreeProps> = ({
|
||||
);
|
||||
|
||||
/**
|
||||
* 使得指定的selectKey的Line置于顶层。
|
||||
* 通过调整line顺序,来实现z-index效果:key为${selectKey}的line在最上层
|
||||
* Causes the Line of the specified selectKey to be placed at the top level.
|
||||
* By adjusting the line order, the z-index effect is achieved: the line with the key ${selectKey} is at the top
|
||||
*/
|
||||
const adjustLineOrder = useCallback(
|
||||
(lines: Line[]): Line[] => {
|
||||
@@ -86,7 +86,7 @@ export const Tree: FC<TreeProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// 支持根据zIndex控制高度
|
||||
// Support controlling height according to zIndex
|
||||
lines.sort((lineA, lineB) => {
|
||||
const zIndexA = lineA.endNode.zIndex ?? -1;
|
||||
const zIndexB = lineB.endNode.zIndex ?? -1;
|
||||
@@ -137,7 +137,7 @@ export const Tree: FC<TreeProps> = ({
|
||||
);
|
||||
|
||||
/**
|
||||
* 根据line信息生成svg path。 colNo, rowNum都从0开始
|
||||
* Generate svg path from line information. colNo, rowNum all start from 0
|
||||
*/
|
||||
const genSvgPath = useCallback(
|
||||
(line: Line): string => {
|
||||
@@ -151,41 +151,41 @@ export const Tree: FC<TreeProps> = ({
|
||||
const { lineRadius = 0, lineGap = 0 } = normalLineStyle;
|
||||
const nodeHeight = nodeBoxHeight + verticalInterval;
|
||||
|
||||
// 起始点
|
||||
// starting point
|
||||
const startX = startColNo * indent + offsetX;
|
||||
const startY =
|
||||
startRowNo * nodeHeight + (nodeBoxHeight + verticalInterval / 2);
|
||||
|
||||
if (startColNo === endColNo) {
|
||||
// 竖线的长度
|
||||
// The length of the vertical line
|
||||
const lineASize =
|
||||
(endRowNo - startRowNo - 1) * nodeHeight + verticalInterval;
|
||||
// 移动到起始点
|
||||
// Move to the starting point
|
||||
const moveToStartPoint = `M ${startX} ${startY + lineGap}`;
|
||||
// 竖线
|
||||
// vertical line
|
||||
const lineA = `L ${startX} ${startY + lineASize}`;
|
||||
return `${moveToStartPoint} ${lineA}`;
|
||||
} else {
|
||||
// 竖线的长度
|
||||
// The length of the vertical line
|
||||
const lineASize =
|
||||
(endRowNo - startRowNo - 1) * nodeHeight +
|
||||
verticalInterval / 2 +
|
||||
nodeHeight / 2 -
|
||||
lineRadius;
|
||||
// 横线的长度
|
||||
// The length of the horizontal line
|
||||
const lineBSize =
|
||||
(endColNo - startColNo) * indent - offsetX - lineRadius;
|
||||
// 结束点的坐标
|
||||
// Coordinates of the end point
|
||||
const endX = startX + lineBSize + lineRadius;
|
||||
const endY = startY + lineASize + lineRadius;
|
||||
|
||||
// 移动到起始点
|
||||
// Move to the starting point
|
||||
const moveToStartPoint = `M ${startX} ${startY + lineGap}`;
|
||||
// 竖线
|
||||
// vertical line
|
||||
const lineA = `L ${startX} ${startY + lineASize}`;
|
||||
// 二次贝塞尔曲线
|
||||
// Quadratic Bézier Curve
|
||||
const qbc = `Q ${startX} ${endY} ${startX + lineRadius} ${endY}`;
|
||||
// 横线
|
||||
// horizontal line
|
||||
const lineB = `L ${endX - lineGap} ${endY}`;
|
||||
return `${moveToStartPoint} ${lineA} ${qbc} ${lineB}`;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ export type LineAttrs = Pick<
|
||||
SVGAttributes<unknown>,
|
||||
'stroke' | 'strokeDasharray' | 'strokeWidth'
|
||||
> & {
|
||||
lineRadius?: number; // line圆角半径 注意:这个数值不要大于 indent/2
|
||||
lineGap?: number; // line距离box的gap
|
||||
lineRadius?: number; // Line fillet radius, note: this value should not be greater than indent/2
|
||||
lineGap?: number; // Line distance box gap
|
||||
};
|
||||
|
||||
export interface LineStyle {
|
||||
@@ -36,12 +36,12 @@ export interface LineStyle {
|
||||
export interface TreeNode {
|
||||
key: string;
|
||||
title: ReactNode | ((nodeData: TreeNodeExtra) => ReactNode);
|
||||
selectEnabled?: boolean; // 默认值 true
|
||||
indentDisabled?: boolean; // 关闭缩进。 仅针对如下场景生效:子节点中的最后一个节点
|
||||
lineStyle?: LineStyle; // 当指定了此属性时,会覆盖全局的lineStyle
|
||||
selectEnabled?: boolean; // Default value true
|
||||
indentDisabled?: boolean; // Turn off indentation. Only works for the following scenarios: the last node in the sub-node
|
||||
lineStyle?: LineStyle; // When this property is specified, the global lineStyle is overridden.
|
||||
children?: TreeNode[];
|
||||
zIndex?: number;
|
||||
// 其他字段,会透传
|
||||
// Other fields will be passed through
|
||||
extra?: unknown;
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@ export interface FilteredTreeNode extends SpanNode, TreeNodeInfo {
|
||||
export type TreeNodeExtra = Omit<TreeNode, 'children'> & {
|
||||
colNo: number;
|
||||
rowNo: number;
|
||||
unindented: boolean; // 相对于父节点,是否未缩进
|
||||
selected: boolean; // 是否被选中
|
||||
hover: boolean; // 是否hover
|
||||
unindented: boolean; // Is it unindented relative to the parent node?
|
||||
selected: boolean; // Is it selected?
|
||||
hover: boolean; // Whether to hover
|
||||
};
|
||||
|
||||
// 拉平后的TreeNode信息
|
||||
// Flattened TreeNode information
|
||||
export type TreeNodeFlatten = Omit<TreeNodeExtra, 'selected' | 'hover'>;
|
||||
|
||||
export interface Line {
|
||||
@@ -72,9 +72,9 @@ export interface Line {
|
||||
}
|
||||
|
||||
export interface GlobalStyle {
|
||||
indent?: number; // 父节点和子节点的缩进距离
|
||||
verticalInterval?: number; // node节点的垂直间距
|
||||
nodeBoxHeight?: number; // node-box节点的高度
|
||||
indent?: number; // Indent distance of parent and child nodes
|
||||
verticalInterval?: number; // Vertical spacing of nodes
|
||||
nodeBoxHeight?: number; // The height of the node-box node
|
||||
offsetX?: number;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export interface MouseEventParams {
|
||||
export interface TreeProps {
|
||||
treeData: TreeNode;
|
||||
selectedKey?: string;
|
||||
indentDisabled?: boolean; // 关闭缩进。 仅针对如下场景生效:最后一个节点
|
||||
indentDisabled?: boolean; // Turn off indentation. Only works for the following scenarios: the last node
|
||||
lineStyle?: LineStyle;
|
||||
globalStyle?: GlobalStyle;
|
||||
className?: string;
|
||||
|
||||
@@ -19,14 +19,14 @@ import { omit } from 'lodash-es';
|
||||
import { type TreeNodeFlatten, type TreeNode, type Line } from './typing';
|
||||
|
||||
/**
|
||||
* 基于TreeData生成:
|
||||
* Generated based on TreeData:
|
||||
*
|
||||
* @param treeData tree原始数据
|
||||
* @param options.indentDisabled 是否取消缩进。仅针对下述场景有效:异常节点+最后一个节点
|
||||
* @param treeData tree original data source
|
||||
* @Param options.indentDisabled Whether to unindent. Valid only for the following scenarios: exception node + last node
|
||||
*
|
||||
* @returns
|
||||
* 1. nodes, 拉平后的node节点信息
|
||||
* 2. lines, 用于将node进行连接
|
||||
* 1. nodes, node information after leveling
|
||||
* 2. lines, used to connect nodes
|
||||
*/
|
||||
export const flattenTreeData = (
|
||||
treeData: TreeNode,
|
||||
@@ -45,7 +45,7 @@ export const flattenTreeData = (
|
||||
...omit(node, ['children']),
|
||||
colNo: nodeColNo,
|
||||
rowNo: nodes.length,
|
||||
unindented: fatherNodeFlatten?.colNo === nodeColNo, // 未缩进
|
||||
unindented: fatherNodeFlatten?.colNo === nodeColNo, // Unindented
|
||||
};
|
||||
nodes.push(nodeFlatten);
|
||||
if (fatherNodeFlatten !== undefined) {
|
||||
@@ -59,7 +59,7 @@ export const flattenTreeData = (
|
||||
const childNodes = node.children;
|
||||
|
||||
childNodes.forEach((childNode, index) => {
|
||||
// 取消缩进。 生效场景:异常节点+最后一个节点
|
||||
// Cancel indentation. Effective scene: exception node + last node
|
||||
const indentDisabled =
|
||||
childNode.indentDisabled ?? options.indentDisabled;
|
||||
if (indentDisabled && childNodes.length - 1 === index) {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* 从 @flow-devops/observation-components copy
|
||||
* 暂不去理解其中逻辑
|
||||
* From @flow-devops/observation-components copy
|
||||
* I don't understand the logic yet.
|
||||
*/
|
||||
export { TraceTree } from './trace-tree';
|
||||
export { TraceFlameThread } from './trace-flame-thread';
|
||||
|
||||
@@ -33,12 +33,12 @@ export type TraceTreeProps = {
|
||||
onCollapseChange?: (id: string) => void;
|
||||
defaultDisplayMode?: DisplayMode;
|
||||
/**
|
||||
* 隐藏模式选择器
|
||||
* hidden mode selector
|
||||
*/
|
||||
hideModeSelect?: boolean;
|
||||
/** 宿主用户信息 */
|
||||
/** Host user information */
|
||||
hostUser?: {
|
||||
/** 用户邮箱 */
|
||||
/** user email */
|
||||
email?: string;
|
||||
/** user id */
|
||||
id?: string;
|
||||
|
||||
@@ -35,25 +35,25 @@ export interface Value {
|
||||
}
|
||||
|
||||
export enum FrontedTagType {
|
||||
/** 文本 */
|
||||
/** Text */
|
||||
TEXT = 0,
|
||||
/** 时间,用时间戳,单位是微秒 */
|
||||
/** Time, with timestamp, in microseconds */
|
||||
TIME = 1,
|
||||
/** 时间间隔,单位是微秒 */
|
||||
/** Time interval, in microseconds */
|
||||
TIME_DURATION = 2,
|
||||
}
|
||||
|
||||
export interface FrontendTag {
|
||||
key: string;
|
||||
/** 多语,如无配置时值沿用 key */
|
||||
/** Multilingual, if there is no configuration value, use the key */
|
||||
key_alias?: string;
|
||||
tag_type: TagType;
|
||||
value?: Value;
|
||||
/** 用于自定义渲染 */
|
||||
/** For custom rendering */
|
||||
element?: ReactNode;
|
||||
/** 前端类型,用于前端处理 */
|
||||
/** Front-end type for front-end processing */
|
||||
frontend_tag_type?: FrontedTagType;
|
||||
/** 是否可复制 */
|
||||
/** Can it be copied? */
|
||||
can_copy?: boolean;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export interface Tag {
|
||||
}
|
||||
|
||||
export enum InputOutputType {
|
||||
/** 文本类型 */
|
||||
/** Text type */
|
||||
TEXT = 0,
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ export interface TraceFrontendSpan {
|
||||
name?: string;
|
||||
alias_name?: string;
|
||||
parent_id?: string;
|
||||
/** 单位是微秒 */
|
||||
/** That's in microseconds. */
|
||||
duration?: Int64;
|
||||
/** 单位是微秒 */
|
||||
/** That's in microseconds. */
|
||||
start_time?: Int64;
|
||||
status_code?: number;
|
||||
product_line?: string;
|
||||
@@ -97,16 +97,16 @@ export interface TraceFrontendSpan {
|
||||
owner_list?: Array<string>;
|
||||
rundown_doc_url?: string;
|
||||
tags?: Array<Tag>;
|
||||
/** 节点详情 */
|
||||
/** node details */
|
||||
summary?: SpanSummary;
|
||||
input?: SpanInputOutput;
|
||||
output?: SpanInputOutput;
|
||||
}
|
||||
|
||||
export interface TraceHeader {
|
||||
/** 单位是微秒 */
|
||||
/** That's in microseconds. */
|
||||
duration?: Int64;
|
||||
/** 输入消耗token数 */
|
||||
/** Enter the number of tokens consumed */
|
||||
tokens?: number;
|
||||
status_code?: number;
|
||||
tags?: Array<FrontendTag>;
|
||||
|
||||
Reference in New Issue
Block a user