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

@@ -58,7 +58,7 @@ describe('useAlign', () => {
act(() => {
result.current.alignLeft();
});
// 由于没有 canvas不应该有任何操作发生
// Since there is no canvas, no operation should occur
});
it('应该在选中对象少于 2 个时不执行任何操作', () => {

View File

@@ -88,11 +88,11 @@ describe('useBackground', () => {
},
);
// 更新 schema
// Update schema
const newSchema = createMockSchema('#000000');
rerender({ currentSchema: newSchema });
// 等待 debounce
// Waiting to debounce
await vi.runAllTimers();
expect(result.current.backgroundColor).toBe('#000000');

View File

@@ -59,7 +59,7 @@ describe('useCanvasChange', () => {
const createMockCanvas = () => {
const mockCanvas = {
on: vi.fn((event: string, callback: (event: any) => void) =>
// 返回一个清理函数
// Returns a cleaning function
() => {
mockCanvas.off(event, callback);
},
@@ -121,7 +121,7 @@ describe('useCanvasChange', () => {
}),
);
// 验证是否监听了所有默认事件
// Verify that all default events are being listened for
expect(mockCanvas.on).toHaveBeenCalledWith(
'object:modified',
expect.any(Function),
@@ -157,12 +157,12 @@ describe('useCanvasChange', () => {
}),
);
// 获取 object:modified 事件的回调函数
// Get the callback function for the object: modified event
const modifiedCallback = (mockCanvas.on as any).mock.calls.find(
(call: [string, Function]) => call[0] === 'object:modified',
)?.[1];
// 模拟事件触发
// simulated event firing
modifiedCallback?.();
expect(mockCanvas.toObject).toHaveBeenCalledWith(saveProps);
@@ -194,15 +194,15 @@ describe('useCanvasChange', () => {
}),
);
// 获取 object:removed 事件的回调函数
// Get the callback function for the object: removed event
const removedCallback = (mockCanvas.on as any).mock.calls.find(
(call: [string, Function]) => call[0] === 'object:removed',
)?.[1];
// 模拟删除事件
// mock delete event
removedCallback?.();
// 验证只保留了存在对象的引用
// Validation only keeps references to existing objects
expect(mockOnChange).toHaveBeenCalledWith({
...mockSchema,
customVariableRefs: [
@@ -296,7 +296,7 @@ describe('useCanvasChange', () => {
}),
);
// 更新已存在的引用
// Update existing references
act(() => {
result.current.updateRefByObjectId({
objectId: 'obj1',
@@ -309,7 +309,7 @@ describe('useCanvasChange', () => {
});
});
// 添加新的引用
// Add a new reference
act(() => {
result.current.updateRefByObjectId({
objectId: 'obj2',
@@ -322,14 +322,14 @@ describe('useCanvasChange', () => {
});
});
// 删除引用
// delete reference
act(() => {
result.current.updateRefByObjectId({
objectId: 'obj1',
});
});
// 验证最终的引用关系
// Verify the final reference relationship
expect(mockCanvas.toObject().customVariableRefs).toEqual([
{ objectId: 'obj2', variableId: 'var3', variableName: 'var3' },
]);

View File

@@ -110,12 +110,12 @@ describe('useCanvasClip', () => {
useCanvasClip({ canvas: mockCanvas, schema }),
);
// 先添加裁剪区域
// Add the clipping area first
act(() => {
result.current.addClip();
});
// 移除裁剪区域
// Remove clipping area
act(() => {
result.current.removeClip();
});

View File

@@ -57,7 +57,7 @@ describe('useGroup', () => {
add: vi.fn(),
remove: vi.fn(),
getObjects: vi.fn(),
// 添加必要的 fabric.Object 属性
// Add the necessary fabric. Object properties
noScaleCache: false,
lockMovementX: false,
lockMovementY: false,

View File

@@ -50,7 +50,7 @@ describe('useInitCanvas', () => {
const mockRequestRenderAll = vi.fn();
const mockDispose = vi.fn();
const mockOn = vi.fn(() => () => {
// 清理函数
// cleanup function
});
let mockCanvas: any;

View File

@@ -24,7 +24,7 @@ describe('useMousePosition', () => {
const createMockCanvas = () => {
const mockCanvas = {
on: vi.fn((event: string, callback: (event: any) => void) =>
// 返回一个清理函数
// Returns a cleaning function
() => {
mockCanvas.off(event, callback);
},
@@ -85,10 +85,10 @@ describe('useMousePosition', () => {
useMousePosition({ canvas: mockCanvas }),
);
// 初始位置
// initial position
expect(result.current.mousePosition).toEqual({ left: 0, top: 0 });
// 模拟鼠标移动
// Simulate mouse movement
act(() => {
moveCallback({
e: { clientX: 100, clientY: 200 },
@@ -135,12 +135,12 @@ describe('useMousePosition', () => {
expect.any(Function),
);
// 更新 canvas
// Update canvas
rerender({ canvas: mockCanvas2 });
// 应该清理旧的事件监听
// Old event listeners should be cleaned up
expect(cleanupSpy).toHaveBeenCalled();
// 应该设置新的事件监听
// New event listeners should be set up
expect(mockCanvas2.on).toHaveBeenCalledWith(
'mouse:move',
expect.any(Function),

View File

@@ -54,7 +54,7 @@ describe('useSnapMove', () => {
const createMockCanvas = () => {
const mockCanvas = {
on: vi.fn((event: string, callback: (event: any) => void) =>
// 返回一个清理函数
// Returns a cleaning function
() => {
mockCanvas.off(event, callback);
},
@@ -114,12 +114,12 @@ describe('useSnapMove', () => {
}),
);
// 获取 mouse:down 事件的回调函数
// Get the callback function for the mouse: down event
const mouseDownCallback = (mockCanvas.on as any).mock.calls.find(
(call: [string, Function]) => call[0] === 'mouse:down',
)?.[1];
// 模拟事件触发
// simulated event firing
mouseDownCallback?.({ target: { id: 'test-object' } });
expect(snap.resetAllObjectsPosition).toHaveBeenCalledWith({
@@ -157,12 +157,12 @@ describe('useSnapMove', () => {
}),
);
// 获取 mouse:up 事件的回调函数
// Get the callback function for the mouse: up event
const mouseUpCallback = (mockCanvas.on as any).mock.calls.find(
(call: [string, Function]) => call[0] === 'mouse:up',
)?.[1];
// 模拟事件触发
// simulated event firing
mouseUpCallback?.({ target: { id: 'test-object' } });
expect(mockSnap.reset).toHaveBeenCalled();
@@ -198,12 +198,12 @@ describe('useSnapMove', () => {
}),
);
// 获取 object:moving 事件的回调函数
// Get the callback function for the object: moving event
const movingCallback = (mockCanvas.on as any).mock.calls.find(
(call: [string, Function]) => call[0] === 'object:moving',
)?.[1];
// 模拟事件触发
// simulated event firing
movingCallback?.({ target: { id: 'test-object' } });
expect(mockSnap.move).toHaveBeenCalledWith({ id: 'test-object' });
@@ -259,7 +259,7 @@ describe('useSnapMove', () => {
},
);
// 更新 scale
// Update scale
rerender({ scale: 2 });
expect(snap.helpline.resetScale).toHaveBeenCalledWith(2);

View File

@@ -37,14 +37,14 @@ describe('typings', () => {
describe('AlignMode', () => {
it('应该定义正确的对齐模式枚举值', () => {
// 注意:这里的具体值需要根据实际的 AlignMode 枚举定义来填写
// Note: The specific values here need to be filled in according to the actual AlignMode enumeration definition
expect(AlignMode).toBeDefined();
expect(typeof AlignMode).toBe('object');
});
});
// 由于其他导出主要是类型定义,在运行时无法直接测试
// 但我们可以通过 TypeScript 的类型检查来验证它们的正确性
// Since other exports are mainly type definitions, they cannot be tested directly at runtime
// But we can verify their correctness through TypeScript's type checking
it('应该正确定义 FormMetaItem 接口', () => {
const formMetaItem = {
name: 'test',
@@ -59,7 +59,7 @@ describe('typings', () => {
},
};
// 这个测试主要是确保类型定义正确,实际运行时不会失败
// The main purpose of this test is to ensure that the type definition is correct and the actual execution does not fail
expect(formMetaItem).toBeDefined();
});