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

@@ -69,12 +69,12 @@ describe('useLineClamp', () => {
const { result } = renderHook(() => useLineClamp());
// 使用 vi.spyOn 来模拟 contentRef.current
// Use vi.spyOn to simulate contentRef.current
vi.spyOn(result.current.contentRef, 'current', 'get').mockReturnValue(
mockDiv,
);
// 使用 act 包装异步操作
// Wrap asynchronous operations with act
act(() => {
window.dispatchEvent(new Event('resize'));
});
@@ -85,10 +85,10 @@ describe('useLineClamp', () => {
it('should handle null contentRef', () => {
const { result } = renderHook(() => useLineClamp());
// 使用 vi.spyOn 来模拟 contentRef.current null
// Use vi.spyOn to simulate contentRef. current is null
vi.spyOn(result.current.contentRef, 'current', 'get').mockReturnValue(null);
// 使用 act 包装异步操作
// Wrap asynchronous operations with act
act(() => {
window.dispatchEvent(new Event('resize'));
});

View File

@@ -15,7 +15,7 @@
*/
/**
* @description `LayoutContext`用于跨组件传递布局相关信息
* @Description 'LayoutContext' is used to pass layout-related information across components
* @since 2024.03.05
*/
import { createContext, useContext } from 'react';

View File

@@ -19,7 +19,7 @@
declare const ENABLE_COVERAGE: boolean;
interface Window {
/**
* tea 实例
* Tea example
*/
Tea?: any;
}

View File

@@ -16,14 +16,14 @@
import { useLocation } from 'react-router-dom';
/** 清空认证数据的路由参数 */
/** Clear the routing parameters of the authentication data */
export const resetAuthLoginDataFromRoute = () => {
window.history.replaceState({}, '');
};
export function useResetLocationState() {
const location = useLocation();
return () => {
// 清空location的state
// Clear the state of the location
location.state = {};
resetAuthLoginDataFromRoute();
};

View File

@@ -24,9 +24,9 @@ export interface ComponentStateUpdateFunc<State extends Obj> {
}
/**
* 对 state 一层封装,用途:
* 1. 默认增量更新
* 2. 支持重置
* One-layer encapsulation of state, use:
* 1. Default incremental update
* 2. Support reset
*
* @example
* const { state, resetState, setState } = useComponentState({ a: 1, b: 2 });

View File

@@ -28,11 +28,11 @@ import {
} from '@coze-arch/bot-api/developer_api';
/**
* 用于校验当前模块默认展开收起状态
* @deprecated 改属性已经废弃不维护,请更换@coze-agent-ide/tool中的useToolContentBlockDefaultExpand
* @param blockKey 主键
* @param configured 是否有配置内容
* @param when 是否校验
* Used to verify the default expanded and stowed state of the current module
* @Deprecated change attribute is deprecated and not maintained, please replace the useToolContentBlockDefaultExpand in @code-agent-ide/tool
* @param blockKey primary key
* @param configured whether there is configuration content
* Check when @param
*
*/
const useDefaultExPandCheck = (
@@ -52,18 +52,18 @@ const useDefaultExPandCheck = (
})),
);
return useMemo(() => {
// 不做校验
// No verification
if (!$when) {
return undefined;
// 状态机未就绪
// Finite-state machine not ready
} else if (!init || size(botSkillBlockCollapsibleState) === 0) {
return undefined;
/**
* @description 仅在满足以下条件时用户行为记录才能生效
* @Description A user behavior record is only valid if the following conditions are met
*
* 1. 用户有编辑权限
* 2. 不能是历史预览环境
* 3. 必须已配置
* 1. Users have editing rights
* 2. Cannot be a historical preview environment
* 3. Must be configured
*/
} else if (editable && !isReadonly && configured) {
const transformerBlockKey = skillKeyToApiStatusKeyTransformer(blockKey);

View File

@@ -24,38 +24,38 @@ import { getFileListByDragOrPaste } from './helper/get-file-list-by-drag';
export interface UseDragAndPasteUploadParam {
ref: RefObject<HTMLDivElement>;
/**
* 触发上传的回调
* Callback that triggers upload
*/
onUpload: (fileList: File[]) => void;
/**
* 是否禁用拖拽上传
* Whether to disable drag-and-drop uploads
*/
disableDrag: boolean;
/**
* 是否禁用粘贴上传
* Whether to disable paste uploads
*/
disablePaste: boolean;
/**
* 最大上传的文件数量
* Maximum number of uploaded files
*/
fileLimit: number;
/**
* 文件大小, eg: 10MB = 10 * 1024 * 1024
* File size, eg: 10MB = 10 * 1024 * 1024
*/
maxFileSize: number;
invalidSizeMessage: string | undefined;
invalidFormatMessage: string | undefined;
fileExceedsMessage: string | undefined;
/**
* 文件格式是否合法
* Is the file format legal?
*/
isFileFormatValid: (file: File) => boolean;
/**
* @returns 已存在文件的数量
* @Returns the number of existing files
*/
getExistingFileCount: () => number;
/**
* 用户离开拖拽区域时, state 变化的延迟
* Delay in state change when the user leaves the drag area
* @default 100
*/
closeDelay: number | undefined;
@@ -79,9 +79,9 @@ export const useDragAndPasteUpload = ({
const [isDragOver, setIsDragOver] = useState(false);
/**
* drag 时, 指针从 parent dom 进入到 child dom 时会快速连续触发 onDragEnter onDragLeave 导致状态流转错误
* 在 onLeave 时给状态流转加上延时能够避免流转问题
* 触发 dragEnter dragLeave , event.target 不一定指向 parent dom, 所以也无法通过 target 来判断
* When dragging, the pointer from the parent dom to the child dom will fire onDragEnter onDragLeave in quick succession, resulting in a state flow error
* Adding a delay to the state flow on onLeave avoids the flow problem
* When dragEnter dragLeave is triggered, event.target does not necessarily point to parent dom, so it cannot be judged by target
*/
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -147,10 +147,10 @@ export const useDragAndPasteUpload = ({
const onDragOver = (e: HTMLElementEventMap['dragover']) => {
/**
* {@link https://segmentfault.com/q/1010000011746669}
* 原理:
* 这里阻止的默认行为是开启可编辑模式,具体就是document.designMode属性,
* 该属性默认是off关闭的当开启之后就可以对网页进行编辑
* 开启的方式就是document.designMode = "on"; 开启之后就不用在监听dragover事件中阻止默认了
* Principle:
* The default behavior blocked here is to enable editable mode, specifically the document.designMode property,
* This property is turned off by default, and when turned on, you can edit the webpage.
* The way to open it is document.designMode = "on"; after opening it, there is no need to block the default in the monitor dragover event.
*/
e.preventDefault();
clearTimer();

View File

@@ -22,20 +22,20 @@ import { useInViewport } from 'ahooks';
import { type EVENT_NAMES, sendTeaEvent } from '@coze-arch/bot-tea';
export interface UseExposureParams {
/** 曝光元素 */
/** Exposure element */
target: BasicTarget;
/** Intersection observer参数 */
/** Intersection observer parameters */
options?: Options;
/** 上报事件名称 */
/** event name reported */
eventName?: EVENT_NAMES;
/** 上报参数 */
/** reporting parameters */
reportParams?: Record<string, unknown>;
/** 是否进行上报 默认为true */
/** Whether to report, the default is true */
needReport?: boolean;
isReportOnce?: boolean;
}
/** 曝光埋点上报 */
/** Exposure event tracking report */
export const useExposure = ({
target,
options,
@@ -49,7 +49,7 @@ export const useExposure = ({
useEffect(() => {
if (isReportOnce && refHasReport.current) {
//已上报过数据,就直接返回
//If the data has been reported, please return directly.
return;
}
if (needReport && isInView) {

View File

@@ -17,6 +17,6 @@
import { userStoreService } from '@coze-studio/user-store';
/**
* 判断当前用户是否处于登陆状态
* Determine whether the current user is logged in
*/
export const useLoggedIn = () => userStoreService.useIsLogined();

View File

@@ -22,9 +22,9 @@ export interface PageStateUpdateFunc<State extends object = object> {
}
/**
* 对state一层封装包含更新state、重置state
* A layer of encapsulation of state, including updating state and resetting state
*
* @deprecated 请使用 bot-hooks 的 useComponentStates
* @deprecated Please use the useComponentStates of bot-hooks
*/
export function usePageState<State extends object = object>(
initState: State,
@@ -52,7 +52,7 @@ export function usePageState<State extends object = object>(
useEffect(
() => () => {
// 自动重置状态
// Automatic reset status
if (destroyRef.current) {
resetState();
}

View File

@@ -21,78 +21,78 @@ import { type ScreenRange } from '@coze-arch/responsive-kit';
export interface TRouteConfigGlobal {
/**
* 展示小助手
* display assistant
* @default true
* @import 开源版不支持该字段
* @Import open source version does not support this field
*/
showAssistant?: boolean;
/**
* 展示小助手引导提示
* Show assistant guide prompt
* @default false
* @import 开源版不支持该字段
* @Import open source version does not support this field
*/
showAssistantGuideTip?: boolean;
/**
* 当企业ID发生变化时的回调函数。
* @import 开源版不支持该字段
* @param enterpriseId - 变化后的企业ID
* @param params - 包含导航函数和当前路径名的对象。
* Callback function when the enterprise ID changes.
* @Import open source version does not support this field
* @Param enterpriseId - Changed enterprise ID.
* @Param params - An object containing the navigation function and the current pathname.
*/
onEnterpriseChange?: (
enterpriseId: string,
params: {
navigate: NavigateFunction; // 导航函数,用于路由跳转。
pathname: string; // 当前路径名,用于构建新的路径。
navigate: NavigateFunction; // Navigation function for routing jumps.
pathname: string; // The current path name is used to build a new path.
},
) => void;
/**
* 是否展示侧边栏
* Whether to display the sidebar
* @default false
*/
hasSider?: boolean;
/**
* 展示移动端不适配提示文案
* Display mobile end does not fit prompt copy
* @default false
*/
showMobileTips?: boolean;
/**
* 是否需要身份验证
* Is authentication required?
* @default false
*/
requireAuth?: boolean;
/**
* 登录失效时的回退地址
* The fallback address when the login fails
* @default /sign
*/
loginFallbackPath?: string;
/**
* @deprecated
* 是否允许身份验证为可选
* Whether to allow authentication is optional
* @default false
*/
requireAuthOptional?: boolean;
/**
* 设置为 true 时自动应用缺省值 { rangeMax: ScreenRange.LG, include: false } 对应之前绝大多数支持响应式路由的配置
* The default value {rangeMax: ScreenRange. LG, include: false} is automatically applied when set to true for most previous configurations that support responsive routing
* @default false
*/
responsive?: { rangeMax: ScreenRange; include?: boolean } | true;
/**
* 子菜单组件
* submenu component
* @default undefined
*/
subMenu?: FC<Record<string, never>>;
/**
* 一级导航菜单项 key
* Primary navigation menu item key
* @default undefined
*/
menuKey?: string;
/**
* 二级导航菜单项 key
* Secondary navigation menu item key
* @default undefined
*/
subMenuKey?: string;
/**
* 控制是否根据 query 中的 page_mode 字段判断页面模式: 默认侧边导航模式 or 全屏popover模式
* Controls whether page mode is determined based on page_mode fields in the query: default side navigation mode or full screen popover mode
* @default false
*/
pageModeByQuery?: boolean;
@@ -102,7 +102,7 @@ export const useRouteConfig = <
TConfig extends TRouteConfigGlobal = TRouteConfigGlobal,
>(
defaults?: TConfig,
// 强制所有字段可能为空
// Force all fields to be empty
): Partial<TConfig> => {
const matches = useMatches();