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

@@ -26,7 +26,7 @@ export interface CreatorProps {
export const Creator: FC<CreatorProps> = ({ avatar, name, extra }) => (
<div className="flex items-center gap-x-[4px] h-[16px] coz-fg-secondary text-[12px] leading-16px">
{/* 开源版无多人协作功能,不展示资源所有者信息 */}
{/* The open-source version has no multi-person collaboration function and does not display resource owner information */}
{IS_OPEN_SOURCE ? null : (
<>
<Avatar className="w-[16px] h-[16px] flex-shrink-0" src={avatar} />

View File

@@ -21,8 +21,8 @@ import { IconCozEmpty, IconCozBroom } from '@coze-arch/coze-design/icons';
import { Button } from '@coze-arch/coze-design';
interface WorkspaceEmptyProps {
onClear?: () => void; // 清空按钮点击事件
hasFilter?: boolean; // 是否有筛选项
onClear?: () => void; // Clear button click event
hasFilter?: boolean; // Is there a filter
}
export const WorkspaceEmpty: FC<WorkspaceEmptyProps> = ({

View File

@@ -19,7 +19,7 @@ export { default as Tool } from './pages/tool';
export { default as MocksetDetail } from './pages/mockset';
export { default as MocksetList } from './pages/mockset-list';
// !Notice 禁止直接导出 knowledge 相关代码,避免首屏加载
// ! Notice prohibits the direct export of knowledge-related codes to avoid first-screen loading
// export { default as KnowledgePreviewPage } from './pages/knowledge-preview';
// export { default as KnowledgeUploadPage } from './pages/knowledge-upload';
export { default as DatabaseDetailPage } from './pages/database';
@@ -29,7 +29,7 @@ export {
compareObjects,
} from './utils';
// 公共组件
// common component
export { Creator } from './components/creator';
export {
Content,

View File

@@ -53,7 +53,7 @@ export interface BotCardProps {
intelligenceInfo: IntelligenceData;
timePrefixType?: 'recentOpen' | 'publish' | 'edit';
/**
* 返回 true 时会打断默认的跳转行为
* Returning true interrupts the default jump behavior
*/
onClick?: (() => true) | (() => void);
onDelete?: (param: {
@@ -128,7 +128,7 @@ export const BotCard: React.FC<BotCardProps> = ({
};
if (!id || !space_id) {
// id 和 space id 对 bot 卡片来说是必须的,这里约束一下 ts 类型
// The id and space id are necessary for the bot card. Here are the constraints on the ts type
throw Error('No botID or no spaceID which are necessary');
}
@@ -169,9 +169,9 @@ export const BotCard: React.FC<BotCardProps> = ({
return formatDate(Number(timestamp), getFormatDateType(Number(timestamp)));
}, [timePrefixType, publish_time, update_time, recently_open_time]);
// 是否展示 card 复层操作按钮
// Whether to display the card layering operation button
const [showActions, setShowActions] = useState(false);
// 是否展示 menu 菜单,这里有其他组件主动调用,需要受控
// Whether to display the menu menu, there are other components actively calling here, which need to be controlled
const [showMenu, setShowMenu] = useState(false);
return (
@@ -211,20 +211,20 @@ export const BotCard: React.FC<BotCardProps> = ({
}}
data-testid="bot-list-page.bot-card"
>
{/* 展示迁移失败状态 icon */}
{/* Display migration failure status icon */}
{statusExtra}
{/* bot 基本信息 */}
{/* Bot basic information */}
<div className="flex justify-between">
<div className="flex flex-col gap-[4px] w-[calc(100%-76px)]">
<div className="flex items-center gap-[4px]">
<Name name={name} />
{isBanned ? (
// 如果失效了,高优展示失效 icon
// If it fails, display the failure icon
<IconCozWarningCircleFill className="text-xxl coz-fg-hglt-red flex-shrink-0" />
) : (
<>
{/* 发布状态 icon */}
{/* Publish status icon */}
{renderPublishStatusIcon()}
{headerExtra}
</>
@@ -240,10 +240,10 @@ export const BotCard: React.FC<BotCardProps> = ({
/>
</div>
{/* 项目/智能体 */}
{/* Projects/Agents */}
<IntelligenceTag intelligenceType={type} />
{/* bot 作者信息 */}
{/* Bot author information */}
{!!owner_info && (
<Creator
avatar={owner_info.avatar_url}
@@ -252,7 +252,7 @@ export const BotCard: React.FC<BotCardProps> = ({
/>
)}
{/* actions 浮层 action 浮层出现的时候下方有一个白色遮罩 */}
{/* Actions Floating layer action When the floating layer appears, there is a white mask below */}
{!hideOperation ? (
<>
{showActions && actionsMenuVisible ? (
@@ -267,14 +267,14 @@ export const BotCard: React.FC<BotCardProps> = ({
<div
className="absolute bottom-[16px] right-[16px] flex gap-[4px]"
onClick={e => {
// 阻止 click 事件冒泡到 card 最外层
// Prevent click events from bubbling to the outermost layer of the card
e.stopPropagation();
}}
>
{showActions && actionsMenuVisible ? (
<>
{!isBanned ? (
// 收藏 bot
// Favorite bot
<FavoriteIconBtn
useButton
isVisible
@@ -295,7 +295,7 @@ export const BotCard: React.FC<BotCardProps> = ({
}}
/>
) : null}
{/* 下拉菜单 */}
{/* dropdown menu */}
<Menu
keepDOM
className="w-fit mt-4px mb-4px"
@@ -304,7 +304,7 @@ export const BotCard: React.FC<BotCardProps> = ({
visible={showMenu}
render={
<Menu.SubMenu mode="menu">
{/* 复制 bot */}
{/* Copy bot */}
{isAgent ? (
<MenuCopyBot
id={id}
@@ -330,7 +330,7 @@ export const BotCard: React.FC<BotCardProps> = ({
</Tooltip>
) : null}
{extraMenu}
{/* 删除 bot */}
{/* Delete bot */}
<Tooltip
position="left"
trigger={can_delete ? 'custom' : 'hover'}
@@ -365,7 +365,7 @@ export const BotCard: React.FC<BotCardProps> = ({
</Menu>
</>
) : is_fav && !isBanned ? (
// 如果 bot 已经收藏了,非 hover 时展示 icon
// If the bot has already been collected, display the icon when not hovering.
<IconButton
className="!pt-[20px]"
color="secondary"

View File

@@ -41,7 +41,7 @@ export const IntelligenceTag: React.FC<IntelligenceTagProps> = ({
if (intelligenceType === IntelligenceType.DouyinAvatarBot) {
return (
<Tag color="red" size="small" className="w-fit">
{/* TODO: i18n 文案 */}
{/* TODO: i18n copywriting */}
</Tag>
);

View File

@@ -49,7 +49,7 @@ export const useCachedQueryParams = () => {
);
useUpdateEffect(() => {
/** 当筛选条件变化时,取合适的 key 存入本地 */
/** When the filter conditions change, take the appropriate key and store it locally */
const { searchScope, isPublish, recentlyOpen, searchType } = filterParams;
localStorageService.setValue(
'workspace-develop-filters',
@@ -63,7 +63,7 @@ export const useCachedQueryParams = () => {
}, [filterParams]);
useEffect(() => {
/** 异步读取本地存储的筛选条件 */
/** Asynchronously reads filters from local storage */
getDefaultFilterParams().then(filters => {
setFilterParams(prev => merge({}, prev, filters));
});
@@ -75,7 +75,7 @@ export const useCachedQueryParams = () => {
...params,
searchValue,
}));
// tea 埋点
// Tea event tracking
sendTeaEvent(EVENT_NAMES.search_front, {
full_url: location.href,
source: 'develop',

View File

@@ -33,7 +33,7 @@ export const useGlobalEventListeners = ({
const handlerRefreshFavList = (
refreshFavListParams: RefreshFavListParams,
) => {
// 只在工作空间收藏取消收藏变化的时候刷新列表
// Refresh the list only when the workspace collection is cancelled and the collection is changed.
if (refreshFavListParams.emitPosition === 'favorites-list-item') {
reload();
}

View File

@@ -62,7 +62,7 @@ const getIntelligenceList = async (
}: FilterParamsType,
cancelTokenRef: React.MutableRefObject<CancelTokenSource | null>,
) => {
// 每次新的请求,都重置一下 cancel token
// Reset the cancel token every time a new request is made.
const source = axios.CancelToken.source();
cancelTokenRef.current = source;
const resp = await intelligenceApi
@@ -76,7 +76,7 @@ const getIntelligenceList = async (
recently_open: recentlyOpen,
cursor_id: dataSource?.nextCursorId,
search_scope: searchScope,
// 固定值,来自历史代码
// Fixed value, from historical code
order_by: orderBy,
status: [
IntelligenceStatus.Using,
@@ -193,7 +193,7 @@ export const useIntelligenceList = ({
useEffect(
() => () => {
// 取消正在请求的接口
// Cancel the requested interface
cancelTokenRef.current?.cancel();
},
[spaceId],

View File

@@ -84,7 +84,7 @@ export const useProjectCopyPolling = ({
});
}),
);
// 需要重新封装下
// Need to be re-packaged
list.forEach(item => {
if (item.entity_status === IntelligenceStatus.Using) {
const successToastId = Toast.success({

View File

@@ -32,7 +32,7 @@ export const produceCopyIntelligenceData = ({
basicInfo: IntelligenceBasicInfo;
};
}) => {
// 这是 fallback
// This is fallback
const userInfo = getUserInfo();
const userLabel = getUserLabel();
return produce<IntelligenceData>(originTemplateData, draft => {

View File

@@ -31,8 +31,8 @@ export const getPublishRequestParam = (
};
/**
* 项目类型请求前后端参数映射,将DevelopCustomTypeStatus映射为IntelligenceType[]
* 需要根据是否可以展示抖音分身来决定是否处理 DouyinAvatarBot
* Project Type Request Front and Back End Parameter Mapping, Mapping DevelopCustomTypeStatus to Intelligence Type []
* You need to decide whether to deal with DouyinAvatarBot according to whether the Douyin doppelganger can be displayed.
* @param type
* @returns
*/

View File

@@ -29,7 +29,7 @@ export enum DevelopCustomTypeStatus {
All = 0,
Project = 1,
Agent = 2,
DouyinAvatarBot = 3, // single agent 类型的抖音分身
DouyinAvatarBot = 3, // Single agent type Douyin doppelganger
}
export interface DraftIntelligenceList {

View File

@@ -83,7 +83,7 @@ export const KnowledgePreviewPage = () => {
if (params.biz === 'project') {
return <BizProjectKnowledgeIDE />;
}
// 默认'library'
// Default'library'
return <BizLibraryKnowledgeIDE />;
})()}
</KnowledgeParamsStoreProvider>

View File

@@ -33,9 +33,9 @@ export const initialParam: QueryParams = {
name: '',
};
/** 是否由当前用户创建:
* 0-不筛选
* 1-当前用户 */
/** Is it created by the current user?
* 0 - Do not filter
* 1 - Current user */
export const getScopeOptions = () => [
{
label: I18n.t('library_filter_tags_all_creators'),
@@ -47,10 +47,10 @@ export const getScopeOptions = () => [
},
];
/** 发布状态:
* 0-不筛选
* 1-未发布
* 2-已发布 */
/** Release status:
* 0 - Do not filter
* 1 - Unpublished
* 2- Published */
export const getStatusOptions = () => [
{
label: I18n.t('library_filter_tags_all_status'),

View File

@@ -27,7 +27,7 @@ import { compareObjects } from '@/utils';
import { initialParam, type QueryParams } from '../consts';
/**
* 从url query中获取搜索参数 优先级最高高于LS缓存
* Get search parameters from url query, highest priority, higher than LS cache
* @returns {} | undefined
*/
const getSearchParamsFromUrl = () => {
@@ -47,7 +47,7 @@ const getSearchParamsFromUrl = () => {
return searchParams;
};
// 异步初始化获取筛选参数, 分别从LS缓存获取和url query获取
// Asynchronous initialization to obtain filter parameters, obtained from LS cache and url query respectively
const getDefaultFilterParams = async () => {
const searchParamsFromUrl = getSearchParamsFromUrl();
const localFilterParams = await localStorageService.getValueSync(
@@ -60,7 +60,7 @@ const getDefaultFilterParams = async () => {
defaultFilterParams = { ...defaultFilterParams, ...safeParams };
}
// 图像流和工作流合并会删除资源中的图像流选项 这里转换成全部
// Merging image flow and workflow removes the image flow option in the resource, here converted to all
if (defaultFilterParams?.res_type_filter?.[0] === 3) {
defaultFilterParams.res_type_filter[0] = -1;
}
@@ -80,21 +80,21 @@ export const useCachedQueryParams = ({ spaceId }: { spaceId: string }) => {
'name',
]);
/** 每次切换空间的时候,重新初始化筛选条件,并清空搜索框,重新请求资源列表 */
/** Each time you switch spaces, reinitialize the filter criteria, clear the search box, and rerequest the resource list */
useEffect(() => {
setReady(false);
getDefaultFilterParams().then(filters => {
setParams(p => ({
...p,
...filters,
cursor: '', // 筛选、刷新时重置为空
cursor: '', // Filter, reset to empty when refreshing
}));
setReady(true);
});
}, [spaceId]);
useUpdateEffect(() => {
/** 当筛选条件变化时,取合适的 key 存入本地 */
/** When the filter conditions change, take the appropriate key and store it locally */
const tempParams = {
res_type_filter: params.res_type_filter,
user_filter: params.user_filter,

View File

@@ -35,7 +35,7 @@ import { BaseLibraryItem } from '../components/base-library-item';
const { Text } = Typography;
// 预设表格cell最小宽度
// Default table cell minimum width
const NAME_COL_WIDTH = 260;
const ACTIONS_COL_WIDTH = 60;
const TYPE_COL_WIDTH = 100;
@@ -43,7 +43,7 @@ const CREATOR_COL_WIDTH = 231;
const EDITED_TIME_COL_WIDTH = 150;
const stopPro = (e: MouseEvent<HTMLDivElement>) => {
e.stopPropagation(); //阻止冒泡
e.stopPropagation(); //Stop bubbling
};
const getResTypeLabelFromConfigMap = (

View File

@@ -90,11 +90,11 @@ export const useDatabaseConfig: UseEntityConfigHook = ({
);
},
renderActions: (item: ResourceInfo) => {
// 是否能删除
// Can it be deleted?
const deleteDisabled = !item.actions?.find(
action => action.key === ActionKey.Delete,
)?.enable;
// 是否启用
// Whether to enable
// delete operation
const deleteProps = {

View File

@@ -36,7 +36,7 @@ import { type UseEntityConfigHook } from './types';
const { TableAction } = Table;
/**
* 知识库tag
* Knowledge base tags:
* 0-text
* 1-table
* 2-image
@@ -48,7 +48,7 @@ const knowledgeSubTypeTextMap: Record<number, I18nKeysNoOptionsType> = {
};
/**
* 禁用状态tag
* Disable status tag:
* 3-disabled
* */
const knowledgeBizStatusTextMap: Record<number, I18nKeysNoOptionsType> = {
@@ -172,7 +172,7 @@ export const useKnowledgeConfig: UseEntityConfigHook = ({
},
});
// 删除
// delete
const { run: delKnowledge } = useRequest(
(datasetId: string) =>
KnowledgeApi.DeleteDataset({
@@ -187,14 +187,14 @@ export const useKnowledgeConfig: UseEntityConfigHook = ({
},
);
// 开启开关
// turn on switch
const { run: enableKnowledge, loading } = useRequest(
(enableStatus: boolean, record: ResourceInfo) =>
KnowledgeApi.UpdateDataset({
dataset_id: record.res_id,
name: record.name,
description: record.desc,
icon_uri: record.biz_extend?.icon_uri, // 从业务字段获取
icon_uri: record.biz_extend?.icon_uri, // Get from business field
status: enableStatus
? DatasetStatus.DatasetReady
: DatasetStatus.DatasetForbid,
@@ -228,7 +228,7 @@ export const useKnowledgeConfig: UseEntityConfigHook = ({
const deleteDisabled = !item.actions?.find(
action => action.key === ActionKey.Delete,
)?.enable;
// knowledge 资源启用状态开关 enable 的是否禁用状态即switch标签的禁用状态
// Knowledge Resource Enabled Status Whether the switch enabled is disabled (i.e. the disabled state of the switch label)
const enableDisabled = !item.actions?.find(
action => action.key === ActionKey.EnableSwitch,
)?.enable;

View File

@@ -75,7 +75,7 @@ export const usePromptConfig: UseEntityConfigHook = ({
usePromptConfiguratorModal({
spaceId,
source: 'resource_library',
// 即将支持,敬请期待
// Support soon, so stay tuned.
enableDiff: FLAGS['bot.studio.prompt_diff'],
onUpdateSuccess: reloadList,
onDiff: ({ libraryId }) => {
@@ -86,7 +86,7 @@ export const usePromptConfig: UseEntityConfigHook = ({
},
});
// 删除
// delete
const { run: delPrompt } = useRequest(
(promptId: string) =>
PlaygroundApi.DeletePromptResource({

View File

@@ -57,7 +57,7 @@ export const useWorkflowConfig: UseEntityConfigHook = ({
value: ResType.Workflow,
},
parseParams: params => {
// 工作流图像流合并之后 选中工作流需要同时也拉取出图像流
// After the workflow image stream is merged, the selected workflow needs to also pull out the image stream
if (params?.res_type_filter?.[0] === ResType.Workflow) {
return {
...params,
@@ -77,7 +77,7 @@ export const useWorkflowConfig: UseEntityConfigHook = ({
>
{I18n.t('library_resource_type_workflow')}
</Menu.Item>
{/* 开源版本暂时不支持对话流 */}
{/* The open-source version does not support conversation streaming for the time being */}
{!IS_OPEN_SOURCE ? (
<Menu.Item
data-testid="workspace.library.header.create.chatflow"

View File

@@ -81,7 +81,7 @@ export const BaseLibraryPage = forwardRef<
hasMore: false,
};
}
// 允许业务定制请求参数
// Allow business to customize request parameters
const resp = await PluginDevelopApi.LibraryResourceList(
entityConfigs.reduce<LibraryResourceListRequest>(
(res, config) => config.parseParams?.(res) ?? res,
@@ -255,7 +255,7 @@ export const BaseLibraryPage = forwardRef<
loading: listResp.loading,
dataSource: listResp.data?.list,
columns,
// 整行点击
// Click on the whole line
onRow: (record?: ResourceInfo) => {
if (
!record ||

View File

@@ -25,61 +25,61 @@ import {
export interface LibraryEntityConfig {
/**
* 资源类型筛选器配置,传入级联选择器的数据类型
* Resource type filter configuration, passing in the data type of the cascading selector
**/
typeFilter?: CascaderData & ({ filterName: string } | { label: string });
/**
* 允许各个业务定制请求参数的格式化逻辑,避免特化逻辑侵入到底层组件中
* @param params 原始的 query 参数
* @returns 格式化后的 query 参数
* Allows each business to customize the formatting logic of request parameters to avoid intrusion of specialized logic into the underlying components
* @Param params original query parameters
* @Returns formatted query parameters
*/
parseParams?: (
params: LibraryResourceListRequest,
) => LibraryResourceListRequest;
/**
* 渲染创建菜单
* @param params 相关参数
* @params params.spaceId 空间 ID
* @params params.isPersonalSpace 是否是个人空间
* @params params.reloadList 刷新列表 API
* @returns 渲染结果
* Render Create Menu
* @param params related parameters
* @Params params.spaceId Space ID
* @Params params.isPersonalSpace is a personal space
* @Params params.reloadList Refresh List API
* @Returns render result
*/
renderCreateMenu?: () => ReactNode;
// #region 表格配置
// #region table configuration
/**
* 匹配数据项是否由当前配置控制渲染
* Whether matching data items are rendered by the current configuration
*/
target: ResType[];
/**
* 表格行点击事件回调,一般用于打开详情弹窗或者跳转详情页
* @param item 点击行数据;
* Table row click event callback, usually used to open the details pop-up window or jump to the details page
* @param item click row data;
* @returns void;
*/
onItemClick: (item: ResourceInfo) => void;
/**
* 渲染表格资源信息列内容,不传则默认使用通用组件进行渲染
* @param item 行数据
* @returns 渲染结果
* Render the content of the table resource information column. If it is not passed, it will be rendered using general components by default.
* @param item row data
* @Returns render result
*/
renderItem?: (item: ResourceInfo) => ReactNode;
/**
* 渲染资源类型文案,缺省会使用 typeFilter 中的 label
* Render the resource type copy, using the label in the typeFilter by default
* @param resType
* @returns
*/
renderResType?: (item: ResourceInfo) => string | undefined;
/**
* 渲染表格操作列内容
* @param item 行数据
* @param reloadList 刷新列表 API
* @returns 渲染结果
* Render table operation column content
* @param item row data
* @param reloadList API
* @Returns render result
*/
renderActions: (item: ResourceInfo, reloadList: () => void) => ReactNode;
// #endregion 表格配置
// #endregion table configuration
}
export interface ListData {

View File

@@ -19,11 +19,11 @@ import { pick } from 'lodash-es';
import { type PluginNavType } from '@coze-studio/bot-plugin-store/src/context';
/**
* 比较两个对象是否相等,只比较指定的 key通过 JSON.stringify 实现
* @param obj1 对象1
* @param obj2 对象2
* @param keys 需要比较的 key
* @returns 是否相等
* Compares two objects for equality, comparing only the specified key, implemented by JSON.stringify
* @param obj1
* @param obj2
* @Param keys The key to compare
* @Returns is equal
*/
export function compareObjects<T>(
obj1: T,