chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
import { StandardNodeType } from '@coze-workflow/base';
|
||||
|
||||
// 默认所有节点可用,可以自定义
|
||||
// All nodes are available by default and can be customized.
|
||||
export const getEnabledNodeTypes = (_params: {
|
||||
loopSelected: boolean;
|
||||
isProject: boolean;
|
||||
|
||||
@@ -18,7 +18,7 @@ import { api, type InferEditorAPIFromPlugins } from '@coze-editor/editor/react';
|
||||
import preset from '@coze-editor/editor/preset-code';
|
||||
import { type EditorView } from '@codemirror/view';
|
||||
|
||||
// 忽略 readOnly 强制设置值
|
||||
// Ignore readOnly to force a value
|
||||
const forceSetValue =
|
||||
({ view }: { view: EditorView }) =>
|
||||
(value: string) => {
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface Output {
|
||||
children?: Output[];
|
||||
}
|
||||
|
||||
// javascript 为历史数据,目前只会有 python | typescript
|
||||
// Javascript is historical data, currently only python | typescript is available.
|
||||
export type LanguageType = 'python' | 'typescript' | 'javascript';
|
||||
|
||||
export interface PreviewerProps {
|
||||
@@ -67,7 +67,7 @@ export interface EditorProps {
|
||||
onTestRun?: () => void;
|
||||
testRunIcon?: ReactNode;
|
||||
/**
|
||||
* @deprecated onTestRunStateChange 已失效,线上也未使用到
|
||||
* @Deprecated onTestRunStateChange has expired and is not used online
|
||||
*/
|
||||
onTestRunStateChange?: (status: string) => void;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ export function DemoComponent(props: { name: string }): JSX.Element {
|
||||
const [foo] = useState('hello world');
|
||||
const { name } = props;
|
||||
return (
|
||||
// font-bold 来自 taiwindcss
|
||||
// 建议优先使用 taiwindcss
|
||||
// Font-bold from taiwindcss
|
||||
// It is recommended to use taiwindcss first.
|
||||
<div className={classNames(s.foo, 'font-bold')}>
|
||||
{foo} {name}!
|
||||
<div>
|
||||
|
||||
@@ -38,14 +38,14 @@ const hasHistory = (): boolean =>
|
||||
type NavigateScene = 'publish' | 'exit';
|
||||
|
||||
/**
|
||||
* 返回上一页逻辑
|
||||
* Return to previous page logic
|
||||
*/
|
||||
export const useNavigateBack = () => {
|
||||
const pageJumpResponse = usePageJumpResponse(PageType.WORKFLOW);
|
||||
const { jump } = usePageJumpService();
|
||||
const navigate = useNavigate();
|
||||
|
||||
/** 流程详情页路由更新会导致 pageJumpResponse 失效, 因此需要缓存一份原始版本 */
|
||||
/** Process details page route update will invalidate pageJumpResponse, so you need to cache a copy of the original version */
|
||||
const memoPageJumpResponse = useMemo(() => pageJumpResponse, []);
|
||||
|
||||
const navigateBack = async (
|
||||
@@ -71,12 +71,12 @@ export const useNavigateBack = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 跳转回bot详情页,并带上场景参数
|
||||
// Jump back to the bot details page with scene parameters
|
||||
if (memoPageJumpResponse?.scene) {
|
||||
if (scene === 'publish') {
|
||||
let pluginID = plugin_id;
|
||||
|
||||
// 第一次发布流程时,需要重新从接口获取pluginID
|
||||
// When you publish the process for the first time, you need to retrieve the pluginID from the interface again.
|
||||
if (!pluginID || pluginID === '0') {
|
||||
const workflowRes = await workflowApi.GetCanvasInfo(
|
||||
{
|
||||
@@ -143,9 +143,9 @@ export const useNavigateBack = () => {
|
||||
namespace: 'workflow',
|
||||
eventName: 'workflow_navigate_back_to_list',
|
||||
});
|
||||
// 如果 history 就一个页面,此时 navigate(-1) 不生效,需要手动指定路径
|
||||
// 目前先写死路径,缺点是需要跟随页面结构更改而更改,后面再优化更好的实现
|
||||
// /library 为 coze 2.0 混排资源列表页
|
||||
// If history is only one page, navigate (-1) does not take effect at this time, you need to manually specify the path
|
||||
// At present, the dead path is written first. The disadvantage is that it needs to be changed with the change of the page structure, and then optimized for a better implementation later.
|
||||
// /library coze 2.0 mixed resource list page
|
||||
navigate(`/space/${spaceId}/library`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,23 +22,23 @@ import { OperateType } from '@coze-workflow/base/api';
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
import { Toast } from '@coze-arch/coze-design';
|
||||
|
||||
/** 流程详情页参数 */
|
||||
/** Process details page parameters */
|
||||
interface SearchParams {
|
||||
workflow_id: string;
|
||||
space_id: string;
|
||||
/** 流程版本, 当多人协作时有版本概念, 单独设置时可预览对应版本流程 */
|
||||
/** Process version, when multiple people cooperate, there is a version concept, and the corresponding version process can be previewed when set separately */
|
||||
version?: string;
|
||||
/** 是否要恢复到目标版本, 如果设置, 则流程草稿会自动设置到对应 version */
|
||||
/** Whether to restore to the target version, if set, the process draft will be automatically set to the corresponding version */
|
||||
set_version?: string;
|
||||
/** 对应 version 的操作类型 */
|
||||
/** Corresponding version of the operation type */
|
||||
opt_type?: string;
|
||||
/** 流程页面打开来源 */
|
||||
/** Process page open source */
|
||||
from?: WorkflowPlaygroundProps['from'];
|
||||
/** 节点id 配置会自动定位到对应节点 */
|
||||
/** The node id configuration will automatically locate to the corresponding node. */
|
||||
node_id?: string;
|
||||
/** 执行id 配置会展示对应执行结果 */
|
||||
/** The execution id configuration will display the corresponding execution result. */
|
||||
execute_id?: string;
|
||||
/** 子流程执行id */
|
||||
/** subprocess execution id */
|
||||
sub_execute_id?: string;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ export function usePageParams() {
|
||||
needUpdateSearch = true;
|
||||
}
|
||||
|
||||
// 强制设置历史版本
|
||||
// Force setting of historical version
|
||||
if (setVersion) {
|
||||
newSearchParams.delete('set_version');
|
||||
newSearchParams.delete('version');
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
import { usePageParams } from './hooks/use-page-params';
|
||||
import { useNavigateBack } from './hooks';
|
||||
|
||||
// 添加节点放在工具栏了,原来侧边栏不需要了
|
||||
// The added node is placed in the toolbar, but the original sidebar is no longer needed.
|
||||
const EmptySidebar = React.forwardRef<AddNodeRef, unknown>(
|
||||
(_props, _addNodeRef) => null,
|
||||
);
|
||||
@@ -48,7 +48,7 @@ export function WorkflowPage(): React.ReactNode {
|
||||
const [initOnce, setInitOnce] = useState(false);
|
||||
const { navigateBack } = useNavigateBack();
|
||||
|
||||
/** 是否只读模式, 来源于流程探索模块 */
|
||||
/** Whether it is read-only mode, derived from the process exploration module */
|
||||
const readonly = from === 'explore';
|
||||
|
||||
if (!workflowId || !spaceId) {
|
||||
@@ -75,14 +75,14 @@ export function WorkflowPage(): React.ReactNode {
|
||||
});
|
||||
}
|
||||
|
||||
// onInit可能被多次调用 这里只需要执行一次
|
||||
// onInit may be called multiple times, it only needs to be executed once
|
||||
if (!initOnce) {
|
||||
// 读取链接上的node_id参数 滚动到对应节点
|
||||
// Read the node_id parameters on the link and scroll to the corresponding node
|
||||
if (nodeId) {
|
||||
workflowPlaygroundRef.current?.scrollToNode(nodeId);
|
||||
}
|
||||
|
||||
// 读取execute_id 展示对应执行结果
|
||||
// Read execute_id show the corresponding execution result
|
||||
if (executeId) {
|
||||
workflowPlaygroundRef.current?.showTestRunResult(
|
||||
executeId,
|
||||
|
||||
@@ -18,79 +18,79 @@
|
||||
import { useState, useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
interface IAudioPlayerOptions {
|
||||
// 是否自动播放
|
||||
// Whether to play automatically
|
||||
autoPlay?: boolean;
|
||||
// 是否循环播放
|
||||
// Whether to loop
|
||||
loop?: boolean;
|
||||
// 播放结束回调
|
||||
// end of play callback
|
||||
onEnded?: () => void;
|
||||
// 加载完成回调
|
||||
// load completion callback
|
||||
onLoad?: () => void;
|
||||
}
|
||||
|
||||
interface IAudioPlayer {
|
||||
// 是否正在播放
|
||||
// Is it playing?
|
||||
isPlaying: boolean;
|
||||
// 是否暂停
|
||||
// Whether to pause
|
||||
isPaused: boolean;
|
||||
// 是否停止
|
||||
// Whether to stop
|
||||
isStopped: boolean;
|
||||
// 当前播放时间
|
||||
// current playing time
|
||||
currentTime: number;
|
||||
// 音频总时长
|
||||
// total audio duration
|
||||
duration: number;
|
||||
// 播放
|
||||
// play
|
||||
play: () => void;
|
||||
// 暂停
|
||||
// pause
|
||||
pause: () => void;
|
||||
// 停止
|
||||
// Stop
|
||||
stop: () => void;
|
||||
// 切换播放暂停
|
||||
// toggle playback pause
|
||||
togglePlayPause: () => void;
|
||||
// 跳转
|
||||
// jump
|
||||
seek: (time: number) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 音频播放器 Hook
|
||||
* @param src - 音频文件的
|
||||
* @param options - 播放器配置选项
|
||||
* @returns 音频播放器控制接口
|
||||
* Audio Player Hook
|
||||
* @Param src - audio files
|
||||
* @Param options - player configuration options
|
||||
* @Returns Audio Player Control Interface
|
||||
*/
|
||||
export const useAudioPlayer = (
|
||||
src: File | string | undefined | null,
|
||||
{ autoPlay, loop, onEnded, onLoad }: IAudioPlayerOptions = {},
|
||||
): IAudioPlayer => {
|
||||
// 播放状态管理
|
||||
// playback state management
|
||||
const [isPlaying, setIsPlaying] = useState(false);
|
||||
const [isPaused, setIsPaused] = useState(false);
|
||||
const [isStopped, setIsStopped] = useState(true);
|
||||
const [currentTime, setCurrentTime] = useState(0);
|
||||
const [duration, setDuration] = useState(0);
|
||||
|
||||
// 音频元素引用
|
||||
// audio element reference
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
|
||||
// 初始化音频元素和事件监听
|
||||
// Initialize audio elements and event listeners
|
||||
useEffect(() => {
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = src instanceof Blob ? URL.createObjectURL(src) : src;
|
||||
// 创建音频实例
|
||||
// Create audio instance
|
||||
const audio = new Audio(url);
|
||||
audioRef.current = audio;
|
||||
|
||||
// 设置循环播放
|
||||
// Set up loop playback
|
||||
audio.loop = loop ?? false;
|
||||
|
||||
// 更新当前播放时间的处理函数
|
||||
// Update the handler for the current playback time
|
||||
const handleTimeUpdate = () => {
|
||||
setCurrentTime(audio.currentTime);
|
||||
};
|
||||
|
||||
// 元数据加载完成的处理函数(获取音频时长等信息)
|
||||
// The processing function for the completion of metadata loading (to obtain information such as audio duration)
|
||||
const handleLoadedMetadata = () => {
|
||||
setDuration(audio.duration);
|
||||
setCurrentTime(0);
|
||||
@@ -101,12 +101,12 @@ export const useAudioPlayer = (
|
||||
}
|
||||
|
||||
if (src instanceof Blob) {
|
||||
// 释放音频文件的 URL,避免内存泄漏
|
||||
// Release the URL of the audio file to avoid memory leaks
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
};
|
||||
|
||||
// 播放结束的处理函数
|
||||
// Handler function for end of playback
|
||||
const handleEnded = () => {
|
||||
setIsPlaying(false);
|
||||
setIsStopped(true);
|
||||
@@ -114,12 +114,12 @@ export const useAudioPlayer = (
|
||||
onEnded?.();
|
||||
};
|
||||
|
||||
// 添加事件监听器
|
||||
// Add event listeners
|
||||
audio.addEventListener('loadedmetadata', handleLoadedMetadata);
|
||||
audio.addEventListener('timeupdate', handleTimeUpdate);
|
||||
audio.addEventListener('ended', handleEnded);
|
||||
|
||||
// 清理函数:组件卸载时移除事件监听并释放资源
|
||||
// Cleanup function: removes event listeners and frees resources when a component is unloaded
|
||||
return () => {
|
||||
audio.removeEventListener('loadedmetadata', handleLoadedMetadata);
|
||||
audio.removeEventListener('timeupdate', handleTimeUpdate);
|
||||
@@ -131,7 +131,7 @@ export const useAudioPlayer = (
|
||||
};
|
||||
}, [src, autoPlay, loop, onEnded, onLoad]);
|
||||
|
||||
// 播放控制函数
|
||||
// playback control function
|
||||
const play = useCallback(() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.play();
|
||||
@@ -141,7 +141,7 @@ export const useAudioPlayer = (
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 暂停控制函数
|
||||
// pause control function
|
||||
const pause = useCallback(() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.pause();
|
||||
@@ -150,7 +150,7 @@ export const useAudioPlayer = (
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 停止控制函数
|
||||
// Stop control function
|
||||
const stop = useCallback(() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.pause();
|
||||
@@ -161,7 +161,7 @@ export const useAudioPlayer = (
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 切换播放/暂停状态
|
||||
// Switch play/pause state
|
||||
const togglePlayPause = useCallback(() => {
|
||||
if (isPlaying) {
|
||||
pause();
|
||||
@@ -170,7 +170,7 @@ export const useAudioPlayer = (
|
||||
}
|
||||
}, [isPlaying, play, pause]);
|
||||
|
||||
// 跳转到指定时间
|
||||
// Jump to the specified time
|
||||
const seek = useCallback((time: number) => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.currentTime = time;
|
||||
@@ -178,7 +178,7 @@ export const useAudioPlayer = (
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 返回音频播放器控制接口
|
||||
// Back to Audio Player Control Interface
|
||||
return {
|
||||
isPlaying,
|
||||
isPaused,
|
||||
|
||||
Reference in New Issue
Block a user