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

@@ -65,7 +65,7 @@ export function StepConfig({
onTableSheetChange,
}: StepConfigProps) {
const [tableData, setTableData] = useState<TableSettingsData>();
// 默认值使用第1个数据表第1行是表头第2行开始是数据
// Default: Use the first data table, the first row is the header, and the second row starts with data
const [tableSettings, setTableSettings] = useState<TableSettings>({
sheet_id: 0,
header_line_idx: 0,
@@ -86,12 +86,12 @@ export function StepConfig({
onSuccess: res => {
setTableData({
sheet_list: res.sheet_list,
preview_data: {}, // TableSettingBar 并没有读取 preview_data但是在判断它非空
preview_data: {}, // TableSettingBar does not read preview_data, but it is not empty
});
if (res.table_meta) {
setTableStructure(
res.table_meta.map(column => {
// 表结构中有同名字段时,使用原本的类型及描述
// When there are fields with the same name in the table structure, use the original type and description
const matchedField = tableFields.find(
field => field.fieldName === column.column_name,
);

View File

@@ -64,13 +64,13 @@ export function StepProcess({
[fileItem],
);
const [progressProps, setProgressProps] = useState<ProcessProps>({
// 第一行文本(文件名)
// First line of text (file name)
mainText: fileItem.name,
// 第二行文本(文件大小)
// Second line of text (file size)
subText: fileSize,
// hover 时显示的第二行文本,与上面保持一致
// The second line of text displayed when hovering, consistent with the above
tipText: fileSize,
// 进度条百分比,初始 10% 与 @coze-data/knowledge-resource-processor-base/unit-progress 保持一致
// Progress bar percentage, initial 10% is consistent with @code-data/knowledge-resource-processor-base/unit-progress
percent: INIT_PERCENT,
status: ProcessStatus.Processing,
});
@@ -87,7 +87,7 @@ export function StepProcess({
onSuccess: res => {
const { data } = res;
if (data) {
// 有错误信息代表处理失败,展示错误信息,并停止轮询
// If there is an error message, it means the processing failed. Display the error message and stop polling.
if (data.status_descript) {
const msg = data.status_descript;
setProgressProps(props => ({
@@ -102,7 +102,7 @@ export function StepProcess({
...props,
percent: data.progress ?? 0,
}));
// 进度 100 代表处理完成,更新状态并停止轮询
// Progress 100 represents process completion, update status and stop polling
if (data.progress === COMPLETE_PERCENT) {
setProgressProps(props => ({
...props,
@@ -117,7 +117,7 @@ export function StepProcess({
},
);
// 提交任务,并开始轮询进度
// Submit the task and start polling progress
useEffect(() => {
MemoryApi.SubmitDatabaseInsertTask({
database_id: databaseId,

View File

@@ -130,7 +130,7 @@ export const DatabaseDetail = ({
}
};
// 需要一个 store后续改造
// Need a store, follow-up renovation
const isReadOnlyMode = databaseInfo.creator_id !== userId || !!version;
const tableInitData: DatabaseInitInfo = useMemo(
@@ -355,7 +355,7 @@ export const DatabaseDetail = ({
databaseId={databaseId}
tableType={TableType.DraftTable}
tableFields={databaseInfo.field_list || []}
// 测试数据无需控制权限,只要能看到的数据就能修改删除
// Test data does not require control rights, as long as the data can be seen, it can be modified and deleted
isReadonlyMode={false}
enterFrom={enterFrom}
onAfterEditRecords={onAfterEditRecords}

View File

@@ -90,7 +90,7 @@ export interface DatabaseModalProps {
botId: string;
spaceId: string;
readonly: boolean;
// eslint-disable-next-line @typescript-eslint/naming-convention -- 历史逻辑
// eslint-disable-next-line @typescript-eslint/naming-convention -- historical logic
NL2DBInfo: NL2DBInfo | null;
expertModeConfig?: ExpertModeConfig;
onSave?: OnSave;
@@ -138,7 +138,7 @@ export const DatabaseModal: React.FC<DatabaseModalProps> = props => {
mapOfShouldHidingDatabaseTableStructureTips,
setMapOfShouldHidingDatabaseTableStructureTips,
] = useLocalStorageState<string | undefined>(
// FIXME: 此属性名意义不明确,处为了兼容,暂不修改此属性名,但后续需要使用更明确的命名
// FIXME: The meaning of this property name is unclear. For compatibility, this property name will not be modified for the time being, but a more explicit naming needs to be used in the future.
'use-local-storage-state-modify-tips',
{
defaultValue: '',
@@ -188,9 +188,9 @@ export const DatabaseModal: React.FC<DatabaseModalProps> = props => {
const showEntry = isEntry && !isEdit && !NL2DBInfo;
const shouldShowAIGenerate =
/**
* 1. 入口不展示
* 2. 编辑态不展示
* 3. Excel导入时不展示
* 1. The entrance is not displayed
* 2. Editing status is not displayed
* 3. Excel is not displayed when importing
*/
!showEntry && !isEdit && createType !== CreateType.excel;
@@ -282,8 +282,8 @@ export const DatabaseModal: React.FC<DatabaseModalProps> = props => {
})),
});
// data 是初始值,此处需要手动 setState 更新子组件状态
// Modal 已提前关闭,子组件卸载,则 ref 为空,需要加上可选链判断一下
// Data is the initial value, where you need to manually setState to update the subcomponent state
// If Modal has been closed early and the subassembly is uninstalled, the ref is empty. You need to add an optional chain to judge.
tableStructureRef.current?.setTableFieldsList(
// @ts-expect-error -- linter-disable-autofix
res.bot_table_list[0].field_list.map(i => ({
@@ -538,7 +538,7 @@ export const DatabaseModal: React.FC<DatabaseModalProps> = props => {
onDeleteField={list => {
setIsDeletedField(
!database.tableMemoryList.every(i =>
// TODO: 当前field id生成规则有问题故暂时使用 nanoid 替换
// TODO: There is a problem with the current field id generation rule, so the nanoid is temporarily replaced
list.find(j => j.nanoid === i.nanoid),
),
);

View File

@@ -56,7 +56,7 @@ export function formatTableDataRow(
dataRowFieldList.forEach(_key => {
const structItem = structList.find(i => i.fieldName === _key);
if (!structItem) {
// 系统字段
// System field
formattedDataRow[_key] = {
fieldName: _key,
type: FieldItemType.Text,
@@ -157,7 +157,7 @@ function DatabaseTableCell({ value }: DatabaseTableCellProps) {
}
/**
* 获取 Table Field 表头数据
* Get Table Field Header Data
*/
export const getTableColumns = ({
fieldList,
@@ -168,7 +168,7 @@ export const getTableColumns = ({
}: GetTableColumnsParams) => {
const columns: ColumnProps<TableRow>[] = [];
// 系统字段列
// System field column
columns.push(
...SYSTEM_FIELDS.map(item => ({
title: () => (
@@ -193,7 +193,7 @@ export const getTableColumns = ({
})),
);
// 用户字段列
// user field column
columns.push(
...fieldList.map(item => ({
title: () => (
@@ -210,7 +210,7 @@ export const getTableColumns = ({
})),
);
// 操作列
// action column
columns.push({
title: I18n.t('db_table_0126_021'),
width: 100,

View File

@@ -54,7 +54,7 @@
padding-bottom: 0;
}
/** table header样式 **/
/** Table header style **/
.semi-table-thead {
// 拖拽列宽度的图标样式
.semi-table-row {
@@ -90,7 +90,7 @@
}
}
/** table body部分样式 **/
/** Table body part style **/
.semi-table-tbody {
.semi-table-row {
>.semi-table-row-cell {

View File

@@ -153,7 +153,7 @@ export function DatabaseTableData({
database_id: databaseId,
table_type: tableType,
record_data_alter: [values],
// 编辑行时,要带上原始的 connector_id后端需要判断数据是否来自/目标为“豆包”渠道
// When editing the line, bring the original connector_id, and the backend needs to determine whether the data comes from/targets the "bean bag" channel
ori_connector_id: originalConnectorId,
});
}
@@ -230,7 +230,7 @@ export function DatabaseTableData({
},
rowKey: (record: TableRow) => record?.bstudio_id?.value as string,
scroll: {
// 128 = ToolButtonsBar(52) + 表头(28) + Pagination(48)
// 128 = ToolButtonsBar (52) + Header (28) + Pagination (48)
y: tableHeight > 128 ? tableHeight - 128 : 'auto',
},
pagination: {
@@ -259,7 +259,7 @@ export function DatabaseTableData({
),
}}
wrapperClassName={classNames(styles['table-wrapper'], {
// database 数据表格在 Project IDE 中要使用 coz-bg-max 白色背景
// Use coz-bg-max white background for database data tables in Project IDE
[styles['table-wrapper-project']]: enterFrom === 'project',
})}
empty={

View File

@@ -20,13 +20,13 @@ import { CSS } from '@dnd-kit/utilities';
import { useSortable } from '@dnd-kit/sortable';
/**
* 拆分自 packages/data/database-v2/src/components/database-table-data/index.tsx
* 原本实现基本是从 Semi 文档复制过来的排序后的数据也没有提交给服务端PM 似乎也不知道有这个功能,所以 ...
* Split from packages/data/database-v2/src/components/database-table-data/index.tsx
* The original implementation was basically copied from the Semi document, and the sorted data was not submitted to the server level. The PM did not seem to know about this function, so...
* @see
*/
export const SortableRow = (
// https://github.com/DouyinFE/semi-design/blob/v2.69.2/packages/semi-ui/table/Body/BaseRow.tsx#L396
// eslint-disable-next-line @typescript-eslint/naming-convention -- semi 没有导出 table row props 的类型
// eslint-disable-next-line @typescript-eslint/naming-convention -- semi does not export the type of table row props
sortProps: HTMLAttributes<HTMLTableRowElement> & { 'data-row-key': string },
) => {
const {

View File

@@ -17,7 +17,7 @@
import { type TableMemoryItem } from '@coze-studio/bot-detail-store';
import { type FieldItemType } from '@coze-arch/bot-api/memory';
// 期待的数据结构是什么样的?
// What is the expected data structure?
export interface TableRowCommonData {
fieldName: string;
required: boolean;

View File

@@ -30,7 +30,7 @@ import keyExample from '../../assets/key-example.png';
import s from './index.module.less';
function getTableStructureColumns(): ColumnProps<TableMemoryItem>[] {
// 字段表头内容来自 ../database-table-structure/index.tsx:578
// The field header content comes from../database-table-structure/index.tsx: 578
return [
{
title: (
@@ -140,7 +140,7 @@ export function DatabaseTableStructureReadonly({
columns,
dataSource,
scroll: {
// 表头的高度是 40px
// The height of the watch header is 40px.
y: tableHeight > 40 ? tableHeight - 40 : 'auto',
},
}}

View File

@@ -47,23 +47,23 @@ const formatValue = (dValue: string | Date | Date[] | string[] | undefined) => {
try {
if (dValue instanceof Date) {
// 单个Date对象
// Single Date Object
formattedValue = format(dValue, 'yyyy-MM-dd HH:mm:ss');
} else if (Array.isArray(dValue)) {
// Date[] string[]
// Date [] or string []
formattedValue = dValue
.map(item => {
if (item instanceof Date) {
return format(item, 'yyyy-MM-dd HH:mm:ss');
} else if (typeof item === 'string') {
// 假设字符串为有效日期格式
// Assume string is in valid date format
return format(new Date(item), 'yyyy-MM-dd HH:mm:ss');
}
return '';
})
.join(', '); // 使用逗号分隔不同的日期
.join(', '); // Use commas to separate different dates
} else if (typeof dValue === 'string') {
// 单个字符串
// Single string
formattedValue = format(new Date(dValue), 'yyyy-MM-dd HH:mm:ss');
}
} catch {

View File

@@ -56,7 +56,7 @@ const FormDatePicker = withField(
<DatePicker
{...props}
type="dateTime"
// Semi DatePicker 使用 date-fns 格式
// Semi DatePicker uses date-fns format
format="yyyy-MM-dd HH:mm:ss"
onChange={date =>
props.onChange?.(dayjs(date as Date).format('YYYY-MM-DD HH:mm:ss'))
@@ -149,7 +149,7 @@ export function RowEditModal({
>
<Form<Record<string, unknown>> allowEmpty ref={formRef}>
{tableType === TableType.OnlineTable ? (
// 只有“线上数据”支持修改“渠道”字段
// Only "Online Data" supports modifying the "Channel" field
<FormSelect
{...getSystemFieldCommonProps(PLATFORM_FIELD)}
optionList={connectorOptions}
@@ -274,7 +274,7 @@ function getUserFieldCommonProps(field: TableFieldData): FieldCommonProps {
required={field.required}
/>
),
// DatabaseFieldTitle 中已经显示 required * 符号
// The required * symbol is already displayed in DatabaseFieldTitle
required: false,
},
};

View File

@@ -156,7 +156,7 @@ export const useSelectDatabaseModal = ({
enterFrom === 'bot' ? TableType.DraftTable : TableType.OnlineTable,
table_name: key_word,
creator_id: filter_creator === 'all' ? '0' : filter_creator,
// 暂时不做分页加载
// Do not do paging loading for the time being
limit: 50,
offset: page_offset,
order_by: [
@@ -191,7 +191,7 @@ export const useSelectDatabaseModal = ({
},
);
// onScroll 判断 scrollRef 是否触底
// onScroll Determines whether scrollRef bottoms out
const handleScroll = () => {
if (!scrollRef.current) {
return;
@@ -364,7 +364,7 @@ export const useSelectDatabaseModal = ({
ref={scrollRef}
onScroll={handleScroll}
>
{/* FIXME: 这里需要根据实际做渲染 */}
{/* FIXME: This needs to be rendered according to the actual situation. */}
{data?.list.map((item, index) => (
<DatabaseListItem
icon={item.icon_url}

View File

@@ -21,25 +21,25 @@ import { type DynamicParams } from '@coze-arch/bot-typings/teamspace';
import { MemoryApi } from '@coze-arch/bot-api';
/**
* 已经迁移的旧渠道 id 到新渠道 id 的映射
* key(旧) -> value(新)
* Mapping of migrated old channel IDs to new channel IDs
* Key (old) - > value (new)
*/
const migratedConnectorIds: Record<string, string | undefined> = {
// 微信服务号
// WeChat service account
'10000114': '10000120',
// 微信订阅号
// WeChat subscribed account
'10000115': '10000121',
};
export interface ConnectorOption {
label: string;
value: string;
/** 该渠道 id 是否已经迁移 */
/** Has the channel ID been migrated? */
migrated?: boolean;
}
export interface UseConnectorOptionsParams {
/** 是否包含已迁移的旧渠道,默认不包含 */
/** Whether to include the old channels that have been migrated, not by default */
includeMigrated?: boolean;
}
@@ -47,7 +47,7 @@ export function useConnectorOptions({
includeMigrated = false,
}: UseConnectorOptionsParams = {}): ConnectorOption[] {
const { space_id } = useParams<DynamicParams>();
// 资源库 workflow 页面的 url 上没有 space_id 参数,需要从 searchParams 中获取
// There is no space_id parameter on the url of the library workflow page, you need to get it from searchParams
const [searchParams] = useSearchParams();
const spaceId = space_id ?? searchParams.get('space_id') ?? '';
const { data } = useRequest(
@@ -73,7 +73,7 @@ export function useConnectorOptions({
},
{
refreshDeps: [spaceId],
// 设置缓存 key, 防止重复请求
// Set cache key to prevent duplicate requests
cacheKey: `db_connector_name_${spaceId}`,
},
);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useEffect, useState } from 'react';
import { DataNamespace, dataReporter } from '@coze-data/reporter';
@@ -55,7 +55,7 @@ export const useExpertModeConfig = (params: {
res = await MemoryApi.GetModeConfig({
bot_id: botId,
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- 复制历史文件
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Copy history file
} catch (error: any) {
dataReporter.errorEvent(DataNamespace.DATABASE, {
eventName: REPORT_EVENTS.DatabaseGetExpertConfig,

View File

@@ -19,7 +19,7 @@ import { useRef } from 'react';
import { type TableData } from '../components/database-table-data/type';
export const useGetTableInstantaneousData = (tableData: TableData) => {
// 缓存 Data 数据,用于在事件中获取数据
// Cache data for fetching data in events
const dataRef = useRef<TableData>(tableData);
dataRef.current = tableData;

View File

@@ -85,7 +85,7 @@ export const useLibraryCreateDatabaseModal = ({
const { id, draft_id } = createRes.database_info ?? {};
if (id && draft_id) {
if (onFinish) {
// bot 绑定数据库需要 draft_id ,其他场景一般只需要用 id
// Bot binding database needs draft_id, other scenarios generally only need to use id
onFinish(id, draft_id);
return;
} else {

View File

@@ -25,7 +25,7 @@ export const getDefaultValue = (type: FieldItemType) => {
} else if (type === FieldItemType.Text) {
return '';
} else if (type === FieldItemType.Date) {
// TODO: @liushuoyan 这里可能存在时区的问题,联调的时候请注意
// TODO: @liushuoyan There may be a time zone problem here, please pay attention when joint debugging
return format(new Date(), 'yyyy-MM-dd HH:mm:ss');
} else {
return undefined;

View File

@@ -13,6 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- 符合预期
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- as expected
export const isEmptyValue = (value: any) => value === '' || value === undefined;

View File

@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// int64 的最大值和最小值
// The maximum and minimum values of int64
export const INT64_MAX = BigInt('9223372036854775807');
export const INT64_MIN = BigInt('-9223372036854775808');
/**
* 检查数值是否在 int64 范围内
* @param value - 要检查的字符串
* Check if the value is in the int64 range
* @Param value - string to check
* @returns
* - 如果是有效的 int64 范围内的整数,返回 true
* - 如果无效或超出范围,返回 false
* If it is a valid integer in the int64 range, return true.
* If invalid or out of range, return false
*/
export const isInInt64Range = (value: string): boolean => {
if (
@@ -41,7 +41,7 @@ export const isInInt64Range = (value: string): boolean => {
return false;
}
return true;
// eslint-disable-next-line @coze-arch/use-error-in-catch -- 正常业务逻辑
// eslint-disable-next-line @coze-arch/use-error-in-catch -- normal business logic
} catch {
return false;
}

View File

@@ -21,14 +21,14 @@ import { type TableRow } from '../components/database-table-data/type';
const FIXED_COLUMN_WIDTH = 60;
const MIN_COLUMN_WIDTH = 100;
/**
* 表格列伸缩时的回调,用于限制伸缩边界
* Callbacks when table columns are scaled to limit the scaling boundaries
* @param column
* @returns
*/
export const resizeFn = (
column: ColumnProps<TableRow>,
): ColumnProps<TableRow> => {
// 多选框/序号列不可伸缩
// The checkbox/serial number column is not retractable
if (column.key === 'column-selection') {
return {
...column,
@@ -36,14 +36,14 @@ export const resizeFn = (
width: FIXED_COLUMN_WIDTH,
};
}
// 固定列(操作列)不可伸缩
// Fixed columns (action columns) are not scalable
if (column.fixed) {
return {
...column,
resizable: false,
};
}
// 其余字段列可伸缩,但需要限制最小宽度
// The remaining field columns are scalable, but the minimum width needs to be limited
return {
...column,
width: