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

@@ -38,7 +38,7 @@ import {
const ImagePlaceholder = `${getUploadCDNAsset('')}/workflow/fabric-canvas/img-placeholder.png`;
// 需要额外保存的属性
// Properties that require additional saving
export const saveProps = [
'width',
'height',
@@ -46,17 +46,17 @@ export const saveProps = [
'text',
'backgroundColor',
'padding',
// 自定义参数
// textBox 的真实高度
// custom parameters
// The true height of the textBox
'customFixedHeight',
// 元素 id
// Element ID
'customId',
// 元素类型
// element type
'customType',
// image 的适应模式
// Adaptive mode of image
'customFixedType',
// // 由变量生成元素的 title
// 引用关系
// The title of the element generated by the variable
// reference relationship
'customVariableRefs',
];
@@ -94,7 +94,7 @@ export const useCanvasChange = ({
schema?.customVariableRefs ?? [],
);
// 删除画布中不存在的引用关系
// Delete reference relationships that do not exist in the canvas
const resetCustomVariableRefs = useCallback(
({ schema: _schema }: { schema: FabricSchema }) => {
let newCustomVariableRefs = cacheCustomVariableRefs.current;
@@ -110,12 +110,12 @@ export const useCanvasChange = ({
[],
);
// 监听画布变化
// Monitor canvas changes
useEffect(() => {
if (canvas && onChangeLatest.current && isListen) {
const _onChange = ({ isRemove }: { isRemove: boolean }) => {
const json = canvas.toObject(saveProps) as FabricSchema;
// 删除时,顺便删掉无效 ref
// When deleting, delete the invalid ref by the way.
if (isRemove) {
json.customVariableRefs = resetCustomVariableRefs({
schema: json,
@@ -146,7 +146,7 @@ export const useCanvasChange = ({
}, [canvas, isListen]);
/**
* 生成带引用的新元素
* Generate new elements with references
*/
const addRefObjectByVariable = useCallback(
async (variable: InputVariable, element?: FabricObject) => {
@@ -167,7 +167,7 @@ export const useCanvasChange = ({
let _element: FabricObject | undefined = element;
// 如果没有传入现有元素,则创建新元素
// If no existing element is passed in, a new element is created
if (!_element) {
if (type === ViewVariableType.Image) {
_element = await createElement({
@@ -205,7 +205,7 @@ export const useCanvasChange = ({
}
if (_element) {
// 更新引用关系
// Update reference relationship
cacheCustomVariableRefs.current.push({
variableId: id as string,
objectId: (_element as FabricObjectWithCustomProps)
@@ -213,7 +213,7 @@ export const useCanvasChange = ({
variableName: name,
});
// 添加到画布并激活
// Add to canvas and activate
canvas.add(_element);
canvas.setActiveObject(_element);
}
@@ -222,10 +222,10 @@ export const useCanvasChange = ({
);
/**
* 更新指定 objectId 的元素的引用关系
* 如果 variable 为空,则删除引用
* 如果 variable 不为空 && customVariableRefs 已存在对应关系,则更新引用
* 如果 variable 不为空 && customVariableRefs 不存在对应关系,则新增引用
* Update the reference relationship of the element specifying objectId
* If the variable is empty, remove the reference
* If variable is not empty & & customVariableRefs already has a correspondence, update the reference
* If variable is not empty & & customVariableRefs does not have a correspondence, add a reference
*
*/
const updateRefByObjectId = useCallback(
@@ -239,12 +239,12 @@ export const useCanvasChange = ({
const customVariableRefs = cacheCustomVariableRefs.current;
const targetRef = customVariableRefs.find(d => d.objectId === objectId);
let newCustomVariableRefs = [];
// 如果 variable 为空,则删除引用
// If the variable is empty, remove the reference
if (!variable) {
newCustomVariableRefs = customVariableRefs.filter(
d => d.objectId !== objectId,
);
// 如果 variable 不为空 && customVariableRefs 不存在对应关系,则新增引用
// If variable is not empty & & customVariableRefs does not have a correspondence, add a reference
} else if (!targetRef) {
newCustomVariableRefs = [
...customVariableRefs,
@@ -254,7 +254,7 @@ export const useCanvasChange = ({
variableName: variable.name,
},
];
// 如果 variable 不为空 && customVariableRefs 已存在对应关系,则更新引用
// If variable is not empty & & customVariableRefs already has a correspondence, update the reference
} else {
newCustomVariableRefs = customVariableRefs.map(d => {
if (d.objectId === objectId) {
@@ -278,7 +278,7 @@ export const useCanvasChange = ({
);
/**
* variables 变化时,更新引用关系中的变量名
* When variables change, update the variable names in the reference relationship
*/
useEffect(() => {
const { customVariableRefs = [] } = schemaLatest.current ?? {};
@@ -310,7 +310,7 @@ export const useCanvasChange = ({
const startListen = useCallback(() => {
setIsListener(true);
// redo undo 完成后,更新引用关系
// After redo undo, update the reference relationship
cacheCustomVariableRefs.current =
schemaLatest.current?.customVariableRefs ?? [];
}, []);