chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -51,7 +51,7 @@ export interface PluginModalContentProps extends PluginModalModeProps {
|
||||
setQuery: (value: Partial<PluginQuery>, refreshPage?: boolean) => void;
|
||||
}
|
||||
export type PluginModalContentListItem = PluginInfoForPlayground & {
|
||||
// 当前数据属于列表的第几页
|
||||
// The current data belongs to the page of the list
|
||||
belong_page?: number;
|
||||
};
|
||||
|
||||
@@ -99,7 +99,7 @@ export const PluginModalContent: FC<PluginModalContentProps> = ({
|
||||
onCopyPluginCallback,
|
||||
clickProjectPluginCallback,
|
||||
}) => {
|
||||
// 状态hook
|
||||
// Status hook
|
||||
const {
|
||||
type,
|
||||
mineActive,
|
||||
@@ -112,9 +112,9 @@ export const PluginModalContent: FC<PluginModalContentProps> = ({
|
||||
pluginType,
|
||||
} = query;
|
||||
const id = useSpaceStore(store => store.space.id);
|
||||
// scroll的container
|
||||
// Scroll container
|
||||
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
// 当前active的key
|
||||
// Currently active key
|
||||
const [activeKey, setActivekey] = useState<string | string[] | undefined>([]);
|
||||
const refInfiniteScroll = useRef<InfiniteListRef>(null);
|
||||
const {
|
||||
@@ -140,10 +140,10 @@ export const PluginModalContent: FC<PluginModalContentProps> = ({
|
||||
nodes: state.nodes,
|
||||
})),
|
||||
);
|
||||
// 首次effect不执行,这个是切换状态的effect
|
||||
// The first effect is not executed, this is the effect of switching the state
|
||||
useUpdateEffect(() => {
|
||||
scroll2Top(); // 当筛选项改变时,回到顶部
|
||||
// 只要是query中非page改变,就执行此effect
|
||||
scroll2Top(); // When the filter item changes, return to the top
|
||||
// Perform this effect whenever a non-page change is made in the query
|
||||
}, []);
|
||||
return (
|
||||
<UICompositionModalMain>
|
||||
|
||||
@@ -53,24 +53,24 @@ export interface UsePluginModalPartsProp extends PluginModalModeProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取初始化类型
|
||||
* @param from 来源
|
||||
* @param spaceType 空间类型
|
||||
* @returns 初始化类型
|
||||
* Get initialization type
|
||||
* @Param from source
|
||||
* @param spaceType
|
||||
* @Returns initialization type
|
||||
*/
|
||||
const getInitType = (from?: From, spaceType?: SpaceType) => {
|
||||
// 项目workflow引用插件,默认选中项目插件
|
||||
// Project workflow reference plug-in, the project plug-in is selected by default
|
||||
if (from === From.ProjectWorkflow) {
|
||||
return '';
|
||||
}
|
||||
if (from !== From.ProjectIde || !spaceType || !from) {
|
||||
return '';
|
||||
}
|
||||
// projectIDE下,并且是个人空间,选中Mine
|
||||
// Under projectIDE, and it is personal space, select Mine.
|
||||
if (spaceType === SpaceType.Personal) {
|
||||
return PluginFilterType.Mine;
|
||||
}
|
||||
// projectIDE下,并且是团队空间,选中Team
|
||||
// Under projectIDE, and is a team space, select Team
|
||||
if (spaceType === SpaceType.Team && from === From.ProjectIde) {
|
||||
return PluginFilterType.Team;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export const usePluginModalParts = ({
|
||||
hideCreateBtn,
|
||||
initQuery,
|
||||
}: UsePluginModalPartsProp) => {
|
||||
// 获取devId
|
||||
// Get devId
|
||||
const userInfo = userStoreService.useUserInfo();
|
||||
const spaceType = useSpaceStore(store => store.space.space_type);
|
||||
const [query, setQuery] = useState<PluginQuery>({
|
||||
@@ -103,14 +103,14 @@ export const usePluginModalParts = ({
|
||||
devId: userInfo?.user_id_str || '',
|
||||
search: '',
|
||||
page: DEFAULT_PAGE,
|
||||
// 项目IDE插件仅展示我的插件
|
||||
// Project IDE plugins only show my plugins
|
||||
type: initQuery?.type ?? getInitType(from, spaceType),
|
||||
orderBy: OrderBy.CreateTime,
|
||||
orderByPublic: SortType.Heat,
|
||||
orderByFavorite: SortType.Newest,
|
||||
mineActive: MineActiveEnum.All,
|
||||
isOfficial: initQuery?.isOfficial ?? undefined,
|
||||
// project workflow添加插件,只展示云插件
|
||||
// Add plugins to project workflow, only show cloud plugins
|
||||
pluginType:
|
||||
from === From.ProjectWorkflow ? PluginType.CLoudPlugin : undefined,
|
||||
});
|
||||
|
||||
@@ -85,11 +85,11 @@ export const PluginModalSider: FC<PluginModalSiderProp> = ({
|
||||
maxLength={MAX_SEARCH_LENGTH}
|
||||
onSearch={search => {
|
||||
if (!search) {
|
||||
// 如果search清空了,那么立即更新query
|
||||
// If the search is empty, update the query immediately
|
||||
cancel();
|
||||
updateSearchQuery(search);
|
||||
} else {
|
||||
// 如果search有值,那么防抖更新
|
||||
// If search has a value, then anti-shake update
|
||||
debounceChangeSearch(search);
|
||||
}
|
||||
}}
|
||||
@@ -102,7 +102,7 @@ export const PluginModalSider: FC<PluginModalSiderProp> = ({
|
||||
className={s.addbtn}
|
||||
theme="solid"
|
||||
onClick={() => {
|
||||
// TODO: 其他场景应该也统一创建方式,如果创建成功回调存在,则打开插件modal,否则打开新tab
|
||||
// TODO: Other scenes should also be created in a unified way. If the creation success callback exists, open the plugin modal, otherwise open a new tab.
|
||||
if (
|
||||
onCreateSuccess &&
|
||||
(from === From.ProjectIde || from === From.ProjectWorkflow)
|
||||
|
||||
@@ -169,7 +169,7 @@ export function useInfiniteScrollCacheLoad<
|
||||
] = true;
|
||||
});
|
||||
|
||||
//数据去重
|
||||
//Data deduplicated
|
||||
const uniqList = (list || []).filter(item => {
|
||||
const pluginId = (item as unknown as { pluginInfo: { id: string } })
|
||||
?.pluginInfo?.id;
|
||||
|
||||
@@ -61,9 +61,9 @@ export const CreateCodePluginModal: React.FC<CreatePluginProps> = props => {
|
||||
const [openApi, setOpenApi] = useState<string | undefined>();
|
||||
|
||||
useEffect(() => {
|
||||
/** 每次打开重置弹窗数据 */
|
||||
/** Reset pop-up data every time you open it */
|
||||
if (visible) {
|
||||
//格式化json
|
||||
//Format json
|
||||
const desc = JSON.stringify(
|
||||
safeJSONParse(editInfo?.code_info?.plugin_desc),
|
||||
null,
|
||||
|
||||
@@ -114,7 +114,7 @@ export const CreateFormPluginModal: FC<CreatePluginFormProps> = props => {
|
||||
return;
|
||||
}
|
||||
if (visible) {
|
||||
// 显示后滚动条滑动到最上边
|
||||
// Scroll bar after display to top
|
||||
const modalContent = document.querySelector(
|
||||
'.create-plugin-modal-content .semi-modal-body',
|
||||
);
|
||||
@@ -122,7 +122,7 @@ export const CreateFormPluginModal: FC<CreatePluginFormProps> = props => {
|
||||
modalContent.scrollTop = 0;
|
||||
}
|
||||
} else {
|
||||
// 隐藏后重置表单
|
||||
// Reset form after hiding
|
||||
formApi?.current?.reset();
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
@@ -167,7 +167,7 @@ export const FileUpload = ({ onUpload, disabled }: FileUploadProps) => {
|
||||
onChange={({ fileList: list }) => {
|
||||
setFileList(list);
|
||||
if (!list.length) {
|
||||
// 清空content
|
||||
// Clear content
|
||||
onUpload();
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -121,7 +121,7 @@ export const ImportPluginModalContent: React.FC<
|
||||
__disableErrorToast: true,
|
||||
});
|
||||
|
||||
// 解析string
|
||||
// Parse string
|
||||
const result = parsePluginInfo({
|
||||
aiPlugin: ai_plugin,
|
||||
openAPI: openapi,
|
||||
|
||||
@@ -146,17 +146,17 @@ const HeaderList = ({
|
||||
value?: commonParamSchema[];
|
||||
onChange?: (val?: commonParamSchema[]) => void;
|
||||
}) => {
|
||||
/** 添加header */
|
||||
/** Add header */
|
||||
// @ts-expect-error -- linter-disable-autofix
|
||||
const addHeader = data => {
|
||||
const h = [...headerList];
|
||||
h.push(data.name ? data : { name: '', value: '' });
|
||||
setHeaderList?.(h);
|
||||
};
|
||||
/** 删除header */
|
||||
/** Delete header */
|
||||
// @ts-expect-error -- linter-disable-autofix
|
||||
const deleteHeader = index => {
|
||||
// 若为最后一个header,则只清空内容,不删除
|
||||
// If it is the last header, only empty the content, not delete it
|
||||
const filterList = cloneDeep(headerList);
|
||||
filterList.splice(index, 1);
|
||||
setHeaderList?.(filterList);
|
||||
@@ -401,7 +401,7 @@ export const ServiceField = ({ disabled }: PluginInfoFormFieldProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
// extItems 动态下发
|
||||
// extItems dynamic delivery
|
||||
export const ExtItems = ({
|
||||
disabled,
|
||||
extItems,
|
||||
@@ -410,7 +410,7 @@ export const ExtItems = ({
|
||||
const formValues = formApi.getValues();
|
||||
return (
|
||||
<>
|
||||
{/* 服务端动态返回授权项 */}
|
||||
{/* Server level dynamic return authorization */}
|
||||
{extItems?.map(item => (
|
||||
<>
|
||||
{disabled ? (
|
||||
|
||||
@@ -77,8 +77,8 @@ const INITIAL_FORM_VALUES = {
|
||||
};
|
||||
|
||||
/**
|
||||
文件导入plugin确认信息弹窗,目前和普通创建导入很像,调用接口不一样,
|
||||
目前感觉这个确认形式不太友好,后续不太确定优化形态,所以新建单独文件处理,以防污染bot-form-edit
|
||||
File import plugin confirmation information pop-up window, currently very similar to ordinary creation and import, the call interface is different.
|
||||
At present, I feel that this confirmation form is not very friendly, and I am not sure about the optimization form in the future, so a new separate file is created to prevent contamination of bot-form-edit.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
@@ -93,7 +93,7 @@ export const PluginInfoConfirm: React.FC<PluginInfoConfirmProps> = props => {
|
||||
} = props;
|
||||
|
||||
const [authOption, setAuthOption] = useState<AuthOption[]>([]);
|
||||
// 合规审核结果
|
||||
// Compliance audit results
|
||||
const [isValidCheckResult, setIsValidCheckResult] = useState(true);
|
||||
|
||||
const [extItems, setExtItems] = useState<OauthTccOpt[]>([]);
|
||||
@@ -121,7 +121,7 @@ export const PluginInfoConfirm: React.FC<PluginInfoConfirmProps> = props => {
|
||||
|
||||
useEffect(() => {
|
||||
if (importInfo) {
|
||||
//更新插件
|
||||
//update plugin
|
||||
setExtItems(
|
||||
findAuthTypeItem(
|
||||
authOption,
|
||||
@@ -279,7 +279,7 @@ export const PluginInfoConfirm: React.FC<PluginInfoConfirmProps> = props => {
|
||||
>
|
||||
{({ values }) => (
|
||||
<>
|
||||
{/* 插件头像 */}
|
||||
{/* plugin avatar */}
|
||||
<PictureUpload
|
||||
noLabel
|
||||
disabled={disabled}
|
||||
@@ -288,13 +288,13 @@ export const PluginInfoConfirm: React.FC<PluginInfoConfirmProps> = props => {
|
||||
iconType={IconType.Plugin}
|
||||
fileBizType={FileBizType.BIZ_PLUGIN_ICON}
|
||||
/>
|
||||
{/* 插件名称/插件描述/插件URL */}
|
||||
{/* Plugin Name/Plugin Description/Plugin URL */}
|
||||
<PluginNameField disabled={disabled} />
|
||||
<PluginDescField disabled={disabled} />
|
||||
<PluginUrlField disabled={true} />
|
||||
{/* 插件Header */}
|
||||
{/* Plugin Header */}
|
||||
<HeaderListField disabled={disabled} />
|
||||
{/* 授权方式 */}
|
||||
{/* Authorization method */}
|
||||
<AuthTypeField
|
||||
disabled={disabled}
|
||||
authOption={authOption}
|
||||
@@ -304,12 +304,12 @@ export const PluginInfoConfirm: React.FC<PluginInfoConfirmProps> = props => {
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* 授权方式-Service */}
|
||||
{/* Authorization method-Service */}
|
||||
{values.auth_type.at(-1) === 1 && (
|
||||
<ServiceField disabled={disabled} />
|
||||
)}
|
||||
<ExtItems disabled={disabled} extItems={extItems} />
|
||||
{/* 协议 */}
|
||||
{/* agreement */}
|
||||
{!disabled && (
|
||||
<Space spacing={8} className={s['footer-draft']}>
|
||||
<IconInfoCircle
|
||||
|
||||
@@ -31,7 +31,7 @@ export const formRuleList = {
|
||||
message: I18n.t('create_plugin_modal_nameerror'),
|
||||
}
|
||||
: {
|
||||
pattern: /^[\w\s\u4e00-\u9fa5]+$/u, // 国内增加支持中文
|
||||
pattern: /^[\w\s\u4e00-\u9fa5]+$/u, // Increased domestic support for Chinese
|
||||
message: I18n.t('create_plugin_modal_nameerror_cn'),
|
||||
},
|
||||
],
|
||||
@@ -95,7 +95,7 @@ export interface AuthOption {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any
|
||||
[key: string]: any;
|
||||
}
|
||||
/** 递归寻找auth选项下的输入项 */
|
||||
/** Recursively find the input under the auth option */
|
||||
// @ts-expect-error -- linter-disable-autofix
|
||||
export const findAuthTypeItem = (data: AuthOption[], targetKey = 0) => {
|
||||
for (const item of data) {
|
||||
|
||||
@@ -120,7 +120,7 @@ export async function getContent(file: Blob, onProgress): Promise<string> {
|
||||
}
|
||||
|
||||
export function isValidURL(str?: string): boolean {
|
||||
// 缩略版
|
||||
// abbreviated version
|
||||
try {
|
||||
const objExp = new RegExp(
|
||||
'^(https?:\\/\\/)?' + // protocol
|
||||
@@ -137,7 +137,7 @@ export function isValidURL(str?: string): boolean {
|
||||
}
|
||||
|
||||
export async function customService(url: string) {
|
||||
// 这里需要自定义请求,需要引入axios
|
||||
// Custom requests are required here, and axios needs to be introduced.
|
||||
const axiosInstance = axios.create({ responseType: 'text' });
|
||||
|
||||
const response = await axiosInstance.get(url);
|
||||
|
||||
Reference in New Issue
Block a user