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

@@ -52,8 +52,8 @@ vi.mock('@coze-arch/bot-tea', () => ({
},
ParamsTypeDefine: {},
PluginMockDataGenerateMode: {
MANUAL: 0, // 手动创建
RANDOM: 1, // 随机生成
MANUAL: 0, // create manually
RANDOM: 1, // random generation
LLM: 2,
},
}));
@@ -61,21 +61,21 @@ vi.mock('@coze-arch/bot-tea', () => ({
vi.mock('@coze-arch/bot-hooks', () => ({
SceneType: {
BOT__VIEW__WORKFLOW: 'botViewWorkflow',
/** bot 详情页查看 workflow或新建 workflow 但未发布,点击返回 */
/** View the workflow on the bot details page, or create a new workflow but not published, click Return */
WORKFLOW__BACK__BOT: 'workflowBackBot',
/** bot 详情页创建 workflow在 workflow 发布后返回 */
/** The bot details page creates a workflow and returns it after the workflow is published */
WORKFLOW_PUBLISHED__BACK__BOT: 'workflowPublishedBackBot',
/** bot 详情页进入 mock data 页面 */
/** Bot details page Enter the mock data page */
BOT__TO__PLUGIN_MOCK_DATA: 'botToPluginMockData',
/** workflow 详情页进入 mock data 页面 */
/** Workflow details page Enter the mock data page */
WORKFLOW__TO__PLUGIN_MOCK_DATA: 'workflowToPluginMockData',
/** mock set 页进入 mock data 页面 */
/** Mock set page Enter the mock data page */
PLUGIN_MOCK_SET__TO__PLUGIN_MOCK_DATA: 'pluginMockSetToPluginMockData',
/** bot 详情页进入 knowledge 页面 */
/** Bot details page Enter the knowledge page */
BOT__VIEW__KNOWLEDGE: 'botViewKnowledge',
/** knowledge 页面点击退出返回 bot 详情页(未点击添加) */
/** Knowledge page Click Exit to return to bot details page (not clicked Add) */
KNOWLEDGE__BACK__BOT: 'knowledgeBackBot',
/** knowledge 页面点击返回 bot 详情页,并添加到 bot */
/** Knowledge page Click to return to bot details page and add to bot */
KNOWLEDGE__ADD_TO__BOT: 'knowledgeAddToBot',
},
usePageJumpService: vi.fn().mockReturnValue({

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
// 引入我们的被测方法
// Introducing our test method
import { describe, expect, it, vi } from 'vitest';
@@ -23,39 +23,39 @@ import { getEnv } from '@/util/get-env';
describe('getEnv function', () => {
it('should return "cn-boe" when not in production', () => {
vi.stubGlobal('IS_PROD', undefined);
// 不设置IS_PROD默认为非生产环境
// Do not set IS_PROD, default to non-production environment
const env = getEnv();
expect(env).toBe('cn-boe');
});
it('should return "cn-release" when in production, not overseas, and is release version', () => {
vi.stubGlobal('IS_PROD', true); // 设置为生产环境
vi.stubGlobal('IS_OVERSEA', false); // 不是海外
vi.stubGlobal('IS_RELEASE_VERSION', true); // 是发布版本
vi.stubGlobal('IS_PROD', true); // Set to production environment
vi.stubGlobal('IS_OVERSEA', false); // Not overseas.
vi.stubGlobal('IS_RELEASE_VERSION', true); // Is the release version
const env = getEnv();
expect(env).toBe('cn-release');
});
it('should return "cn-inhouse" when in production, not overseas, and is not release version', () => {
vi.stubGlobal('IS_PROD', true); // 设置为生产环境
vi.stubGlobal('IS_OVERSEA', false); // 不是海外
vi.stubGlobal('IS_RELEASE_VERSION', false); // 不是发布版本
vi.stubGlobal('IS_PROD', true); // Set to production environment
vi.stubGlobal('IS_OVERSEA', false); // Not overseas.
vi.stubGlobal('IS_RELEASE_VERSION', false); // Not the release version
const env = getEnv();
expect(env).toBe('cn-inhouse');
});
it('should return "oversea-release" when in production, overseas, and is release version', () => {
vi.stubGlobal('IS_PROD', true); // 设置为生产环境
vi.stubGlobal('IS_OVERSEA', true); // 是海外
vi.stubGlobal('IS_RELEASE_VERSION', true); // 是发布版本
vi.stubGlobal('IS_PROD', true); // Set to production environment
vi.stubGlobal('IS_OVERSEA', true); // Is overseas
vi.stubGlobal('IS_RELEASE_VERSION', true); // Is the release version
const env = getEnv();
expect(env).toBe('oversea-release');
});
it('should return "oversea-inhouse" when in production, overseas, and is not release version', () => {
vi.stubGlobal('IS_PROD', true); // 设置为生产环境
vi.stubGlobal('IS_OVERSEA', true); // 是海外
vi.stubGlobal('IS_RELEASE_VERSION', false); // 不是发布版本
vi.stubGlobal('IS_PROD', true); // Set to production environment
vi.stubGlobal('IS_OVERSEA', true); // Is overseas
vi.stubGlobal('IS_RELEASE_VERSION', false); // Not the release version
const env = getEnv();
expect(env).toBe('oversea-inhouse');
});

View File

@@ -61,7 +61,7 @@ export const PluginModal: React.FC<PluginModalProps> = ({
return openMode === OpenModeType.OnlyOnceAdd ? [] : pluginApis;
};
const { sider, filter, content } = usePluginModalParts({
// 如果是仅添加一次,清空默认选中
// If it is added only once, clear the default selection.
pluginApiList: getPluginApiList(),
onPluginApiListChange: updateSkillPluginApis,
openMode,

View File

@@ -36,7 +36,7 @@ export const usePluginApisModal = (props?: PluginModalModeProps) => {
const _initQuery = isNumber(params) ? undefined : params?.initQuery;
setVisible(true);
setInitQuery(_initQuery);
// 0 也有效
// 0 is also valid
if (isNumber(openType)) {
setType(openType);
}

View File

@@ -54,17 +54,17 @@ export interface ToolDetailPageProps
onDebugSuccessCallback?: () => void;
}
// 页面-编辑插件API
// Page - Edit Plugin API
export const ToolDetailPage: FC<ToolDetailPageProps> = ({
toolID,
onDebugSuccessCallback,
renderDescComponent,
renderParamsComponent,
}) => {
//捕获错误信息,跳转统一落地页
//Capture error messages and jump to the unified landing page
const capture = useErrorHandler();
const [editVersion, setEditVersion] = useState<number>();
//插件-API详情
//Plugin-API Details
const [apiInfo, setApiInfo] = useState<PluginAPIInfo>();
const [debugApiInfo, setDebugApiInfo] = useState<PluginAPIInfo>();
const [loading, setLoading] = useState<boolean>(true);
@@ -104,7 +104,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
});
};
// 重置 request 参数
// Reset request parameters
const resetRequestParams = (data: PluginAPIInfo) => {
const requestParams = cloneDeep(data.request_params as APIParameter[]);
if (
@@ -120,7 +120,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
return requestParams;
};
// 设置接口信息(回显和置空)
// Set interface information (echo and empty)
const handleInit = async (useloading = false) => {
setApiInfo({
...apiInfo,
@@ -140,12 +140,12 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
if (api_info.length > 0) {
const apiInfoTemp = api_info.length > 0 ? api_info[0] : {};
// debug 的数据 如果有 example 需要回显 入参数据额外处理
// Debug data, if there is an example, the imported parameter data needs to be echoed for additional processing
setDebugApiInfo({
...apiInfoTemp,
request_params: resetRequestParams(apiInfoTemp),
});
// 给对象增加层级标识
// Adding hierarchical identifiers to objects
addDepthAndValue(apiInfoTemp.request_params);
addDepthAndValue(apiInfoTemp.response_params);
setApiInfo(apiInfoTemp);
@@ -170,7 +170,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
useloading && setLoading(false);
};
// 1.基本信息
// 1. Basic information
const {
isBaseInfoDisabled,
header: baseInfoHeader,
@@ -190,7 +190,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
renderDescComponent,
});
// 2 更多设置
// 2 more settings
const {
isBaseMoreDisabled,
header: baseMoreHeader,
@@ -211,7 +211,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
onSuccess: handleSuccess,
});
// 3.设置 request
// 3. Set request
const {
isRequestParamsDisabled,
itemKey: requestItemKey,
@@ -233,7 +233,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
renderParamsComponent,
});
// 4.设置 response
// 4. Set up the response
const {
isResponseParamsDisabled,
itemKey: responseItemKey,
@@ -298,7 +298,7 @@ export const ToolDetailPage: FC<ToolDetailPageProps> = ({
};
}, []);
// 预览状态解锁,如果有一步为编辑态,则不解锁
// The preview state is unlocked. If there is an edit state, it will not be unlocked.
useUpdateEffect(() => {
if (
!isBaseInfoDisabled ||

View File

@@ -69,7 +69,7 @@ const ToolHeader: FC<ToolHeaderProps> = ({
unlockPlugin();
};
// 管理模拟集
// management simulation set
const handleManageMockset = () => {
resourceNavigate.mocksetList?.(tool_id);
};
@@ -119,7 +119,7 @@ const ToolHeader: FC<ToolHeaderProps> = ({
/>
<span className={s.title}>{I18n.t('plugin_edit_tool_title')}</span>
<OauthButtonAction />
{/* 即将支持,敬请期待 */}
{/* Support soon, so stay tuned. */}
{FLAGS['bot.devops.plugin_mockset'] ? (
<Tooltip
style={{ display: mocksetDisabled ? 'block' : 'none' }}

View File

@@ -54,12 +54,12 @@ export const useContentBaseMore = ({
editVersion,
onSuccess,
}: UseContentBaseInfoProps) => {
// 是否显示安全检查失败信息
// Is the security check failure message displayed?
const [showSecurityCheckFailedMsg, setShowSecurityCheckFailedMsg] =
useState(false);
const [isBaseMoreDisabled, setIsBaseMoreDisabled] = useState(true);
// 基本信息
// Basic information
const { baseInfoNode, submitBaseInfo } = useBaseMore({
pluginId: plugin_id || '',
pluginMeta: pluginInfo?.meta_info || {},
@@ -101,7 +101,7 @@ export const useContentBaseMore = ({
onClick={async e => {
e.stopPropagation();
const status = await submitBaseInfo();
// 更新成功后进入下一步
// After the update is successful, proceed to the next step
if (status) {
handleInit();
}

View File

@@ -48,12 +48,12 @@ export const useContentBaseInfo = ({
editVersion,
renderDescComponent,
}: UseContentBaseInfoProps) => {
// 是否显示安全检查失败信息
// Is the security check failure message displayed?
const [showSecurityCheckFailedMsg, setShowSecurityCheckFailedMsg] =
useState(false);
const [isBaseInfoDisabled, setIsBaseInfoDisabled] = useState(true);
// 基本信息
// Basic information
const { baseInfoNode, submitBaseInfo } = useBaseInfo({
pluginId: plugin_id || '',
apiId: tool_id,
@@ -93,7 +93,7 @@ export const useContentBaseInfo = ({
onClick={async e => {
e.stopPropagation();
const status = await submitBaseInfo();
// 更新成功后进入下一步
// After the update is successful, proceed to the next step
if (status) {
handleInit();
}

View File

@@ -77,7 +77,7 @@ export const useContentDebug = ({
debugApiInfo && tool_id ? (
<Debug
pluginType={pluginInfo?.plugin_type}
disabled={false} // 是否可调试
disabled={false} // Is it debuggable?
setDebugStatus={setDebugStatus}
pluginId={String(plugin_id)}
apiId={String(tool_id)}
@@ -113,7 +113,7 @@ export const useContentDebug = ({
>
<Debug
pluginType={pluginInfo?.plugin_type}
disabled={false} // 是否可调试
disabled={false} // Is it debuggable?
setDebugStatus={setDebugStatus}
pluginId={String(plugin_id)}
apiId={String(tool_id)}

View File

@@ -58,11 +58,11 @@ export const useContentRequest = ({
onSuccess,
renderParamsComponent,
}: UseContentRequestProps) => {
// 是否显示安全检查失败信息
// Is the security check failure message displayed?
const [showSecurityCheckFailedMsg, setShowSecurityCheckFailedMsg] =
useState(false);
const [isRequestParamsDisabled, setIsRequestParamsDisabled] = useState(true);
// 设置请求参数
// Set request parameters
const { requestParamsNode, submitRequestParams, nlTool } = useRequestParams({
apiInfo,
pluginId: plugin_id || '',
@@ -107,7 +107,7 @@ export const useContentRequest = ({
onClick={async e => {
e.stopPropagation();
const status = await submitRequestParams();
// 更新成功后进入下一步
// After the update is successful, proceed to the next step
if (status) {
handleInit();
setIsRequestParamsDisabled(true);

View File

@@ -66,12 +66,12 @@ export const useContentResponse = ({
onSuccess,
renderParamsComponent,
}: UseContentResponseProps) => {
// 是否显示安全检查失败信息
// Is the security check failure message displayed?
const [showSecurityCheckFailedMsg, setShowSecurityCheckFailedMsg] =
useState(false);
const [isResponseParamsDisabled, setIsResponseParamsDisabled] =
useState(true);
// 第三步设置相应参数的hooks组件
// The third step is to set the corresponding parameters of the hooks component
const { responseParamsNode, submitResponseParams, extra } = useResponseParams(
{
apiInfo,
@@ -94,7 +94,7 @@ export const useContentResponse = ({
},
);
// 处理 debug 时 example数据先显示后隐藏的问题
// When dealing with debugging, the example data is displayed first and then hidden
useEffect(() => {
if (!isResponseParamsDisabled) {
setDebugApiInfo({
@@ -133,7 +133,7 @@ export const useContentResponse = ({
onClick={async e => {
e.stopPropagation();
const status = await submitResponseParams();
// 更新成功后进入下一步
// After the update is successful, proceed to the next step
if (status) {
handleInit();
setIsResponseParamsDisabled(true);

View File

@@ -78,8 +78,8 @@ const useAuthForApiTool = () => {
return {
canEdit,
needAuth, // 需要 auth 授权
isHasAuth, // 是否完成了授权
needAuth, // Requires auth authorization
isHasAuth, // Has the authorization been completed?
doCancelOauth,
isUpdateLoading,
doOauth,

View File

@@ -42,7 +42,7 @@
& svg {
width: 16px;
height: 16px;
/* stylelint-disable-next-line declaration-no-important -- 覆盖icon颜色 */
/* stylelint-disable-next-line declaration-no-important -- Override icon color */
color: var(--semi-color-text-2) !important;
}
}

View File

@@ -66,9 +66,9 @@ enum PageSource {
}
enum PageMode {
/** 整页 UI类似全覆盖浮层 */
/** Full page UI similar to full coverage floating layer */
FULL_PAGE = 'full_page',
/** 嵌入(左侧有菜单栏) */
/** Embed (with menu bar on the left) */
EMBED = 'embed',
}
@@ -87,16 +87,16 @@ const MockSetDetail: FC<{
[],
);
const routeResponse = usePageJumpResponse(PageType.PLUGIN_MOCK_DATA);
// API 详情
// API Details
const [apiInfo, setApiInfo] = useState<PluginAPIInfo>({
name: routeResponse?.toolName,
});
// mock set 详情
// Mock set details
const [mockSetInfo, setMockSetInfo] = useState<MockSet>({
id: mocksetID,
name: routeResponse?.mockSetName,
});
// API 对应 schema
// API correspondence schema
const [toolSchema, setToolSchema] = useState<string>('');
const [perm, setPerm] = useState<{
readOnly: boolean;
@@ -109,9 +109,9 @@ const MockSetDetail: FC<{
const listRef = useRef<MockDataListActions>(null);
const contentEleRef = useRef<HTMLDivElement>(null);
// 页面展示模式
// page display mode
const pageMode = params.hideMenu ? PageMode.FULL_PAGE : PageMode.EMBED;
// 页面来源
// page source
const fromSource = routeResponse?.fromSource
? (routeResponse.fromSource as PageSource)
: PageSource.FROM_MOCK_SET;
@@ -142,7 +142,7 @@ const MockSetDetail: FC<{
[toolID, pluginID],
);
// 获取当前 tool 信息
// Get current tool information
const getPluginToolInfo = async () => {
try {
const { api_info = [] } = await PluginDevelopApi.GetPluginAPIs(
@@ -164,7 +164,7 @@ const MockSetDetail: FC<{
}
};
// 获取当前 mock set 信息
// Get current mock set information
const getMockSetInfo = async () => {
if (!mocksetID) {
return;

View File

@@ -65,7 +65,7 @@ import { getDisplayCols } from './get-col';
import styles from './index.module.less';
interface ListParams {
pageNo?: number; // 用于前端计算数量
pageNo?: number; // Quantity for front-end computing
pageSize?: number;
pageToken?: string;
order?: {
@@ -80,13 +80,13 @@ const TOOL_NOT_FOUND_CODE = '600303108';
const MockSetList: FC<{ toolID: string }> = ({ toolID }) => {
const resourceNavigate = usePluginNavigate();
// user信息
// User information
const userInfo = userStoreService.useUserInfo();
// 路由信息
// routing information
const [params, setParams] = useState<ListParams>({
//请求参数
//request parameters
pageSize: PAGE_SIZE,
pageNo: 1,
});
@@ -101,11 +101,11 @@ const MockSetList: FC<{ toolID: string }> = ({ toolID }) => {
})),
);
// space信息
// Space information
const space = useSpace(spaceID);
const isPersonal = space?.space_type === SpaceType.Personal;
// API 详情
// API Details
const [apiInfo, setApiInfo] = useState<PluginAPIInfo>();
const [showCreateModal, setShowCreateModal] = useState(false);
@@ -118,7 +118,7 @@ const MockSetList: FC<{ toolID: string }> = ({ toolID }) => {
const [editDisabled, setEditDisabled] = useState(false);
// 后端需要的mock上下文信息
// The mock context information required by the backend
const ctxInfo = {
bizCtx: {
trafficScene: TrafficScene.Undefined,
@@ -216,7 +216,7 @@ const MockSetList: FC<{ toolID: string }> = ({ toolID }) => {
}
};
// 获取当前tool信息
// Get current tool information
const getPluginToolInfo = async () => {
try {
const { api_info = [] } = await PluginDevelopApi.GetPluginAPIs({
@@ -351,13 +351,13 @@ const MockSetList: FC<{ toolID: string }> = ({ toolID }) => {
if (!editDisabled) {
handleEdit(record);
}
}, // 点击行
}, // Click line
}),
onChange: e => {
if (e.sorter?.sortOrder) {
tableRef.current?.reset();
//时间排序
//chronological sorting
setParams(p => ({
...p,
pageSize: PAGE_SIZE,
@@ -410,7 +410,7 @@ const MockSetList: FC<{ toolID: string }> = ({ toolID }) => {
></MockSetEditModal>
) : null}
{
// 删除弹窗
// Delete pop-up window
deleteMockSet ? (
<MockSetDeleteModal
visible={!!deleteMockSet}

View File

@@ -35,8 +35,8 @@ interface UseCreateToolProps {
plugin_id: string;
onClickWrapper?: (fn: () => void) => () => Promise<void>;
/**
* 点击创建工具按钮前的回调函数
* @returns {boolean | void} 返回false时将阻止后续动作
* The callback function before clicking the Create Tool button
* @Returns {boolean | void} returns false to block subsequent actions
*/
onBeforeClick?: () => void;
disabled: boolean;
@@ -151,7 +151,7 @@ export const useCreateTool = ({
};
/**
* @description 创建工具
* @description creation tool
*/
export const CreateTool: FC<CreateToolProps> = props => {
const { content } = useCreateTool({

View File

@@ -155,7 +155,7 @@ const PluginDetailPage = ({
);
const [params, setParams] = useState<GetPluginAPIsRequest>({
//请求参数
//request parameters
page: 1,
size: 10,
plugin_id: pluginID,
@@ -236,7 +236,7 @@ const PluginDetailPage = ({
const dataSource = data?.api_info;
/** 不再提示 */
/** no longer prompt */
const noTips = async () => {
const res = await PluginDevelopApi.NoUpdatedPrompt({
plugin_id: pluginID,
@@ -248,7 +248,7 @@ const PluginDetailPage = ({
const checkPublish = async () => {
if (!pluginInfo?.published) {
//未发布过点击直接发布
//It has not been published. Click to publish directly.
setPublishPopShow(true);
return;
}
@@ -264,7 +264,7 @@ const PluginDetailPage = ({
setPublishPopData(res);
setShowPublishCheckPop(true);
} else {
//没有修改api直接发布
//Publish directly without modifying the api
setPublishPopShow(true);
}
};
@@ -308,14 +308,14 @@ const PluginDetailPage = ({
onStatusChange?.('error');
}
}, [initSuccessed]);
// 区分ide的跳转
// Differentiate IDE jumps
const handleIdeJump = (
initialAction = InitialAction.DEFAULT,
toolId = '',
) => {
// ide 逻辑
// IDE logic
if (isCloudIDEPlugin) {
// 改变路由地址 返回的时候会清掉
// Change the routing address and it will be cleared when returning.
preloadIDE?.handleShowIde({ initialAction, toolId });
} else if (toolId) {
resourceNavigate.tool?.(toolId);
@@ -337,7 +337,7 @@ const PluginDetailPage = ({
canEdit ? { mode: 'preview' } : {},
);
}
}, // 点击行
}, // Click line
});
const { exampleNode, openExample } = useEditExample({
@@ -445,7 +445,7 @@ const PluginDetailPage = ({
) : null}
<Layout.Content className={s['layout-content']}>
{/* 已发布且有更新展示 */}
{/* Published and updated */}
{pluginInfo?.status &&
pluginInfo?.published &&
canEdit &&
@@ -470,7 +470,7 @@ const PluginDetailPage = ({
}
/>
) : null}
{/* plugin简介 */}
{/* Plugin Introduction */}
{pluginInfo ? (
<PluginHeader
pluginInfo={pluginInfo}
@@ -502,7 +502,7 @@ const PluginDetailPage = ({
onBeforeClick={() => {
setShowDropDownItem(undefined);
if (isCloudIDEPlugin) {
// 改变路由地址 返回的时候会清掉
// Change the routing address and it will be cleared when returning.
preloadIDE?.handleShowIde({
initialAction: InitialAction.CREATE_TOOL,
toolId: '',
@@ -529,7 +529,7 @@ const PluginDetailPage = ({
{I18n.t('import')}
</Button>
) : null}
{/* ! 发布按钮 */}
{/* ! Post button */}
{isRenderIDEPublishButton ? (
<Tooltip
position="left"
@@ -598,7 +598,7 @@ const PluginDetailPage = ({
}
/>
) : null}
{/* 工具列表表格 */}
{/* Tool List Form */}
{!!dataSource?.length && (
<div className="mb-[24px] mt-[36px] text-[18px] weight-[600]">
{I18n.t('plugin_api_list_table_name')}
@@ -615,7 +615,7 @@ const PluginDetailPage = ({
onRow,
onChange: e => {
if (e.sorter?.sortOrder) {
//时间排序
//chronological sorting
setParams(p => ({
...p,
page: 1,
@@ -634,7 +634,7 @@ const PluginDetailPage = ({
btnText: canEdit ? createToolText : undefined,
btnOnClick: () => {
if (isCloudIDEPlugin) {
// 改变路由地址 返回的时候会清掉
// Change the routing address and it will be cleared when returning.
preloadIDE?.handleShowIde({
initialAction: InitialAction.CREATE_TOOL,
toolId: '',