chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
import { sliceEditor } from '@/component/onboarding-message/onboarding-editor/method/slice-editor';
|
||||
|
||||
// vi.mock需要在顶部,因为它会被提升
|
||||
// Vi.mock needs to be at the top because it will be promoted
|
||||
vi.mock('@coze-common/md-editor-adapter', () => ({
|
||||
ZoneDelta: vi.fn().mockImplementation(() => ({
|
||||
retain: vi.fn().mockReturnThis(),
|
||||
@@ -24,7 +24,7 @@ vi.mock('@coze-common/md-editor-adapter', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
// 导入模拟后的ZoneDelta
|
||||
// Import the simulated ZoneDelta
|
||||
import { ZoneDelta } from '@coze-common/md-editor-adapter';
|
||||
|
||||
describe('sliceEditor', () => {
|
||||
@@ -36,13 +36,13 @@ describe('sliceEditor', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
|
||||
// 创建一个新的模拟实例
|
||||
// Create a new simulation instance
|
||||
mockZoneDeltaInstance = {
|
||||
retain: vi.fn().mockReturnThis(),
|
||||
delete: vi.fn().mockReturnThis(),
|
||||
};
|
||||
|
||||
// 重置ZoneDelta构造函数的实现
|
||||
// Implementation of Reset ZoneDelta Constructor
|
||||
vi.mocked(ZoneDelta).mockImplementation(() => mockZoneDeltaInstance);
|
||||
|
||||
mockedEditor = {
|
||||
@@ -110,7 +110,7 @@ describe('sliceEditor', () => {
|
||||
|
||||
expect(ZoneDelta).toHaveBeenCalledWith({ zoneId: 'zone1' });
|
||||
expect(mockZoneDeltaInstance.retain).toHaveBeenCalledWith(maxCount);
|
||||
expect(mockZoneDeltaInstance.delete).toHaveBeenCalledWith(1); // 实际计算出的值是1
|
||||
expect(mockZoneDeltaInstance.delete).toHaveBeenCalledWith(1); // The actual calculated value is 1.
|
||||
expect(mockApply).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,8 +43,8 @@ vi.mock('@coze-arch/bot-tea', () => ({
|
||||
},
|
||||
ParamsTypeDefine: {},
|
||||
PluginMockDataGenerateMode: {
|
||||
MANUAL: 0, // 手动创建
|
||||
RANDOM: 1, // 随机生成
|
||||
MANUAL: 0, // create manually
|
||||
RANDOM: 1, // random generation
|
||||
LLM: 2,
|
||||
},
|
||||
}));
|
||||
@@ -52,21 +52,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({
|
||||
|
||||
@@ -42,9 +42,9 @@ export interface AuthorizeButtonProps {
|
||||
revokeSuccess: (id: string) => void;
|
||||
authInfo: AuthLoginInfo;
|
||||
isMouseIn?: boolean;
|
||||
/** 是否使用 Coze 2.0 的 Button 组件,默认 false */
|
||||
/** Whether to use the Button component of Coze 2.0, the default is false */
|
||||
isV2?: boolean;
|
||||
/** 自定义 Coze 2.0 Button 的 props */
|
||||
/** Custom Coze 2.0 Button props */
|
||||
v2ButtonProps?: ButtonProps;
|
||||
onBeforeAuthRedirect?: (
|
||||
parameters: Pick<AuthorizeButtonProps, 'id' | 'authInfo' | 'origin'>,
|
||||
@@ -156,7 +156,7 @@ export const AuthorizeButton = ({
|
||||
|
||||
return status === ConfigStatus.Configured ? (
|
||||
<>
|
||||
{/* 在 hover 渠道表单对应行,或“撤销授权”弹窗显示中时,显示“撤销授权”按钮 */}
|
||||
{/* Display the "Revoke Authorization" button in the corresponding line of the hover channel form, or in the display of the "Revoke Authorization" pop-up window */}
|
||||
{isMouseIn || revokeModalVisible ? authButton : null}
|
||||
{revokeModal(
|
||||
agentType === 'project' ? (
|
||||
|
||||
@@ -53,17 +53,17 @@ export const AutoGenerateButton: React.FC<AutoGenerateProps> = ({
|
||||
}, [loading]);
|
||||
|
||||
const handleClick = () => {
|
||||
// loading时 触发stop生成
|
||||
// When loading, stop generating
|
||||
if (loading) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
// 有开场白时 点击触发二次确认弹窗
|
||||
// When there is an opening statement, click to trigger the secondary confirmation pop-up window.
|
||||
if (needConfirmAgain) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 其余触发自动生成开场白逻辑
|
||||
// The remaining triggers automatically generate opening logic
|
||||
generate();
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ export const ConnectorField = (props: ConnectorFieldProps) => {
|
||||
}
|
||||
|
||||
function createRules(fieldSchema: FormSchemaItem): RuleItem[] {
|
||||
// 确保 formItemSchema.rules 是一个数组
|
||||
// Make sure formItemSchema.rules is an array
|
||||
const itemRules = fieldSchema.rules ?? [];
|
||||
|
||||
const rules = itemRules.map(rule => {
|
||||
@@ -91,7 +91,7 @@ export const ConnectorField = (props: ConnectorFieldProps) => {
|
||||
return { ...rule, ...(ruleMessage && { message: ruleMessage }) };
|
||||
});
|
||||
|
||||
// 添加 'required' 规则
|
||||
// Add'required 'rule
|
||||
rules.push({
|
||||
required: fieldSchema.required,
|
||||
message: I18n.t('bot_publish_field_placeholder', {
|
||||
@@ -116,7 +116,7 @@ export const ConnectorField = (props: ConnectorFieldProps) => {
|
||||
logger.error({ error: e as Error });
|
||||
values = [];
|
||||
}
|
||||
// 添加一个默认空值
|
||||
// Add a default null value
|
||||
if (!values.length) {
|
||||
values.push('');
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export interface ConnectorFormProps {
|
||||
|
||||
const DEFAULT_FORM_STEP = 2;
|
||||
|
||||
// 多选 Select 在 Form 中的 value 是 string[],但提交到后端需要转换成 JSON string
|
||||
// Multiple Select The value in the Form is string [], but it needs to be converted to a JSON string when submitted to the backend.
|
||||
type FormValues = Record<string, string | string[]>;
|
||||
|
||||
export const ConnectorForm = forwardRef(
|
||||
@@ -75,7 +75,7 @@ export const ConnectorForm = forwardRef(
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
// 解决formApiRef.current取值不实时问题
|
||||
// Solve the problem that the value of formApiRef.current is not real-time
|
||||
update();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- ignore
|
||||
}, [schemaAreaInfo]);
|
||||
|
||||
@@ -34,7 +34,7 @@ export const ConnectorLink = ({
|
||||
botId: string;
|
||||
initValue?: TFormData;
|
||||
}) => {
|
||||
//支持通配URL
|
||||
//Support for wildcard URLs
|
||||
const formatUrl = (url?: string) => {
|
||||
let newUrl = url ?? '';
|
||||
if (newUrl) {
|
||||
|
||||
@@ -87,7 +87,7 @@ export const useConnectorFormModal = ({
|
||||
if (onUnbind) {
|
||||
onUnbind();
|
||||
} else {
|
||||
// 兼容历史逻辑,未传入 onUnbind 时,解绑后也调用 onSuccess
|
||||
// Compatible with historical logic, when onUnbind is not passed in, onSuccess is also called after unbinding.
|
||||
onSuccess({
|
||||
...(initValue as BotPublishConnectorInfo),
|
||||
bind_info: {},
|
||||
@@ -138,9 +138,9 @@ export const useConnectorFormModal = ({
|
||||
const { schema_area_pages: schemaPages = [] } = connectorConfigInfo ?? {};
|
||||
|
||||
const bindCb = (data: BindConnectorResponse) => {
|
||||
/** 适用Kv+Auth授权场景:KvAuthBind = 4
|
||||
* reddit渠道:若成功返回client_id,则覆盖auth_login_info中的client_id,并附带加密state跳转授权页面
|
||||
* 其余渠道:若成功返回auth_params,则合并auth_login_info作为授权链接参数跳转
|
||||
/** Applicable to Kv + Auth authorization scenarios: KvAuthBind = 4
|
||||
* Reddit channel: If the client_id is successfully returned, the client_id in the auth_login_info will be overwritten and the encrypted state jump authorization page will be attached
|
||||
* Other channels: If the auth_params is successfully returned, the merge auth_login_info jump as the authorization link parameter
|
||||
* */
|
||||
if (
|
||||
initValue?.bind_type === BindType.KvAuthBind &&
|
||||
@@ -254,7 +254,7 @@ export const useConnectorFormModal = ({
|
||||
{schemaPages?.length &&
|
||||
step !== 0 &&
|
||||
schemaPages[step]?.api_action !== SchemaAreaPageApi.NotQuery ? (
|
||||
// 页面按钮不执行任何操作时 不展示上一步
|
||||
// When the page button does not perform any action, the previous step is not displayed
|
||||
<UIButton
|
||||
theme="solid"
|
||||
onClick={() => {
|
||||
|
||||
@@ -35,7 +35,7 @@ interface IItemGridView {
|
||||
|
||||
export function ItemGridView(props: IItemGridView) {
|
||||
const { title, resources, showStatus = false, onResourceClick } = props;
|
||||
// HACK: 由于 grid 布局下边界线是透出的背景色,所以 resource 数量为单数的时候需要补齐一个
|
||||
// HACK: Since the boundary line under the grid layout is the transparent background color, one needs to be filled when the number of resources is singular
|
||||
const isEven = size(resources) % 2 === 0;
|
||||
const finalResources = isEven
|
||||
? resources
|
||||
|
||||
@@ -65,7 +65,7 @@ export function useSelectSpacePane() {
|
||||
) : (
|
||||
<SelectorItem
|
||||
space={{
|
||||
// MOCK: 用于展示未加入任何空间的兜底情况
|
||||
// MOCK: used to show the bottom of the cover without joining any space
|
||||
name: I18n.t('resource_move_no_team_joined'),
|
||||
}}
|
||||
disabled
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @coze-arch/max-line-per-function -- 不好拆 */
|
||||
|
||||
/* eslint-disable @coze-arch/max-line-per-function -- not easy to dismantle */
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { size } from 'lodash-es';
|
||||
@@ -41,27 +41,27 @@ interface BotMoveFailedModalOptions {
|
||||
*/
|
||||
botInfo: Pick<DraftBot, 'id' | 'name'> | null;
|
||||
/**
|
||||
* 更新 bot 状态
|
||||
* Update bot status
|
||||
*/
|
||||
onUpdateBotStatus?: (status: DraftBotStatus) => void;
|
||||
/**
|
||||
* 迁移成功等效于删除 bot
|
||||
* Successful migration is equivalent to deleting the bot
|
||||
*/
|
||||
onMoveSuccess?: () => void;
|
||||
}
|
||||
|
||||
interface UseBotMoveFailedModalValue {
|
||||
/**
|
||||
* 打开弹窗的方法
|
||||
* @param {BotMoveModalOptions} [options] - 此次打开Modal的配置项
|
||||
* How to open the pop-up window
|
||||
* @Param {BotMoveModalOptions} [options] - Open Modal's configuration item this time
|
||||
*/
|
||||
open: (options?: BotMoveFailedModalOptions) => void;
|
||||
/**
|
||||
* 关闭弹窗的方法
|
||||
* How to close the pop-up window
|
||||
*/
|
||||
close: () => void;
|
||||
/**
|
||||
* 弹窗组件实例,需要手动挂载一下
|
||||
* The pop-up component instance needs to be mounted manually.
|
||||
*/
|
||||
modalNode: React.ReactNode;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @coze-arch/max-line-per-function -- 难拆*/
|
||||
|
||||
/* eslint-disable @coze-arch/max-line-per-function -- difficult to remove*/
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
@@ -50,31 +50,31 @@ interface BotMoveModalOptions {
|
||||
*/
|
||||
botInfo: Pick<DraftBot, 'name' | 'id'> | null;
|
||||
/**
|
||||
* 更新 bot 状态
|
||||
* Update bot status
|
||||
*/
|
||||
onUpdateBotStatus?: (status: DraftBotStatus) => void;
|
||||
/**
|
||||
* 迁移成功等效于删除 bot
|
||||
* Successful migration is equivalent to deleting the bot
|
||||
*/
|
||||
onMoveSuccess?: () => void;
|
||||
/**
|
||||
* 关闭 modal
|
||||
* Close modal
|
||||
*/
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
interface UseBotMoveModalValue {
|
||||
/**
|
||||
* 打开弹窗的方法
|
||||
* @param {BotMoveModalOptions} [options] - 此次打开Modal的配置项
|
||||
* How to open the pop-up window
|
||||
* @Param {BotMoveModalOptions} [options] - Open Modal's configuration item this time
|
||||
*/
|
||||
open: (options?: BotMoveModalOptions) => void;
|
||||
/**
|
||||
* 关闭弹窗的方法
|
||||
* How to close the pop-up window
|
||||
*/
|
||||
close: () => void;
|
||||
/**
|
||||
* 弹窗组件实例,需要手动挂载一下
|
||||
* The pop-up component instance needs to be mounted manually.
|
||||
*/
|
||||
modalNode: React.ReactNode;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export const ChatBackground: React.FC<ITextToSpeechProps> = ({ title }) => {
|
||||
|
||||
const defaultExpand = useDefaultExPandCheck({
|
||||
blockKey: SkillKeyEnum.BACKGROUND_IMAGE_BLOCK,
|
||||
configured: hasBackGroundImage || showDot, // 无图 有进行中的状态也展示背景图模块不允许被隐藏
|
||||
configured: hasBackGroundImage || showDot, // No picture, there is a status in progress, and the background cover module is not allowed to be hidden.
|
||||
});
|
||||
|
||||
const userInfo = userStoreService.useUserInfo();
|
||||
|
||||
@@ -35,7 +35,7 @@ import styles from './index.module.less';
|
||||
interface CommonTextareaType {
|
||||
textAreaClassName?: string;
|
||||
textAreaProps?: Partial<TextAreaProps>;
|
||||
// 一种特殊的针对placeholder处理方式,::placeholder达不到预期
|
||||
// A special treatment for placeholders, where:: placeholders do not meet expectations
|
||||
emptyClassName?: string;
|
||||
}
|
||||
interface ChatflowCustomTextareaProps extends TextAreaProps {
|
||||
@@ -44,11 +44,11 @@ interface ChatflowCustomTextareaProps extends TextAreaProps {
|
||||
value: string,
|
||||
e: React.MouseEvent<HTMLTextAreaElement, MouseEvent>,
|
||||
) => void;
|
||||
/** 展示模式(即需要省略时)的配置 */
|
||||
/** Configuration of presentation mode (i.e. when omitted) */
|
||||
ellipse?: {
|
||||
rows?: number;
|
||||
} & CommonTextareaType;
|
||||
/** 编辑模式(即需要自动适应)的配置 */
|
||||
/** Configuration of editing mode (i.e. requires automatic adaptation) */
|
||||
autoSize?: {
|
||||
maxHeight?: number;
|
||||
} & CommonTextareaType;
|
||||
@@ -87,10 +87,10 @@ export const CollapsibleTextarea = forwardRef(
|
||||
|
||||
useEffect(() => {
|
||||
if (focused) {
|
||||
// 加timeout可以实现focus的时候滚动到最底并光标在最后
|
||||
// Add timeout to scroll to the bottom and cursor at the end when focusing.
|
||||
setTimeout(() => {
|
||||
if (textAreaRef.current) {
|
||||
// 默认光标在最后
|
||||
// Default cursor at the end
|
||||
textAreaRef.current.setSelectionRange(
|
||||
Number.MAX_SAFE_INTEGER,
|
||||
Number.MAX_SAFE_INTEGER,
|
||||
@@ -107,13 +107,13 @@ export const CollapsibleTextarea = forwardRef(
|
||||
return (
|
||||
<TextArea
|
||||
autosize
|
||||
// key是保证readonly变化后重新渲染
|
||||
// The key is to ensure readonly after changes
|
||||
key="not-readonly"
|
||||
style={
|
||||
autoSize?.maxHeight
|
||||
? // 这里的 style 会应用到 wrapper 上,不限定高度时会意外出现滚动条,只能通过变量修改 textarea 的 overflow
|
||||
// 此外,max-height 会导致预期外的 blur 事件,也只能通过 css 变量将 max-height 动态传给 textarea
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- 传递 css 变量
|
||||
? // The style here will be applied to the wrapper, and the scroll bar will appear unexpectedly when the height is not limited. You can only modify the overflow of the textarea through variables.
|
||||
// In addition, max-height causes an unexpected blur event, and max-height can only be dynamically passed to textarea through the css variable
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- pass css variable
|
||||
({
|
||||
'--chatflow-custom-textarea-overflow-y': 'auto',
|
||||
'--chatflow-custom-textarea-focused-max-height': `${autoSize.maxHeight}px`,
|
||||
@@ -143,7 +143,7 @@ export const CollapsibleTextarea = forwardRef(
|
||||
}
|
||||
return (
|
||||
<TextArea
|
||||
// key是保证readonly变化后重新渲染
|
||||
// The key is to ensure readonly after changes
|
||||
key="readonly"
|
||||
style={{ WebkitLineClamp: ellipse?.rows }}
|
||||
value={value}
|
||||
|
||||
@@ -34,13 +34,13 @@ interface KvBindButtonProps {
|
||||
setDataSource?: (value: SetStateAction<BotPublishConnectorInfo[]>) => void;
|
||||
setSelectedPlatforms?: (id: SetStateAction<string[]>) => void;
|
||||
record: BotPublishConnectorInfo | PublishConnectorInfo;
|
||||
/** 渠道配置成功的回调。若不传入 `unbindCallback`,解绑渠道也会调用该回调,且 bind_id 为空字符串 `''` */
|
||||
/** The callback of the successful channel configuration. If'unbindCallback 'is not passed, the callback will also be called by unbinding the channel, and the bind_id is empty string "" */
|
||||
bindSuccessCallback?: (value: PublishConnectorInfo | undefined) => void;
|
||||
/** 解绑渠道的回调 */
|
||||
/** Callback of untied channels */
|
||||
unbindCallback?: () => void;
|
||||
/** 绑定的 agent_type 。默认为 bot */
|
||||
/** Bound agent_type. Defaults to bot */
|
||||
origin?: 'project' | 'bot';
|
||||
/** 绑定的 bot_id/project_id 。不传则根据 origin 从路由参数中获取 */
|
||||
/** The bound bot_id/project_id. If not passed, get it from the route parameter according to origin */
|
||||
originId?: string;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export const KvBindButton = ({
|
||||
originId,
|
||||
}: KvBindButtonProps) => {
|
||||
const { bot_id = '', project_id = '' } = useParams<DynamicParams>();
|
||||
// 传给后端的参数名字是 bot_id,另外使用参数 agent_type 来区分 0-bot 1-project
|
||||
// The name of the parameter passed to the backend is bot_id, and the parameter agent_type is used to distinguish 0-bot 1-project.
|
||||
const botId = originId ?? (origin === 'bot' ? bot_id : project_id);
|
||||
const bindSuccessCb = (
|
||||
value: BotPublishConnectorInfo | PublishConnectorInfo | undefined,
|
||||
@@ -66,7 +66,7 @@ export const KvBindButton = ({
|
||||
setDataSource?.((list: BotPublishConnectorInfo[]) => {
|
||||
const target = list.find(l => l.id === value?.id);
|
||||
if (target) {
|
||||
// 解绑旧的服务号后,需要隐藏掉旧的服务号渠道,不允许再绑定
|
||||
// After unbinding the old service number, you need to hide the old service number channel and do not allow it to be bound again.
|
||||
if (target.id === OLD_WX_FWH_ID && !value?.bind_id) {
|
||||
return list.filter(item => item.id !== OLD_WX_FWH_ID);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export const VariableGroupWrapper = (
|
||||
key: string | ReactNode;
|
||||
description: string | ReactNode;
|
||||
};
|
||||
defaultOpen?: boolean; // 添加默认展开属性
|
||||
defaultOpen?: boolean; // Add default expansion properties
|
||||
level?: number;
|
||||
}>,
|
||||
) => {
|
||||
|
||||
@@ -41,7 +41,7 @@ import s from './index.module.less';
|
||||
|
||||
export type TVariable = VariableItem & {
|
||||
enable?: boolean;
|
||||
must_not_use_in_prompt?: string; // 服务端类型已上线无法改boolean。""、"false"、"true"
|
||||
must_not_use_in_prompt?: string; // The server level type is online and cannot be changed to boolean. "," false "," true "
|
||||
ext_desc?: string;
|
||||
prompt_disabled?: boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
@@ -94,7 +94,7 @@ export const useSystemVariables = (
|
||||
group_conf: [],
|
||||
},
|
||||
);
|
||||
// 分组新逻辑
|
||||
// group new logic
|
||||
const configInfo = initSysVarStatus(resData);
|
||||
setConfig(configInfo);
|
||||
});
|
||||
@@ -108,7 +108,7 @@ export const useSystemVariables = (
|
||||
conf: [],
|
||||
groupConf: [],
|
||||
});
|
||||
// 这里需要根据config来设置sysVariables
|
||||
// Here you need to set sysVariables according to the config.
|
||||
const sysVariables = useMemo(() => {
|
||||
const group = sysConfig.groupConf?.reduce(
|
||||
(prev, cur) => prev.concat(cur?.var_info_list),
|
||||
@@ -117,7 +117,7 @@ export const useSystemVariables = (
|
||||
return [...sysConfig.conf, ...group];
|
||||
}, [sysConfig]);
|
||||
|
||||
// 拼接已启用的系统变量和自定义变量
|
||||
// Splice enabled system variables and custom variables
|
||||
const enableVariables = useMemo(() => {
|
||||
const enableSysVariables =
|
||||
sysVariables
|
||||
@@ -356,7 +356,7 @@ export const useSystemVariables = (
|
||||
: undefined,
|
||||
}));
|
||||
|
||||
// 系统变量
|
||||
// system variable
|
||||
const sysConfigList: ISysConfigItem[] = sysConfig?.conf?.map(item =>
|
||||
configItem(item),
|
||||
);
|
||||
|
||||
@@ -123,7 +123,7 @@ export const MemoryAddModal: React.FC<MemoryAddModalProps> = props => {
|
||||
}, [props.activeId, props.visible]);
|
||||
|
||||
useEffect(() => {
|
||||
// 控制高亮的元素滚至视区内
|
||||
// Controls the highlighted elements to roll into the viewport
|
||||
if (highLight) {
|
||||
document.getElementsByClassName('active-row')?.[0]?.scrollIntoView();
|
||||
}
|
||||
@@ -416,7 +416,7 @@ export const MemoryAddModal: React.FC<MemoryAddModalProps> = props => {
|
||||
'gap-y-2',
|
||||
)}
|
||||
>
|
||||
{/* 用户变量 */}
|
||||
{/* user variable */}
|
||||
<VariableGroupWrapper
|
||||
variableGroup={{
|
||||
key: I18n.t('variable_user_name'),
|
||||
@@ -433,7 +433,7 @@ export const MemoryAddModal: React.FC<MemoryAddModalProps> = props => {
|
||||
header={<UserParamHeader isReadonly={isReadonly} />}
|
||||
/>
|
||||
</VariableGroupWrapper>
|
||||
{/* 系统变量 */}
|
||||
{/* system variable */}
|
||||
<VariableGroupWrapper
|
||||
variableGroup={{
|
||||
key: I18n.t('variable_system_name'),
|
||||
@@ -463,7 +463,7 @@ export const MemoryAddModal: React.FC<MemoryAddModalProps> = props => {
|
||||
showType="variableList"
|
||||
addTemplate={(arr: VariableItem[]) => {
|
||||
const result = [
|
||||
// 使用模版时覆盖历史变量
|
||||
// Override history variables when using templates
|
||||
// ...variables,
|
||||
...arr.map(q => ({
|
||||
id: nanoid(),
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* 检查没有遗漏的项
|
||||
* Check for no missing items
|
||||
*/
|
||||
export const exhaustiveCheckSimple = (_: never) => undefined;
|
||||
|
||||
@@ -89,7 +89,7 @@ export const Setting: React.FC<{ modelId: string }> = ({ modelId }) => {
|
||||
dataSetInfo={knowledge.dataSetInfo}
|
||||
onDataSetInfoChange={async newVal => {
|
||||
const { auto } = newVal;
|
||||
// 修改调用模式时做前置检查
|
||||
// Pre-check when modifying the invocation mode
|
||||
if (auto !== knowledge.dataSetInfo.auto) {
|
||||
try {
|
||||
setLocked(true);
|
||||
@@ -218,8 +218,8 @@ export const DataSetAreaItem: FC<IDataSetAreaProps> = ({
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
// 排除首次初始化和删除更新,原因:
|
||||
// 因为删除会快速操作,useEffect 追踪到数据可能是最终结果,无法保证每次删除都能监听到
|
||||
// Exclude first initialization and deletion of updates for:
|
||||
// Because deletion is quick, useEffect traces that the data may be the final result, and there is no guarantee that every deletion will be monitored
|
||||
if (initRef.current && removedIds.length === 0) {
|
||||
updateSkillKnowledgeDatasetList(
|
||||
dataSetList.map(d => ({
|
||||
@@ -409,7 +409,7 @@ export const useDataSetArea = () => {
|
||||
const validDatasetList = (resp?.dataset_list ?? []).filter(item =>
|
||||
knowledge.dataSetList.some(i => i.dataset_id === item.dataset_id),
|
||||
);
|
||||
// 方便数据复用
|
||||
// Easy data reuse
|
||||
useDraftBotDataSetStore.getState().batchUpdate(validDatasetList);
|
||||
setDataSetList(validDatasetList);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ interface InputSliderProps {
|
||||
marks?: SliderProps['marks'];
|
||||
className?: string;
|
||||
|
||||
/** 是否使用 rc-slider 替换 semi-slider,目前 semi-slider 存在一个比较明显的 bug,在缩放场景下,拖拽定位存在问题,已经反馈等待修复 */
|
||||
/** Whether to use rc-slider to replace semi-slider? At present, there is an obvious bug in semi-slider. In the zoom scene, there is a problem with drag and drop positioning, which has been fed back and is waiting to be fixed. */
|
||||
useRcSlider?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ export function ChangeButton({
|
||||
}: ChangeButtonProps) {
|
||||
const [FLAGS] = useFlags();
|
||||
|
||||
// 即将支持,敬请期待
|
||||
// Support soon, so stay tuned.
|
||||
const showText = modeInfo?.showText || FLAGS['bot.studio.prompt_diff'];
|
||||
const ToolTipFragment = tooltip ? Tooltip : React.Fragment;
|
||||
|
||||
|
||||
@@ -60,11 +60,11 @@ export const ModeSelect: React.FC<ModeSelectProps> = ({
|
||||
const handleModeChange = async (value: BotMode) => {
|
||||
try {
|
||||
setBotState({ modeSwitching: true });
|
||||
// bot信息全量保存
|
||||
// The bot information is fully saved.
|
||||
const { botSkillInfo } = getBotDetailDtoInfo();
|
||||
await updateBotRequest(botSkillInfo);
|
||||
|
||||
// 服务端约定 切换模式需要单独调一次只传 bot_mode 的 update
|
||||
// Server level convention, switching mode needs to be adjusted once, only bot_mode update is transmitted.
|
||||
const switchModeParams = {
|
||||
bot_mode: value,
|
||||
...(value === BotMode.MultiMode
|
||||
|
||||
@@ -45,7 +45,7 @@ export const useInitEditor = ({
|
||||
editorRef,
|
||||
});
|
||||
}
|
||||
// 滚动到顶部
|
||||
// Scroll to top
|
||||
editorRef.current?.scrollModule?.scrollTo({
|
||||
top: 0,
|
||||
});
|
||||
|
||||
@@ -56,19 +56,19 @@ export interface OnboardingEditorProps {
|
||||
prologue: string;
|
||||
};
|
||||
isReadonly?: boolean;
|
||||
// 生成中
|
||||
// Generating
|
||||
isGenerating?: boolean;
|
||||
// 聚焦展开
|
||||
// Focus Expand
|
||||
focusExpand?: boolean;
|
||||
onChange?: (context: OnboardingEditorContext) => void;
|
||||
onBlur?: (context: OnboardingEditorContext) => void;
|
||||
noExpand?: boolean; // 右下角展开icon
|
||||
onExpand?: () => void; // 点击展开icon
|
||||
noExpand?: boolean; // Expand icon in lower right corner
|
||||
onExpand?: () => void; // Click expand icon
|
||||
style?: CSSProperties;
|
||||
businessKey?: string; // 用于注册toolbar
|
||||
businessKey?: string; // To register the toolbar
|
||||
noLabel?: boolean;
|
||||
/**
|
||||
* 开启 plainText 模式后,输入内容与原生 textarea 不会有区别,会取消 markdown 支持,并隐藏 toolbar(会覆盖 noToolbar 属性)
|
||||
* When plainText mode is enabled, the input content will not be different from the native textarea, markdown support will be removed, and toolbar will be hidden (the noToolbar property will be overridden).
|
||||
* @default false
|
||||
*/
|
||||
plainText?: boolean;
|
||||
|
||||
@@ -36,7 +36,7 @@ export const sliceEditor = (editorRef: RefObject<Editor>, maxCount: number) => {
|
||||
const sliceCount = currentCount - maxCount;
|
||||
if (sliceCount > 0) {
|
||||
const delta = new ZoneDelta({ zoneId: zone });
|
||||
// 保留maxCount, 删除之后的内容
|
||||
// Keep maxCount, delete the content
|
||||
delta.retain(maxCount).delete(sliceCount);
|
||||
editor.getContentState().apply(delta);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export const useAddEmptySuggestion = (context: SuggestionListContext) => {
|
||||
} = context.props;
|
||||
useEffect(() => {
|
||||
const addItemIfLastIsNotEmpty = () => {
|
||||
// 如果列表全部有值,且不是只读状态,添加一条空项
|
||||
// If the list has all values and is not read-only, add an empty item
|
||||
const canAddItem =
|
||||
suggested_questions.length < maxItemLength &&
|
||||
suggested_questions.every(sug => sug.content);
|
||||
|
||||
@@ -89,9 +89,9 @@ export const SuggestQuestionItemContent: React.FC<{
|
||||
|
||||
useEffect(() => {
|
||||
if (message.highlight) {
|
||||
// bot详情 - 用户定时任务 - 在开场白中添加引导 - 需要展开开场白模块
|
||||
// Bot Details - User Timed Tasks - Add Bootstrap to Opener - Need to Expand Opener Module
|
||||
emitEvent(OpenBlockEvent.ONBORDING_MESSAGE_BLOCK_OPEN);
|
||||
// 动画效果
|
||||
// animation effect
|
||||
const duration = 250;
|
||||
setTimeout(() => {
|
||||
const settingAreaScrollElement =
|
||||
@@ -103,7 +103,7 @@ export const SuggestQuestionItemContent: React.FC<{
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
// 折叠区域展开 250ms 动画时间
|
||||
// Folded area unfolded 250ms animation time
|
||||
}, duration);
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -31,9 +31,9 @@ import { CustomPlatform } from './custom';
|
||||
import s from './index.module.less';
|
||||
|
||||
enum ETab {
|
||||
// 自定义渠道
|
||||
// custom channel
|
||||
Custom = 'custom',
|
||||
// 通用渠道
|
||||
// common channel
|
||||
Normal = 'normal',
|
||||
}
|
||||
const PublishPlatformSetting = () => {
|
||||
@@ -56,7 +56,7 @@ const PublishPlatformSetting = () => {
|
||||
|
||||
return (
|
||||
<div className="pt-[10px] w-full h-full" ref={contentRef}>
|
||||
{/* 为企业管理员时才需要显示 tab */}
|
||||
{/* You only need to display tabs when you are an enterprise administrator. */}
|
||||
{showCustomTab ? (
|
||||
<Space spacing={16} className="mb-[16px]">
|
||||
<span
|
||||
@@ -86,7 +86,7 @@ const PublishPlatformSetting = () => {
|
||||
</Space>
|
||||
) : null}
|
||||
<div className={s['publish-platform-frame']}>
|
||||
{/* 为企业管理员时才需要显示 tab */}
|
||||
{/* You only need to display tabs when you are an enterprise administrator. */}
|
||||
{showCustomTab ? (
|
||||
<>
|
||||
{current === ETab.Normal && <NormalPlatform />}
|
||||
|
||||
@@ -37,7 +37,7 @@ export const HandleTooltip: React.FC<HandleTooltipProps> = props => {
|
||||
|
||||
const rafRef = React.useRef<number | null>(null);
|
||||
|
||||
// 用来更新 Tooltip 的位置
|
||||
// To update the location of Tooltip
|
||||
const [refreshKey, setRefreshKey] = React.useState('1');
|
||||
|
||||
function cancelKeepAlign() {
|
||||
|
||||
@@ -139,7 +139,7 @@ export function MultipleSheet({
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
{/* 头部插槽 */}
|
||||
{/* head slot */}
|
||||
<div className={styles['sheet-header-scope']}> {titleNode}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -181,8 +181,8 @@ export function MultipleSheet({
|
||||
placement={placement}
|
||||
visible={open}
|
||||
getPopupContainer={() =>
|
||||
// @tip 不确定这个PopupContainer的实现逻辑,采用ref.current拿不到最新的值,
|
||||
// @tip Semi需更新至2.54.0以上:当SideSheet的visible为true才挂载可以确保`getPopupContainer`使用querySelector可以获取到父组件dom,但兜底值要去掉(https://github.com/DouyinFE/semi-design/pull/2094)
|
||||
// @Tip is not sure about the implementation logic of this PopupContainer. Using ref.current cannot get the latest value.
|
||||
// @Tip Semi needs to be updated to above 2.54.0: When the visible of the SideSheet is true, it can ensure that'getPopupContainer 'can get the parent component dom using querySelector, but the bottom value should be removed (https://github.com/DouyinFE/semi-design/pull/2094)
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
document.querySelector(`#${containerId}`)!
|
||||
}
|
||||
@@ -194,7 +194,7 @@ export function MultipleSheet({
|
||||
<div
|
||||
className={classNames(styles['sheet-content'], containerClassName)}
|
||||
>
|
||||
{/* 浮层头部 */}
|
||||
{/* Floating head */}
|
||||
|
||||
{renderContent ? (
|
||||
renderContent(header)
|
||||
|
||||
@@ -42,7 +42,7 @@ export function SingleSheet({
|
||||
}: SingleSheetProps) {
|
||||
const headerNode = (
|
||||
<div className={classNames(styles.card, containerClassName)}>
|
||||
{/* 浮层头部 */}
|
||||
{/* Floating head */}
|
||||
<div className={classNames(styles['sheet-header'], headerClassName)}>
|
||||
<div
|
||||
className={classNames(
|
||||
@@ -53,7 +53,7 @@ export function SingleSheet({
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
{/* 头部插槽 */}
|
||||
{/* head slot */}
|
||||
<div
|
||||
className={classNames(
|
||||
styles['sheet-header-scope'],
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
}
|
||||
|
||||
.prompt-text {
|
||||
/* stylelint-disable-next-line custom-property-pattern -- 设计命名如此 */
|
||||
/* stylelint-disable-next-line custom-property-pattern -- so named */
|
||||
color: var(--Light-usage-text---color-text-0, #1D1C23);
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
@@ -17,7 +17,7 @@
|
||||
}
|
||||
|
||||
.custom-prompt-checkbox :global(.semi-checkbox-addon) {
|
||||
/* stylelint-disable-next-line custom-property-pattern -- 设计命名如此 */
|
||||
/* stylelint-disable-next-line custom-property-pattern -- so named */
|
||||
color: var(--Light-usage-text---color-text-2, rgba(28, 29, 35, 60%));
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
|
||||
@@ -31,13 +31,13 @@ import s from './suggestion-content.module.less';
|
||||
export type SuggestionContentProps = {
|
||||
disabled?: boolean;
|
||||
onChange: (config: Partial<BotSuggestionConfig>) => void;
|
||||
/** mode 是否来自子 bot */
|
||||
/** Is the mode from the child bot? */
|
||||
followBot?: boolean;
|
||||
} & (
|
||||
| {
|
||||
mode: SuggestReplyMode.WithCustomizedPrompt;
|
||||
prompt: string;
|
||||
/** 是否为 multi-agent 模式 */
|
||||
/** Is it in multi-agent mode? */
|
||||
multiAgent?: boolean;
|
||||
}
|
||||
| {
|
||||
@@ -45,7 +45,7 @@ export type SuggestionContentProps = {
|
||||
}
|
||||
);
|
||||
|
||||
/** 自定义 suggestion textarea 最大高度 */
|
||||
/** Custom suggestion textarea maximum height */
|
||||
const MAX_CUSTOM_SUGGESTION_PROMPT_HEIGHT = 340;
|
||||
|
||||
export function SuggestionContent({
|
||||
@@ -58,14 +58,14 @@ export function SuggestionContent({
|
||||
|
||||
return (
|
||||
<div className={s['suggestion-content']}>
|
||||
{/* 无 suggestion */}
|
||||
{/* No suggestion */}
|
||||
{props.mode === SuggestReplyMode.Disable && (
|
||||
<div className={s.description}>
|
||||
{I18n.t('bot_edit_auto_suggestion_off_description')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 默认 suggestion */}
|
||||
{/* Default suggestion */}
|
||||
{props.mode === SuggestReplyMode.WithDefaultPrompt && (
|
||||
<>
|
||||
<div className={s.description}>
|
||||
@@ -90,7 +90,7 @@ export function SuggestionContent({
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 自定义 suggestion prompt */}
|
||||
{/* Custom suggestion prompt */}
|
||||
{props.mode === SuggestReplyMode.WithCustomizedPrompt && (
|
||||
<>
|
||||
<div className={s.description}>
|
||||
|
||||
@@ -101,9 +101,9 @@ const BaseTableMemory: FC<TableMemoryProps> = ({
|
||||
if (removeCallback) {
|
||||
removeCallback?.();
|
||||
}
|
||||
// 更新 list
|
||||
// Update list
|
||||
await reloadDatabaseList();
|
||||
// 更新 bot draft
|
||||
// Update bot draft
|
||||
await saveTableMemory();
|
||||
} else {
|
||||
Toast.error(res.msg);
|
||||
@@ -111,14 +111,14 @@ const BaseTableMemory: FC<TableMemoryProps> = ({
|
||||
};
|
||||
|
||||
const onCreateDatabase = async (databaseId: string, draftId: string) => {
|
||||
// NOTE: 绑定/解绑 bot 数据库,需要传入 DatabaseInfo 的 draft_id
|
||||
// NOTE: Bind/unbind the bot database, you need to pass in the draft_id of DatabaseInfo
|
||||
await MemoryApi.BindDatabase({
|
||||
database_id: draftId,
|
||||
bot_id: botId,
|
||||
});
|
||||
// 更新 list
|
||||
// Update list
|
||||
await reloadDatabaseList();
|
||||
// 更新 bot draft
|
||||
// Update bot draft
|
||||
await saveTableMemory();
|
||||
};
|
||||
|
||||
@@ -135,9 +135,9 @@ const BaseTableMemory: FC<TableMemoryProps> = ({
|
||||
if (addCallback) {
|
||||
addCallback?.();
|
||||
}
|
||||
// 更新 list
|
||||
// Update list
|
||||
await reloadDatabaseList();
|
||||
// 更新 bot draft
|
||||
// Update bot draft
|
||||
await saveTableMemory();
|
||||
} else {
|
||||
Toast.error(res.msg);
|
||||
|
||||
@@ -20,8 +20,8 @@ import { OpenBlockEvent } from '@coze-arch/bot-utils';
|
||||
export { SkillKeyEnum };
|
||||
|
||||
/**
|
||||
* `模块折叠 有关事件` 和 `模块主键` 之间的映射关系
|
||||
* @deprecated 废弃,请使用@coze-agent-ide/tool中的openBlockEventToToolKey
|
||||
* Module folding, the mapping between related events and module primary keys
|
||||
* @Deprecated, please use the openBlockEventToToolKey in @code-agent-ide/tool
|
||||
*/
|
||||
export const openBlockEventToBlockKey = {
|
||||
[OpenBlockEvent.PLUGIN_API_BLOCK_OPEN]: SkillKeyEnum.PLUGIN_API_BLOCK,
|
||||
|
||||
@@ -94,12 +94,12 @@ export const useMessageReportEvent = () => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 用于校验当前模块默认展开收起状态
|
||||
* Used to verify the default expanded and stowed state of the current module
|
||||
*
|
||||
* @deprecated 废弃,请使用@coze-agent-ide/tool中的useToolContentBlockDefaultExpand
|
||||
* @param blockKey 主键
|
||||
* @param configured 是否有配置内容
|
||||
* @param when 是否校验
|
||||
* @Deprecated, please use the useToolContentBlockDefaultExpand in @code-agent-ide/tool
|
||||
* @param blockKey primary key
|
||||
* @param configured whether there is configuration content
|
||||
* Check when @param
|
||||
*
|
||||
* @see
|
||||
*/
|
||||
@@ -120,18 +120,18 @@ export 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. Have editing rights
|
||||
* 2. Cannot be a historical preview environment
|
||||
* 3. Must be configured
|
||||
*/
|
||||
} else if (editable && !isReadonly && configured) {
|
||||
const transformerBlockKey = skillKeyToApiStatusKeyTransformer(blockKey);
|
||||
|
||||
@@ -37,7 +37,7 @@ import { PluginType } from '@coze-arch/bot-api/developer_api';
|
||||
import { PluginDevelopApi } from '@coze-arch/bot-api';
|
||||
|
||||
/**
|
||||
* workflow 发布成功后跳转回 bot 编辑页,弹窗提示是否添加到 bot
|
||||
* After the workflow is successfully published, jump back to the bot editing page, and the pop-up window prompts whether to add it to the bot.
|
||||
*/
|
||||
export const useWorkflowPublishedModel = ({
|
||||
flowMode,
|
||||
@@ -48,11 +48,11 @@ export const useWorkflowPublishedModel = ({
|
||||
pageType = PageType.BOT,
|
||||
}: {
|
||||
flowMode?: WorkflowMode;
|
||||
/** 已添加的 workflow(若已添加该 workflow 则不弹窗)。为了兼容 single 和 multi 模式,所以由外部传入 */
|
||||
/** The workflow that has been added (if the workflow has been added, the window will not pop up). For compatibility with single and multi modes, it is passed in externally */
|
||||
addedWorkflows: WorkFlowItemType[];
|
||||
/** 点击确认并查询 workflow 对应的 plugin 成功后的回调,也是为了兼容 single 和 multi 两种模式才由外部传入 */
|
||||
/** Click Confirm and query the callback after the plugin corresponding to the workflow is successful. It is also passed in externally for compatibility with single and multi modes */
|
||||
onOk: (workflow: WorkFlowItemType) => unknown;
|
||||
/** 允许业务方额外附带禁止弹窗的条件。主要用于 multi 模式 */
|
||||
/** Allows the business side to attach additional conditions to prohibit pop-ups. Mainly used in multi mode */
|
||||
skipByExternal?: (
|
||||
jumpResponse: SceneResponseType<
|
||||
| SceneType.WORKFLOW_PUBLISHED__BACK__BOT
|
||||
@@ -66,7 +66,7 @@ export const useWorkflowPublishedModel = ({
|
||||
const isImageflow = flowMode === WorkflowMode.Imageflow;
|
||||
const jumpResponse = usePageJumpResponse(pageType);
|
||||
|
||||
// 使用 useCallback 缓存防抖函数,避免 UIModal 弹窗出现多次
|
||||
// Use useCallback cache stabilization function to avoid multiple UIModal pop-ups
|
||||
const debouncedEffect = useCallback(
|
||||
debounce(() => {
|
||||
const isNotWorkflowPublishedBackBot =
|
||||
@@ -88,11 +88,11 @@ export const useWorkflowPublishedModel = ({
|
||||
isNotWorkflowPublishedBackSocialScene) ||
|
||||
isOnlyOnceAdd
|
||||
) {
|
||||
// 不是发布跳转的场景,或者是仅添加一次,直接不弹窗
|
||||
// It is not to publish the jump scene, or to add it only once without popping up.
|
||||
return;
|
||||
}
|
||||
|
||||
// 配置了 flowMode 才判断,否则不进行 flowMode 限制(适配 ChatFlow)
|
||||
// The flowMode is configured to judge, otherwise the flowMode restriction will not be performed (adapted to ChatFlow)
|
||||
if (
|
||||
typeof flowMode !== 'undefined' &&
|
||||
(jumpResponse?.flowMode || WorkflowMode.Workflow) !== flowMode
|
||||
@@ -109,7 +109,7 @@ export const useWorkflowPublishedModel = ({
|
||||
workflow => workflow.workflow_id === jumpResponse.workflowID,
|
||||
)
|
||||
) {
|
||||
// 已经添加过该 workflow 了,不弹窗
|
||||
// The workflow has been added, no pop-up window.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,13 +174,13 @@ export const useWorkflowPublishedModel = ({
|
||||
},
|
||||
});
|
||||
}, 1000),
|
||||
[], // 空依赖数组
|
||||
[], // empty dependent array
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
debouncedEffect();
|
||||
|
||||
// 清理函数
|
||||
// cleanup function
|
||||
return () => {
|
||||
debouncedEffect.cancel();
|
||||
};
|
||||
|
||||
@@ -230,7 +230,7 @@ export const useAgentPersistence = ({
|
||||
content: I18n.t('bot_created_toast'),
|
||||
showClose: false,
|
||||
});
|
||||
// 兼容 onSuccess 回调为同步函数的场景
|
||||
// Scenarios that are compatible with onSuccess callbacks as synchronization functions
|
||||
await onSuccess?.(resp.data?.bot_id, paramsSpaceId, {
|
||||
botName: values?.name,
|
||||
botDesc: values?.target,
|
||||
@@ -259,7 +259,7 @@ export const useAgentPersistence = ({
|
||||
});
|
||||
}
|
||||
onError?.();
|
||||
// 阻止弹窗关闭
|
||||
// Prevent pop-ups from closing
|
||||
throw e;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -26,7 +26,7 @@ const useEditConfirm = () => {
|
||||
const { savingInfo } = usePageRuntimeStore.getState();
|
||||
const leaveWarningInfo = I18n.t('pop_edit_save_confirm');
|
||||
|
||||
// 保存navigate和location.pathname的引用
|
||||
// Save navigate and location.pathname references
|
||||
const navigateRef = useRef(navigate);
|
||||
const locationRef = useRef(location.pathname);
|
||||
const debouncingRef = useRef(savingInfo.debouncing);
|
||||
@@ -45,7 +45,7 @@ const useEditConfirm = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// popstate 执行回调的时候,由于产生了闭包,会保存支持的值,所以需要在这里处理一下
|
||||
// When popstate executes the callback, it will save the supported values due to the closure generated, so it needs to be dealt with here.
|
||||
navigateRef.current = navigate;
|
||||
locationRef.current = location.pathname;
|
||||
|
||||
@@ -62,7 +62,7 @@ const useEditConfirm = () => {
|
||||
}, [navigate, location]);
|
||||
|
||||
useEffect(() => {
|
||||
// 刷新页面 & 关闭页面情况,用 beforeunload
|
||||
// Refresh page & close page condition, use beforeunload
|
||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -63,8 +63,8 @@ const checkShouldAlertMaxToken = (inputMaxToken: number | undefined) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 当用户模型 max_token 字段 <= 5 时进行提示
|
||||
* 避免用户误操作无法正常使用模型
|
||||
* Prompt when the user model max_token field < = 5
|
||||
* Avoid user misoperation and cannot use the model normally
|
||||
*/
|
||||
const modelMaxTokenAlert = () => {
|
||||
const { useModelStore, useMultiAgentStore } = useBotDetailStoreSet.getStore();
|
||||
@@ -74,7 +74,7 @@ const modelMaxTokenAlert = () => {
|
||||
const toastOptions = {
|
||||
content: I18n.t(alertI18nKey),
|
||||
showClose: true,
|
||||
// 当 duration 设置为 0 时,toast 不会自动关闭,此时必须通过手动关闭。
|
||||
// When duration is set to 0, toast is not automatically turned off and must be turned off manually.
|
||||
duration: 0,
|
||||
id: maxTokenAlertId,
|
||||
};
|
||||
@@ -133,9 +133,9 @@ const startAutosaveManagerConditionally = ({
|
||||
const saveAllEdit = async ({ disable }: { disable: boolean | undefined }) => {
|
||||
const { botId, mode } = useBotInfoStore.getState();
|
||||
|
||||
// readonly如果依赖hook会更新滞后。因为页面卸载时clearStore,保留了overall的值
|
||||
// 所以这里的readonly需要执行时去获取
|
||||
// 增加是否是offline或者没有锁的的状态判断,如果是,也不进行保存。
|
||||
// readonly if dependent hook will update lagged. Because clearStore retains the overall value when the page is unloaded
|
||||
// So the readonly here needs to be obtained when executed.
|
||||
// Increase the status of whether it is offline or without a lock, and if so, do not save it.
|
||||
if (!botId || getBotDetailIsReadonly() || disable) {
|
||||
return;
|
||||
}
|
||||
@@ -149,10 +149,10 @@ const saveAllEdit = async ({ disable }: { disable: boolean | undefined }) => {
|
||||
|
||||
const useInit = (props: AgentInitProps = { initCallback: {} }) => {
|
||||
const { initCallback } = props;
|
||||
// TODO: 后续加锁操作会收敛到hooks中,不再侵入到业务
|
||||
// 初始化 store 锁,在未执行结束前,不执行页面销毁的回调
|
||||
// TODO: Subsequent locking operations will converge into hooks and no longer invade the business
|
||||
// Initialize the store lock, do not execute the page destruction callback before the end of the execution
|
||||
const lock = useRef(false);
|
||||
// 取消初始化函数标志位,在先执行页面销毁的回调时,退出初始化函数执行
|
||||
// Cancel the initialization function flag bit, and exit the initialization function execution when the page destruction callback is executed first
|
||||
const abort = useRef(false);
|
||||
const searchParams = parse(location.search.slice(1)) as TaskParams;
|
||||
const params = useParams<DynamicParams>();
|
||||
@@ -197,15 +197,15 @@ const useInit = (props: AgentInitProps = { initCallback: {} }) => {
|
||||
initCallback?.onBeforeInitStore?.();
|
||||
getBotSkillBlockCollapsibleState();
|
||||
await initBotDetailStore({ version: searchParams.version });
|
||||
// 需要判断是否为只读态,依赖store初始化,因此放在initBotDetailStore之后
|
||||
// It needs to determine whether it is read-only and relies on store initialization, so it is placed after initBotDetailStore.
|
||||
initGenerateImageStore();
|
||||
const isAbort = abort.current;
|
||||
const callbackRes = initCallback?.onInitStoreSuccess?.({ isAbort });
|
||||
// 判断是否先执行页面销毁的回调,是退出函数执行
|
||||
// Determine whether to execute the callback of page destruction first, and exit the function execution
|
||||
if (isAbort) {
|
||||
return;
|
||||
}
|
||||
//explore中的bot都不是自己的!!!
|
||||
//None of the bots in Explore are their own!!!
|
||||
const isSelf =
|
||||
useBotInfoStore.getState().creator_id === userInfo?.user_id_str;
|
||||
|
||||
@@ -233,21 +233,21 @@ const useInit = (props: AgentInitProps = { initCallback: {} }) => {
|
||||
|
||||
return () => {
|
||||
Toast.close(maxTokenAlertId);
|
||||
// 设置取消标志位
|
||||
// Set Cancel Flag
|
||||
abort.current = true;
|
||||
const unmountRes = initCallback?.onUnmount?.({
|
||||
isInitializing: lock.current,
|
||||
});
|
||||
// 有锁的情况下不执行销毁回调
|
||||
// Do not execute destruction callback with lock
|
||||
if (lock.current) {
|
||||
return;
|
||||
}
|
||||
// 页面离开时,全量保存一下编辑的内容
|
||||
// When the page leaves, save the edited content in full
|
||||
const { botId } = useBotInfoStore.getState();
|
||||
saveAllEdit({ disable: unmountRes?.disableSaveAll });
|
||||
|
||||
setBotState({
|
||||
// 页面卸载时,将上一个botId改为当前的botId
|
||||
// When the page is unloaded, change the previous botId to the current botId
|
||||
previousBotID: botId,
|
||||
});
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import { useBotInfoStore } from '@coze-studio/bot-detail-store/bot-info';
|
||||
import { useBotDetailIsReadonly } from '@coze-studio/bot-detail-store';
|
||||
|
||||
/**
|
||||
* bot 付费配置是否可编辑
|
||||
* Is the bot paid configuration editable?
|
||||
*
|
||||
* 与 bot 是否可编辑的区别:作者本人可以编辑,有 bot 编辑权限的协作者也无法修改付费配置
|
||||
* The difference between whether the bot is editable: the author himself can edit, and collaborators with bot editing rights cannot modify the paid configuration
|
||||
*/
|
||||
export function useMonetizeConfigReadonly() {
|
||||
const userId = userStoreService.useUserInfo()?.user_id_str;
|
||||
|
||||
@@ -13,25 +13,25 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import { useCurrentEntity } from '@flowgram-adapter/free-layout-editor';
|
||||
|
||||
/**
|
||||
* 获取当前节点 id,若返回 undefined 则代表不在 multi 模式的节点上下文
|
||||
* Get the current node id, if it returns undefined, it represents the node context that is not in multi mode
|
||||
*
|
||||
* Q1:这个 hook 应该放到 multi-agent 模块下?
|
||||
* A1:multi-agent 模块下已有类似 hook。
|
||||
* 单独提出来是为了避免某些在 single 和 multi 都会复用的组件要使用 node id 时,产生不合理的 import 路径
|
||||
* Q1: Should this hook be placed under the multi-agent module?
|
||||
* A1: A similar hook exists under the multi-agent module.
|
||||
* It is proposed separately to avoid unreasonable import paths when some components that are reused in both single and multi need to use node id.
|
||||
*
|
||||
* Q2:在 single 和 multi 都复用的组件,应该由调用方传入 node id?
|
||||
* A2:太理想了。有些组件业务逻辑过于复杂,由调用方传入的话会导致层层传参的深度略显夸张,比如 bot 的 workflow 弹窗。
|
||||
* Q2: For components that are reused in both single and multi, should the caller pass in the node id?
|
||||
* A2: Ideal. Some component business logic is too complex, and the depth of parameters passed by the caller will be slightly exaggerated, such as the workflow pop-up window of the bot.
|
||||
*/
|
||||
export function useCurrentNodeId() {
|
||||
let nodeId: string | undefined;
|
||||
try {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks -- 并未条件性调用 hook
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks -- no conditional call to hook
|
||||
nodeId = useCurrentEntity().id;
|
||||
// eslint-disable-next-line @coze-arch/use-error-in-catch -- SDK 符合预期的报错,无需额外处理
|
||||
// eslint-disable-next-line @coze-arch/use-error-in-catch -- SDK meets expected errors, no additional processing required
|
||||
} catch {
|
||||
nodeId = undefined;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { type FreeGrabModalHierarchyAction } from '@coze-agent-ide/bot-editor-co
|
||||
import { type ModalHierarchyServiceConstructor } from './type';
|
||||
|
||||
export class FreeGrabModalHierarchyService {
|
||||
/** Tip: semi modal zIndex 为 1000 */
|
||||
/** Tip: semi modal zIndex is 1000 */
|
||||
private baseZIndex = 1000;
|
||||
public registerModal: FreeGrabModalHierarchyAction['registerModal'];
|
||||
public removeModal: FreeGrabModalHierarchyAction['removeModal'];
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
|
||||
import { type NLPromptModalVisibilityProps } from './type';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- mitt 不认 interface
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- mitt do not recognize interface
|
||||
type VisibilityEvent = {
|
||||
visibilitychange:
|
||||
| { isShow: true; openModalSource: OpenModalSource }
|
||||
|
||||
@@ -29,7 +29,7 @@ export const initialStore: BotModeStore = {
|
||||
isCollaboration: false,
|
||||
};
|
||||
|
||||
//TODO 后续改成context或者迁移到package内。
|
||||
//TODO is subsequently changed to context or migrated to the package.
|
||||
export const useBotModeStore = create<BotModeStore & BotModeAction>()(
|
||||
devtools(
|
||||
(set, get) => ({
|
||||
|
||||
@@ -18,9 +18,9 @@ import { devtools } from 'zustand/middleware';
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface DebugPanelStore {
|
||||
/** debug panel 展示状态 */
|
||||
/** Debug panel display status */
|
||||
isDebugPanelShow: boolean;
|
||||
/** 当前选中的debug query id */
|
||||
/** Currently selected debug query id */
|
||||
currentDebugQueryId: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ interface RiskAction {
|
||||
const initialStore: RiskStore = {
|
||||
pluginRiskIsRead: true,
|
||||
toolHiddenModeNewbieGuideIsRead: true,
|
||||
// 支持扩展其它风险提示...
|
||||
// Support for expanding other risk alerts...
|
||||
};
|
||||
|
||||
export const useRiskWarningStore = create<RiskStore & RiskAction>()(
|
||||
|
||||
@@ -84,20 +84,20 @@ export enum PublishDisabledType {
|
||||
}
|
||||
|
||||
export interface PublisherBotInfo {
|
||||
// bot名称
|
||||
// bot name
|
||||
name: string;
|
||||
// bot描述
|
||||
// Bot description
|
||||
description: string;
|
||||
// bot prompt
|
||||
prompt: string;
|
||||
// bot 分支(用于多人协作diff)
|
||||
// Bot branch (for multi-person collaborative diff)
|
||||
branch?: Branch;
|
||||
// bot模式: single or multi
|
||||
// Bot mode: single or multi
|
||||
botMode?: BotMode;
|
||||
// 是否发布过
|
||||
// Has it been published?
|
||||
hasPublished?: boolean;
|
||||
// 收费插件列表
|
||||
// List of paid plugins
|
||||
pluginPricingRules?: Array<PluginPricingRule>;
|
||||
// 业务类型 DouyinAvatar=1 抖音分身
|
||||
// Business Type DouyinAvatar = 1 Douyin Clone
|
||||
businessType?: BusinessType;
|
||||
}
|
||||
|
||||
@@ -35,16 +35,16 @@ export {
|
||||
} from './auth';
|
||||
|
||||
/**
|
||||
* 获得bot详情页的path,非explore页面
|
||||
* @param {String} spaceID - 空间ID
|
||||
* Get the path to bot details pages, not explore pages
|
||||
* @param {String} spaceID - space ID
|
||||
* @param {String} botID - bot ID
|
||||
*/
|
||||
export const getBotDetailPagePath = (spaceID: string, botID: string) =>
|
||||
`/space/${spaceID}/bot/${botID}`;
|
||||
|
||||
/**
|
||||
* 打平bot diff data,flat数组内的子树结构,并添加层级到每个节点中
|
||||
* @param {Array<DiffDisplayNode & { level?: number }>} dataSource - 空间ID
|
||||
* Flatten bot diff data, flat subtree structure within array, and add hierarchy to each node
|
||||
* @param {Array < DiffDisplayNode & {level?: number} >} dataSource - space ID
|
||||
* @param {String} botID - bot ID
|
||||
*/
|
||||
export const flatDataSource = (
|
||||
@@ -71,13 +71,13 @@ export const setPCBodyWithDebugPanel = () => {
|
||||
htmlStyle.minWidth = '1680px';
|
||||
};
|
||||
|
||||
// 旧的要下线的服务号id
|
||||
// The old service number id to be offline.
|
||||
export const OLD_WX_FWH_ID = '10000114';
|
||||
|
||||
// 新的微信服务号id
|
||||
// New WeChat service ID
|
||||
export const NEW_WX_FWH_ID = '10000120';
|
||||
|
||||
// store渠道的id
|
||||
// Store channel id
|
||||
export const STORE_CONNECTOR_ID = '10000122';
|
||||
|
||||
export const getPublishResult: (
|
||||
@@ -100,7 +100,7 @@ export const getPublishResult: (
|
||||
});
|
||||
};
|
||||
|
||||
// 新旧微信公众号迁移特判逻辑:当绑定新微信渠道时,提示先解绑已绑定的旧的渠道,防止同bot重复绑定
|
||||
// New and old WeChat official account migration special judgment logic: When binding a new WeChat channel, it is prompted to unbind the bound old channel first to prevent repeated binding with the bot
|
||||
export const isWeChatMigration = (
|
||||
record: PublishConnectorInfo,
|
||||
dataSource: PublishConnectorInfo[],
|
||||
|
||||
Reference in New Issue
Block a user