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

@@ -30,12 +30,12 @@ import {
import { ViewService } from '../create-preset-plugin/view-service';
const CUSTOM_COMMAND = {
// 在左侧分屏打开
// Open split screen on left
SPLIT_LEFT: {
id: 'view.custom.split-left',
label: I18n.t('project_ide_tabs_open_on_left'),
},
// 在右侧分屏打开
// Open in split screen on the right
SPLIT_RIGHT: {
id: 'view.custom.split-right',
label: I18n.t('project_ide_tabs_open_on_right'),
@@ -49,10 +49,10 @@ const CUSTOM_COMMAND = {
function getAllTabsCount(dockPanel: FlowDockPanel): number {
let count = 0;
// 遍历 DockPanel 中的所有小部件
// Traverse all widgets in DockPanel
Array.from(dockPanel.children()).forEach(widget => {
if (widget instanceof TabBar) {
// 累计 TabBar 中的所有标签页数
// Accumulate all tab pages in TabBar
count += widget.titles.length;
}
});
@@ -70,9 +70,9 @@ export const createContextMenuPlugin: PluginCreator<void> = definePluginCreator(
const shortcutsService =
ctx.container.get<ShortcutsService>(ShortcutsService);
/**
* 更改标题
* Change the title
*/
// 更新 command 标题 label
// Update command title label
command.updateCommand(Command.Default.VIEW_CLOSE_CURRENT_WIDGET, {
label: I18n.t('project_ide_tabs_close'),
});
@@ -95,7 +95,7 @@ export const createContextMenuPlugin: PluginCreator<void> = definePluginCreator(
execute: widget => {
viewService.splitScreen('left', widget);
},
// 分屏功能在所有 tab 大于 1 时才可以使用
// Split screen function can only be used when all tabs are greater than 1
isEnabled: () => {
const tabCounts = getAllTabsCount(shell.mainPanel);
return tabCounts > 1;
@@ -105,46 +105,46 @@ export const createContextMenuPlugin: PluginCreator<void> = definePluginCreator(
execute: widget => {
viewService.splitScreen('right', widget);
},
// 分屏功能在所有 tab 大于 1 时才可以使用
// Split screen function can only be used when all tabs are greater than 1
isEnabled: () => {
const tabCounts = getAllTabsCount(shell.mainPanel);
return tabCounts > 1;
},
});
/**
* 注册 menu
* Registration menu
*/
// 关闭
// close
menuService.addMenuItem({
command: Command.Default.VIEW_CLOSE_CURRENT_WIDGET,
selector: '.lm-TabBar-tab',
});
// 关闭其他
// Close other
menuService.addMenuItem({
command: Command.Default.VIEW_CLOSE_OTHER_WIDGET,
selector: '.lm-TabBar-tab',
});
// 关闭所有
// Close all
menuService.addMenuItem({
command: Command.Default.VIEW_CLOSE_ALL_WIDGET,
selector: '.lm-TabBar-tab',
});
// 刷新标签
// refresh label
menuService.addMenuItem({
command: CUSTOM_COMMAND.REFRESH.id,
selector: '.lm-TabBar-tab',
});
// 分割线
// dividing line
menuService.addMenuItem({
type: 'separator',
selector: '.lm-TabBar-tab',
});
// 向左分屏
// Split screen to the left
menuService.addMenuItem({
command: CUSTOM_COMMAND.SPLIT_LEFT.id,
selector: '.lm-TabBar-tab',
});
// 向右分屏
// Split screen to the right
menuService.addMenuItem({
command: CUSTOM_COMMAND.SPLIT_RIGHT.id,
selector: '.lm-TabBar-tab',

View File

@@ -139,7 +139,7 @@ export class PresetContribution
this.services.contextmenu.registerContextMenu(menus, registry.match);
}
});
// 覆写全屏逻辑
// Override full screen logic
this.commandRegistry.unregisterCommand(Command.Default.VIEW_FULL_SCREEN);
this.commandRegistry.registerCommand(
{
@@ -176,7 +176,7 @@ export class PresetContribution
}
private createLayout(shell: ApplicationShell) {
// 设置 panel 存储到 widgetManager
// Set up panel storage to widgetManager
const uiBuilderPanel = new BoxPanel();
uiBuilderPanel.id = UI_BUILDER_URI.displayName;
this.widgetManager.setWidget(UI_BUILDER_URI.toString(), uiBuilderPanel);
@@ -238,7 +238,7 @@ export class PresetContribution
main: {
splitOptions: {
maxSplitCount: 2,
splitOrientation: 'horizontal', // 只支持水平分屏
splitOrientation: 'horizontal', // Only horizontal split screen is supported.
},
dockPanelOptions: {
spacing: 6,

View File

@@ -31,11 +31,11 @@ import {
import { ViewService } from './view-service';
/**
* 获取 service 操作
* 全局任意位置均可调用
* command命令系统注册
* contextmenu:右键菜单注册
* view视图操作
* Acquire service operation
* It can be called anywhere in the world
* Command: Command system registration
* Contextmenu: right-click menu registration
* View: view operation
*/
@injectable()
export class ProjectIDEServices {

View File

@@ -24,7 +24,7 @@ import {
} from '@coze-project-ide/client';
import { Tooltip } from '@coze-arch/coze-design';
// 自定义 IDE HoverService 样式
// Custom IDE HoverService style
@injectable()
class TooltipContribution implements LabelHandler {
@inject(HoverService) hoverService: HoverService;
@@ -41,21 +41,21 @@ class TooltipContribution implements LabelHandler {
}
renderer(uri: URI, opt?: any): React.ReactNode {
// 下边的 opacitywidth 设置原因:
// semi 源码位置:https://github.com/DouyinFE/semi-design/blob/main/packages/semi-foundation/tooltip/foundation.ts#L342
// semi trigger 元素判断,本次自定义 semi 组件没有 focus 内部元素。
// The reason for the opacity and width settings below:
// Semi source code location: https://github.com/DouyinFE/semi-design/blob/main/packages/semi-foundation/tooltip/foundation.ts#L342
// Semi has a trigger element to judge, and this custom semi component does not have a focus internal element.
return opt?.content ? (
<Tooltip
key={opt.content}
content={opt.content}
position={opt.position}
// 覆盖设置重置 foundation opacity,避免 tooltip 跳动
// Override settings to reset foundation opacity to avoid tooltip jumping
style={{ opacity: 1 }}
trigger="custom"
getPopupContainer={() => document.body}
visible={true}
>
{/* 宽度 0 避免被全局样式影响导致 Tooltip 定位错误 */}
{/* Width 0 to avoid Tooltip positioning errors due to global style influence */}
<div style={{ width: 0 }}></div>
</Tooltip>
) : null;

View File

@@ -70,7 +70,7 @@ export class ViewService {
this.onFullScreenModeChangeEmitter.event;
/**
* 主侧边栏功能集合
* Main Sidebar Feature Collection
*/
public primarySidebar = {
onSidebarVisibleChange: this.onSidebarVisibleChange,
@@ -90,7 +90,7 @@ export class ViewService {
getVisible: () => this.shell.secondarySidebar.isVisible,
changeVisible: (vis: boolean) => {
if (vis) {
// 打开前需要判断面板是否已经注册打开
// Before opening, you need to determine whether the panel has been registered and opened.
const secondaryPanel = this.widgetManager.getWidgetFromURI(
SECONDARY_SIDEBAR_URI,
);
@@ -109,7 +109,7 @@ export class ViewService {
private switchPanel(uri?: URI) {
const uiBuilderPanel = this.widgetManager.getWidgetFromURI(UI_BUILDER_URI);
if (uri && UI_BUILDER_URI.match(uri)) {
// 跳转到 UIBuilder
// Jump to UIBuilder
(this.shell.mainPanel.parent?.parent as BoxPanel).hide();
uiBuilderPanel?.show();
} else {
@@ -161,7 +161,7 @@ export class ViewService {
this.switchPanel();
}
}
// 打开默认页
// Open default page
async openDefault() {
await this.openerService.open(MAIN_PANEL_DEFAULT_URI, {
mode: 'single-document',
@@ -184,8 +184,8 @@ export class ViewService {
return undefined;
}
// 由于最大分屏数量为 2
// 因此 children[0] 为左边分屏,children[1] 为右边分屏
// Since the maximum number of split screens is 2
// Therefore, children [0] is the left split screen, and children [1] is the right split screen
splitScreen(direction: 'left' | 'right', widget: ReactWidget) {
const mode = direction === 'left' ? 'split-left' : 'split-right';
const splitScreenIdx = direction === 'left' ? 0 : 1;
@@ -193,7 +193,7 @@ export class ViewService {
const layoutConfig = (
this.shell.mainPanel?.layout as DockLayout
)?.saveLayout()?.main;
// 未分屏场景,直接打开
// No split-screen scene, open it directly
if ((layoutConfig as DockLayout.ITabAreaConfig)?.type === 'tab-area') {
this.shell.mainPanel.addWidget(widget, {
mode,
@@ -205,7 +205,7 @@ export class ViewService {
const { widgets } = (layoutConfig as DockLayout.ISplitAreaConfig)
?.children[splitScreenIdx] as DockLayout.ITabAreaConfig;
const tabActivateWidget = widgets.find(_widget => _widget.isVisible);
// 已分屏场景
// split screen scene
this.shell.mainPanel.addWidget(widget, {
mode: 'tab-after',
ref: tabActivateWidget,
@@ -215,7 +215,7 @@ export class ViewService {
}
/**
* 全屏模式切换
* full screen mode toggle
*/
switchFullScreenMode() {
if (!this.isFullScreenMode) {
@@ -226,16 +226,16 @@ export class ViewService {
}
/**
* 开启全屏模式
* CozeProjectIDE 中,全屏模式隐藏侧边栏和顶部导航栏
* Enable full screen mode
* In CozeProject IDE, full-screen mode hides the sidebar and top navigation bar
*/
enableFullScreenMode() {
if (this.isFullScreenMode) {
return;
}
// 隐藏侧边栏
// Hide Sidebar
this.primarySidebar.changeVisible(false);
// 隐藏顶部导航栏
// Hide top navigation bar
const topBar = this.shell.getPanelFromArea(LayoutPanelType.TOP_BAR);
topBar.hide();
@@ -247,9 +247,9 @@ export class ViewService {
if (!this.isFullScreenMode) {
return;
}
// 显示侧边栏
// Show Sidebar
this.primarySidebar.changeVisible(true);
// 显示顶部导航栏
// Show top navigation bar
const topBar = this.shell.getPanelFromArea(LayoutPanelType.TOP_BAR);
topBar.show();

View File

@@ -60,7 +60,7 @@ export class WidgetService {
this.setTitle(this._title);
}
/** 触发重渲染 */
/** Trigger rerendering */
update() {
(this.widget.title as CustomTitleType).iconLabel = this._widgetTitleRender({
commandRegistry: this.commandRegistry,

View File

@@ -42,7 +42,7 @@ export const useLifeCycle = (
contextKeyService.setContext('widgetContext', widgetContext);
}, [widgetContext]);
const shell = useIDEService<ApplicationShell>(ApplicationShell);
// 生命周期管理
// Life Cycle Management
useEffect(() => {
const currentUri = (shell.mainPanel.currentTitle?.owner as ProjectIDEWidget)
?.uri;

View File

@@ -15,7 +15,7 @@
*/
/**
* 控制组件真正的挂载时机
* True mount timing of cgroup pieces
*/
import {
useEffect,
@@ -36,21 +36,21 @@ export const useMount = (
widget: ProjectIDEWidget,
) => {
/**
* 是否已经挂载
* Is it already mounted?
*/
const [mounted, setMounted] = useState(widget.isVisible);
const [version, setVersion] = useState(0);
const mountedRef = useRef(widget.isVisible);
/**
* 是否已加载完成
* Is it loaded?
*/
const [loaded, setLoaded] = useState(!registry.load);
/**
* renderContent 函数结果缓存
* 由于 registry widget 基本不变,可以保证在同一个 widget 中 renderContent 函数只会运行一次
* 除非 WidgetComp 组件被卸载 =.=
* renderContent function result cache
* Since the registry and widget are essentially unchanged, it is guaranteed that the renderContent function will only run once within the same widget
* Unless the WidgetComp component is uninstalled =. =
*/
const content = useMemo(() => {
if (!isFunction(registry.renderContent)) {
@@ -61,7 +61,7 @@ export const useMount = (
}, [registry, widget, version]);
/**
* 支持 registry 定义加载函数
* Support registry definition load function
*/
const load = useCallback(async () => {
if (!registry.load || !isFunction(registry.load)) {
@@ -72,7 +72,7 @@ export const useMount = (
}, [registry, widget, setLoaded]);
/**
* 监听 widget 的显示隐藏状态,若 widget 显示且未挂载,则需要主动挂载一次
* Monitor the display hidden state of the widget. If the widget is displayed and not mounted, you need to actively mount it once.
*/
const watchWidgetStatus = useCallback(
(w: ProjectIDEWidget) => {
@@ -92,7 +92,7 @@ export const useMount = (
);
/**
* 监听器可以较早挂载,避免多渲染一次
* Listeners can be mounted earlier to avoid multiple renders
*/
useLayoutEffect(() => {
const dispose = watchWidgetStatus(widget);
@@ -106,7 +106,7 @@ export const useMount = (
}, [widget, watchWidgetStatus]);
/**
* 加载函数时机暂无特殊设计,先保持和历史逻辑一致
* There is no special design for loading function timing, so keep it consistent with historical logic
*/
useEffect(() => {
load();