Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🌐 chore: translate non-English comments to English in desktop controllers (#10034)

LobeHub Botaae047265e00
diff --git a/apps/desktop/src/main/controllers/AuthCtr.ts b/apps/desktop/src/main/controllers/AuthCtr.ts
index 80a707d7a12..599bb43179d 100644
--- a/apps/desktop/src/main/controllers/AuthCtr.ts
+++ b/apps/desktop/src/main/controllers/AuthCtr.ts
@@ -58,7 +58,7 @@ export default class AuthCtr extends ControllerModule {
*/
@ipcClientEvent('requestAuthorization')
async requestAuthorization(config: DataSyncConfig) {
- // 清理任何旧的授权状态
+ // Clear any old authorization state
this.clearAuthorizationState();
const remoteUrl = await this.remoteServerConfigCtr.getRemoteServerUrl(config);
@@ -186,8 +186,8 @@ export default class AuthCtr extends ControllerModule {
}
/**
- * 清理授权状态
- * 在开始新的授权流程前或授权失败/超时后调用
+ * Clear authorization state
+ * Called before starting a new authorization flow or after authorization failure/timeout
*/
private clearAuthorizationState() {
logger.debug('Clearing authorization state');
diff --git a/apps/desktop/src/main/controllers/MenuCtr.ts b/apps/desktop/src/main/controllers/MenuCtr.ts
index 9f79001bc34..efdbc31a430 100644
--- a/apps/desktop/src/main/controllers/MenuCtr.ts
+++ b/apps/desktop/src/main/controllers/MenuCtr.ts
@@ -2,16 +2,16 @@ import { ControllerModule, ipcClientEvent } from './index';
export default class MenuController extends ControllerModule {
/**
- * 刷新菜单
+ * Refresh menu
*/
@ipcClientEvent('refreshAppMenu')
refreshAppMenu() {
- // 注意:可能需要根据具体情况决定是否允许渲染进程刷新所有菜单
+ // Note: May need to decide whether to allow renderer process to refresh all menus based on specific circumstances
return this.app.menuManager.refreshMenus();
}
/**
- * 显示上下文菜单
+ * Show context menu
*/
@ipcClientEvent('showContextMenu')
showContextMenu(params: { data?: any; type: string }) {
@@ -19,11 +19,11 @@ export default class MenuController extends ControllerModule {
}
/**
- * 设置开发菜单可见性
+ * Set development menu visibility
*/
@ipcClientEvent('setDevMenuVisibility')
setDevMenuVisibility(visible: boolean) {
- // 调用 MenuManager 的方法来重建应用菜单
+ // Call MenuManager method to rebuild application menu
return this.app.menuManager.rebuildAppMenu({ showDevItems: visible });
}
}
diff --git a/apps/desktop/src/main/controllers/NotificationCtr.ts b/apps/desktop/src/main/controllers/NotificationCtr.ts
index 60899d985d4..246b13e3469 100644
--- a/apps/desktop/src/main/controllers/NotificationCtr.ts
+++ b/apps/desktop/src/main/controllers/NotificationCtr.ts
@@ -13,31 +13,31 @@ const logger = createLogger('controllers:NotificationCtr');
export default class NotificationCtr extends ControllerModule {
/**
- * 在应用准备就绪后设置桌面通知
+ * Set up desktop notifications after the application is ready
*/
afterAppReady() {
this.setupNotifications();
}
/**
- * 设置桌面通知权限和配置
+ * Set up desktop notification permissions and configuration
*/
private setupNotifications() {
logger.debug('Setting up desktop notifications');
try {
- // 检查通知支持
+ // Check notification support
if (!Notification.isSupported()) {
logger.warn('Desktop notifications are not supported on this platform');
return;
}
- // 在 macOS 上,我们可能需要显式请求通知权限
+ // On macOS, we may need to explicitly request notification permissions
if (macOS()) {
logger.debug('macOS detected, notification permissions should be handled by system');
}
- // 在 Windows 上设置应用用户模型 ID
+ // Set app user model ID on Windows
if (windows()) {
app.setAppUserModelId('com.lobehub.chat');
logger.debug('Set Windows App User Model ID for notifications');
@@ -49,34 +49,34 @@ export default class NotificationCtr extends ControllerModule {
}
}
/**
- * 显示系统桌面通知(仅当窗口隐藏时)
+ * Show system desktop notification (only when window is hidden)
*/
@ipcClientEvent('showDesktopNotification')
async showDesktopNotification(
params: ShowDesktopNotificationParams,
): Promise<DesktopNotificationResult> {
- logger.debug('收到桌面通知请求:', params);
+ logger.debug('Received desktop notification request:', params);
try {
- // 检查通知支持
+ // Check notification support
if (!Notification.isSupported()) {
- logger.warn('系统不支持桌面通知');
+ logger.warn('System does not support desktop notifications');
return { error: 'Desktop notifications not supported', success: false };
}
- // 检查窗口是否隐藏
+ // Check if window is hidden
const isWindowHidden = this.isMainWindowHidden();
if (!isWindowHidden) {
- logger.debug('主窗口可见,跳过桌面通知');
+ logger.debug('Main window is visible, skipping desktop notification');
return { reason: 'Window is visible', skipped: true, success: true };
}
- logger.info('窗口已隐藏,显示桌面通知:', params.title);
+ logger.info('Window is hidden, showing desktop notification:', params.title);
const notification = new Notification({
body: params.body,
- // 添加更多配置以确保通知能正常显示
+ // Add more configuration to ensure notifications display properly
hasReply: false,
silent: params.silent || false,
timeoutType: 'default',
@@ -84,38 +84,38 @@ export default class NotificationCtr extends ControllerModule {
urgency: 'normal',
});
- // 添加更多事件监听来调试
+ // Add more event listeners for debugging
notification.on('show', () => {
- logger.info('通知已显示');
+ logger.info('Notification shown');
});
notification.on('click', () => {
- logger.debug('用户点击通知,显示主窗口');
+ logger.debug('User clicked notification, showing main window');
const mainWindow = this.app.browserManager.getMainWindow();
mainWindow.show();
mainWindow.browserWindow.focus();
});
notification.on('close', () => {
- logger.debug('通知已关闭');
+ logger.debug('Notification closed');
});
notification.on('failed', (error) => {
- logger.error('通知显示失败:', error);
+ logger.error('Notification display failed:', error);
});
- // 使用 Promise 来确保通知显示
+ // Use Promise to ensure notification is shown
return new Promise((resolve) => {
notification.show();
- // 给通知一些时间来显示,然后检查结果
+ // Give the notification some time to display, then check the result
setTimeout(() => {
- logger.info('通知显示调用完成');
+ logger.info('Notification display call completed');
resolve({ success: true });
}, 100);
});
} catch (error) {
- logger.error('显示桌面通知失败:', error);
+ logger.error('Failed to show desktop notification:', error);
return {
error: error instanceof Error ? error.message : 'Unknown error',
success: false,
@@ -124,7 +124,7 @@ export default class NotificationCtr extends ControllerModule {
}
/**
- * 检查主窗口是否隐藏
+ * Check if the main window is hidden
*/
@ipcClientEvent('isMainWindowHidden')
isMainWindowHidden(): boolean {
@@ -132,23 +132,23 @@ export default class NotificationCtr extends ControllerModule {
const mainWindow = this.app.browserManager.getMainWindow();
const browserWindow = mainWindow.browserWindow;
- // 如果窗口被销毁,认为是隐藏的
+ // If window is destroyed, consider it hidden
if (browserWindow.isDestroyed()) {
return true;
}
- // 检查窗口是否可见和聚焦
+ // Check if window is visible and focused
const isVisible = browserWindow.isVisible();
const isFocused = browserWindow.isFocused();
const isMinimized = browserWindow.isMinimized();
- logger.debug('窗口状态检查:', { isFocused, isMinimized, isVisible });
+ logger.debug('Window state check:', { isFocused, isMinimized, isVisible });
- // 窗口隐藏的条件:不可见或最小化或失去焦点
+ // Window is hidden if: not visible, minimized, or not focused
return !isVisible || isMinimized || !isFocused;
} catch (error) {
- logger.error('检查窗口状态失败:', error);
- return true; // 发生错误时认为窗口隐藏,确保通知能显示
+ logger.error('Failed to check window state:', error);
+ return true; // Consider window hidden on error to ensure notifications can be shown
}
}
}
diff --git a/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts b/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts
index 13484ca2f7d..4b9072005cd 100644
--- a/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts
+++ b/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts
@@ -246,8 +246,8 @@ export default class RemoteServerConfigCtr extends ControllerModule {
}
/**
- * 刷新访问令牌
- * 使用存储的刷新令牌获取新的访问令牌
+ * Refresh access token
+ * Use stored refresh token to obtain a new access token
* Handles concurrent requests by returning the existing refresh promise if one is in progress.
*/
async refreshAccessToken(): Promise<{ error?: string; success: boolean }> {
@@ -271,27 +271,27 @@ export default class RemoteServerConfigCtr extends ControllerModule {
*/
private async performTokenRefresh(): Promise<{ error?: string; success: boolean }> {
try {
- // 获取配置信息
+ // Get configuration information
const config = await this.getRemoteServerConfig();
if (!config.remoteServerUrl || !config.active) {
logger.warn('Remote server not active or configured, skipping refresh.');
- return { error: '远程服务器未激活或未配置', success: false };
+ return { error: 'Remote server is not active or configured', success: false };
}
- // 获取刷新令牌
+ // Get refresh token
const refreshToken = await this.getRefreshToken();
if (!refreshToken) {
logger.error('No refresh token available for refresh operation.');
- return { error: '没有可用的刷新令牌', success: false };
+ return { error: 'No refresh token available', success: false };
}
- // 构造刷新请求
+ // Construct refresh request
const remoteUrl = await this.getRemoteServerUrl(config);
const tokenUrl = new URL('/oidc/token', remoteUrl);
- // 构造请求体
+ // Construct request body
const body = querystring.stringify({
client_id: 'lobehub-desktop',
grant_type: 'refresh_token',
@@ -300,7 +300,7 @@ export default class RemoteServerConfigCtr extends ControllerModule {
logger.debug(`Sending token refresh request to ${tokenUrl.toString()}`);
- // 发送请求
+ // Send request
const response = await fetch(tokenUrl.toString(), {
body,
headers: {
@@ -310,25 +310,25 @@ export default class RemoteServerConfigCtr extends ControllerModule {
});
if (!response.ok) {
- // 尝试解析错误响应
+ // Try to parse error response
const errorData = await response.json().catch(() => ({}));
- const errorMessage = `刷新令牌失败: ${response.status} ${response.statusText} ${
+ const errorMessage = `Token refresh failed: ${response.status} ${response.statusText} ${
errorData.error_description || errorData.error || ''
}`.trim();
logger.error(errorMessage, errorData);
return { error: errorMessage, success: false };
}
- // 解析响应
+ // Parse response
const data = await response.json();
- // 检查响应中是否包含必要令牌
+ // Check if response contains necessary tokens
if (!data.access_token || !data.refresh_token) {
logger.error('Refresh response missing access_token or refresh_token', data);
- return { error: '刷新响应中缺少令牌', success: false };
+ return { error: 'Missing tokens in refresh response', success: false };
}
- // 保存新令牌
+ // Save new tokens
logger.info('Token refresh successful, saving new tokens.');
await this.saveTokens(data.access_token, data.refresh_token, data.expires_in);
@@ -336,7 +336,7 @@ export default class RemoteServerConfigCtr extends ControllerModule {
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
logger.error('Exception during token refresh operation:', errorMessage, error);
- return { error: `刷新令牌时发生异常: ${errorMessage}`, success: false };
+ return { error: `Exception occurred during token refresh: ${errorMessage}`, success: false };
} finally {
// Ensure the promise reference is cleared once the operation completes
logger.debug('Clearing the refresh promise reference.');
diff --git a/apps/desktop/src/main/controllers/ShortcutCtr.ts b/apps/desktop/src/main/controllers/ShortcutCtr.ts
index 3b7f9db9c17..ff1a4bf82af 100644
--- a/apps/desktop/src/main/controllers/ShortcutCtr.ts
+++ b/apps/desktop/src/main/controllers/ShortcutCtr.ts
@@ -4,7 +4,7 @@ import { ControllerModule, ipcClientEvent } from '.';
export default class ShortcutController extends ControllerModule {
/**
- * 获取所有快捷键配置
+ * Get all shortcut configurations
*/
@ipcClientEvent('getShortcutsConfig')
getShortcutsConfig() {
@@ -12,7 +12,7 @@ export default class ShortcutController extends ControllerModule {
}
/**
- * 更新单个快捷键配置
+ * Update a single shortcut configuration
*/
@ipcClientEvent('updateShortcutConfig')
updateShortcutConfig({
diff --git a/apps/desktop/src/main/controllers/TrayMenuCtr.ts b/apps/desktop/src/main/controllers/TrayMenuCtr.ts
index 8fd6e2c586b..3750b700511 100644
--- a/apps/desktop/src/main/controllers/TrayMenuCtr.ts
+++ b/apps/desktop/src/main/controllers/TrayMenuCtr.ts
@@ -8,24 +8,24 @@ import { createLogger } from '@/utils/logger';
import { ControllerModule, ipcClientEvent } from './index';
-// 创建日志记录器
+// Create logger
const logger = createLogger('controllers:TrayMenuCtr');
export default class TrayMenuCtr extends ControllerModule {
async toggleMainWindow() {
- logger.debug('通过快捷键切换主窗口可见性');
+ logger.debug('Toggle main window visibility via shortcut');
const mainWindow = this.app.browserManager.getMainWindow();
mainWindow.toggleVisible();
}
/**
- * 显示托盘气泡通知
- * @param options 气泡选项
- * @returns 操作结果
+ * Show tray balloon notification
+ * @param options Balloon options
+ * @returns Operation result
*/
@ipcClientEvent('showTrayNotification')
async showNotification(options: ShowTrayNotificationParams) {
- logger.debug('显示托盘气泡通知');
+ logger.debug('Show tray balloon notification');
if (process.platform === 'win32') {
const mainTray = this.app.trayManager.getMainTray();
@@ -42,19 +42,19 @@ export default class TrayMenuCtr extends ControllerModule {
}
return {
- error: '托盘通知仅在 Windows 平台支持',
+ error: 'Tray notifications are only supported on Windows platform',
success: false,
};
}
/**
- * 更新托盘图标
- * @param options 图标选项
- * @returns 操作结果
+ * Update tray icon
+ * @param options Icon options
+ * @returns Operation result
*/
@ipcClientEvent('updateTrayIcon')
async updateTrayIcon(options: UpdateTrayIconParams) {
- logger.debug('更新托盘图标');
+ logger.debug('Update tray icon');
if (process.platform === 'win32') {
const mainTray = this.app.trayManager.getMainTray();
@@ -64,7 +64,7 @@ export default class TrayMenuCtr extends ControllerModule {
mainTray.updateIcon(options.iconPath);
return { success: true };
} catch (error) {
- logger.error('更新托盘图标失败:', error);
+ logger.error('Failed to update tray icon:', error);
return {
error: String(error),
success: false,
@@ -74,19 +74,19 @@ export default class TrayMenuCtr extends ControllerModule {
}
return {
- error: '托盘功能仅在 Windows 平台支持',
+ error: 'Tray functionality is only supported on Windows platform',
success: false,
};
}
/**
- * 更新托盘提示文本
- * @param options 提示文本选项
- * @returns 操作结果
+ * Update tray tooltip text
+ * @param options Tooltip text options
+ * @returns Operation result
*/
@ipcClientEvent('updateTrayTooltip')
async updateTrayTooltip(options: UpdateTrayTooltipParams) {
- logger.debug('更新托盘提示文本');
+ logger.debug('Update tray tooltip text');
if (process.platform === 'win32') {
const mainTray = this.app.trayManager.getMainTray();
@@ -98,7 +98,7 @@ export default class TrayMenuCtr extends ControllerModule {
}
return {
- error: '托盘功能仅在 Windows 平台支持',
+ error: 'Tray functionality is only supported on Windows platform',
success: false,
};
}
diff --git a/apps/desktop/src/main/controllers/UpdaterCtr.ts b/apps/desktop/src/main/controllers/UpdaterCtr.ts
index 481bb8da5d9..7f554b2e675 100644
--- a/apps/desktop/src/main/controllers/UpdaterCtr.ts
+++ b/apps/desktop/src/main/controllers/UpdaterCtr.ts
@@ -6,7 +6,7 @@ const logger = createLogger('controllers:UpdaterCtr');
export default class UpdaterCtr extends ControllerModule {
/**
- * 检查更新
+ * Check for updates
*/
@ipcClientEvent('checkUpdate')
async checkForUpdates() {
@@ -15,7 +15,7 @@ export default class UpdaterCtr extends ControllerModule {
}
/**
- * 下载更新
+ * Download update
*/
@ipcClientEvent('downloadUpdate')
async downloadUpdate() {
@@ -24,7 +24,7 @@ export default class UpdaterCtr extends ControllerModule {
}
/**
- * 关闭应用并安装更新
+ * Quit application and install update
*/
@ipcClientEvent('installNow')
quitAndInstallUpdate() {
@@ -33,7 +33,7 @@ export default class UpdaterCtr extends ControllerModule {
}
/**
- * 下次启动时安装更新
+ * Install update on next startup
*/
@ipcClientEvent('installLater')
installLater() {
diff --git a/apps/desktop/src/main/controllers/__tests__/TrayMenuCtr.test.ts b/apps/desktop/src/main/controllers/__tests__/TrayMenuCtr.test.ts
index cf7bc5b8a52..b2089a066fd 100644
--- a/apps/desktop/src/main/controllers/__tests__/TrayMenuCtr.test.ts
+++ b/apps/desktop/src/main/controllers/__tests__/TrayMenuCtr.test.ts
@@ -106,7 +106,7 @@ describe('TrayMenuCtr', () => {
expect(mockGetMainTray).not.toHaveBeenCalled();
expect(mockDisplayBalloon).not.toHaveBeenCalled();
expect(result).toEqual({
- error: '托盘通知仅在 Windows 平台支持',
+ error: 'Tray notifications are only supported on Windows platform',
success: false,
});
});
@@ -126,7 +126,7 @@ describe('TrayMenuCtr', () => {
expect(mockGetMainTray).toHaveBeenCalled();
expect(mockDisplayBalloon).not.toHaveBeenCalled();
expect(result).toEqual({
- error: '托盘通知仅在 Windows 平台支持',
+ error: 'Tray notifications are only supported on Windows platform',
success: false
});
});
@@ -188,7 +188,7 @@ describe('TrayMenuCtr', () => {
const result = await trayMenuCtr.updateTrayIcon(options);
expect(result).toEqual({
- error: '托盘功能仅在 Windows 平台支持',
+ error: 'Tray functionality is only supported on Windows platform',
success: false,
});
});
@@ -226,7 +226,7 @@ describe('TrayMenuCtr', () => {
const result = await trayMenuCtr.updateTrayTooltip(options);
expect(result).toEqual({
- error: '托盘功能仅在 Windows 平台支持',
+ error: 'Tray functionality is only supported on Windows platform',
success: false,
});
});
@@ -248,7 +248,7 @@ describe('TrayMenuCtr', () => {
expect(mockUpdateTooltip).not.toHaveBeenCalled();
expect(result).toEqual({
- error: '托盘功能仅在 Windows 平台支持',
+ error: 'Tray functionality is only supported on Windows platform',
success: false,
});
});
diff --git a/apps/desktop/src/main/controllers/index.ts b/apps/desktop/src/main/controllers/index.ts
index 144e9b581f2..d3ca032df4b 100644
--- a/apps/desktop/src/main/controllers/index.ts
+++ b/apps/desktop/src/main/controllers/index.ts
@@ -19,13 +19,13 @@ const ipcDecorator =
};
/**
- * controller 用的 ipc client event 装饰器
+ * IPC client event decorator for controllers
*/
export const ipcClientEvent = (method: keyof ClientDispatchEvents) =>
ipcDecorator(method, 'client');
/**
- * controller 用的 ipc server event 装饰器
+ * IPC server event decorator for controllers
*/
export const ipcServerEvent = (method: keyof ServerDispatchEvents) =>
ipcDecorator(method, 'server');
@@ -56,8 +56,8 @@ const protocolDecorator =
/**
* Protocol handler decorator
- * @param urlType 协议URL类型 (如: 'plugin')
- * @param action 操作类型 (如: 'install')
+ * @param urlType Protocol URL type (e.g., 'plugin')
+ * @param action Action type (e.g., 'install')
*/
export const createProtocolHandler = (urlType: string) => (action: string) =>
protocolDecorator(urlType, action);