diff --git a/.eslintrc.js b/.eslintrc.js index 4bb67da9e..d3d4646f0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -36,6 +36,7 @@ module.exports = { ], plugins: ['prettier', 'unused-imports'], rules: { + 'prefer-const': 'off', '@typescript-eslint/no-unused-expressions': 'off', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-var-requires': 'off', diff --git a/.github/workflows/themes-weekly-pull.yml b/.github/workflows/themes-weekly-pull.yml index 0590e421f..d2945f339 100644 --- a/.github/workflows/themes-weekly-pull.yml +++ b/.github/workflows/themes-weekly-pull.yml @@ -1,63 +1,63 @@ -name: themes-weekly-pull - -on: - schedule: - # run every friday at 5AM - - cron: '0 5 * * 5' - workflow_dispatch: - -env: - # See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml - GO_VERSION: '1.21' - NODE_VERSION: '18.17' - -jobs: - pull-from-jsonbin: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - registry-url: 'https://registry.npmjs.org' - cache: 'yarn' - - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Install Task - uses: arduino/setup-task@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - version: 3.x - - - name: Install dependencies - run: yarn install --immutable - - - name: Run themes:pull script - run: yarn run themes:pull - env: - JSONBIN_MASTER_KEY: ${{ secrets.JSONBIN_MASTER_KEY }} - JSONBIN_ID: ${{ secrets.JSONBIN_ID }} - - - name: Generate dark tokens - run: npx token-transformer scripts/themes/tokens/arduino-tokens.json scripts/themes/tokens/dark.json core,ide-default,ide-dark,theia core,ide-default,ide-dark - - - name: Generate default tokens - run: npx token-transformer scripts/themes/tokens/arduino-tokens.json scripts/themes/tokens/default.json core,ide-default,theia core,ide-default - - - name: Run themes:generate script - run: yarn run themes:generate - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - with: - commit-message: Updated themes - title: Update themes - branch: themes/themes-update - author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +name: themes-weekly-pull + +on: + schedule: + # run every friday at 5AM + - cron: '0 5 * * 5' + workflow_dispatch: + +env: + # See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml + GO_VERSION: '1.21' + NODE_VERSION: '18.17' + +jobs: + pull-from-jsonbin: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install Task + uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Install dependencies + run: yarn install --immutable + + - name: Run themes:pull script + run: yarn run themes:pull + env: + JSONBIN_MASTER_KEY: ${{ secrets.JSONBIN_MASTER_KEY }} + JSONBIN_ID: ${{ secrets.JSONBIN_ID }} + + - name: Generate dark tokens + run: npx token-transformer scripts/themes/tokens/arduino-tokens.json scripts/themes/tokens/dark.json core,ide-default,ide-dark,theia core,ide-default,ide-dark + + - name: Generate default tokens + run: npx token-transformer scripts/themes/tokens/arduino-tokens.json scripts/themes/tokens/default.json core,ide-default,theia core,ide-default + + - name: Run themes:generate script + run: yarn run themes:generate + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: Updated themes + title: Update themes + branch: themes/themes-update + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b53773f8b..16b50e61d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -40,7 +40,10 @@ { "label": "Watch All", "type": "shell", - "dependsOn": ["Watch Extension", "Watch App"] + "dependsOn": [ + "Watch Extension", + "Watch App" + ] } ] -} +} \ No newline at end of file diff --git a/arduino-ide-extension/package.json b/arduino-ide-extension/package.json index 45e852988..180e83fda 100644 --- a/arduino-ide-extension/package.json +++ b/arduino-ide-extension/package.json @@ -1,6 +1,6 @@ { "name": "arduino-ide-extension", - "version": "2.3.5", + "version": "3.6.0", "description": "An extension for Theia building the Arduino IDE", "license": "AGPL-3.0-or-later", "scripts": { @@ -188,4 +188,4 @@ "version": "14.0.0" } } -} +} \ No newline at end of file diff --git a/arduino-ide-extension/scripts/compose-changelog.js b/arduino-ide-extension/scripts/compose-changelog.js old mode 100755 new mode 100644 index f8a4c42ba..83095b532 --- a/arduino-ide-extension/scripts/compose-changelog.js +++ b/arduino-ide-extension/scripts/compose-changelog.js @@ -27,8 +27,7 @@ // item.name is the name of the release changelog return ( acc + - `## ${item.name}\n\n${body}${ - index !== releases.length - 1 ? '\n\n---\n\n' : '\n' + `## ${item.name}\n\n${body}${index !== releases.length - 1 ? '\n\n---\n\n' : '\n' }` ); }, ''); diff --git a/arduino-ide-extension/scripts/download-cli.js b/arduino-ide-extension/scripts/download-cli.js old mode 100755 new mode 100644 diff --git a/arduino-ide-extension/scripts/download-fwuploader.js b/arduino-ide-extension/scripts/download-fwuploader.js old mode 100755 new mode 100644 diff --git a/arduino-ide-extension/scripts/download-ls.js b/arduino-ide-extension/scripts/download-ls.js old mode 100755 new mode 100644 index 8fc2e1989..65aac00e9 --- a/arduino-ide-extension/scripts/download-ls.js +++ b/arduino-ide-extension/scripts/download-ls.js @@ -120,11 +120,10 @@ } if (typeof lsVersion === 'string') { - const lsUrl = `https://downloads.arduino.cc/arduino-language-server/${ - lsVersion === 'nightly' + const lsUrl = `https://downloads.arduino.cc/arduino-language-server/${lsVersion === 'nightly' ? 'nightly/arduino-language-server' : 'arduino-language-server_' + lsVersion - }_${lsSuffix}`; + }_${lsSuffix}`; downloader.downloadUnzipAll( lsUrl, resourcesFolder, diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index 9ca0a9c61..96d53effb 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -22,7 +22,6 @@ import { MenuModelRegistry, } from '@theia/core/lib/common/menu'; import { MessageService } from '@theia/core/lib/common/message-service'; -import { nls } from '@theia/core/lib/common/nls'; import { isHighContrast } from '@theia/core/lib/common/theme'; import { ElectronWindowPreferences } from '@theia/core/lib/electron-browser/window/electron-window-preferences'; import { @@ -42,17 +41,17 @@ import { ArduinoMenus } from './menu/arduino-menus'; import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution'; import { SerialPlotterContribution } from './serial/plotter/plotter-frontend-contribution'; import { ArduinoToolbar } from './toolbar/arduino-toolbar'; +import { ResponseService } from '../common/protocol'; @injectable() export class ArduinoFrontendContribution implements - FrontendApplicationContribution, - TabBarToolbarContribution, - CommandContribution, - MenuContribution, - ColorContribution, - StylingParticipant -{ + FrontendApplicationContribution, + TabBarToolbarContribution, + CommandContribution, + MenuContribution, + ColorContribution, + StylingParticipant { @inject(MessageService) private readonly messageService: MessageService; @@ -68,16 +67,22 @@ export class ArduinoFrontendContribution @inject(FrontendApplicationStateService) private readonly appStateService: FrontendApplicationStateService; + @inject(ResponseService) + private readonly responseService: ResponseService; + @postConstruct() protected init(): void { if (!window.navigator.onLine) { // tslint:disable-next-line:max-line-length - this.messageService.warn( - nls.localize( - 'arduino/common/offlineIndicator', - 'You appear to be offline. Without an Internet connection, the Arduino CLI might not be able to download the required resources and could cause malfunction. Please connect to the Internet and restart the application.' - ) - ); + // this.messageService.warn( + // nls.localize( + // 'arduino/common/offlineIndicator', + // '你好像离线了。如果没有互联网连接,CLI可能无法下载所需的资源,并可能导致故障。请连接到互联网并重新启动应用程序。' + // ) + // ); + const chunk = + '你好像离线了。如果没有互联网连接,CLI可能无法下载所需的资源,并可能导致故障。请连接到互联网并重新启动应用程序\n'; + this.responseService.appendToOutput({ chunk }); } } @@ -119,15 +124,12 @@ export class ArduinoFrontendContribution registry.registerItem({ id: 'toggle-serial-plotter', command: SerialPlotterContribution.Commands.OPEN_TOOLBAR.id, - tooltip: nls.localize( - 'arduino/serial/openSerialPlotter', - 'Serial Plotter' - ), + tooltip: '串口绘图仪', }); registry.registerItem({ id: 'toggle-serial-monitor', command: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR, - tooltip: nls.localize('arduino/common/serialMonitor', 'Serial Monitor'), + tooltip: '串口监视器', }); } @@ -156,14 +158,8 @@ export class ArduinoFrontendContribution registry.getMenu(MAIN_MENU_BAR).removeNode(menuId(TerminalMenus.TERMINAL)); registry.getMenu(MAIN_MENU_BAR).removeNode(menuId(CommonMenus.VIEW)); - registry.registerSubmenu( - ArduinoMenus.SKETCH, - nls.localize('arduino/menu/sketch', 'Sketch') - ); - registry.registerSubmenu( - ArduinoMenus.TOOLS, - nls.localize('arduino/menu/tools', 'Tools') - ); + registry.registerSubmenu(ArduinoMenus.SKETCH, '项目'); + registry.registerSubmenu(ArduinoMenus.TOOLS, '工具'); } registerColors(colors: ColorRegistry): void { diff --git a/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts b/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts index d6779c302..6de500d50 100644 --- a/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts +++ b/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts @@ -61,10 +61,6 @@ import { TreeWidget, } from '@theia/core/lib/browser'; import { MenuContribution } from '@theia/core/lib/common/menu'; -import { - ApplicationShell, - DockPanelRenderer, -} from './theia/core/application-shell'; import { FrontendApplication } from './theia/core/frontend-application'; import { BoardsConfigDialog, @@ -260,7 +256,6 @@ import { UserFieldsDialog, UserFieldsDialogProps, } from './dialogs/user-fields/user-fields-dialog'; -import { nls } from '@theia/core/lib/common'; import { IDEUpdaterCommands } from './ide-updater/ide-updater-commands'; import { IDEUpdater, @@ -378,6 +373,39 @@ import { DebugSessionWidget } from '@theia/debug/lib/browser/view/debug-session- import { DebugConfigurationWidget } from './theia/debug/debug-configuration-widget'; import { DebugConfigurationWidget as TheiaDebugConfigurationWidget } from '@theia/debug/lib/browser/view/debug-configuration-widget'; import { DebugToolBar } from '@theia/debug/lib/browser/view/debug-toolbar-widget'; +import { HomeWidget } from './home/home-widget'; +import { HomeWidgetContribution } from './home/home-widget-contribution'; +import { BoardImgWidget } from './boardImg/boardImg-widget'; +import { BoardImgWidgetContribution } from './boardImg/boardImg-widget-contribution'; +import { + ApplicationShell, + bindToolbarApplicationShell, + DockPanelRenderer, +} from './theia/core/application-shell'; +import { MySearchInWorkspaceWidget } from './theia/search-in-workspace/search-in-workspace-widget'; +import { SearchInWorkspaceWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-widget'; +import { OutputWidget } from '@theia/output/lib/browser/output-widget'; +import { MyOutputWidget } from './theia/out-put/out-put-widget'; +import { KeymapsFrontendWidget } from './theia/keymaps/keymaps-frontend-widget'; +import { KeybindingWidget } from '@theia/keymaps/lib/browser/keybindings-widget'; +import { MyNotificationsContribution } from './theia/messages/notifications-contribution'; +import { NotificationsContribution } from '@theia/messages/lib/browser/notifications-contribution'; +import { MyFileSystemWatcherErrorHandler } from './theia/filesystem/filesystem-watcher-error-handler'; +import { FileSystemWatcherErrorHandler } from '@theia/filesystem/lib/browser/filesystem-watcher-error-handler'; +import { MyLibraryListWidget } from './library/my-library-list-widget'; +import { MyLibraryListWidgetFrontendContribution } from './library/my-library-widget-frontend-contribution'; +import { + LibrarysDialog, + LibrarysDialogProps, +} from './dialogs/librarys/librarys-dialog'; +import { OpenLibrarys } from './dialogs/librarys/open-librarys'; +import { + KeymapsDialog, + KeymapsDialogProps, +} from './dialogs/Keymaps/keymaps-dialog'; +import { OpenKeymaps } from './dialogs/Keymaps/open-keymaps'; +import { OutputContribution } from '@theia/output/lib/browser/output-contribution'; +import { MyOutputContribution } from './theia/out-put/output-contribution'; import { PluginTree, PluginTreeModel, @@ -411,6 +439,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(FrontendApplicationContribution).toService(ArduinoFrontendContribution); bind(ColorContribution).toService(ArduinoFrontendContribution); bind(StylingParticipant).toService(ArduinoFrontendContribution); + bind(CommandContribution).to(BoardImgWidgetContribution); + bind(CommandContribution).to(HomeWidgetContribution); bind(ArduinoToolbarContribution).toSelf().inSingletonScope(); bind(FrontendApplicationContribution).toService(ArduinoToolbarContribution); @@ -431,7 +461,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { .inSingletonScope(); // Library list widget - bind(LibraryListWidget).toSelf(); + // bind(LibraryListWidget).toSelf(); bindViewContribution(bind, LibraryListWidgetFrontendContribution); bind(WidgetFactory).toDynamicValue((context) => ({ id: LibraryListWidget.WIDGET_ID, @@ -501,7 +531,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(FrontendApplicationContribution).toService(BoardsAutoInstaller); // Boards list widget - bind(BoardsListWidget).toSelf(); + // bind(BoardsListWidget).toSelf(); bindViewContribution(bind, BoardsListWidgetFrontendContribution); bind(WidgetFactory).toDynamicValue((context) => ({ id: BoardsListWidget.WIDGET_ID, @@ -515,10 +545,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { // Board select dialog bind(BoardsConfigDialog).toSelf().inSingletonScope(); bind(BoardsConfigDialogProps).toConstantValue({ - title: nls.localize( - 'arduino/board/boardConfigDialogTitle', - 'Select Other Board and Port' - ), + title: '选择“其他单板和端口”', }); // Core service @@ -591,6 +618,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { rebind(TheiaKeymapsFrontendContribution) .to(KeymapsFrontendContribution) .inSingletonScope(); + rebind(KeybindingWidget).to(KeymapsFrontendWidget).inSingletonScope(); rebind(TheiaEditorContribution).to(EditorContribution).inSingletonScope(); rebind(TheiaMonacoStatusBarContribution) .to(MonacoStatusBarContribution) @@ -787,6 +815,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { Contribution.configure(bind, UpdateArduinoState); Contribution.configure(bind, BoardsDataMenuUpdater); Contribution.configure(bind, AutoSelectProgrammer); + Contribution.configure(bind, OpenLibrarys); + Contribution.configure(bind, OpenKeymaps); bindContributionProvider(bind, StartupTaskProvider); bind(StartupTaskProvider).toService(BoardsServiceProvider); // to reuse the boards config in another window @@ -942,17 +972,62 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(SettingsWidget).toSelf().inSingletonScope(); bind(SettingsDialog).toSelf().inSingletonScope(); bind(SettingsDialogProps).toConstantValue({ - title: nls.localize( - 'vscode/preferences.contribution/preferences', - 'Preferences' - ), + title: '设置', + }); + + bind(LibrarysDialog).toSelf().inSingletonScope(); + bind(LibrarysDialogProps).toConstantValue({ + title: '从本地安装库', + }); + + bind(KeymapsDialog).toSelf().inSingletonScope(); + bind(KeymapsDialogProps).toConstantValue({ + title: '键盘快捷方式参考', }); bind(NotificationManager).toSelf().inSingletonScope(); rebind(TheiaNotificationManager).toService(NotificationManager); + bind(MyNotificationsContribution).toSelf().inSingletonScope(); + rebind(NotificationsContribution).toService(MyNotificationsContribution); bind(NotificationsRenderer).toSelf().inSingletonScope(); rebind(TheiaNotificationsRenderer).toService(NotificationsRenderer); + //==================== + // bind(YourCustomWidget).toSelf(); + // bind(YourCustomWidgetContribution).toSelf(); + // bind(FrontendApplicationContribution).toService(YourCustomWidgetContribution); + // bind(WidgetFactory).toDynamicValue(({ container }) => ({ + // id: 'your-custom-widget-id',d + // createWidget: () => container.get(YourCustomWidget), + // })); + + //UI for the BoardImg + bind(BoardImgWidget).toSelf(); + bind(BoardImgWidgetContribution).toSelf(); + bind(FrontendApplicationContribution).toService(BoardImgWidgetContribution); + bind(WidgetFactory).toDynamicValue(({ container }) => ({ + id: 'lingzhi-boardImg-widget', + createWidget: () => container.get(BoardImgWidget), + })); + + //UI for the library + bind(MyLibraryListWidget).toSelf(); + bind(MyLibraryListWidgetFrontendContribution).toSelf(); + bind(WidgetFactory).toDynamicValue(({ container }) => ({ + id: 'lingzhi-library-widget', + createWidget: () => container.get(MyLibraryListWidget), + })); + + //UI for the Home + bind(HomeWidget).toSelf(); + bind(HomeWidgetContribution).toSelf(); + // bindViewContribution(bind, HomeWidgetContribution); + bind(FrontendApplicationContribution).toService(HomeWidgetContribution); + bind(WidgetFactory).toDynamicValue(({ container }) => ({ + id: 'lingzhi-home-widget', + createWidget: () => container.get(HomeWidget), + })); + // UI for the Sketchbook bind(SketchbookWidget).toSelf(); bind(SketchbookTreeWidget).toDynamicValue(({ container }) => @@ -1092,6 +1167,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { // https://github.com/arduino/arduino-ide/issues/437 bind(FileResourceResolver).toSelf().inSingletonScope(); rebind(TheiaFileResourceResolver).toService(FileResourceResolver); + bind(MyFileSystemWatcherErrorHandler).toSelf().inSingletonScope(); + rebind(FileSystemWatcherErrorHandler).toService( + MyFileSystemWatcherErrorHandler + ); // Full control over the editor context menu to filter undesired menu items contributed by Theia. // https://github.com/arduino/arduino-ide/issues/1394 @@ -1108,6 +1187,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { ); bindViewsWelcome_TheiaGH14309({ bind, widget: TreeViewWidget }); + + bindToolbarApplicationShell(bind, rebind); + rebind(SearchInWorkspaceWidget) + .to(MySearchInWorkspaceWidget) + .inSingletonScope(); + + rebind(OutputWidget).to(MyOutputWidget); + + rebind(OutputContribution).to(MyOutputContribution).inSingletonScope(); }); // Align the viewsWelcome rendering with VS Code (https://github.com/eclipse-theia/theia/issues/14309) diff --git a/arduino-ide-extension/src/browser/arduino-preferences.ts b/arduino-ide-extension/src/browser/arduino-preferences.ts index 40ae222d1..dfb762c75 100644 --- a/arduino-ide-extension/src/browser/arduino-preferences.ts +++ b/arduino-ide-extension/src/browser/arduino-preferences.ts @@ -69,70 +69,49 @@ type ArduinoPreferenceSchemaProperties = const properties: ArduinoPreferenceSchemaProperties = { 'arduino.language.log': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/language.log', - "True if the Arduino Language Server should generate log files into the sketch folder. Otherwise, false. It's false by default." - ), + description: + 'True 则 Arduino Language Server 将日志文件生成到项目文件夹中。默认为 False。', default: false, }, 'arduino.language.realTimeDiagnostics': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/language.realTimeDiagnostics', - "If true, the language server provides real-time diagnostics when typing in the editor. It's false by default." - ), + description: + 'True 则 language server 在编辑器中输入时提供实时诊断。默认为 False。', default: false, }, 'arduino.language.asyncWorkers': { type: 'number', - description: nls.localize( - 'arduino/preferences/language.asyncWorkers', - 'Number of async workers used by the Arduino Language Server (clangd). Background index also uses this many workers. The minimum value is 0, and the maximum is 8. When it is 0, the language server uses all available cores. The default value is 0.' - ), + description: + 'Arduino 语言服务器(clangd)使用的异步工作线程数。 后台索引也使用相同数量的工作线程。 最小值为 0,最大值为 8。 当值为 0 时,语言服务器将使用所有可用的核心。 默认值为 0。', minimum: minAsyncWorkers, maximum: maxAsyncWorkers, default: defaultAsyncWorkers, }, 'arduino.compile.verbose': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/compile.verbose', - 'True for verbose compile output. False by default' - ), - default: false, + description: 'True 则输出详细编译信息。默认为 False', + default: true, }, 'arduino.compile.experimental': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/compile.experimental', - 'True if the IDE should handle multiple compiler errors. False by default' - ), + description: 'True 则 IDE 处理多个编译器错误。默认为 False。', default: false, }, 'arduino.compile.revealRange': { enum: [...ErrorRevealStrategyLiterals], - description: nls.localize( - 'arduino/preferences/compile.revealRange', - "Adjusts how compiler errors are revealed in the editor after a failed verify/upload. Possible values: 'auto': Scroll vertically as necessary and reveal a line. 'center': Scroll vertically as necessary and reveal a line centered vertically. 'top': Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition. 'centerIfOutsideViewport': Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport. The default value is '{0}'.", - ErrorRevealStrategy.Default - ), + description: + '调整编译器错误在 “验证/上传” 失败后在编辑器中的显示方式。可能的值:‘auto’:根据需要垂直滚动并显示一行。‘center’:必要时垂直滚动并显示垂直居中的一行。‘top’:必要时垂直滚动并显示靠近视口顶部的一行,优化用于查看代码定义。‘centerIfOutsideViewport’:根据需要垂直滚动并显示垂直居中的线,只有当它位于视口之外时。', default: ErrorRevealStrategy.Default, }, 'arduino.compile.warnings': { enum: [...CompilerWarningLiterals], - description: nls.localize( - 'arduino/preferences/compile.warnings', - "Tells gcc which warning level to use. It's 'None' by default" - ), + description: '设置 gcc 警告级别。默认为 None', default: 'None', }, 'arduino.upload.verbose': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/upload.verbose', - 'True for verbose upload output. False by default.' - ), - default: false, + description: 'True 则输出详细上传信息。默认情况下为 False。', + default: true, }, 'arduino.upload.verify': { type: 'boolean', @@ -152,92 +131,61 @@ const properties: ArduinoPreferenceSchemaProperties = { }, 'arduino.window.autoScale': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/window.autoScale', - 'True if the user interface automatically scales with the font size.' - ), + description: 'True 则用户界面随字体大小自动缩放。', default: true, }, 'arduino.window.zoomLevel': { type: 'number', description: '', default: 0, - deprecationMessage: nls.localize( - 'arduino/preferences/window.zoomLevel/deprecationMessage', - "Deprecated. Use 'window.zoomLevel' instead." - ), + deprecationMessage: '已弃用。请改用“window.zoomLevel”。', }, 'arduino.ide.updateChannel': { type: 'string', enum: Object.values(UpdateChannel) as UpdateChannel[], default: UpdateChannel.Stable, - description: nls.localize( - 'arduino/preferences/ide.updateChannel', - "Release channel to get updated from. 'stable' is the stable release, 'nightly' is the latest development build." - ), + description: + '在发布频道中获取更新信息。‘stable’ 是稳定的版本,‘nightly’ 是最新的开发版本。', }, 'arduino.ide.updateBaseUrl': { type: 'string', - default: 'https://downloads.arduino.cc/arduino-ide', - description: nls.localize( - 'arduino/preferences/ide.updateBaseUrl', - "The base URL where to download updates from. Defaults to 'https://downloads.arduino.cc/arduino-ide'" - ), + default: 'https://www.zxjian.com/api/databook', + description: '下载更新的网址。默认为 ‘https://www.zxjian.com/api/databook’', }, 'arduino.board.certificates': { type: 'string', - description: nls.localize( - 'arduino/preferences/board.certificates', - 'List of certificates that can be uploaded to boards' - ), + description: '可上传到开发板的证书列表', default: '', }, 'arduino.sketchbook.showAllFiles': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/sketchbook.showAllFiles', - 'True to show all sketch files inside the sketch. It is false by default.' - ), + description: 'True 则显示项目中的所有项目文件。默认情况下为 False。', default: false, }, 'arduino.cloud.enabled': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/cloud.enabled', - 'True if the sketch sync functions are enabled. Defaults to true.' - ), + description: 'True 则启用项目同步功能。默认为 True。', default: true, }, 'arduino.cloud.pull.warn': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/cloud.pull.warn', - 'True if users should be warned before pulling a cloud sketch. Defaults to true.' - ), + description: 'True 则在拉取 cloud 项目之前警告用户。默认为 True。', default: true, }, 'arduino.cloud.push.warn': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/cloud.push.warn', - 'True if users should be warned before pushing a cloud sketch. Defaults to true.' - ), + description: 'True 则在推送 cloud 项目之前警告用户。默认为 True。', default: true, }, 'arduino.cloud.pushpublic.warn': { type: 'boolean', - description: nls.localize( - 'arduino/preferences/cloud.pushpublic.warn', - 'True if users should be warned before pushing a public sketch to the cloud. Defaults to true.' - ), + description: 'True 则将公开项目推送到 cloud 中之前警告用户。默认为 True。', default: true, }, 'arduino.cloud.sketchSyncEndpoint': { type: 'string', - description: nls.localize( - 'arduino/preferences/cloud.sketchSyncEndpoint', - 'The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.' - ), + description: + '用于从后台推送项目的端点。默认情况下,它指向 Arduino Cloud API。', default: 'https://api2.arduino.cc/create', }, 'arduino.cloud.sharedSpaceID': { @@ -250,10 +198,7 @@ const properties: ArduinoPreferenceSchemaProperties = { }, 'arduino.auth.clientID': { type: 'string', - description: nls.localize( - 'arduino/preferences/auth.clientID', - 'The OAuth2 client ID.' - ), + description: 'OAuth2 客户端 ID', default: 'C34Ya6ex77jTNxyKWj01lCe1vAHIaPIo', }, 'arduino.auth.domain': { diff --git a/arduino-ide-extension/src/browser/boardImg/boardImg-widget-contribution.ts b/arduino-ide-extension/src/browser/boardImg/boardImg-widget-contribution.ts new file mode 100644 index 000000000..162c76002 --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/boardImg-widget-contribution.ts @@ -0,0 +1,131 @@ +/* eslint-disable prettier/prettier */ +import { inject, injectable } from '@theia/core/shared/inversify'; +import { CommandRegistry, CommandService } from '@theia/core/lib/common/command'; +import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'; +import { BoardImgWidget } from './boardImg-widget'; +import { MainMenuManager } from '../../common/main-menu-manager'; +import { MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry'; +import { ApplicationShell } from '../theia/core/application-shell'; +import { StorageService } from '@theia/core/lib/browser/storage-service'; +import { toArray } from '@theia/core/shared/@phosphor/algorithm'; +import { WorkspaceService } from '../theia/workspace/workspace-service'; +import { SketchesService } from '../../common/protocol/sketches-service'; + +@injectable() +export class BoardImgWidgetContribution + extends AbstractViewContribution + implements FrontendApplicationContribution { + @inject(MainMenuManager) + protected readonly mainMenuManager: MainMenuManager; + + @inject(ApplicationShell) + protected readonly shelloverride: ApplicationShell; + + @inject(WorkspaceService) + private readonly workspaceService: WorkspaceService; + + @inject(CommandService) + private readonly commandService: CommandService; + + @inject(SketchesService) + private readonly sketchesService: SketchesService; + + @inject(StorageService) protected storageService: StorageService; + constructor() { + super({ + widgetId: 'lingzhi-boardImg-widget', + widgetName: BoardImgWidget.LABEL, + defaultWidgetOptions: { + area: 'right', + rank: 1, + }, + toggleCommandId: BoardImgWidgetCommand.id, + }); + } + + onStart(): void { + // 在应用启动时可以进行一些初始化操作,如果需要的话 + } + + async initializeLayout(): Promise { + return this.openView() as Promise; + } + + override registerCommands(commands: CommandRegistry): void { + commands.registerCommand(BoardImgWidgetCommand, { + execute: () => { + super.openView({ activate: false, reveal: true }); + }, + }); + commands.registerCommand(BoardImgWidgetClose, { + execute: () => { + super.closeView(); + }, + }); + + let toHome = true; + let leftPanelWidth: number | undefined; + commands.registerCommand(MyWidgetCommandHome, { + execute: async () => { + if (!toHome) { + leftPanelWidth = this.shell.leftPanelHandler.getLayoutData().size; + toHome = true; + } + this.shelloverride.mainContainer.hide(); + this.shelloverride.rightPanelCustom.hide(); + this.shell.rightPanelHandler.container.hide(); + } + }); + commands.registerCommand(MyWidgetCommandOther, { + execute: async () => { + this.shell.rightPanelHandler.container.hide(); + this.shell.leftPanelHandler.container.hide(); + this.shell.leftPanelHandler.container.show(); + if (toHome) { + toHome = false; + if (leftPanelWidth) { + this.shell.leftPanelHandler.resize(leftPanelWidth); + } else { + this.shell.leftPanelHandler.resize(160); + } + } + this.shelloverride.mainContainer.show(); + this.shelloverride.rightPanelCustom.show(); + this.shelloverride.rightPanelCustom.node.style.maxWidth = 'none'; + } + }); + + commands.registerCommand(MAIN_WIDGET_CLOSE_AND_OPEN, { + execute: () => { + const currentWidgetInMain = toArray( + this.shell.mainPanel.widgets() + ); + if (currentWidgetInMain) { + currentWidgetInMain.forEach((widget) => { + widget.close(); + }) + } + } + }) + } + + override registerMenus(registry: MenuModelRegistry): void { + registry.unregisterMenuAction({ + commandId: BoardImgWidgetCommand.id, + }); + } +} + +export const BoardImgWidgetCommand = { + id: 'toggle-lingzhi-boardImg-widget', +}; + +export const BoardImgWidgetClose = { + id: 'close-lingzhi-boardImg-widget', +}; + +export const MAIN_WIDGET_CLOSE_AND_OPEN = { id: 'lingzhi-colse-and-open' }; + +export const MyWidgetCommandHome = { id: 'closeMainAndRight:command' }; +export const MyWidgetCommandOther = { id: 'openMainAndRight:command' }; \ No newline at end of file diff --git a/arduino-ide-extension/src/browser/boardImg/boardImg-widget.ts b/arduino-ide-extension/src/browser/boardImg/boardImg-widget.ts new file mode 100644 index 000000000..11a5fd476 --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/boardImg-widget.ts @@ -0,0 +1,258 @@ +/* eslint-disable prettier/prettier */ +import { injectable } from '@theia/core/shared/inversify'; +import { BaseWidget } from '@theia/core/lib/browser/widgets/widget'; +import { nls } from '@theia/core/lib/common'; + +@injectable() +export class BoardImgWidget extends BaseWidget { + static readonly LABEL = nls.localize('arduino/home/boardImg', '开发板'); + // 声明一个私有成员变量用于存储滚动容器 + private scrollContainer: HTMLDivElement; + + constructor( + // @inject(BoardsService) private readonly boardsService: BoardsService, + // @inject(CommandService) private commandService: CommandService, + // @inject(BoardsServiceProvider) + // private readonly boardsServiceProvider: BoardsServiceProvider + ) { + super(); + this.id = 'lingzhi-boardImg-widget'; + this.title.caption = BoardImgWidget.LABEL; + this.title.label = BoardImgWidget.LABEL; + this.title.iconClass = 'fa lingzhi-chanpinfenlei-kaifaban'; + this.title.closable = true; + this.node.tabIndex = 0; + + // this.selectExamples(); + + // // 添加一个包含滚动条的容器元素到小部件的节点中 + // this.scrollContainer = document.createElement('div'); + // this.scrollContainer.style.overflowY = 'auto'; + // this.scrollContainer.style.display = 'flex'; + // this.scrollContainer.style.alignItems = 'center'; + // this.scrollContainer.style.justifyContent = 'center'; + // this.scrollContainer.style.height = `calc(100% - 102px)`; + // this.scrollContainer.style.borderTop = '1px solid #dae3e3'; + + // this.node.appendChild(this.scrollContainer); + // this.officialWebsiteInformation(); + + // this.imgDisplay(); + } + + // private officialWebsiteInformation() { + // const container1 = document.createElement('div'); + // container1.style.display = 'flex'; + // container1.style.alignItems = 'center'; + // container1.style.margin = '5px 10px '; + + // // 创建文字 + // const name = document.createElement('span'); + // name.textContent = '名称:'; + // name.style.marginRight = '15px'; + // name.style.whiteSpace = 'nowrap'; + + // const name1 = document.createElement('span'); + // this.boardsServiceProvider.onBoardListDidChange((boardList) => { + // if (boardList.boardsConfig.selectedBoard?.fqbn) { + // const fqbn = boardList.boardsConfig.selectedBoard.fqbn; + // const lastColonIndex = fqbn.lastIndexOf(':'); + // const valueAfterLastColon = fqbn.slice(lastColonIndex + 1); + // switch (valueAfterLastColon) { + // case 'lzesp32': + // name1.textContent = '零知-ESP32'; + // break; + // case 'lzesp8266': + // name1.textContent = '零知-ESP8266'; + // break; + // case 'lingzhistandard': + // name1.textContent = '零知-标准板'; + // break; + // case 'lingzhiMini': + // name1.textContent = '零知-迷你板'; + // break; + // case 'lingzhiM4': + // name1.textContent = '零知-增强板'; + // break; + // case 'lz_ble52': + // name1.textContent = '零知-BLE52'; + // break; + // default: + // if (boardList.boardsConfig.selectedBoard?.name) { + // name1.textContent = boardList.boardsConfig.selectedBoard.name; + // } + // break; + // } + // } + // }); + // name1.style.marginRight = '15px'; + // name1.style.whiteSpace = 'nowrap'; + // name1.style.color = '#5500ff'; + + // container1.appendChild(name); + // container1.appendChild(name1); + // this.node.appendChild(container1); + + // const container2 = document.createElement('div'); + // container2.style.display = 'flex'; + // container2.style.alignItems = 'center'; + // container2.style.margin = '5px 10px '; + + // // 创建文字 + // const brand = document.createElement('span'); + // brand.textContent = '品牌:'; + // brand.style.marginRight = '15px'; + + // const brand1 = document.createElement('span'); + // brand1.textContent = '零知实验室'; + // brand1.style.marginRight = '15px'; + // brand1.style.color = '#5500ff'; + + // container2.appendChild(brand); + // container2.appendChild(brand1); + // this.node.appendChild(container2); + + // const container3 = document.createElement('div'); + // container3.style.display = 'flex'; + // container3.style.alignItems = 'center'; + // container3.style.margin = '5px 10px '; + + // // 创建文字 + // const officialWebsite = document.createElement('span'); + // officialWebsite.textContent = '官网:'; + // officialWebsite.style.marginRight = '15px'; + + // const officialWebsite1 = document.createElement('a'); + // officialWebsite1.textContent = 'www.lingzhilab.com'; + // officialWebsite1.style.textDecoration = 'underline'; + // officialWebsite1.style.marginRight = '15px'; + // officialWebsite1.style.cursor = 'pointer'; + // officialWebsite1.style.color = '#5500ff'; + + // officialWebsite1.addEventListener('click', () => { + // this.commandService.executeCommand('arduino-visit-arduino'); + // }); + + // container3.appendChild(officialWebsite); + // container3.appendChild(officialWebsite1); + // this.node.appendChild(container3); + // } + + // // file:///D:/work/work3/arduino-ide-2.3.2/electron-app/lib/frontend/index.html?port=59791#/d:/work/work3/arduino-ide-2.3.2/arduino-ide-extension/lib/node/resources/Examples/lz-esp32/BLE(%E8%93%9D%E7%89%99)/BLE_notify(%E8%93%9D%E7%89%99%E9%80%9A%E7%9F%A5)/BLE_notify + // private imgDisplay(imgName = '') { + // // 先清除之前的图片 + // while (this.scrollContainer.firstChild) { + // this.scrollContainer.removeChild(this.scrollContainer.firstChild); + // } + + // const img = new Image(); + // let absolutePath = `./icon/${imgName}.svg`; + // if (imgName === 'lzesp8266') { + // absolutePath = `./icon/${imgName}.png`; + // } + // img.src = absolutePath; + // const resizeObserver = new ResizeObserver(() => { + // if (this.scrollContainer.clientWidth === 232) { + // img.style.width = '50%'; + // } else { + // img.style.width = '100%'; + // } + // }); + // resizeObserver.observe(this.scrollContainer); + + // img.style.margin = 'auto'; + // img.style.position = 'relative'; + // this.scrollContainer.appendChild(img); + // } + + // private async selectExamples() { + // // 创建包含文字和下拉框的容器 + // const container = document.createElement('div'); + // container.style.display = 'flex'; + // container.style.alignItems = 'center'; + // container.style.margin = '5px 10px '; + + // // 创建文字 + // const label = document.createElement('span'); + // label.textContent = '开发板:'; + // label.style.marginRight = '15px'; + + // // 创建下拉框 + // const dropdown = document.createElement('select'); + + // const allBoards = await this.boardsService.getInstalledBoards(); + + + // this.boardsServiceProvider.onBoardListDidChange((boardList) => { + // dropdown.value = boardList.boardsConfig.selectedBoard?.fqbn as string; + // const parts = dropdown.value.split(':'); + // const imgName = parts[parts.length - 1]; + // this.imgDisplay(imgName); + // }); + + // this.boardsServiceProvider.onBoardsConfigDidChange(() => { + // this.boardsServiceProvider.ready.then(() => { + // const { selectedBoard } = this.boardsServiceProvider.boardsConfig; + // const name = selectedBoard?.fqbn; + // dropdown.value = name as string; + // }); + // }); + + // allBoards.forEach((board) => { + // const option = document.createElement('option'); + // const fqbn = board.fqbn as string; + // option.value = fqbn; + // const lastColonIndex = fqbn.lastIndexOf(':'); + // const valueAfterLastColon = fqbn.slice(lastColonIndex + 1); + // switch (valueAfterLastColon) { + // case 'lzesp32': + // option.textContent = '零知-ESP32'; + // break; + // case 'lzesp8266': + // option.textContent = '零知-ESP8266'; + // break; + // case 'lingzhistandard': + // option.textContent = '零知-标准板'; + // break; + // case 'lingzhiMini': + // option.textContent = '零知-迷你板'; + // break; + // case 'lingzhiM4': + // option.textContent = '零知-增强板'; + // break; + // case 'lz_ble52': + // option.textContent = '零知-BLE52'; + // break; + // default: + // if (board.name) { + // option.textContent = board.name; + // } + // break; + // } + // dropdown.appendChild(option); + // }); + // dropdown.style.borderColor = 'rgb(172, 172, 172)'; + // dropdown.style.color = 'rgb(0, 0, 0)'; + // dropdown.style.backgroundImage = + // 'linear-gradient(to bottom, rgb(254, 254, 254) 0%, rgb(241, 241, 241) 100%)'; + // dropdown.style.width = '125px'; + // dropdown.addEventListener('change', () => { + // const commandId = `arduino-select-board--${dropdown.value}`; + // this.commandService + // .executeCommand(commandId) + // .then(() => { + // console.log(`Executed command: ${commandId}`); + // }) + // .catch((error) => { + // console.error(`Failed to execute command ${commandId}: ${error}`); + // }); + // }); + + // // 将文字和下拉框添加到容器中 + // container.appendChild(label); + // container.appendChild(dropdown); + + // // 将容器添加到节点中 + // this.node.insertBefore(container, this.scrollContainer); + // } +} diff --git a/arduino-ide-extension/src/browser/boardImg/icon/diecimila.png b/arduino-ide-extension/src/browser/boardImg/icon/diecimila.png new file mode 100644 index 000000000..6d121d0b6 Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/diecimila.png differ diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lingzhiM4.svg b/arduino-ide-extension/src/browser/boardImg/icon/lingzhiM4.svg new file mode 100644 index 000000000..03c2ea7bf --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/icon/lingzhiM4.svg @@ -0,0 +1,3014 @@ + + + + +Fritzing breadboard generated by brd2svg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +layer 21 + + + + + + + + + + + + + + + + 0 + + + + + + + + + 1 + + + + + + + + + 2 + + + + + + + + + 3 + + + + + + + + + 4 + + + + + + + + + 5 + + + + + + + + + 6 + + + + + + + + + 7 + + + + + + + + + 8 + + + + + + + + + 9 + + + + + + + + + 10 + + + + + + + + + 11 + + + + + + + + + 12 + + + + + + + + + 13 + + + + + + text:0 + + + A0 + + + + + text:1 + + + A1 + + + + + text:2 + + + A2 + + + + + text:3 + + + A3 + + + + + text:4 + + + A4 + + + + + text:5 + + + A5 + + + + + text:6 + + + A6 + + + + + text:7 + + + A7 + + + + + text:8 + + + A8 + + + + + text:9 + + + A9 + + + + + text:10 + + + A10 + + + + + text:11 + + + A11 + + + + + text:12 + + + A12 + + + + + text:13 + + + A13 + + + + + text:14 + + + A14 + + + + + text:15 + + + A15 + + + + + text:22 + + 22 + + + text:24 + + 24 + + + text:26 + + 26 + + + text:28 + + 28 + + + text:30 + + 30 + + + text:31 + + 31 + + + text:32 + + 32 + + + text:33 + + 33 + + + text:34 + + 34 + + + text:35 + + 35 + + + text:36 + + 36 + + + text:37 + + 37 + + + text:38 + + 38 + + + text:39 + + 39 + + + text:41 + + 41 + + + text:40 + + 40 + + + text:43 + + 43 + + + text:42 + + 42 + + + text:45 + + 45 + + + text:47 + + 47 + + + text:49 + + 49 + + + text:51 + + 51 + + + text:44 + + 44 + + + text:46 + + 46 + + + text:50 + + 50 + + + text:48 + + 48 + + + text:53 + + 53 + + + text:52 + + 52 + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C10 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:C12 + + package:C0603-ROUND + + + + element:C13 + + package:C0603-ROUND + + + + element:C14 + + package:C0603-ROUND + + + + element:C15 + + package:C0603-ROUND + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:FD4 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:L + + text:L + + L + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RN1 + + package:CAT16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:RN5 + + package:CAT16 + + + + element:RX + + text:RX + + RX + + + + element:TX + + text:TX + + TX + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + +text:ANALOG IN +ANALOG IN + + + COMMUNICATION + +text:ANALOG IN +POWER + + + + NC + + + + + + + GND + + + + + + + TX0 + + + + + + + RX0 + + + + + + + RESET + + + + + + + + 3V3 + + + + + + + 5V + + +text:VIN +VIN +text:GND +GND +text:GND +GND + + + + SDA 20 + + + + + + + SCL 21 + + + + + + + TX3 16 + + + + + + + RX3 17 + + + + + + + RX5 15 + + + +text:TX3 + + + TX5 14 + + + + + + RX2 19 + + + + + + + TX2 18 + + + +text:MADE IN +text:ITALY + + + + PWM + + +text:5V +3V3 +text:GND +GND +text:DIGITAL + + + + DIGITAL + + + +text:MEGA 2560 +text:M.Banzi +text:D.Cuartielles +text:D.Mellis +text:G.Martino +text:T.Igoe +text:SDA +text:SCL +element:C1 + + package:C0603-ROUND + +element:C2 + + package:C0603-ROUND + +element:C3 + + package:C0603-ROUND + +element:C4 + + package:C0603-ROUND + +element:C5 + + package:C0603-ROUND + +element:C6 + + package:C0603-ROUND + +element:C7 + + package:C0603-ROUND + +element:C8 + + package:C0603-ROUND + +element:C9 + + package:C0603-ROUND + +element:C10 + + package:C0603-ROUND + +element:C11 + + package:C0603-ROUND + +element:C12 + + package:C0603-ROUND + +element:C13 + + package:C0603-ROUND + +element:C14 + + package:C0603-ROUND + +element:C15 + + package:C0603-ROUND + +element:D1 + + package:SMB + +element:D2 + + package:MINIMELF + +element:D3 + + package:MINIMELF + +element:F1 + + package:L1812 + +element:FD1 + + package:FIDUCIA-MOUNT + +element:FD2 + + package:FIDUCIA-MOUNT + +element:FD3 + + package:FIDUCIA-MOUNT + +element:FD4 + + package:FIDUCIA-MOUNT + +element:GROUND + + package:SJ + +element:IC3 + + package:TQFP100 + +element:IC4 + + package:MLF32 + +element:IC6 + + package:SOT23-DBV + +element:IC7 + + package:MSOP08 + +element:L + + package:CHIP-LED0805 + +element:L1 + + package:0805 + +element:ON +element:R1 + + package:R0603-ROUND + +element:R2 + + package:R0603-ROUND + +element:RN1 + + package:CAT16 + +element:RN2 + + package:CAY16 + +element:RN3 + + package:CAY16 + +element:RN4 + + package:CAY16 + +element:RN5 + + package:CAT16 + +element:RX + + package:CHIP-LED0805 + +element:T1 + + package:SOT-23 + +element:TX + + package:CHIP-LED0805 + +element:XIO + + package:2X18 + + text:XIO + + +element:Y1 + + package:RESONATOR + +element:Y2 + + package:QS + +element:Z1 + + package:CT/CN0603 + +element:Z2 + + package:CT/CN0603 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +零知-增强板 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:RESET + + + + + + + + + RESET + + + + + + + + + + + + + + + +LI-PO +USB +UART + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + element:TX + + text:TX + + PWR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STM32 + F4 + + + + + Camera + + + + + + + SWD + + + + + + + SDA 20 + + + + + + + SCL 21 + + + + + + + + 3V3 + + + + + + + + + GND + + + + + + + + + + diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lingzhiMini.svg b/arduino-ide-extension/src/browser/boardImg/icon/lingzhiMini.svg new file mode 100644 index 000000000..af295f549 --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/icon/lingzhiMini.svg @@ -0,0 +1,911 @@ + + + + + + + + + +Reset +1 +TX +RX +GND +5V + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STM32 + F1 + + + + + + +3 +2 +4 +6 +5 +7 +9 +8 +10 +RST + + + + + + + + + + + + + + + + + + + + + + + +12 +14 +13 +3.3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +零知-迷你板 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GND + + + + +3.3 + + + + +0 + + + + +5V +29 + + + + + + + + + + + + + + + + +27 +28 +26 +24 +25 +23 +21 +22 +20 +18 + + + + + + + + + + + + + + + + + + + + + + + +17 +15 +16 +GND +3.3 + + + + +BT0 + + + + +30 + + + + +31 +RST +BT0 + +11 + + +19 + + diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lingzhistandard.svg b/arduino-ide-extension/src/browser/boardImg/icon/lingzhistandard.svg new file mode 100644 index 000000000..acdb78aff --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/icon/lingzhistandard.svg @@ -0,0 +1,3982 @@ + + + + + + arduino_Uno_Rev3-02-TH_breadboard.svg + +Fritzing breadboard generated by brd2svg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +layer 21 + + text:MADE IN + + + text:ITALY + + + text:Prototype + + + text:Limited + + + text:Edition + + + + + + + + + + + + + + + + + + + + + + 13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:L + + text:L + + + + + + + + + L + + + + + + + + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + +layer 25 + + + + + + + + 5V + + + + + + + + text:A0 + + + + + + + + + A0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + text:M.Banzi + + + text:D.Cuartielles + + + text:D.Mellis + + + text:TX + + + + + + + + + TX + + + + + + + + + + text:RX + + + + + + + + + RX + + + + + + + + + + text:G.Martino + + + text:T.Igoe + + + + + + + + + + + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3V3 + + + + + + + + + + + + + + + + + + + + + text:A1 + + + + + + A1 + + + + + + + text:A2 + + + + + + + + + A2 + + + + + + + + + + text:A3 + + + + + + + + + A3 + + + + + + + + + + text:A4 + + + + + + + + + A4 + + + + + + + + + + text:A5 + + + + + + + + + A5 + + + + + + + + + + + + + + + + + + + VIN + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:SDA + + + text:SCL + + + element:AD + + package:1X06 + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:D1 + + package:SMB + + + + element:D2 + + package:MINIMELF + + + + element:D3 + + package:MINIMELF + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:ICSP1 + + package:2X03 + + + + element:IOH + + package:1X10@1 + + + + element:IOL + + package:1X08 + + + + element:JP2 + + package:2X02 + + + + element:L + + package:CHIP-LED0805 + + + + element:L1 + + package:0805 + + + + element:PC1 + + package:PANASONIC_D + + + + element:PC2 + + package:PANASONIC_D + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RESET + + package:TS42 + + + + element:RESET-EN + + package:SJ + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:RX + + package:CHIP-LED0805 + + + + element:T1 + + package:SOT-23 + + + + element:TX + + package:CHIP-LED0805 + + + + element:U1 + + package:SOT223 + + + + element:U2 + + package:SOT23-DBV + + + + element:U3 + + package:MLF32 + + + + element:U5 + + package:MSOP08 + + + + element:X1 + + package:POWERSUPPLY_DC-21MM + + + + element:X2 + + package:PN61729 + + + + element:Y1 + + package:QS + + + + element:Y2 + + package:RESONATOR + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + + + element:ZU4 + + package:DIL28-3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:RESET + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +电源 +模拟输入 +PWR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:# + + + + + + + + + + + + + + + + + + + + + + + + + + text:# + + + + + + + + + + + + + + + + + + + + + + + + + + text:# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +LI-PO +USB +UART + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +21 +22 +23 +25 +27 +29 +31 +24 +26 +28 +30 +32 +34 +36 +GND +33 +35 +37 + + + + + + + + + + + + + + + + + + + + + 14 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +零知-标准板 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STM32 + F1 + + + +数字引脚(PWM~) + diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lz_ble52.svg b/arduino-ide-extension/src/browser/boardImg/icon/lz_ble52.svg new file mode 100644 index 000000000..b4fdd9d5c --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/icon/lz_ble52.svg @@ -0,0 +1,3454 @@ + + + + + + + + arduino_Uno_Rev3-02-TH_breadboard.svg + +Fritzing breadboard generated by brd2svg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +layer 21 + + text:MADE IN + + + text:ITALY + + + text:Prototype + + + text:Limited + + + text:Edition + + + + + + + + + + + + + + + + + + + + + + 13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + +layer 25 + + + + + + + + 5V + + + + + + + + text:A0 + + + + + + + + + A0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + text:M.Banzi + + + text:D.Cuartielles + + + text:D.Mellis + + + text:G.Martino + + + text:T.Igoe + + + + + + + + + + + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3V3 + + + + + + + + + + + + + + + + + + + + + text:A1 + + + + + + A1 + + + + + + + text:A2 + + + + + + + + + A2 + + + + + + + + + + text:A3 + + + + + + + + + A3 + + + + + + + + + + text:A4 + + + + + + + + + A4 + + + + + + + + + + text:A5 + + + + + + + + + A5 + + + + + + + + + + + + + + + + + + + NC + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + text:SDA + + + text:SCL + + + element:AD + + package:1X06 + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:D1 + + package:SMB + + + + element:D2 + + package:MINIMELF + + + + element:D3 + + package:MINIMELF + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:ICSP1 + + package:2X03 + + + + element:IOH + + package:1X10@1 + + + + element:IOL + + package:1X08 + + + + element:JP2 + + package:2X02 + + + + element:L + + package:CHIP-LED0805 + + + + element:L1 + + package:0805 + + + + element:PC1 + + package:PANASONIC_D + + + + element:PC2 + + package:PANASONIC_D + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RESET + + package:TS42 + + + + element:RESET-EN + + package:SJ + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:RX + + package:CHIP-LED0805 + + + + element:T1 + + package:SOT-23 + + + + element:TX + + package:CHIP-LED0805 + + + + element:U1 + + package:SOT223 + + + + element:U2 + + package:SOT23-DBV + + + + element:U3 + + package:MLF32 + + + + element:U5 + + package:MSOP08 + + + + element:X1 + + package:POWERSUPPLY_DC-21MM + + + + element:X2 + + package:PN61729 + + + + element:Y1 + + package:QS + + + + element:Y2 + + package:RESONATOR + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + + + element:ZU4 + + package:DIL28-3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:RESET + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +电源 +模拟输入 + + + + + + + + + + + + + + +LI-PO +UART + + + + + + + + + + + + + + + + + + + + + NC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +零知-BLE52 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nRF52 + + + +数字引脚 + + + + + + + + + + + + + + + + + + + + + SCL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SDA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:A0 + + + + + + + + + SWD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +L +PWR +RX +TX +STDBY + + + + + + + + + + + + + + + + + + + + + + + + + + text:RESET + + + + + + + + + KEY + + + + + + + + + +BEEP + + + + + + + + +Antenna + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lzesp32.svg b/arduino-ide-extension/src/browser/boardImg/icon/lzesp32.svg new file mode 100644 index 000000000..3d2681606 --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/icon/lzesp32.svg @@ -0,0 +1,738 @@ + + + + + + lz-esp8266.svg + + + + + + D23 + + + + + D22 + + + + + TX0 + + + + + RX0 + + + + + D21 + + + + + D19 + + + + + D18 + + + + + D5 + + + + + TX2 + + + + + RX2 + + + + + D4 + + + + + D2 + + + + + D15 + + + + + GND + + + + + 3V3 + + + + + VIN + + + + + GND + + + + + D13 + + + + + D12 + + + + + D14 + + + + + D27 + + + + + VN + + + + + D34 + + + + + D35 + + + + + D32 + + + + + D33 + + + + + VP + + + + + EN + + + + + + + + + FLASH + + + + + + RST + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 零知-ESP32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + D26 + + + + + D25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lzesp8266.png b/arduino-ide-extension/src/browser/boardImg/icon/lzesp8266.png new file mode 100644 index 000000000..3aedf9a3f Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/lzesp8266.png differ diff --git a/arduino-ide-extension/src/browser/boardImg/icon/lzesp8266.svg b/arduino-ide-extension/src/browser/boardImg/icon/lzesp8266.svg new file mode 100644 index 000000000..8f0c26692 --- /dev/null +++ b/arduino-ide-extension/src/browser/boardImg/icon/lzesp8266.svg @@ -0,0 +1,585 @@ + + + + + +D0 +D1 +D2 +D3 +D4 +3V3 +GND +D5 +D6 +D7 +D8 +RX +TX +GND +3V3 +5V +GND +RST +EN +3V3 +GND +RSV +RSV +RSV +RSV +RSV +RSV +A0 + + + + +FLASH + +RST + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +零知-ESP8266 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +3V3 +GND + diff --git a/arduino-ide-extension/src/browser/boardImg/icon/mega.png b/arduino-ide-extension/src/browser/boardImg/icon/mega.png new file mode 100644 index 000000000..0360da4cc Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/mega.png differ diff --git a/arduino-ide-extension/src/browser/boardImg/icon/nano.png b/arduino-ide-extension/src/browser/boardImg/icon/nano.png new file mode 100644 index 000000000..2d51c20f2 Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/nano.png differ diff --git a/arduino-ide-extension/src/browser/boardImg/icon/uno.png b/arduino-ide-extension/src/browser/boardImg/icon/uno.png new file mode 100644 index 000000000..f4293e39a Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/uno.png differ diff --git a/arduino-ide-extension/src/browser/boardImg/icon/unomini.png b/arduino-ide-extension/src/browser/boardImg/icon/unomini.png new file mode 100644 index 000000000..5d1e966ab Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/unomini.png differ diff --git a/arduino-ide-extension/src/browser/boardImg/icon/yun.png b/arduino-ide-extension/src/browser/boardImg/icon/yun.png new file mode 100644 index 000000000..3aedf9a3f Binary files /dev/null and b/arduino-ide-extension/src/browser/boardImg/icon/yun.png differ diff --git a/arduino-ide-extension/src/browser/boards/boards-auto-installer.ts b/arduino-ide-extension/src/browser/boards/boards-auto-installer.ts index 4b0f45e69..6c8684248 100644 --- a/arduino-ide-extension/src/browser/boards/boards-auto-installer.ts +++ b/arduino-ide-extension/src/browser/boards/boards-auto-installer.ts @@ -160,7 +160,7 @@ export class BoardsAutoInstaller implements FrontendApplicationContribution { const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes'); const message = nls.localize( 'arduino/board/installNow', - 'The "{0} {1}" core has to be installed for the currently selected "{2}" board. Do you want to install it now?', + '必须为当前选择的“{2}”板安装“{0}{1}”核心。您想现在安装吗?', candidate.name, version, selectedBoard.name diff --git a/arduino-ide-extension/src/browser/boards/boards-config-component.tsx b/arduino-ide-extension/src/browser/boards/boards-config-component.tsx index f14b8f390..e3a637d9c 100644 --- a/arduino-ide-extension/src/browser/boards/boards-config-component.tsx +++ b/arduino-ide-extension/src/browser/boards/boards-config-component.tsx @@ -246,7 +246,7 @@ export class BoardsConfigComponent extends React.Component< label += details; } if (manuallyInstalled) { - label += nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)'); + label += '(在项目文件夹中)'; } return label; }; diff --git a/arduino-ide-extension/src/browser/boards/boards-config-dialog.tsx b/arduino-ide-extension/src/browser/boards/boards-config-dialog.tsx index 79e5e9183..9e2a90c91 100644 --- a/arduino-ide-extension/src/browser/boards/boards-config-dialog.tsx +++ b/arduino-ide-extension/src/browser/boards/boards-config-dialog.tsx @@ -27,7 +27,7 @@ import { BoardsConfigComponent } from './boards-config-component'; import { BoardsServiceProvider } from './boards-service-provider'; @injectable() -export class BoardsConfigDialogProps extends DialogProps {} +export class BoardsConfigDialogProps extends DialogProps { } export type BoardsConfigDialogState = Omit & { selectedBoard: BoardsConfig['selectedBoard'] | BoardWithPackage; @@ -81,9 +81,9 @@ export class BoardsConfigDialog extends ReactDialog { this.node.id = 'select-board-dialog-container'; this.contentNode.classList.add('select-board-dialog'); this.appendCloseButton( - nls.localize('vscode/issueMainService/cancel', 'Cancel') + nls.localize('vscode/issueMainService/cancel', '取消') ); - this.appendAcceptButton(nls.localize('vscode/issueMainService/ok', 'OK')); + this.appendAcceptButton(nls.localize('vscode/issueMainService/ok', '确定')); this._boardsConfig = emptyBoardsConfig(); this.onFilterTextDidChangeEmitter = new Emitter(); } @@ -132,12 +132,7 @@ export class BoardsConfigDialog extends ReactDialog { <>
-
- {nls.localize( - 'arduino/board/configDialog1', - 'Select both a Board and a Port if you want to upload a sketch.' - )} -
+
{'如果要上传项目,请选择开发板和端口。'}
{nls.localize( 'arduino/board/configDialog2', diff --git a/arduino-ide-extension/src/browser/boards/boards-data-store.ts b/arduino-ide-extension/src/browser/boards/boards-data-store.ts index d4204c703..88a8740fc 100644 --- a/arduino-ide-extension/src/browser/boards/boards-data-store.ts +++ b/arduino-ide-extension/src/browser/boards/boards-data-store.ts @@ -42,10 +42,9 @@ export interface SelectConfigOptionParams { @injectable() export class BoardsDataStore implements - FrontendApplicationContribution, - StartupTaskProvider, - CommandContribution -{ + FrontendApplicationContribution, + StartupTaskProvider, + CommandContribution { @inject(ILogger) @named('store') private readonly logger: ILogger; @@ -433,5 +432,5 @@ export interface BoardsDataStoreChangeEvent { } const USE_INHERITED_DATA: Command = { - id: 'arduino-use-inherited-boards-data', + id: 'lingzhi-use-inherited-boards-data', }; diff --git a/arduino-ide-extension/src/browser/boards/boards-list-widget.ts b/arduino-ide-extension/src/browser/boards/boards-list-widget.ts index 7067225dc..d64e77e4c 100644 --- a/arduino-ide-extension/src/browser/boards/boards-list-widget.ts +++ b/arduino-ide-extension/src/browser/boards/boards-list-widget.ts @@ -26,7 +26,7 @@ export class BoardsListWidget extends ListWidget { super({ id: BoardsListWidget.WIDGET_ID, label: BoardsListWidget.WIDGET_LABEL, - iconClass: 'fa fa-arduino-boards', + iconClass: 'fa lingzhi-circuitcomposer', searchable: service, installable: service, itemLabel: (item: BoardsPackage) => item.name, @@ -62,7 +62,7 @@ export class BoardsListWidget extends ListWidget { this.messageService.info( nls.localize( 'arduino/board/succesfullyInstalledPlatform', - 'Successfully installed platform {0}:{1}', + '成功安装平台{0}:{1}', item.name, version ), @@ -81,7 +81,7 @@ export class BoardsListWidget extends ListWidget { this.messageService.info( nls.localize( 'arduino/board/succesfullyUninstalledPlatform', - 'Successfully uninstalled platform {0}:{1}', + '成功卸载平台{0}:{1}', item.name, item.installedVersion! ), diff --git a/arduino-ide-extension/src/browser/boards/boards-service-provider.ts b/arduino-ide-extension/src/browser/boards/boards-service-provider.ts index 29bccb242..6ca38b1fe 100644 --- a/arduino-ide-extension/src/browser/boards/boards-service-provider.ts +++ b/arduino-ide-extension/src/browser/boards/boards-service-provider.ts @@ -93,7 +93,7 @@ export type UpdateBoardsConfigParams = | 'unset-board' | PortIdentifier | (Readonly> & - Readonly<{ reason?: UpdateBoardsConfigReason }>); + Readonly<{ reason?: UpdateBoardsConfigReason }>); type HistoryDidNotChange = undefined; type HistoryDidDelete = Readonly<{ [portKey: string]: undefined }>; @@ -165,9 +165,8 @@ export class BoardListDumper implements Disposable { dump(boardList: BoardList): void { if (!this.outputChannel) { - this.outputChannel = this.outputChannelManager.getChannel( - 'Developer (Arduino)' - ); + this.outputChannel = + this.outputChannelManager.getChannel('Developer (LinZhi)'); } this.outputChannel.show({ preserveFocus: true }); this.outputChannel.append(boardList.toString() + '\n'); @@ -181,10 +180,9 @@ export class BoardListDumper implements Disposable { @injectable() export class BoardsServiceProvider implements - FrontendApplicationContribution, - StartupTaskProvider, - CommandContribution -{ + FrontendApplicationContribution, + StartupTaskProvider, + CommandContribution { @inject(ILogger) private readonly logger: ILogger; @inject(MessageService) @@ -331,7 +329,7 @@ export class BoardsServiceProvider ): Promise { const boardsConfig = await this.commandService.executeCommand< BoardsConfig | undefined - >('arduino-open-boards-dialog', params); + >('lingzhi-open-boards-dialog', params); if (boardsConfig) { this.update({ boardsConfig }, 'dialog'); } @@ -374,7 +372,7 @@ export class BoardsServiceProvider !portIdentifierEquals(portToSelect, previousSelectedPort); const boardDidChangeEvent = boardDidChange ? // The change event must always contain any custom board options. Hence the board to select is not sanitized. - { selectedBoard: boardToSelect, previousSelectedBoard } + { selectedBoard: boardToSelect, previousSelectedBoard } : undefined; const portDidChangeEvent = portDidChange ? { selectedPort: portToSelect, previousSelectedPort } @@ -520,23 +518,23 @@ export class BoardsServiceProvider installedSelectedBoard ? installedSelectedBoard : 'unset-board' ); if (!installedSelectedBoard) { - const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes'); - const answer = await this.messageService.warn( - nls.localize( - 'arduino/board/couldNotFindPreviouslySelected', - "Could not find previously selected board '{0}' in installed platform '{1}'. Please manually reselect the board you want to use. Do you want to reselect it now?", - selectedBoard.name, - platformDidInstallEvent.item.name - ), - nls.localize('arduino/board/reselectLater', 'Reselect later'), - yes - ); - if (answer === yes) { - this.onBoardsConfigEdit({ - query: selectedBoard.name, - portToSelect: this._boardsConfig.selectedPort, - }); - } + // const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes'); + // const answer = await this.messageService.warn( + // nls.localize( + // 'arduino/board/couldNotFindPreviouslySelected', + // '无法在安装的平台‘{1}’中找到先前选择的‘{0}’板。请手动重新选择要使用的单板。您现在要重新选择吗?', + // selectedBoard.name, + // platformDidInstallEvent.item.name + // ), + // nls.localize('arduino/board/reselectLater', '重新选择'), + // yes + // ); + // if (answer === yes) { + // this.onBoardsConfigEdit({ + // query: selectedBoard.name, + // portToSelect: this._boardsConfig.selectedPort, + // }); + // } } } } @@ -549,13 +547,13 @@ export class BoardsServiceProvider const selectedPort = isPortIdentifier(portToSelect) ? portToSelect : portToSelect === 'ignore-port' - ? this._boardsConfig.selectedPort - : undefined; + ? this._boardsConfig.selectedPort + : undefined; const selectedBoard = isBoardIdentifier(boardToSelect) ? boardToSelect : boardToSelect === 'ignore-board' - ? this._boardsConfig.selectedBoard - : undefined; + ? this._boardsConfig.selectedBoard + : undefined; if (selectedBoard && selectedPort) { const match = this.boardList.items.find( (item) => @@ -668,13 +666,13 @@ export class BoardsServiceProvider * For example, the new window already has a valid boards config persisted to the local storage. */ const USE_INHERITED_CONFIG: Command = { - id: 'arduino-use-inherited-boards-config', + id: 'lingzhi-use-inherited-boards-config', }; const DUMP_BOARD_LIST: Command = { id: 'arduino-dump-board-list', label: nls.localize('arduino/developer/dumpBoardList', 'Dump the Board List'), - category: 'Developer (Arduino)', + category: 'Developer (LinZhi)', }; const CLEAR_BOARD_LIST_HISTORY: Command = { @@ -683,14 +681,11 @@ const CLEAR_BOARD_LIST_HISTORY: Command = { 'arduino/developer/clearBoardList', 'Clear the Board List History' ), - category: 'Developer (Arduino)', + category: 'Developer (LinZhi)', }; const CLEAR_BOARDS_CONFIG: Command = { id: 'arduino-clear-boards-config', - label: nls.localize( - 'arduino/developer/clearBoardsConfig', - 'Clear the Board and Port Selection' - ), - category: 'Developer (Arduino)', + label: '清除已经选择的开发板和连接端口s', + category: 'Developer (LinZhi)', }; diff --git a/arduino-ide-extension/src/browser/boards/boards-toolbar-item.tsx b/arduino-ide-extension/src/browser/boards/boards-toolbar-item.tsx index e2311fb1d..942b96f92 100644 --- a/arduino-ide-extension/src/browser/boards/boards-toolbar-item.tsx +++ b/arduino-ide-extension/src/browser/boards/boards-toolbar-item.tsx @@ -188,10 +188,7 @@ export class BoardListDropDown extends React.Component {
handleOnClick(event, () => boardList.edit(edit.params)) } diff --git a/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts b/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts index c64d08690..32ce058ba 100644 --- a/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts +++ b/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts @@ -18,7 +18,7 @@ export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendCont widgetName: BoardsListWidget.WIDGET_LABEL, defaultWidgetOptions: { area: 'left', - rank: 2, + rank: 3, }, toggleCommandId: `${BoardsListWidget.WIDGET_ID}:toggle`, toggleKeybinding: 'CtrlCmd+Shift+B', diff --git a/arduino-ide-extension/src/browser/config/config-service-client.ts b/arduino-ide-extension/src/browser/config/config-service-client.ts index 65e678180..e77479d2d 100644 --- a/arduino-ide-extension/src/browser/config/config-service-client.ts +++ b/arduino-ide-extension/src/browser/config/config-service-client.ts @@ -96,7 +96,8 @@ export class ConfigServiceClient implements FrontendApplicationContribution { if (this.config.messages?.length) { const message = this.config.messages.join(' '); // toast the error later otherwise it might not show up in IDE2 - setTimeout(() => this.messageService.error(message), 1_000); + // setTimeout(() => this.messageService.error(message), 1_000); + setTimeout(() => console.error(message), 1_000); } } } diff --git a/arduino-ide-extension/src/browser/contributions/about.ts b/arduino-ide-extension/src/browser/contributions/about.ts index 201d13b41..1954bf342 100644 --- a/arduino-ide-extension/src/browser/contributions/about.ts +++ b/arduino-ide-extension/src/browser/contributions/about.ts @@ -31,34 +31,41 @@ export class About extends Contribution { commandId: About.Commands.ABOUT_APP.id, label: nls.localize( 'arduino/about/label', - 'About {0}', + '关于 {0}', this.applicationName ), order: '0', }); } + // 定义一个异步方法,用于显示关于信息 private async showAbout(): Promise { + // 获取应用程序信息 const appInfo = await this.appService.info(); + // 解构赋值,获取应用程序版本、CLI版本、构建日期 const { appVersion, cliVersion, buildDate } = appInfo; + // 定义一个函数,用于生成详细信息 const detail = (showAll: boolean) => nls.localize( 'arduino/about/detail', - 'Version: {0}\nDate: {1}{2}\nCLI Version: {3}\n\n{4}', + '版本 : {0}\nDate: {1}{2}\nCLI Version: {3}\n\n{4}', appVersion, buildDate ? buildDate : nls.localize('', 'dev build'), buildDate && showAll ? ` (${this.ago(buildDate)})` : '', cliVersion, nls.localize( 'arduino/about/copyright', - 'Copyright © {0} Arduino SA', + '版权 © {0} 零知实验室', new Date().getFullYear().toString() ) ); - const ok = nls.localize('vscode/issueMainService/ok', 'OK'); - const copy = nls.localize('vscode/textInputActions/copy', 'Copy'); + // 定义确定按钮和复制按钮的文本 + const ok = nls.localize('vscode/issueMainService/ok', '确定'); + const copy = nls.localize('vscode/textInputActions/copy', '复制'); + // 根据操作系统,确定按钮的顺序 const buttons = !isWindows && !isOSX ? [copy, ok] : [ok, copy]; + // 显示消息框,包含应用程序名称、详细信息、按钮等 const { response } = await this.dialogService.showMessageBox({ message: `${this.applicationName}`, title: `${this.applicationName}`, @@ -70,6 +77,7 @@ export class About extends Contribution { cancelId: buttons.indexOf(ok), }); + // 如果点击了复制按钮,则将详细信息复制到剪贴板 if (buttons[response] === copy) { await this.clipboardService.writeText(detail(false).trim()); } @@ -86,91 +94,91 @@ export class About extends Contribution { if (result < 60) { return result === 1 ? nls.localize( - 'vscode/date/date.fromNow.minutes.singular.ago', - '{0} minute ago', - result.toString() - ) + 'vscode/date/date.fromNow.minutes.singular.ago', + '{0} minute ago', + result.toString() + ) : nls.localize( - 'vscode/date/date.fromNow.minutes.plural.ago', - '{0} minutes ago', - result.toString() - ); + 'vscode/date/date.fromNow.minutes.plural.ago', + '{0} minutes ago', + result.toString() + ); } result = now.diff(other, 'hour'); if (result < 25) { return result === 1 ? nls.localize( - 'vscode/date/date.fromNow.hours.singular.ago', - '{0} hour ago', - result.toString() - ) + 'vscode/date/date.fromNow.hours.singular.ago', + '{0} hour ago', + result.toString() + ) : nls.localize( - 'vscode/date/date.fromNow.hours.plural.ago', - '{0} hours ago', - result.toString() - ); + 'vscode/date/date.fromNow.hours.plural.ago', + '{0} hours ago', + result.toString() + ); } result = now.diff(other, 'day'); if (result < 8) { return result === 1 ? nls.localize( - 'vscode/date/date.fromNow.days.singular.ago', - '{0} day ago', - result.toString() - ) + 'vscode/date/date.fromNow.days.singular.ago', + '{0} day ago', + result.toString() + ) : nls.localize( - 'vscode/date/date.fromNow.days.plural.ago', - '{0} days ago', - result.toString() - ); + 'vscode/date/date.fromNow.days.plural.ago', + '{0} days ago', + result.toString() + ); } result = now.diff(other, 'week'); if (result < 5) { return result === 1 ? nls.localize( - 'vscode/date/date.fromNow.weeks.singular.ago', - '{0} week ago', - result.toString() - ) + 'vscode/date/date.fromNow.weeks.singular.ago', + '{0} week ago', + result.toString() + ) : nls.localize( - 'vscode/date/date.fromNow.weeks.plural.ago', - '{0} weeks ago', - result.toString() - ); + 'vscode/date/date.fromNow.weeks.plural.ago', + '{0} weeks ago', + result.toString() + ); } result = now.diff(other, 'month'); if (result < 13) { return result === 1 ? nls.localize( - 'vscode/date/date.fromNow.months.singular.ago', - '{0} month ago', - result.toString() - ) + 'vscode/date/date.fromNow.months.singular.ago', + '{0} month ago', + result.toString() + ) : nls.localize( - 'vscode/date/date.fromNow.months.plural.ago', - '{0} months ago', - result.toString() - ); + 'vscode/date/date.fromNow.months.plural.ago', + '{0} months ago', + result.toString() + ); } result = now.diff(other, 'year'); return result === 1 ? nls.localize( - 'vscode/date/date.fromNow.years.singular.ago', - '{0} year ago', - result.toString() - ) + 'vscode/date/date.fromNow.years.singular.ago', + '{0} year ago', + result.toString() + ) : nls.localize( - 'vscode/date/date.fromNow.years.plural.ago', - '{0} years ago', - result.toString() - ); + 'vscode/date/date.fromNow.years.plural.ago', + '{0} years ago', + result.toString() + ); } } export namespace About { export namespace Commands { export const ABOUT_APP: Command = { - id: 'arduino-about', + id: 'lingzhi-about', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/account.ts b/arduino-ide-extension/src/browser/contributions/account.ts index a8f728de2..fe16650bc 100644 --- a/arduino-ide-extension/src/browser/contributions/account.ts +++ b/arduino-ide-extension/src/browser/contributions/account.ts @@ -1,24 +1,17 @@ -import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; import { SidebarMenu } from '@theia/core/lib/browser/shell/sidebar-menu-widget'; import { WindowService } from '@theia/core/lib/browser/window/window-service'; import { DisposableCollection } from '@theia/core/lib/common/disposable'; -import { MenuPath } from '@theia/core/lib/common/menu'; import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; -import { CloudUserCommands, LEARN_MORE_URL } from '../auth/cloud-user-commands'; +import { LEARN_MORE_URL } from '../auth/cloud-user-commands'; import { CreateFeatures } from '../create/create-features'; import { ArduinoMenus } from '../menu/arduino-menus'; import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service'; -import { - Command, - CommandRegistry, - Contribution, - MenuModelRegistry, -} from './contribution'; +import { Command, CommandRegistry, Contribution } from './contribution'; export const accountMenu: SidebarMenu = { id: 'arduino-accounts-menu', - iconClass: 'codicon codicon-account', + iconClass: 'fa lingzhi-account', title: nls.localize('arduino/account/menuTitle', 'Arduino Cloud'), menuPath: ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT, order: 0, @@ -34,17 +27,17 @@ export class Account extends Contribution { private readonly connectionStatus: ApplicationConnectionStatusContribution; private readonly toDispose = new DisposableCollection(); - private app: FrontendApplication; + // private app: FrontendApplication; - override onStart(app: FrontendApplication): void { - this.app = app; - this.updateSidebarCommand(); - this.toDispose.push( - this.createFeatures.onDidChangeEnabled((enabled) => - this.updateSidebarCommand(enabled) - ) - ); - } + // override onStart(app: FrontendApplication): void { + // this.app = app; + // this.updateSidebarCommand(); + // this.toDispose.push( + // this.createFeatures.onDidChangeEnabled((enabled) => + // this.updateSidebarCommand(enabled) + // ) + // ); + // } onStop(): void { this.toDispose.dispose(); @@ -78,78 +71,78 @@ export class Account extends Contribution { }); } - override registerMenus(registry: MenuModelRegistry): void { - const register = ( - menuPath: MenuPath, - ...commands: (Command | [command: Command, menuLabel: string])[] - ) => - commands.forEach((command, index) => { - const commandId = Array.isArray(command) ? command[0].id : command.id; - const label = Array.isArray(command) ? command[1] : command.label; - registry.registerMenuAction(menuPath, { - label, - commandId, - order: String(index), - }); - }); + // override registerMenus(registry: MenuModelRegistry): void { + // const register = ( + // menuPath: MenuPath, + // ...commands: (Command | [command: Command, menuLabel: string])[] + // ) => + // commands.forEach((command, index) => { + // const commandId = Array.isArray(command) ? command[0].id : command.id; + // const label = Array.isArray(command) ? command[1] : command.label; + // registry.registerMenuAction(menuPath, { + // label, + // commandId, + // order: String(index), + // }); + // }); - register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_IN_GROUP, [ - CloudUserCommands.LOGIN, - nls.localize('arduino/cloud/signInToCloud', 'Sign in to Arduino Cloud'), - ]); - register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__LEARN_MORE_GROUP, [ - Account.Commands.LEARN_MORE, - nls.localize('arduino/cloud/learnMore', 'Learn more'), - ]); - register( - ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__GO_TO_GROUP, - [ - Account.Commands.GO_TO_PROFILE, - nls.localize('arduino/account/goToProfile', 'Go to Profile'), - ], - [ - Account.Commands.GO_TO_CLOUD_EDITOR, - nls.localize('arduino/account/goToCloudEditor', 'Go to Cloud Editor'), - ], - [ - Account.Commands.GO_TO_IOT_CLOUD, - nls.localize('arduino/account/goToIoTCloud', 'Go to IoT Cloud'), - ] - ); - register( - ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_OUT_GROUP, - CloudUserCommands.LOGOUT - ); - } + // register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_IN_GROUP, [ + // CloudUserCommands.LOGIN, + // nls.localize('arduino/cloud/signInToCloud', 'Sign in to Arduino Cloud'), + // ]); + // register(ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__LEARN_MORE_GROUP, [ + // Account.Commands.LEARN_MORE, + // nls.localize('arduino/cloud/learnMore', 'Learn more'), + // ]); + // register( + // ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__GO_TO_GROUP, + // [ + // Account.Commands.GO_TO_PROFILE, + // nls.localize('arduino/account/goToProfile', 'Go to Profile'), + // ], + // [ + // Account.Commands.GO_TO_CLOUD_EDITOR, + // nls.localize('arduino/account/goToCloudEditor', 'Go to Cloud Editor'), + // ], + // [ + // Account.Commands.GO_TO_IOT_CLOUD, + // nls.localize('arduino/account/goToIoTCloud', 'Go to IoT Cloud'), + // ] + // ); + // register( + // ArduinoMenus.ARDUINO_ACCOUNT__CONTEXT__SIGN_OUT_GROUP, + // CloudUserCommands.LOGOUT + // ); + // } - private updateSidebarCommand( - visible: boolean = this.preferences['arduino.cloud.enabled'] - ): void { - if (!this.app) { - return; - } - const handler = this.app.shell.leftPanelHandler; - if (visible) { - handler.addBottomMenu(accountMenu); - } else { - handler.removeBottomMenu(accountMenu.id); - } - } + // private updateSidebarCommand( + // visible: boolean = this.preferences['arduino.cloud.enabled'] + // ): void { + // if (!this.app) { + // return; + // } + // const handler = this.app.shell.leftPanelHandler; + // if (visible) { + // handler.addBottomMenu(accountMenu); + // } else { + // handler.removeBottomMenu(accountMenu.id); + // } + // } } export namespace Account { export namespace Commands { export const GO_TO_PROFILE: Command = { - id: 'arduino-go-to-profile', + id: 'lingzhi-go-to-profile', }; export const GO_TO_CLOUD_EDITOR: Command = { - id: 'arduino-go-to-cloud-editor', + id: 'lingzhi-go-to-cloud-editor', }; export const GO_TO_IOT_CLOUD: Command = { - id: 'arduino-go-to-iot-cloud', + id: 'lingzhi-go-to-iot-cloud', }; export const LEARN_MORE: Command = { - id: 'arduino-learn-more', + id: 'lingzhi-learn-more', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/add-file.ts b/arduino-ide-extension/src/browser/contributions/add-file.ts index da1796048..9dcc7d981 100644 --- a/arduino-ide-extension/src/browser/contributions/add-file.ts +++ b/arduino-ide-extension/src/browser/contributions/add-file.ts @@ -26,7 +26,8 @@ export class AddFile extends SketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.SKETCH__UTILS_GROUP, { commandId: AddFile.Commands.ADD_FILE.id, - label: nls.localize('arduino/contributions/addFile', 'Add File') + '...', + + label: '添加文件...', order: '2', }); } @@ -37,7 +38,7 @@ export class AddFile extends SketchContribution { return; } const toAddUri = await this.fileDialogService.showOpenDialog({ - title: nls.localize('arduino/contributions/addFile', 'Add File'), + title: '添加文件', canSelectFiles: true, canSelectFolders: false, canSelectMany: false, @@ -51,10 +52,10 @@ export class AddFile extends SketchContribution { if (exists) { const { response } = await this.dialogService.showMessageBox({ type: 'question', - title: nls.localize('arduino/contributions/replaceTitle', 'Replace'), + title: nls.localize('arduino/contributions/replaceTitle', '替换'), buttons: [ - nls.localize('vscode/issueMainService/cancel', 'Cancel'), - nls.localize('vscode/issueMainService/ok', 'OK'), + nls.localize('vscode/issueMainService/cancel', '取消'), + nls.localize('vscode/issueMainService/ok', '确定'), ], message: nls.localize( 'arduino/replaceMsg', @@ -71,7 +72,7 @@ export class AddFile extends SketchContribution { this.messageService.info( nls.localize( 'arduino/contributions/fileAdded', - 'One file added to the sketch.' + '在草图中添加了一个文件。' ), { timeout: 2000, @@ -99,7 +100,7 @@ export class AddFile extends SketchContribution { export namespace AddFile { export namespace Commands { export const ADD_FILE: Command = { - id: 'arduino-add-file', + id: 'lingzhi-add-file', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/add-zip-library.ts b/arduino-ide-extension/src/browser/contributions/add-zip-library.ts index b765f9681..7b9b9cf1c 100644 --- a/arduino-ide-extension/src/browser/contributions/add-zip-library.ts +++ b/arduino-ide-extension/src/browser/contributions/add-zip-library.ts @@ -1,15 +1,9 @@ import { inject, injectable } from '@theia/core/shared/inversify'; import URI from '@theia/core/lib/common/uri'; import { ConfirmDialog } from '@theia/core/lib/browser/dialogs'; -import { ArduinoMenus } from '../menu/arduino-menus'; import { LibraryService, ResponseServiceClient } from '../../common/protocol'; import { ExecuteWithProgress } from '../../common/protocol/progressible'; -import { - SketchContribution, - Command, - CommandRegistry, - MenuModelRegistry, -} from './contribution'; +import { SketchContribution, Command, CommandRegistry } from './contribution'; import { nls } from '@theia/core/lib/common'; @injectable() @@ -26,17 +20,17 @@ export class AddZipLibrary extends SketchContribution { }); } - override registerMenus(registry: MenuModelRegistry): void { - const includeLibMenuPath = [ - ...ArduinoMenus.SKETCH__UTILS_GROUP, - '0_include', - ]; - registry.registerMenuAction([...includeLibMenuPath, '1_install'], { - commandId: AddZipLibrary.Commands.ADD_ZIP_LIBRARY.id, - label: nls.localize('arduino/library/addZip', 'Add .ZIP Library...'), - order: '1', - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // const includeLibMenuPath = [ + // ...ArduinoMenus.SKETCH__UTILS_GROUP, + // '0_include', + // ]; + // registry.registerMenuAction([...includeLibMenuPath, '1_install'], { + // commandId: AddZipLibrary.Commands.ADD_ZIP_LIBRARY.id, + // label: nls.localize('arduino/library/addZip', 'Add .ZIP Library...'), + // order: '1', + // }); + // } private async addZipLibrary(): Promise { const homeUri = await this.envVariableServer.getHomeDirUri(); @@ -83,7 +77,7 @@ export class AddZipLibrary extends SketchContribution { await ExecuteWithProgress.doWithProgress({ messageService: this.messageService, progressText: - nls.localize('arduino/common/processing', 'Processing') + + nls.localize('arduino/common/processing', '处理') + ` ${new URI(zipUri).path.base}`, responseService: this.responseService, run: () => this.libraryService.installZip({ zipUri, overwrite }), @@ -91,7 +85,7 @@ export class AddZipLibrary extends SketchContribution { this.messageService.info( nls.localize( 'arduino/library/successfullyInstalledZipLibrary', - 'Successfully installed library from {0} archive', + '从{0}存档成功安装库', new URI(zipUri).path.base ), { timeout: 3000 } @@ -105,7 +99,7 @@ export class AddZipLibrary extends SketchContribution { throw new AlreadyInstalledError( nls.localize( 'arduino/library/namedLibraryAlreadyExists', - 'A library folder named {0} already exists. Do you want to overwrite it?', + '已存在名为{0}的库文件夹。您想要覆盖它吗?', name ), name @@ -114,13 +108,15 @@ export class AddZipLibrary extends SketchContribution { throw new AlreadyInstalledError( nls.localize( 'arduino/library/libraryAlreadyExists', - 'A library already exists. Do you want to overwrite it?' + '库已经存在。您想要覆盖它吗?' ) ); } } } - this.messageService.error(error.toString()); + // this.messageService.error(error.toString()); + const chunk = `${error.toString()}\n`; + this.responseService.appendToOutput({ chunk }); throw error; } } @@ -136,7 +132,7 @@ class AlreadyInstalledError extends Error { export namespace AddZipLibrary { export namespace Commands { export const ADD_ZIP_LIBRARY: Command = { - id: 'arduino-add-zip-library', + id: 'lingzhi-add-zip-library', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/archive-sketch.ts b/arduino-ide-extension/src/browser/contributions/archive-sketch.ts index f49f85caf..abf989c66 100644 --- a/arduino-ide-extension/src/browser/contributions/archive-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/archive-sketch.ts @@ -21,7 +21,7 @@ export class ArchiveSketch extends SketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.TOOLS__MAIN_GROUP, { commandId: ArchiveSketch.Commands.ARCHIVE_SKETCH.id, - label: nls.localize('arduino/sketch/archiveSketch', 'Archive Sketch'), + label: '项目存档', order: '1', }); } @@ -39,10 +39,7 @@ export class ArchiveSketch extends SketchContribution { const defaultUri = defaultContainerUri.resolve(archiveBasename); const defaultPath = await this.fileService.fsPath(defaultUri); const { filePath, canceled } = await this.dialogService.showSaveDialog({ - title: nls.localize( - 'arduino/sketch/saveSketchAs', - 'Save sketch folder as...' - ), + title: '将项目文件夹另存为…', defaultPath, }); if (!filePath || canceled) { @@ -56,7 +53,7 @@ export class ArchiveSketch extends SketchContribution { this.messageService.info( nls.localize( 'arduino/sketch/createdArchive', - "Created archive '{0}'.", + "创建存档 '{0}'.", archiveBasename ), { @@ -69,7 +66,7 @@ export class ArchiveSketch extends SketchContribution { export namespace ArchiveSketch { export namespace Commands { export const ARCHIVE_SKETCH: Command = { - id: 'arduino-archive-sketch', + id: 'lingzhi-archive-sketch', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/board-selection.ts b/arduino-ide-extension/src/browser/contributions/board-selection.ts index f9c2d2b36..19ece176e 100644 --- a/arduino-ide-extension/src/browser/contributions/board-selection.ts +++ b/arduino-ide-extension/src/browser/contributions/board-selection.ts @@ -22,41 +22,58 @@ import type { BoardList } from '../../common/protocol/board-list'; import { BoardsListWidget } from '../boards/boards-list-widget'; import { BoardsDataStore } from '../boards/boards-data-store'; import { BoardsServiceProvider } from '../boards/boards-service-provider'; -import { - ArduinoMenus, - PlaceholderMenuNode, - unregisterSubmenu, -} from '../menu/arduino-menus'; +import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus'; import { NotificationCenter } from '../notification-center'; import { Command, CommandRegistry, SketchContribution } from './contribution'; +import { SidebarMenu } from '@theia/core/lib/browser/shell/sidebar-menu-widget'; +import { CreateFeatures } from '../create/create-features'; +import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; + +export const PortMenu: SidebarMenu = { + id: 'arduino-port-sketch', + iconClass: 'fa lingzhi-connect-left', + title: '连接', + menuPath: ['100_serial'], + order: 3, +}; @injectable() export class BoardSelection extends SketchContribution { + // 注入 CommandRegistry,用于注册命令 @inject(CommandRegistry) private readonly commandRegistry: CommandRegistry; + // 注入 MainMenuManager,用于管理主菜单 @inject(MainMenuManager) private readonly mainMenuManager: MainMenuManager; + // 注入 MenuModelRegistry,用于管理菜单模型 @inject(MenuModelRegistry) private readonly menuModelRegistry: MenuModelRegistry; + // 注入 NotificationCenter,用于接收通知 @inject(NotificationCenter) private readonly notificationCenter: NotificationCenter; @inject(BoardsDataStore) private readonly boardsDataStore: BoardsDataStore; + // 注入 BoardsService,用于与开发板服务进行交互 @inject(BoardsService) private readonly boardsService: BoardsService; + // 注入 BoardsServiceProvider,用于获取开发板列表等信息 @inject(BoardsServiceProvider) private readonly boardsServiceProvider: BoardsServiceProvider; + // 用于在菜单重建前处理可弃用对象的集合 private readonly toDisposeBeforeMenuRebuild = new DisposableCollection(); - // do not query installed platforms on every change + // 不每次改变时都查询已安装的平台 private _installedBoards: Deferred | undefined; + // 重写 SketchContribution 的 registerCommands 方法 override registerCommands(registry: CommandRegistry): void { registry.registerCommand(BoardSelection.Commands.GET_BOARD_INFO, { + // 当执行获取开发板信息的命令时的操作 execute: async () => { const boardInfo = await getBoardInfo( this.boardsServiceProvider.boardList ); + // 如果返回的是字符串,说明没有获取到具体的开发板信息,显示信息提示 if (typeof boardInfo === 'string') { this.messageService.info(boardInfo); return; @@ -73,7 +90,7 @@ SN: ${SN} title: nls.localize('arduino/board/boardInfo', 'Board Info'), type: 'info', detail, - buttons: [nls.localize('vscode/issueMainService/ok', 'OK')], + buttons: [nls.localize('vscode/issueMainService/ok', '确定')], }); }, }); @@ -102,30 +119,49 @@ SN: ${SN} }); } - override onStart(): void { + @inject(CreateFeatures) + private app: FrontendApplication; + + // 重写 SketchContribution 的 onStart 方法 + override onStart(app: FrontendApplication): void { + // 订阅平台安装事件,当平台安装时调用 updateMenus 方法并传入 true this.notificationCenter.onPlatformDidInstall(() => this.updateMenus(true)); + // 订阅平台卸载事件,当平台卸载时调用 updateMenus 方法并传入 true this.notificationCenter.onPlatformDidUninstall(() => this.updateMenus(true) ); + // 订阅开发板列表变化事件,当开发板列表变化时调用 updateMenus 方法 this.boardsServiceProvider.onBoardListDidChange(() => this.updateMenus()); + + this.app = app; + // 在 onStart 方法中添加新菜单 + const handler = this.app.shell.leftPanelHandler; + handler.addBottomMenu(PortMenu); } + // 重写 SketchContribution 的 onReady 方法 override async onReady(): Promise { + // 启动时调用 updateMenus 方法进行菜单初始化 this.updateMenus(); } - private async updateMenus(discardCache = false): Promise { + public async updateMenus(discardCache = false): Promise { + // 如果 discardCache 为 true,则拒绝并重置 _installedBoards 的延迟对象 if (discardCache) { this._installedBoards?.reject(); this._installedBoards = undefined; } + // 如果 _installedBoards 未定义,则创建一个新的延迟对象 if (!this._installedBoards) { this._installedBoards = new Deferred(); + // 获取已安装的开发板列表并在完成时处理延迟对象 this.installedBoards().then((installedBoards) => this._installedBoards?.resolve(installedBoards) ); } + // 获取已安装的开发板列表的承诺结果 const installedBoards = await this._installedBoards.promise; + // 根据已安装的开发板列表和当前开发板列表重建菜单 this.rebuildMenus(installedBoards, this.boardsServiceProvider.boardList); } @@ -133,17 +169,17 @@ SN: ${SN} installedBoards: InstalledBoardWithPackage[], boardList: BoardList ): void { + // 清理在菜单重建前需要处理的可弃用对象集合 this.toDisposeBeforeMenuRebuild.dispose(); // Boards submenu const boardsSubmenuPath = [ - ...ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP, + // ...ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP, '1_boards', ]; const { selectedBoard, selectedPort } = boardList.boardsConfig; const boardsSubmenuLabel = selectedBoard?.name; - // Note: The submenu order starts from `100` because `Auto Format`, `Serial Monitor`, etc starts from `0` index. - // The board specific items, and the rest, have order with `z`. We needed something between `0` and `z` with natural-order. + // 注册开发板子菜单,并设置菜单标签和顺序 this.menuModelRegistry.registerSubmenu( boardsSubmenuPath, nls.localize( @@ -153,29 +189,33 @@ SN: ${SN} ), { order: '100' } ); - this.toDisposeBeforeMenuRebuild.push( - Disposable.create(() => - unregisterSubmenu(boardsSubmenuPath, this.menuModelRegistry) - ) - ); + // 将取消注册开发板子菜单的操作添加到可弃用对象集合中 + // this.toDisposeBeforeMenuRebuild.push( + // Disposable.create(() => + // unregisterSubmenu(boardsSubmenuPath, this.menuModelRegistry) + // ) + // ); // Ports submenu - const portsSubmenuPath = ArduinoMenus.TOOLS__PORTS_SUBMENU; + // const portsSubmenuPath = ArduinoMenus.TOOLS__PORTS_SUBMENU; const portsSubmenuLabel = selectedPort?.address; - this.menuModelRegistry.registerSubmenu( - portsSubmenuPath, - nls.localize( - 'arduino/board/port', - 'Port{0}', - portsSubmenuLabel ? `: "${portsSubmenuLabel}"` : '' - ), - { order: '101' } - ); - this.toDisposeBeforeMenuRebuild.push( - Disposable.create(() => - unregisterSubmenu(portsSubmenuPath, this.menuModelRegistry) - ) - ); + console.log('portsSubmenuLabel', portsSubmenuLabel); + // 注册端口子菜单,并设置菜单标签和顺序 + // this.menuModelRegistry.registerSubmenu( + // portsSubmenuPath, + // nls.localize( + // 'arduino/board/port', + // 'Port{0}', + // portsSubmenuLabel ? `: "${portsSubmenuLabel}"` : '' + // ), + // { order: '101' } + // ); + // 将取消注册端口子菜单的操作添加到可弃用对象集合中 + // this.toDisposeBeforeMenuRebuild.push( + // Disposable.create(() => + // unregisterSubmenu(portsSubmenuPath, this.menuModelRegistry) + // ) + // ); const reloadBoardData = { commandId: BoardSelection.Commands.RELOAD_BOARD_DATA.id, @@ -192,24 +232,27 @@ SN: ${SN} ) ); - const getBoardInfo = { - commandId: BoardSelection.Commands.GET_BOARD_INFO.id, - label: nls.localize('arduino/board/getBoardInfo', 'Get Board Info'), - order: '103', - }; - this.menuModelRegistry.registerMenuAction( - ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP, - getBoardInfo - ); - this.toDisposeBeforeMenuRebuild.push( - Disposable.create(() => - this.menuModelRegistry.unregisterMenuAction(getBoardInfo) - ) - ); + // const getBoardInfo = { + // commandId: BoardSelection.Commands.GET_BOARD_INFO.id, + // label: '获得开发板信息', + // order: '103', + // }; + // 注册获取开发板信息的菜单动作 + // this.menuModelRegistry.registerMenuAction( + // ArduinoMenus.TOOLS__BOARD_SELECTION_GROUP, + // getBoardInfo + // ); + // // 将取消注册获取开发板信息菜单动作的操作添加到可弃用对象集合中 + // this.toDisposeBeforeMenuRebuild.push( + // Disposable.create(() => + // this.menuModelRegistry.unregisterMenuAction(getBoardInfo) + // ) + // ); const boardsManagerGroup = [...boardsSubmenuPath, '0_manager']; - const boardsPackagesGroup = [...boardsSubmenuPath, '1_packages']; + const boardsPackagesGroup = [...boardsSubmenuPath, '1_packages']; //板子 + // 注册开发板管理的菜单动作 this.menuModelRegistry.registerMenuAction(boardsManagerGroup, { commandId: `${BoardsListWidget.WIDGET_ID}:toggle`, label: `${BoardsListWidget.WIDGET_LABEL}...`, @@ -254,14 +297,7 @@ SN: ${SN} if (!platformMenuPath) { let packageLabel = packageName + - `${ - manuallyInstalled - ? nls.localize( - 'arduino/board/inSketchbook', - ' (in Sketchbook)' - ) - : '' - }`; + `${manuallyInstalled ? '(在项目文件夹中)' : ''}`; if ( selectedBoardPlatformId && platformIdentifierEquals(packageId, selectedBoardPlatformId) @@ -330,19 +366,21 @@ SN: ${SN} // Register placeholder for protocol const menuPath = [ - ...portsSubmenuPath, + // ...portsSubmenuPath, `${protocolOrder.toString()}_${protocol}`, ]; + const placeholder = new PlaceholderMenuNode( menuPath, - nls.localize( - 'arduino/board/typeOfPorts', - '{0} ports', - Port.Protocols.protocolLabel(protocol) - ), + // nls.localize( + // 'arduino/board/typeOfPorts', + // '{0} 端口', + // Port.Protocols.protocolLabel(protocol) + // ), + '串口 端口', { order: protocolOrder.toString().padStart(4) } ); - this.menuModelRegistry.registerMenuNode(menuPath, placeholder); + // this.menuModelRegistry.registerMenuNode(menuPath, placeholder); this.toDisposeBeforeMenuRebuild.push( Disposable.create(() => this.menuModelRegistry.unregisterMenuNode(placeholder.id) @@ -382,6 +420,11 @@ SN: ${SN} ) ); this.menuModelRegistry.registerMenuAction(menuPath, menuAction); + this.toDisposeBeforeMenuRebuild.push( + Disposable.create(() => + this.menuModelRegistry.unregisterMenuNode(menuAction.commandId) + ) + ); } }; @@ -391,6 +434,7 @@ SN: ${SN} registerPorts(protocol, ports, protocolOrder); protocolOrder += 100; }); + // 更新主菜单管理器 this.mainMenuManager.update(); } @@ -401,9 +445,9 @@ SN: ${SN} } export namespace BoardSelection { export namespace Commands { - export const GET_BOARD_INFO: Command = { id: 'arduino-get-board-info' }; + export const GET_BOARD_INFO: Command = { id: 'lingzhi-get-board-info' }; export const RELOAD_BOARD_DATA: Command = { - id: 'arduino-reload-board-data', + id: 'lingzhi-reload-board-data', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/boards-data-menu-updater.ts b/arduino-ide-extension/src/browser/contributions/boards-data-menu-updater.ts index 382e0f2ef..e612bfaf3 100644 --- a/arduino-ide-extension/src/browser/contributions/boards-data-menu-updater.ts +++ b/arduino-ide-extension/src/browser/contributions/boards-data-menu-updater.ts @@ -68,12 +68,24 @@ export class BoardsDataMenuUpdater extends Contribution { await this.boardsDataStore.getData(fqbn); if (configOptions.length) { const boardsConfigMenuPath = [ - ...ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP, + // ...ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP, 'z01_boardsConfig', ]; // `z_` is for ordering. - for (const { label, option, values } of configOptions.sort( + for (let { label, option, values } of configOptions.sort( ConfigOption.LABEL_COMPARATOR )) { + label = label.replace('Core Debug Level', '核心调试级'); + label = label.replace('CPU Frequency', '处理器外频'); + label = label.replace('Flash Frequency', '闪烁频率'); + label = label.replace('Flash Mode', '闪烁模式'); + label = label.replace('Flash Size', 'Flash大小'); + label = label.replace('Partition Scheme', '分区方案'); + label = label.replace('Upload Speed', '上传速度'); + label = label.replace('Debug Level', '调试级别'); + label = label.replace('Debug port', '调试端口'); + label = label.replace('Erase Flash', '擦除闪存'); + label = label.replace('Exceptions', '异常处理'); + label = label.replace('lwIP Variant', 'lwIP变体'); const menuPath = [...boardsConfigMenuPath, `${option}`]; const commands = new Map< string, diff --git a/arduino-ide-extension/src/browser/contributions/burn-bootloader.ts b/arduino-ide-extension/src/browser/contributions/burn-bootloader.ts index e951ac2f9..97640bfe0 100644 --- a/arduino-ide-extension/src/browser/contributions/burn-bootloader.ts +++ b/arduino-ide-extension/src/browser/contributions/burn-bootloader.ts @@ -1,12 +1,10 @@ import { nls } from '@theia/core/lib/common'; import { injectable } from '@theia/core/shared/inversify'; import { CoreService } from '../../common/protocol'; -import { ArduinoMenus } from '../menu/arduino-menus'; import { Command, CommandRegistry, CoreServiceContribution, - MenuModelRegistry, } from './contribution'; @injectable() @@ -17,16 +15,13 @@ export class BurnBootloader extends CoreServiceContribution { }); } - override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP, { - commandId: BurnBootloader.Commands.BURN_BOOTLOADER.id, - label: nls.localize( - 'arduino/bootloader/burnBootloader', - 'Burn Bootloader' - ), - order: 'z99', - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // registry.registerMenuAction(ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP, { + // commandId: BurnBootloader.Commands.BURN_BOOTLOADER.id, + // label: '烧录引导程序', + // order: 'z99', + // }); + // } private async burnBootloader(): Promise { this.clearVisibleNotification(); @@ -50,7 +45,7 @@ export class BurnBootloader extends CoreServiceContribution { this.messageService.info( nls.localize( 'arduino/bootloader/doneBurningBootloader', - 'Done burning bootloader.' + '完成了程序的烧录。' ), { timeout: 3000, @@ -86,7 +81,7 @@ export class BurnBootloader extends CoreServiceContribution { export namespace BurnBootloader { export namespace Commands { export const BURN_BOOTLOADER: Command = { - id: 'arduino-burn-bootloader', + id: 'lingzhi-burn-bootloader', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/check-for-ide-updates.ts b/arduino-ide-extension/src/browser/contributions/check-for-ide-updates.ts index 7ac57ac01..1f6fa694b 100644 --- a/arduino-ide-extension/src/browser/contributions/check-for-ide-updates.ts +++ b/arduino-ide-extension/src/browser/contributions/check-for-ide-updates.ts @@ -1,4 +1,3 @@ -import { nls } from '@theia/core/lib/common/nls'; import { LocalStorageService } from '@theia/core/lib/browser/storage-service'; import { inject, injectable } from '@theia/core/shared/inversify'; import { @@ -11,7 +10,8 @@ import { Contribution } from './contribution'; import { VersionWelcomeDialog } from '../dialogs/version-welcome-dialog'; import { AppService } from '../app-service'; import { SemVer } from 'semver'; - +import { ResponseService } from '../../common/protocol'; +import { nls } from '@theia/core/lib/common/nls'; @injectable() export class CheckForIDEUpdates extends Contribution { @inject(IDEUpdater) @@ -29,6 +29,9 @@ export class CheckForIDEUpdates extends Contribution { @inject(AppService) private readonly appService: AppService; + @inject(ResponseService) + private readonly responseService: ResponseService; + override onStart(): void { this.preferences.onPreferenceChanged( ({ preferenceName, newValue, oldValue }) => { @@ -76,10 +79,12 @@ export class CheckForIDEUpdates extends Contribution { this.messageService.error( nls.localize( 'arduino/ide-updater/errorCheckingForUpdates', - 'Error while checking for Arduino IDE updates.\n{0}', + '检查lingzhilab IDE更新时出错。\n{0}', e.message ) ); + const chunk = `${e.message}\n$`; + this.responseService.appendToOutput({ chunk }); }) .finally(() => { this.setCurrentIDEVersion(); diff --git a/arduino-ide-extension/src/browser/contributions/check-for-updates.ts b/arduino-ide-extension/src/browser/contributions/check-for-updates.ts index d305f9db2..33d35495c 100644 --- a/arduino-ide-extension/src/browser/contributions/check-for-updates.ts +++ b/arduino-ide-extension/src/browser/contributions/check-for-updates.ts @@ -21,27 +21,27 @@ import { Command, CommandRegistry, Contribution } from './contribution'; const NoUpdates = nls.localize( 'arduino/checkForUpdates/noUpdates', - 'There are no recent updates available.' + '没有最近可用的更新。' ); const PromptUpdateBoards = nls.localize( 'arduino/checkForUpdates/promptUpdateBoards', - 'Updates are available for some of your boards.' + '您的一些板可以使用更新。' ); const PromptUpdateLibraries = nls.localize( 'arduino/checkForUpdates/promptUpdateLibraries', - 'Updates are available for some of your libraries.' + '您的一些库可以获得更新。' ); const UpdatingBoards = nls.localize( 'arduino/checkForUpdates/updatingBoards', - 'Updating boards...' + '更新板……' ); const UpdatingLibraries = nls.localize( 'arduino/checkForUpdates/updatingLibraries', - 'Updating libraries...' + '更新库……' ); const InstallAll = nls.localize( 'arduino/checkForUpdates/installAll', - 'Install All' + '安装全部' ); interface Task { @@ -131,9 +131,9 @@ export class CheckForUpdates extends Contribution { const { items, installable, - viewContribution, + // viewContribution, promptMessage: message, - viewSearchOptions, + // viewSearchOptions, updatingMessage, } = options; @@ -149,9 +149,9 @@ export class CheckForUpdates extends Contribution { ); this.executeTasks(updatingMessage, tasks); } else if (answer === InstallManually) { - viewContribution - .openView({ reveal: true }) - .then((widget) => widget.refresh(viewSearchOptions)); + // viewContribution + // .openView({ reveal: true }) + // .then((widget) => widget.refresh(viewSearchOptions)); } }); } @@ -173,9 +173,9 @@ export class CheckForUpdates extends Contribution { await run(); // runs update sequentially. // TODO: is parallel update desired? } catch (err) { console.error(err); - this.messageService.error( - `Failed to update ${item.name}. ${err}` - ); + // this.messageService.error(`更新失败 ${item.name}. ${err}`); + const chunk = `更新失败 ${item.name}. ${err}\n`; + this.responseService.appendToOutput({ chunk }); } finally { progress.report({ work: { total, done: ++count } }); } @@ -209,13 +209,10 @@ export class CheckForUpdates extends Contribution { } export namespace CheckForUpdates { export namespace Commands { - export const CHECK_FOR_UPDATES: Command = Command.toLocalizedCommand( - { - id: 'arduino-check-for-updates', - label: 'Check for Arduino Updates', - category: 'Arduino', - }, - 'arduino/checkForUpdates/checkForUpdates' - ); + export const CHECK_FOR_UPDATES: Command = Command.toLocalizedCommand({ + id: 'arduino-check-for-updates', + label: '检查 LingZhiLab 更新', + category: 'LingZhi', + }); } } diff --git a/arduino-ide-extension/src/browser/contributions/close.ts b/arduino-ide-extension/src/browser/contributions/close.ts index c5bab561f..7dba84e32 100644 --- a/arduino-ide-extension/src/browser/contributions/close.ts +++ b/arduino-ide-extension/src/browser/contributions/close.ts @@ -1,4 +1,3 @@ -import { Dialog } from '@theia/core/lib/browser/dialogs'; import type { FrontendApplication, OnWillStopAction, @@ -9,19 +8,18 @@ import type { MaybePromise } from '@theia/core/lib/common/types'; import { toArray } from '@theia/core/shared/@phosphor/algorithm'; import { inject, injectable } from '@theia/core/shared/inversify'; import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor'; -import { ArduinoMenus } from '../menu/arduino-menus'; import { CurrentSketch } from '../sketches-service-client-impl'; import { WindowServiceExt } from '../theia/core/window-service-ext'; import { Command, CommandRegistry, KeybindingRegistry, - MenuModelRegistry, Sketch, SketchContribution, URI, } from './contribution'; import { SaveAsSketch } from './save-as-sketch'; +import { Dialog } from '../theia/dialogs/theiaDialogs/dialogs'; /** * Closes the `current` closeable editor, or any closeable current widget from the main area, or the current sketch window. @@ -38,9 +36,11 @@ export class Close extends SketchContribution { } override registerCommands(registry: CommandRegistry): void { + // 注册关闭命令 registry.registerCommand(Close.Commands.CLOSE, { + // 执行关闭命令的函数 execute: () => { - // Close current editor if closeable. + // 尝试关闭当前可关闭的编辑器 const { currentEditor } = this.editorManager; if (currentEditor && currentEditor.title.closable) { currentEditor.close(); @@ -48,29 +48,30 @@ export class Close extends SketchContribution { } if (this.shell) { - // Close current widget from the main area if possible. + // 获取当前主区域的小部件,如果有可关闭的小部件则关闭它 const { currentWidget } = this.shell; if (currentWidget) { const currentWidgetInMain = toArray( this.shell.mainPanel.widgets() ).find((widget) => widget === currentWidget); - if (currentWidgetInMain && currentWidgetInMain.title.closable) { + if (currentWidgetInMain) { return currentWidgetInMain.close(); } } } + // 如果没有可关闭的编辑器或小部件,则关闭窗口 return this.windowServiceExt.close(); }, }); } - override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { - commandId: Close.Commands.CLOSE.id, - label: nls.localize('vscode/editor.contribution/close', 'Close'), - order: '6', - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { + // commandId: Close.Commands.CLOSE.id, + // label: nls.localize('vscode/editor.contribution/close', 'Close'), + // order: '6', + // }); + // } override registerKeybindings(registry: KeybindingRegistry): void { registry.registerKeybinding({ @@ -90,33 +91,42 @@ export class Close extends SketchContribution { } /** - * If returns with `true`, IDE2 will close. Otherwise, it won't. + * 如果返回' true ', IDE2将关闭。否则,它不会. */ private async showSaveSketchDialog(): Promise { + // 检查当前的草图是否为临时草图,如果不是临时草图,则返回 false,表示无需进行保存草图的对话框展示。 const sketch = await this.isCurrentSketchTemp(); if (!sketch) { - // Normal close workflow: if there are dirty editors prompt the user. + // 如果无法获取应用的外壳(shell),则记录错误信息并返回 true,可能表示进行默认的关闭流程。 if (!this.shell) { console.error( `Could not get the application shell. Something went wrong.` ); return true; } + // 如果应用的外壳可以保存所有内容(可能表示有未保存的编辑器等) if (this.shell.canSaveAll()) { + // 显示提示对话框并等待用户的响应 const prompt = await this.prompt(false); + // 根据用户的响应进行不同的操作 switch (prompt) { case Prompt.DoNotSave: + // 用户选择不保存,直接返回 true,表示可以继续关闭流程 return true; case Prompt.Cancel: + // 用户选择取消,返回 false,表示不继续关闭流程 return false; case Prompt.Save: { + // 用户选择保存,调用应用外壳的保存所有方法,并返回 true,表示可以继续关闭流程 await this.shell.saveAll(); return true; } default: + // 如果出现意外的提示响应,抛出错误 throw new Error(`Unexpected prompt: ${prompt}`); } } + // 如果应用外壳不能保存所有内容,直接返回 true,表示进行默认的关闭流程 return true; } @@ -154,19 +164,13 @@ export class Close extends SketchContribution { private async prompt(isTemp: boolean): Promise { const { response } = await this.dialogService.showMessageBox({ - message: nls.localize( - 'arduino/sketch/saveSketch', - 'Save your sketch to open it again later.' - ), - title: nls.localize( - 'theia/core/quitTitle', - 'Are you sure you want to quit?' - ), + message: '保存您的草图,以便稍后再次打开它。', + title: '你确定要退出吗?', type: 'question', buttons: [ - nls.localizeByDefault("Don't Save"), + nls.localizeByDefault('不保存'), Dialog.CANCEL, - nls.localizeByDefault(isTemp ? 'Save As...' : 'Save'), + nls.localizeByDefault(isTemp ? '保存于...' : '保存'), ], defaultId: 2, // `Save`/`Save As...` button index is the default. }); @@ -183,13 +187,17 @@ export class Close extends SketchContribution { } private async isCurrentSketchTemp(): Promise { + // 获取当前的草图对象 const currentSketch = await this.sketchServiceClient.currentSketch(); if (CurrentSketch.isValid(currentSketch)) { + // 检查当前草图是否为临时草图 const isTemp = await this.sketchesService.isTemp(currentSketch); if (isTemp) { + // 如果是临时草图,返回当前草图对象 return currentSketch; } } + // 如果不是临时草图或者当前草图无效,返回 false return false; } @@ -197,16 +205,22 @@ export class Close extends SketchContribution { * If the file was ever touched/modified. We get this based on the `version` of the monaco model. */ protected async wasTouched(uri: string): Promise { + // 根据给定的 URI 获取对应的编辑器小部件(editorWidget) const editorWidget = await this.editorManager.getByUri(new URI(uri)); if (editorWidget) { + // 解构获取编辑器实例(editor) const { editor } = editorWidget; + // 如果编辑器是 MonacoEditor 类型 if (editor instanceof MonacoEditor) { + // 获取编辑器模型的版本 ID const versionId = editor.getControl().getModel()?.getVersionId(); + // 如果版本 ID 是整数且大于 1,表示编辑器内容有过修改(被触碰过) if (this.isInteger(versionId) && versionId > 1) { return true; } } } + // 如果没有满足上述条件,返回 false,表示未被触碰过 return false; } @@ -224,7 +238,7 @@ enum Prompt { export namespace Close { export namespace Commands { export const CLOSE: Command = { - id: 'arduino-close', + id: 'lingzhi-close', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/cloud-contribution.ts b/arduino-ide-extension/src/browser/contributions/cloud-contribution.ts index 47e14210d..5cdea8a5e 100644 --- a/arduino-ide-extension/src/browser/contributions/cloud-contribution.ts +++ b/arduino-ide-extension/src/browser/contributions/cloud-contribution.ts @@ -11,36 +11,37 @@ import { CloudSketchbookTreeWidget } from '../widgets/cloud-sketchbook/cloud-ske import { SketchbookWidget } from '../widgets/sketchbook/sketchbook-widget'; import { SketchbookWidgetContribution } from '../widgets/sketchbook/sketchbook-widget-contribution'; import { SketchContribution } from './contribution'; +import { ResponseService } from '../../common/protocol'; export function sketchAlreadyExists(input: string): string { return nls.localize( 'arduino/cloudSketch/alreadyExists', - "Cloud sketch '{0}' already exists.", + '云草图“{0}”已经存在。', input ); } export function sketchNotFound(input: string): string { return nls.localize( 'arduino/cloudSketch/notFound', - "Could not pull the cloud sketch '{0}'. It does not exist.", + '无法拖动云素描‘{0}’。它不存在。', input ); } export const synchronizingSketchbook = nls.localize( 'arduino/cloudSketch/synchronizingSketchbook', - 'Synchronizing sketchbook...' + '同步草图…' ); export function pullingSketch(input: string): string { return nls.localize( 'arduino/cloudSketch/pulling', - "Synchronizing sketchbook, pulling '{0}'...", + "同步草图, 拉取 '{0}'...", input ); } export function pushingSketch(input: string): string { return nls.localize( 'arduino/cloudSketch/pushing', - "Synchronizing sketchbook, pushing '{0}'...", + "同步草图, 推送 '{0}'...", input ); } @@ -53,6 +54,8 @@ export abstract class CloudSketchContribution extends SketchContribution { protected readonly createApi: CreateApi; @inject(CreateFeatures) protected readonly createFeatures: CreateFeatures; + @inject(ResponseService) + private readonly responseService: ResponseService; protected async treeModel(): Promise< (CloudSketchbookTreeModel & { root: CompositeTreeNode }) | undefined @@ -83,14 +86,10 @@ export abstract class CloudSketchContribution extends SketchContribution { const id = CreateUri.toUri(sketch).path.toString(); const node = treeModel.getNode(id); if (!node) { - throw new Error( - `Could not find cloud sketchbook tree node with ID: ${id}.` - ); + throw new Error(`找不到具有ID的云草图树节点: ${id}.`); } if (!CloudSketchbookTree.CloudSketchDirNode.is(node)) { - throw new Error( - `Cloud sketchbook tree node expected to represent a directory but it did not. Tree node ID: ${id}.` - ); + throw new Error(`云草图树节点期望表示一个目录,但它没有树节点ID: ${id}.`); } try { await treeModel.sketchbookTree().pull({ node }, true); @@ -98,7 +97,9 @@ export abstract class CloudSketchContribution extends SketchContribution { } catch (err) { if (isNotFound(err)) { await treeModel.refresh(); - this.messageService.error(sketchNotFound(sketch.name)); + // this.messageService.error(sketchNotFound(sketch.name)); + const chunk = `${sketchNotFound(sketch.name)}\n`; + this.responseService.appendToOutput({ chunk }); return undefined; } throw err; diff --git a/arduino-ide-extension/src/browser/contributions/compiler-errors.ts b/arduino-ide-extension/src/browser/contributions/compiler-errors.ts index a689ea3df..46ab8c484 100644 --- a/arduino-ide-extension/src/browser/contributions/compiler-errors.ts +++ b/arduino-ide-extension/src/browser/contributions/compiler-errors.ts @@ -130,8 +130,7 @@ namespace ErrorDecoration { @injectable() export class CompilerErrors extends Contribution - implements monaco.languages.CodeLensProvider, monaco.languages.LinkProvider -{ + implements monaco.languages.CodeLensProvider, monaco.languages.LinkProvider { @inject(EditorManager) private readonly editorManager: EditorManager; @@ -540,7 +539,7 @@ export class CompilerErrors } if ( candidateErrorRange.startLineNumber <= - currentSelection.startLineNumber && + currentSelection.startLineNumber && candidateErrorRange.endLineNumber >= currentSelection.endLineNumber ) { console.trace('Same line.'); @@ -687,8 +686,7 @@ export class CompilerErrors if (index < 0) { console.warn( 'compiler-errors', - `Failed to mark error ${ - ref.id + `Failed to mark error ${ref.id } as the current one. Error is unknown. Known errors are: ${this.errors.map( ({ id }) => id )}` @@ -792,13 +790,13 @@ export class CompilerErrors export namespace CompilerErrors { export namespace Commands { export const NEXT_ERROR: Command = { - id: 'arduino-editor-next-error', + id: 'lingzhi-editor-next-error', }; export const PREVIOUS_ERROR: Command = { - id: 'arduino-editor-previous-error', + id: 'lingzhi-editor-previous-error', }; export const MARK_AS_CURRENT: Command = { - id: 'arduino-editor-mark-as-current-error', + id: 'lingzhi-editor-mark-as-current-error', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/contribution.ts b/arduino-ide-extension/src/browser/contributions/contribution.ts index 1a8ff5798..7d2aaa935 100644 --- a/arduino-ide-extension/src/browser/contributions/contribution.ts +++ b/arduino-ide-extension/src/browser/contributions/contribution.ts @@ -90,12 +90,11 @@ export { @injectable() export abstract class Contribution implements - CommandContribution, - MenuContribution, - KeybindingContribution, - TabBarToolbarContribution, - FrontendApplicationContribution -{ + CommandContribution, + MenuContribution, + KeybindingContribution, + TabBarToolbarContribution, + FrontendApplicationContribution { @inject(ILogger) protected readonly logger: ILogger; @@ -132,22 +131,22 @@ export abstract class Contribution } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars - onStart(app: FrontendApplication): MaybePromise {} + onStart(app: FrontendApplication): MaybePromise { } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars - registerCommands(registry: CommandRegistry): void {} + registerCommands(registry: CommandRegistry): void { } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars - registerMenus(registry: MenuModelRegistry): void {} + registerMenus(registry: MenuModelRegistry): void { } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars - registerKeybindings(registry: KeybindingRegistry): void {} + registerKeybindings(registry: KeybindingRegistry): void { } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, unused-imports/no-unused-vars - registerToolbarItems(registry: TabBarToolbarRegistry): void {} + registerToolbarItems(registry: TabBarToolbarRegistry): void { } // eslint-disable-next-line @typescript-eslint/no-empty-function - onReady(): MaybePromise {} + onReady(): MaybePromise { } } @injectable() @@ -201,15 +200,21 @@ export abstract class SketchContribution extends Contribution { * Otherwise, the URI of the user home directory. */ protected async defaultUri(): Promise { + // 获取配置服务中的错误信息 const errors = this.configService.tryGetMessages(); + // 尝试获取 Sketch 目录的 URI let defaultUri = this.configService.tryGetSketchDirUri(); if (!defaultUri || errors?.length) { - // Fall back to user home when the `directories.user` is not available or there are known CLI config errors + // 如果默认 URI 未定义或者存在 CLI 配置错误,则回退到用户主目录 defaultUri = new URI(await this.envVariableServer.getHomeDirUri()); } return defaultUri; } + /** + * 获取默认路径。 + * 先调用 defaultUri 方法获取默认的 URI,然后将其转换为文件系统路径并返回。 + */ protected async defaultPath(): Promise { const defaultUri = await this.defaultUri(); return this.fileService.fsPath(defaultUri); @@ -273,30 +278,34 @@ export abstract class CoreServiceContribution extends SketchContribution { } else { try { message = JSON.stringify(error); - } catch {} + } catch { } } if (message) { if (message.includes('Missing FQBN (Fully Qualified Board Name)')) { - message = nls.localize( - 'arduino/coreContribution/noBoardSelected', - 'No board selected. Please select your Arduino board from the Tools > Board menu.' - ); + message = '没有选择板。请从代码页面中选择Lingzhi板'; } const copyAction = nls.localize( 'arduino/coreContribution/copyError', - 'Copy error messages' + '复制错误信息' ); this.visibleNotificationId = this.notificationId(message, copyAction); - this.messageService.error(message, copyAction).then(async (action) => { - if (action === copyAction) { - const content = await this.outputChannelManager.contentOfChannel( - 'Arduino' - ); - if (content) { - this.clipboardService.writeText(content); - } - } - }); + // this.messageService.error(message, copyAction).then(async (action) => { + // if (action === copyAction) { + // const content = await this.outputChannelManager.contentOfChannel( + // 'Arduino' + // ); + // if (content) { + // this.clipboardService.writeText(content); + // } + // } + // }); + message = message.includes( + "Cannot read properties of undefined (reading 'board')" + ) + ? '无法读取未定义的属性(读取‘板子’)' + : message; + // const chunk = `${message}\n`; + // this.responseService.appendToOutput({ chunk }); } else { throw error; } diff --git a/arduino-ide-extension/src/browser/contributions/create-cloud-copy.ts b/arduino-ide-extension/src/browser/contributions/create-cloud-copy.ts index 73b967f0f..b7df6acd9 100644 --- a/arduino-ide-extension/src/browser/contributions/create-cloud-copy.ts +++ b/arduino-ide-extension/src/browser/contributions/create-cloud-copy.ts @@ -111,7 +111,7 @@ export class CreateCloudCopy extends CloudSketchContribution { export namespace CreateCloudCopy { export namespace Commands { export const CREATE_CLOUD_COPY: Command = { - id: 'arduino-create-cloud-copy', + id: 'lingzhi-create-cloud-copy', iconClass: 'fa fa-arduino-cloud-upload', }; } diff --git a/arduino-ide-extension/src/browser/contributions/daemon.ts b/arduino-ide-extension/src/browser/contributions/daemon.ts index 740dcccf7..586350d63 100644 --- a/arduino-ide-extension/src/browser/contributions/daemon.ts +++ b/arduino-ide-extension/src/browser/contributions/daemon.ts @@ -25,17 +25,17 @@ export namespace Daemon { export const START_DAEMON: Command = { id: 'arduino-start-daemon', label: nls.localize('arduino/daemon/start', 'Start Daemon'), - category: 'Arduino', + category: 'LingZhi', }; export const STOP_DAEMON: Command = { id: 'arduino-stop-daemon', label: nls.localize('arduino/daemon/stop', 'Stop Daemon'), - category: 'Arduino', + category: 'LingZhi', }; export const RESTART_DAEMON: Command = { id: 'arduino-restart-daemon', label: nls.localize('arduino/daemon/restart', 'Restart Daemon'), - category: 'Arduino', + category: 'LingZhi', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/debug.ts b/arduino-ide-extension/src/browser/contributions/debug.ts index 93dd2aa51..557b6d25c 100644 --- a/arduino-ide-extension/src/browser/contributions/debug.ts +++ b/arduino-ide-extension/src/browser/contributions/debug.ts @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import { Emitter, Event } from '@theia/core/lib/common/event'; import { MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry'; import { nls } from '@theia/core/lib/common/nls'; @@ -10,6 +11,7 @@ import { BoardsService, CheckDebugEnabledParams, ExecutableService, + ResponseService, SketchRef, isBoardIdentifierChangeEvent, isCompileSummary, @@ -82,8 +84,7 @@ export interface DebugDisabledStatusMessageSource { @injectable() export class Debug extends SketchContribution - implements DebugDisabledStatusMessageSource -{ + implements DebugDisabledStatusMessageSource { @inject(HostedPluginSupport) private readonly hostedPluginSupport: HostedPluginSupport; @inject(NotificationCenter) @@ -96,6 +97,8 @@ export class Debug private readonly boardsServiceProvider: BoardsServiceProvider; @inject(BoardsDataStore) private readonly boardsDataStore: BoardsDataStore; + @inject(ResponseService) + private readonly responseService: ResponseService; /** * If `undefined`, debugging is enabled. Otherwise, the human-readable reason why it's disabled. @@ -115,15 +118,14 @@ export class Debug private readonly debugToolbarItem = { id: Debug.Commands.START_DEBUGGING.id, command: Debug.Commands.START_DEBUGGING.id, - tooltip: `${ - this.message - ? nls.localize( - 'arduino/debug/debugWithMessage', - 'Debug - {0}', - this.message - ) - : Debug.Commands.START_DEBUGGING.label - }`, + tooltip: `${this.message + ? nls.localize( + 'arduino/debug/debugWithMessage', + 'Debug - {0}', + this.message + ) + : Debug.Commands.START_DEBUGGING.label + }`, priority: 3, onDidChange: this.onDidChangeMessage as Event, }; @@ -131,14 +133,13 @@ export class Debug override onStart(): void { this.onDidChangeMessage( () => - (this.debugToolbarItem.tooltip = `${ + (this.debugToolbarItem.tooltip = `${this.message + ? nls.localize( + 'arduino/debug/debugWithMessage', + 'Debug - {0}', this.message - ? nls.localize( - 'arduino/debug/debugWithMessage', - 'Debug - {0}', - this.message - ) - : Debug.Commands.START_DEBUGGING.label + ) + : Debug.Commands.START_DEBUGGING.label }`) ); this.boardsServiceProvider.onBoardsConfigDidChange((event) => { @@ -173,8 +174,8 @@ export class Debug override registerCommands(registry: CommandRegistry): void { registry.registerCommand(Debug.Commands.START_DEBUGGING, { execute: () => this.startDebug(), - isVisible: (widget) => - ArduinoToolbar.is(widget) && widget.side === 'left', + isVisible: (widget, showToolbar: boolean) => + showToolbar && ArduinoToolbar.is(widget) && widget.side === 'left', isEnabled: () => !this.message, }); registry.registerCommand(Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG, { @@ -245,18 +246,22 @@ export class Debug return Boolean(result); } catch (err) { if (await this.isSketchNotVerifiedError(err, sketch)) { - const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes'); - const answer = await this.messageService.error( - sketchIsNotCompiled(sketch.name), - yes - ); - if (answer === yes) { - this.commandService.executeCommand('arduino-verify-sketch'); - } + // const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes'); + // const answer = await this.messageService.error( + // sketchIsNotCompiled(sketch.name), + // yes + // ); + // if (answer === yes) { + // this.commandService.executeCommand('lingzhi-verify-sketch'); + // } + const chunk = `在开始调试会话之前,必须验证草图.请验证草图并重新开始调试\n`; + this.responseService.appendToOutput({ chunk }); } else { - this.messageService.error( - err instanceof Error ? err.message : String(err) - ); + // this.messageService.error( + // err instanceof Error ? err.message : String(err) + // ); + const chunk = `${err instanceof Error ? err.message : String(err)}\n`; + this.responseService.appendToOutput({ chunk }); } } return false; @@ -290,7 +295,7 @@ export class Debug if (err instanceof Error) { try { const buildPaths = await this.sketchesService.getBuildPath(sketch); - return buildPaths.some((tempBuildPath) => + return buildPaths.some((tempBuildPath: string) => err.message.includes(tempBuildPath) ); } catch { @@ -309,7 +314,7 @@ export class Debug let debugFqbn: string | undefined = undefined; try { debugFqbn = await this.isDebugEnabled(board); - } catch {} + } catch { } if (!debugFqbn) { return undefined; } @@ -348,20 +353,20 @@ export namespace Debug { { id: 'arduino-start-debug', label: 'Start Debugging', - category: 'Arduino', + category: 'LingZhi', }, 'vscode/debug.contribution/startDebuggingHelp' ); export const TOGGLE_OPTIMIZE_FOR_DEBUG = Command.toLocalizedCommand( { id: 'arduino-toggle-optimize-for-debug', - label: 'Optimize for Debugging', - category: 'Arduino', + label: '调试优化', + category: 'LingZhi', }, 'arduino/debug/optimizeForDebugging' ); export const IS_OPTIMIZE_FOR_DEBUG: Command = { - id: 'arduino-is-optimize-for-debug', + id: 'lingzhi-is-optimize-for-debug', }; } } @@ -382,8 +387,35 @@ export async function isDebugEnabled( throw new Error(noBoardSelected); } const { fqbn } = board; + const str = board.fqbn as string; + const lastColonIndex = str.lastIndexOf(':'); + const valueAfterLastColon = str.slice(lastColonIndex + 1); + let name = board.name; + switch (valueAfterLastColon) { + case 'lzesp32': + name = '零知-ESP32'; + break; + case 'lzesp8266': + name = '零知-ESP8266'; + break; + case 'lingzhistandard': + name = '零知-标准板'; + break; + case 'lingzhiMini': + name = '零知-迷你板'; + break; + case 'lingzhiM4': + name = '零知-增强板'; + break; + case 'lz_ble52': + name = '零知-BLE52'; + break; + default: + name = board.name; + break; + } if (!fqbn) { - throw new Error(noPlatformInstalledFor(board.name)); + throw new Error(noPlatformInstalledFor(name)); } const [details, data, fqbnWithConfig] = await Promise.all([ getDetails(fqbn), @@ -391,12 +423,10 @@ export async function isDebugEnabled( appendConfigToFqbn(fqbn), ]); if (!details) { - throw new Error(noPlatformInstalledFor(board.name)); + throw new Error(noPlatformInstalledFor(name)); } if (!fqbnWithConfig) { - throw new Error( - `Failed to append boards config to the FQBN. Original FQBN was: ${fqbn}` - ); + throw new Error(`日志含义单板配置追加到FQBN失败。原来的FQBN是: ${fqbn}`); } const params = { fqbn: fqbnWithConfig, @@ -406,7 +436,7 @@ export async function isDebugEnabled( const debugFqbn = await checkDebugEnabled(params); return debugFqbn; } catch (err) { - throw new Error(debuggingNotSupported(board.name)); + throw new Error(debuggingNotSupported(name)); } } @@ -416,7 +446,7 @@ export async function isDebugEnabled( export function sketchIsNotCompiled(sketchName: string): string { return nls.localize( 'arduino/debug/sketchIsNotCompiled', - "Sketch '{0}' must be verified before starting a debug session. Please verify the sketch and start debugging again. Do you want to verify the sketch now?", + '在开始调试会话之前,必须验证草图“{0}”。请验证草图并重新开始调试。你想现在验证一下草图吗?', sketchName ); } @@ -426,7 +456,7 @@ export function sketchIsNotCompiled(sketchName: string): string { export function noPlatformInstalledFor(boardName: string): string { return nls.localize( 'arduino/debug/noPlatformInstalledFor', - "Platform is not installed for '{0}'", + "没有安装平台 '{0}'", boardName ); } @@ -436,7 +466,7 @@ export function noPlatformInstalledFor(boardName: string): string { export function debuggingNotSupported(boardName: string): string { return nls.localize( 'arduino/debug/debuggingNotSupported', - "Debugging is not supported by '{0}'", + "不支持调试 '{0}'", boardName ); } diff --git a/arduino-ide-extension/src/browser/contributions/delete-sketch.ts b/arduino-ide-extension/src/browser/contributions/delete-sketch.ts index 08a72f690..8092231e1 100644 --- a/arduino-ide-extension/src/browser/contributions/delete-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/delete-sketch.ts @@ -2,7 +2,6 @@ import { Dialog } from '@theia/core/lib/browser/dialogs'; import { NavigatableWidget } from '@theia/core/lib/browser/navigatable-types'; import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell'; import { WindowService } from '@theia/core/lib/browser/window/window-service'; -import { nls } from '@theia/core/lib/common/nls'; import type { MaybeArray } from '@theia/core/lib/common/types'; import URI from '@theia/core/lib/common/uri'; import type { Widget } from '@theia/core/shared/@phosphor/widgets'; @@ -67,20 +66,12 @@ export class DeleteSketch extends CloudSketchContribution { const cloudUri = this.createFeatures.cloudUri(sketch); if (willNavigateAway !== 'force') { const { response } = await this.dialogService.showMessageBox({ - title: nls.localizeByDefault('Delete'), + title: '删除', type: 'question', buttons: [Dialog.CANCEL, Dialog.OK], message: cloudUri - ? nls.localize( - 'theia/workspace/deleteCloudSketch', - "The cloud sketch '{0}' will be permanently deleted from the Arduino servers and the local caches. This action is irreversible. Do you want to delete the current sketch?", - sketch.name - ) - : nls.localize( - 'theia/workspace/deleteCurrentSketch', - "The sketch '{0}' will be permanently deleted. This action is irreversible. Do you want to delete the current sketch?", - sketch.name - ), + ? `云草图‘${sketch.name}’将从Arduino服务器和本地缓存中永久删除。这种行为是不可逆转的。是否要删除当前草图?` + : `草图“${sketch.name}”将被永久删除。这种行为是不可逆转的。是否要删除当前草图?`, }); // cancel if (response === 0) { @@ -145,7 +136,7 @@ export class DeleteSketch extends CloudSketchContribution { export namespace DeleteSketch { export namespace Commands { export const DELETE_SKETCH: Command = { - id: 'arduino-delete-sketch', + id: 'lingzhi-delete-sketch', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/edit-contributions.ts b/arduino-ide-extension/src/browser/contributions/edit-contributions.ts index d8e439088..b90efe42f 100644 --- a/arduino-ide-extension/src/browser/contributions/edit-contributions.ts +++ b/arduino-ide-extension/src/browser/contributions/edit-contributions.ts @@ -10,7 +10,6 @@ import { CommandRegistry, } from './contribution'; import { ArduinoMenus } from '../menu/arduino-menus'; -import { nls } from '@theia/core/lib/common'; import type { ICodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser'; import type { StandaloneCodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor'; @@ -70,105 +69,94 @@ ${value} override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { commandId: CommonCommands.CUT.id, + label: '剪切', order: '0', }); registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { commandId: CommonCommands.COPY.id, + label: '复制', order: '1', }); - registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { - commandId: EditContributions.Commands.COPY_FOR_FORUM.id, - label: nls.localize( - 'arduino/editor/copyForForum', - 'Copy for Forum (Markdown)' - ), - order: '2', - }); + // registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { + // commandId: EditContributions.Commands.COPY_FOR_FORUM.id, + // label: nls.localize( + // 'arduino/editor/copyForForum', + // 'Copy for Forum (Markdown)' + // ), + // order: '2', + // }); registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { commandId: CommonCommands.PASTE.id, + label: '粘贴', order: '3', }); registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { commandId: CommonCommands.SELECT_ALL.id, + label: '全选', order: '4', }); registry.registerMenuAction(ArduinoMenus.EDIT__TEXT_CONTROL_GROUP, { commandId: EditContributions.Commands.GO_TO_LINE.id, - label: nls.localize( - 'vscode/standaloneStrings/gotoLineActionLabel', - 'Go to Line...' - ), + label: '转到行/列...', order: '5', }); registry.registerMenuAction(ArduinoMenus.EDIT__CODE_CONTROL_GROUP, { commandId: EditContributions.Commands.TOGGLE_COMMENT.id, - label: nls.localize( - 'arduino/editor/commentUncomment', - 'Comment/Uncomment' - ), + label: '注释/取消注释', order: '0', }); registry.registerMenuAction(ArduinoMenus.EDIT__CODE_CONTROL_GROUP, { commandId: EditContributions.Commands.INDENT_LINES.id, - label: nls.localize('arduino/editor/increaseIndent', 'Increase Indent'), + label: '增加缩进', order: '1', }); registry.registerMenuAction(ArduinoMenus.EDIT__CODE_CONTROL_GROUP, { commandId: EditContributions.Commands.OUTDENT_LINES.id, - label: nls.localize('arduino/editor/decreaseIndent', 'Decrease Indent'), + label: '减少缩进', order: '2', }); registry.registerMenuAction(ArduinoMenus.EDIT__CODE_CONTROL_GROUP, { commandId: EditContributions.Commands.AUTO_FORMAT.id, - label: nls.localize('arduino/editor/autoFormat', 'Auto Format'), + label: '自动格式化', order: '3', }); registry.registerMenuAction(ArduinoMenus.EDIT__FIND_GROUP, { commandId: EditContributions.Commands.FIND.id, - label: nls.localize('vscode/findController/startFindAction', 'Find'), + label: '查找', order: '0', }); registry.registerMenuAction(ArduinoMenus.EDIT__FIND_GROUP, { commandId: EditContributions.Commands.FIND_NEXT.id, - label: nls.localize( - 'vscode/findController/findNextMatchAction', - 'Find Next' - ), + label: '查找下一个', order: '1', }); registry.registerMenuAction(ArduinoMenus.EDIT__FIND_GROUP, { commandId: EditContributions.Commands.FIND_PREVIOUS.id, - label: nls.localize( - 'vscode/findController/findPreviousMatchAction', - 'Find Previous' - ), + label: '查找上一个', order: '2', }); registry.registerMenuAction(ArduinoMenus.EDIT__FIND_GROUP, { commandId: EditContributions.Commands.USE_FOR_FIND.id, - label: nls.localize( - 'vscode/findController/startFindWithSelectionAction', - 'Use Selection for Find' - ), // XXX: The Java IDE uses `Use Selection For Find`. + label: '查找选定内容', // XXX: The Java IDE uses `Use Selection For Find`. order: '3', }); // `Tools` registry.registerMenuAction(ArduinoMenus.TOOLS__MAIN_GROUP, { commandId: EditContributions.Commands.AUTO_FORMAT.id, - label: nls.localize('arduino/editor/autoFormat', 'Auto Format'), // XXX: The Java IDE uses `Use Selection For Find`. + label: '自动格式化', // XXX: The Java IDE uses `Use Selection For Find`. order: '0', }); } override registerKeybindings(registry: KeybindingRegistry): void { - registry.registerKeybinding({ - command: EditContributions.Commands.COPY_FOR_FORUM.id, - keybinding: 'CtrlCmd+Shift+C', - when: 'editorFocus', - }); + // registry.registerKeybinding({ + // command: EditContributions.Commands.COPY_FOR_FORUM.id, + // keybinding: 'CtrlCmd+Shift+C', + // when: 'editorFocus', + // }); registry.registerKeybinding({ command: EditContributions.Commands.GO_TO_LINE.id, keybinding: 'CtrlCmd+L', @@ -241,34 +229,34 @@ ${value} export namespace EditContributions { export namespace Commands { export const COPY_FOR_FORUM: Command = { - id: 'arduino-copy-for-forum', + id: 'lingzhi-copy-for-forum', }; export const GO_TO_LINE: Command = { - id: 'arduino-go-to-line', + id: 'lingzhi-go-to-line', }; export const TOGGLE_COMMENT: Command = { - id: 'arduino-toggle-comment', + id: 'lingzhi-toggle-comment', }; export const INDENT_LINES: Command = { - id: 'arduino-indent-lines', + id: 'lingzhi-indent-lines', }; export const OUTDENT_LINES: Command = { - id: 'arduino-outdent-lines', + id: 'lingzhi-outdent-lines', }; export const FIND: Command = { - id: 'arduino-find', + id: 'lingzhi-find', }; export const FIND_NEXT: Command = { - id: 'arduino-find-next', + id: 'lingzhi-find-next', }; export const FIND_PREVIOUS: Command = { - id: 'arduino-find-previous', + id: 'lingzhi-find-previous', }; export const USE_FOR_FIND: Command = { - id: 'arduino-for-find', + id: 'lingzhi-for-find', }; export const AUTO_FORMAT: Command = { - id: 'arduino-auto-format', // `Auto Format` should belong to `Tool`. + id: 'lingzhi-auto-format', // `Auto Format` should belong to `Tool`. }; } } diff --git a/arduino-ide-extension/src/browser/contributions/examples.ts b/arduino-ide-extension/src/browser/contributions/examples.ts index 9bb2cbd56..5053931c0 100644 --- a/arduino-ide-extension/src/browser/contributions/examples.ts +++ b/arduino-ide-extension/src/browser/contributions/examples.ts @@ -7,11 +7,7 @@ import { DisposableCollection, } from '@theia/core/lib/common/disposable'; import { OpenSketch } from './open-sketch'; -import { - ArduinoMenus, - examplesLabel, - PlaceholderMenuNode, -} from '../menu/arduino-menus'; +import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus'; import { BoardsServiceProvider } from '../boards/boards-service-provider'; import { ExamplesService } from '../../common/protocol/examples-service'; import { @@ -30,14 +26,14 @@ import { Sketch, isBoardIdentifierChangeEvent, BoardIdentifier, + ResponseService, } from '../../common/protocol'; import { nls } from '@theia/core/lib/common/nls'; import { unregisterSubmenu } from '../menu/arduino-menus'; import { MaybePromise } from '@theia/core/lib/common/types'; import { ApplicationError } from '@theia/core/lib/common/application-error'; - /** - * Creates a cloned copy of the example sketch and opens it in a new window. + * 创建示例草图的克隆副本,并在新窗口中打开它。 */ export async function openClonedExample( uri: string, @@ -69,15 +65,20 @@ export async function openClonedExample( const { sketchesService, commandService } = services; const { onDidFailClone, onDidFailOpen } = onError; try { + // 尝试克隆示例草图 const sketch = await sketchesService.cloneExample(uri); try { + // 执行打开草图的命令 await commandService.executeCommand( OpenSketch.Commands.OPEN_SKETCH.id, - sketch + sketch, + uri ); } catch (openError) { + // 如果打开失败且是因为草图未找到 if (SketchesError.NotFound.is(openError)) { if (onDidFailOpen) { + // 执行自定义的打开失败处理逻辑 await onDidFailOpen(openError, sketch); return; } @@ -85,8 +86,10 @@ export async function openClonedExample( throw openError; } } catch (cloneError) { + // 如果克隆失败且是因为草图未找到 if (SketchesError.NotFound.is(cloneError)) { if (onDidFailClone) { + // 执行自定义的克隆失败处理逻辑 await onDidFailClone(cloneError, uri); return; } @@ -115,15 +118,20 @@ export abstract class Examples extends SketchContribution { @inject(NotificationCenter) protected readonly notificationCenter: NotificationCenter; + @inject(ResponseService) + public readonly responseService: ResponseService; + protected readonly toDispose = new DisposableCollection(); protected override init(): void { super.init(); + // 监听电路板配置变化事件 this.boardsServiceProvider.onBoardsConfigDidChange((event) => { if (isBoardIdentifierChangeEvent(event)) { this.handleBoardChanged(event.selectedBoard); } }); + // 监听重新初始化事件,进行更新 this.notificationCenter.onDidReinitialize(() => this.update({ board: this.boardsServiceProvider.boardsConfig.selectedBoard, @@ -132,6 +140,7 @@ export abstract class Examples extends SketchContribution { ); } + // 处理电路板变化的抽象方法,默认不执行任何操作 // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars protected handleBoardChanged(board: Board | undefined): void { // NOOP @@ -142,17 +151,16 @@ export abstract class Examples extends SketchContribution { forceRefresh?: boolean; }): void; - override registerMenus(registry: MenuModelRegistry): void { - // Registering the same submenu multiple times has no side-effect. - // TODO: unregister submenu? https://github.com/eclipse-theia/theia/issues/7300 - registry.registerSubmenu( - ArduinoMenus.FILE__EXAMPLES_SUBMENU, - examplesLabel, - { - order: '4', - } - ); - } + // override registerMenus(registry: MenuModelRegistry): void { + // // 注册子菜单 + // registry.registerSubmenu( + // ArduinoMenus.FILE__EXAMPLES_SUBMENU, // 注册子菜单的路径 + // examplesLabel, // 子菜单的标签 + // { + // order: '4', // 子菜单的显示顺序 + // } + // ); + // } registerRecursively( sketchContainerOrPlaceholder: @@ -164,6 +172,7 @@ export abstract class Examples extends SketchContribution { subMenuOptions?: SubMenuOptions | undefined ): void { if (typeof sketchContainerOrPlaceholder === 'string') { + // 如果传入的是字符串,创建占位节点并注册 const placeholder = new PlaceholderMenuNode( menuPath, sketchContainerOrPlaceholder @@ -180,6 +189,7 @@ export abstract class Examples extends SketchContribution { let submenuPath = menuPath; if (SketchContainer.is(sketchContainerOrPlaceholder)) { + // 如果传入的是 SketchContainer 类型,处理并注册子菜单 const { label } = sketchContainerOrPlaceholder; submenuPath = [...menuPath, label]; this.menuRegistry.registerSubmenu(submenuPath, label, subMenuOptions); @@ -191,6 +201,7 @@ export abstract class Examples extends SketchContribution { sketches.push(...sketchContainerOrPlaceholder.sketches); children.push(...sketchContainerOrPlaceholder.children); } else { + // 如果传入的是数组类型,遍历分类并处理 for (const sketchOrContainer of sketchContainerOrPlaceholder) { if (SketchContainer.is(sketchOrContainer)) { children.push(sketchOrContainer); @@ -199,6 +210,8 @@ export abstract class Examples extends SketchContribution { } } } + + // 递归注册子菜单和动作 children.forEach((child) => this.registerRecursively(child, submenuPath, pushToDispose) ); @@ -210,8 +223,23 @@ export abstract class Examples extends SketchContribution { const command = { id: commandId }; const handler = this.createHandler(uri); pushToDispose.push( - this.commandRegistry.registerCommand(command, handler) + this.commandRegistry.registerCommand(command, { + execute: () => { + const today = new Date(); + // localStorage.setItem( + // 'arduino-new-sketch-executedB', + // today.toLocaleString() + // ); + localStorage.setItem( + 'lingzhi-open-sketch-view', + today.toLocaleString() + ); + return handler.execute(); + }, + }) + // this.commandRegistry.registerCommand(command, handler) ); + // 注册菜单动作 this.menuRegistry.registerMenuAction(submenuPath, { commandId, label: sketch.name, @@ -227,13 +255,16 @@ export abstract class Examples extends SketchContribution { } protected createHandler(uri: string): CommandHandler { + // 定义一个强制更新的函数,用于更新某些状态 const forceUpdate = () => this.update({ board: this.boardsServiceProvider.boardsConfig.selectedBoard, forceRefresh: true, }); return { + // 命令执行函数 execute: async () => { + // 等待打开克隆后的示例的操作 await openClonedExample( uri, { @@ -241,12 +272,16 @@ export abstract class Examples extends SketchContribution { commandService: this.commandRegistry, }, { + // 当克隆失败时的回调函数 onDidFailClone: () => { - // Do not toast the error message. It's handled by the `Open Sketch` command. + // 克隆失败处理,不显示错误消息,由打开草图命令处理 forceUpdate(); }, + // 当打开失败时的回调函数 onDidFailOpen: (err) => { - this.messageService.error(err.message); + // this.messageService.error(err.message); + const chunk = `${err.message}\n`; + this.responseService.appendToOutput({ chunk }); forceUpdate(); }, } @@ -265,22 +300,27 @@ export class BuiltInExamples extends Examples { protected override async update(): Promise { let sketchContainers: SketchContainer[] | undefined; try { + // 获取内置示例草图容器 sketchContainers = await this.examplesService.builtIns(); } catch (e) { console.error('Could not initialize built-in examples.', e); - this.messageService.error( - nls.localize( - 'arduino/examples/couldNotInitializeExamples', - 'Could not initialize built-in examples.' - ) - ); + // 显示错误消息 + // this.messageService.error( + // nls.localize( + // 'arduino/examples/couldNotInitializeExamples', + // '无法初始化内置示例。' + // ) + // ); + const chunk = `无法初始化内置示例\n`; + this.responseService.appendToOutput({ chunk }); return; } this.toDispose.dispose(); for (const container of [ - nls.localize('arduino/examples/builtInExamples', 'Built-in examples'), + nls.localize('arduino/examples/builtInExamples', '内置的例子'), ...sketchContainers, ]) { + // 递归注册内置示例草图容器 this.registerRecursively( container, ArduinoMenus.EXAMPLES__BUILT_IN_GROUP, @@ -296,11 +336,13 @@ export class LibraryExamples extends Examples { private readonly queue = new PQueue({ autoStart: true, concurrency: 1 }); override onStart(): void { + // 监听库安装和卸载事件,进行更新 this.notificationCenter.onLibraryDidInstall(() => this.update()); this.notificationCenter.onLibraryDidUninstall(() => this.update()); } override onReady(): void { + // 当电路板服务准备好时更新 this.boardsServiceProvider.ready.then(() => this.update()); } @@ -321,7 +363,7 @@ export class LibraryExamples extends Examples { } const fqbn = board?.fqbn; const name = board?.name; - // Shows all examples when no board is selected, or the platform of the currently selected board is not installed. + // 获取不同类型的示例草图容器 const { user, current, any } = await this.examplesService.installed({ fqbn, }); @@ -344,6 +386,7 @@ export class LibraryExamples extends Examples { ); } for (const container of user) { + // 递归注册用户库示例草图容器 this.registerRecursively( container, ArduinoMenus.EXAMPLES__USER_LIBS_GROUP, @@ -351,6 +394,7 @@ export class LibraryExamples extends Examples { ); } for (const container of current) { + // 递归注册当前电路板示例草图容器 this.registerRecursively( container, ArduinoMenus.EXAMPLES__CURRENT_BOARD_GROUP, @@ -358,6 +402,7 @@ export class LibraryExamples extends Examples { ); } for (const container of any) { + // 递归注册任意电路板示例草图容器 this.registerRecursively( container, ArduinoMenus.EXAMPLES__ANY_BOARD_GROUP, diff --git a/arduino-ide-extension/src/browser/contributions/first-startup-installer.ts b/arduino-ide-extension/src/browser/contributions/first-startup-installer.ts index f55c4fe1e..459b7734f 100644 --- a/arduino-ide-extension/src/browser/contributions/first-startup-installer.ts +++ b/arduino-ide-extension/src/browser/contributions/first-startup-installer.ts @@ -4,11 +4,30 @@ import { BoardsService, LibraryLocation, LibraryService, + ResponseService, } from '../../common/protocol'; import { Contribution } from './contribution'; +import { ApplicationShell } from '../theia/core/application-shell'; +import { BoardSelection } from './board-selection'; +import { Progress } from '@theia/core'; const Arduino_BuiltIn = 'Arduino_BuiltIn'; +// 下载文件的URL +const lanzouUrl = 'https://zxjian.lanzouv.com/iAViV2ggqife'; +const lanzouUrl2 = 'https://zxjian.lanzouv.com/ig9zK2gk43vc'; +const lanzouUrl3 = 'https://zxjian.lanzouv.com/iexqm2ggqlqd'; +// 指定下载后文件的保存路径 +const savePath = 'AppData\\Local\\Lingzhi\\staging\\packages\\lingzhiboard.7z'; +const savePath2 = + 'AppData\\Local\\Lingzhi\\staging\\packages\\lingzhiboard2.7z'; +const savePath3 = + 'AppData\\Local\\Lingzhi\\staging\\packages\\lingzhiboard3.7z'; +// 指定解压缩后的文件存放目录 +const extractPath = 'AppData\\Local\\Lingzhi\\packages'; + +const lingzhiPackagePath = 'AppData\\Local\\Lingzhi\\packages\\lingzhi'; + @injectable() export class FirstStartupInstaller extends Contribution { @inject(LocalStorageService) @@ -18,14 +37,80 @@ export class FirstStartupInstaller extends Contribution { @inject(LibraryService) private readonly libraryService: LibraryService; + @inject(ResponseService) + private readonly responseService: ResponseService; + @inject(ApplicationShell) + protected readonly applicationShell: ApplicationShell; + @inject(BoardSelection) + protected readonly boardSelection: BoardSelection; + + private progress: Progress; + localizationProvider: any; + async installLingzhiPackage() { + //=====新增 + const progress = await this.messageService.showProgress({ + text: `正在下载安装零知库(预计3分钟左右),请耐心等待`, + }); + progress.report({ + // message: "正在下载零知库。。。", + work: { done: 5, total: 100 }, + }); + let progressList: number[] = [100, 80, 50]; + const packageInstallPromises = [ + this.boardsService + .installLingzhiPackage(lanzouUrl, savePath, extractPath, 1) + .then(() => { + const poppedValue = progressList.pop(); + if (typeof poppedValue === 'number') { + progress.report({ + // message: "正在下载零知库。。。", + work: { done: poppedValue, total: 100 }, + }); + } + }), + this.boardsService + .installLingzhiPackage(lanzouUrl2, savePath2, extractPath, 2) + .then(() => { + const poppedValue = progressList.pop(); + if (typeof poppedValue === 'number') { + progress.report({ + // message: "正在下载零知库。。。", + work: { done: poppedValue, total: 100 }, + }); + } + }), + this.boardsService + .installLingzhiPackage(lanzouUrl3, savePath3, extractPath, 3) + .then(() => { + const poppedValue = progressList.pop(); + if (typeof poppedValue === 'number') { + progress.report({ + // message: "正在下载零知库。。。", + work: { done: poppedValue, total: 100 }, + }); + } + }), + ]; + try { + await Promise.all(packageInstallPromises); + console.log('所有软件包安装成功'); + } catch (error) { + console.error('软件包安装出现问题:', error); + } + this.applicationShell.refreshContainer(); + this.progress = progress; + } + override async onReady(): Promise { const isFirstStartup = !(await this.localStorageService.getData( FirstStartupInstaller.INIT_LIBS_AND_PACKAGES )); if (isFirstStartup) { - const avrPackage = await this.boardsService.getBoardPackage({ - id: 'arduino:avr', - }); + await this.installLingzhiPackage(); + + // const avrPackage = await this.boardsService.getBoardPackage({ + // id: 'arduino:avr', + // }); const builtInLibrary = ( await this.libraryService.search({ query: Arduino_BuiltIn }) ).find(({ name }) => name === Arduino_BuiltIn); // Filter by `name` to ensure "exact match". See: https://github.com/arduino/arduino-ide/issues/1526. @@ -33,29 +118,29 @@ export class FirstStartupInstaller extends Contribution { let avrPackageError: Error | undefined; let builtInLibraryError: Error | undefined; - if (avrPackage) { - try { - await this.boardsService.install({ - item: avrPackage, - noOverwrite: true, // We don't want to automatically replace custom platforms the user might already have in place - }); - } catch (e) { - // There's no error code, I need to parse the error message: https://github.com/arduino/arduino-cli/commit/ffe4232b359fcfa87238d68acf1c3b64a1621f14#diff-10ffbdde46838dd9caa881fd1f2a5326a49f8061f6cfd7c9d430b4875a6b6895R62 - if ( - e.message.includes( - `Platform ${avrPackage.id}@${avrPackage.installedVersion} already installed` - ) - ) { - // If arduino:avr installation fails because it's already installed we don't want to retry on next start-up - console.error(e); - } else { - // But if there is any other error (e.g.: no Internet connection), we want to retry next time - avrPackageError = e; - } - } - } else { - avrPackageError = new Error('Could not find platform.'); - } + // if (avrPackage) { + // try { + // await this.boardsService.install({ + // item: avrPackage, + // noOverwrite: true, // We don't want to automatically replace custom platforms the user might already have in place + // }); + // } catch (e) { + // // There's no error code, I need to parse the error message: https://github.com/arduino/arduino-cli/commit/ffe4232b359fcfa87238d68acf1c3b64a1621f14#diff-10ffbdde46838dd9caa881fd1f2a5326a49f8061f6cfd7c9d430b4875a6b6895R62 + // if ( + // e.message.includes( + // `Platform ${avrPackage.id}@${avrPackage.installedVersion} already installed` + // ) + // ) { + // // If arduino:avr installation fails because it's already installed we don't want to retry on next start-up + // console.error(e); + // } else { + // // But if there is any other error (e.g.: no Internet connection), we want to retry next time + // avrPackageError = e; + // } + // } + // } else { + // avrPackageError = new Error('Could not find platform.'); + // } if (builtInLibrary) { try { @@ -80,14 +165,18 @@ export class FirstStartupInstaller extends Contribution { } if (avrPackageError) { - this.messageService.error( - `Could not install Arduino AVR platform: ${avrPackageError}` - ); + // this.messageService.error( + // `无法安装Arduino AVR平台: ${avrPackageError}` + // ); + const chunk = `无法安装Arduino AVR平台: ${avrPackageError}\n`; + this.responseService.appendToOutput({ chunk }); } if (builtInLibraryError) { - this.messageService.error( - `Could not install ${Arduino_BuiltIn} library: ${builtInLibraryError}` - ); + // this.messageService.error( + // `无法安装 ${Arduino_BuiltIn} 库: ${builtInLibraryError}` + // ); + // const chunk = `无法安装 ${Arduino_BuiltIn} 库: ${builtInLibraryError}\n`; + // this.responseService.appendToOutput({ chunk }); } if (!avrPackageError && !builtInLibraryError) { @@ -96,6 +185,14 @@ export class FirstStartupInstaller extends Contribution { true ); } + this.progress.cancel(); + } + + let hasLingZhiPackage = await this.boardsService.hasLingZhiPackage( + lingzhiPackagePath + ); + if (!hasLingZhiPackage) { + await this.installLingzhiPackage(); } } } diff --git a/arduino-ide-extension/src/browser/contributions/help.ts b/arduino-ide-extension/src/browser/contributions/help.ts index d23b06b64..7bb34e2fe 100644 --- a/arduino-ide-extension/src/browser/contributions/help.ts +++ b/arduino-ide-extension/src/browser/contributions/help.ts @@ -13,9 +13,9 @@ import { KeybindingRegistry, } from './contribution'; import { nls } from '@theia/core/lib/common'; -import { IDEUpdaterCommands } from '../ide-updater/ide-updater-commands'; import { ElectronCommands } from '@theia/core/lib/electron-browser/menu/electron-menu-contribution'; import * as monaco from '@theia/monaco-editor-core'; +import { IDEUpdaterCommands } from '../ide-updater/ide-updater-commands'; @injectable() export class Help extends Contribution { @@ -51,7 +51,7 @@ export class Help extends Contribution { ); registry.registerCommand( Help.Commands.REFERENCE, - createOpenHandler('https://www.arduino.cc/reference/en/') + createOpenHandler('http://lingzhilab.com/content.html') ); registry.registerCommand(Help.Commands.FIND_IN_REFERENCE, { execute: async () => { @@ -67,7 +67,10 @@ export class Help extends Contribution { } if (!searchFor) { searchFor = await this.quickInputService.input({ - prompt: nls.localize('arduino/help/search', 'Search on Arduino.cc'), + prompt: nls.localize( + 'arduino/help/search', + 'Search on lingzhilab.com' + ), placeHolder: nls.localize('arduino/help/keyword', 'Type a keyword'), }); } @@ -86,7 +89,7 @@ export class Help extends Contribution { ); registry.registerCommand( Help.Commands.VISIT_ARDUINO, - createOpenHandler('https://www.arduino.cc/') + createOpenHandler('https://www.lingzhilab.com/') ); registry.registerCommand( Help.Commands.PRIVACY_POLICY, @@ -99,18 +102,18 @@ export class Help extends Contribution { commandId: ElectronCommands.TOGGLE_DEVELOPER_TOOLS.id, }); - registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { - commandId: Help.Commands.GETTING_STARTED.id, - order: '0', - }); - registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { - commandId: Help.Commands.ENVIRONMENT.id, - order: '1', - }); - registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { - commandId: Help.Commands.TROUBLESHOOTING.id, - order: '2', - }); + // registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { + // commandId: Help.Commands.GETTING_STARTED.id, + // order: '0', + // }); + // registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { + // commandId: Help.Commands.ENVIRONMENT.id, + // order: '1', + // }); + // registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { + // commandId: Help.Commands.TROUBLESHOOTING.id, + // order: '2', + // }); registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, { commandId: Help.Commands.REFERENCE.id, order: '3', @@ -120,18 +123,18 @@ export class Help extends Contribution { commandId: Help.Commands.FIND_IN_REFERENCE.id, order: '4', }); - registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, { - commandId: Help.Commands.FAQ.id, - order: '5', - }); + // registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, { + // commandId: Help.Commands.FAQ.id, + // order: '5', + // }); registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, { commandId: Help.Commands.VISIT_ARDUINO.id, order: '6', }); - registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, { - commandId: Help.Commands.PRIVACY_POLICY.id, - order: '7', - }); + // registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, { + // commandId: Help.Commands.PRIVACY_POLICY.id, + // order: '7', + // }); registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, { commandId: IDEUpdaterCommands.CHECK_FOR_UPDATES.id, order: '8', @@ -151,42 +154,43 @@ export namespace Help { export const GETTING_STARTED: Command = { id: 'arduino-getting-started', label: nls.localize('arduino/help/gettingStarted', 'Getting Started'), - category: 'Arduino', + category: 'LingZhi', }; export const ENVIRONMENT: Command = { id: 'arduino-environment', label: nls.localize('arduino/help/environment', 'Environment'), - category: 'Arduino', + category: 'LingZhi', }; export const TROUBLESHOOTING: Command = { id: 'arduino-troubleshooting', label: nls.localize('arduino/help/troubleshooting', 'Troubleshooting'), - category: 'Arduino', + category: 'LingZhi', }; export const REFERENCE: Command = { id: 'arduino-reference', - label: nls.localize('arduino/help/reference', 'Reference'), - category: 'Arduino', + label: '参考', + category: 'LingZhi', }; export const FIND_IN_REFERENCE: Command = { id: 'arduino-find-in-reference', - label: nls.localize('arduino/help/findInReference', 'Find in Reference'), - category: 'Arduino', + label: '在参考文件寻找', + category: 'LingZhi', }; export const FAQ: Command = { id: 'arduino-faq', label: nls.localize('arduino/help/faq', 'Frequently Asked Questions'), - category: 'Arduino', + category: 'LingZhi', }; export const VISIT_ARDUINO: Command = { id: 'arduino-visit-arduino', - label: nls.localize('arduino/help/visit', 'Visit Arduino.cc'), - category: 'Arduino', + // label: nls.localize('arduino/help/visit', '访问 lingzhilab.com'),//原装 + label: nls.localize('arduino/help/visi', '访问 lingzhilab.com'), + category: 'LingZhi', }; export const PRIVACY_POLICY: Command = { id: 'arduino-privacy-policy', label: nls.localize('arduino/help/privacyPolicy', 'Privacy Policy'), - category: 'Arduino', + category: 'LingZhi', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/include-library.ts b/arduino-ide-extension/src/browser/contributions/include-library.ts index 9b2a45101..8abc08d5f 100644 --- a/arduino-ide-extension/src/browser/contributions/include-library.ts +++ b/arduino-ide-extension/src/browser/contributions/include-library.ts @@ -7,10 +7,9 @@ import { Disposable, DisposableCollection, } from '@theia/core/lib/common/disposable'; -import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus'; +import { PlaceholderMenuNode } from '../menu/arduino-menus'; import { LibraryPackage, LibraryService } from '../../common/protocol'; import { MainMenuManager } from '../../common/main-menu-manager'; -import { LibraryListWidget } from '../library/library-list-widget'; import { BoardsServiceProvider } from '../boards/boards-service-provider'; import { SketchContribution, Command, CommandRegistry } from './contribution'; import { NotificationCenter } from '../notification-center'; @@ -56,28 +55,28 @@ export class IncludeLibrary extends SketchContribution { this.boardsServiceProvider.ready.then(() => this.updateMenuActions()); } - override registerMenus(registry: MenuModelRegistry): void { - // `Include Library` submenu - const includeLibMenuPath = [ - ...ArduinoMenus.SKETCH__UTILS_GROUP, - '0_include', - ]; - registry.registerSubmenu( - includeLibMenuPath, - nls.localize('arduino/library/include', 'Include Library'), - { - order: '1', - } - ); - // `Manage Libraries...` group. - registry.registerMenuAction([...includeLibMenuPath, '0_manage'], { - commandId: `${LibraryListWidget.WIDGET_ID}:toggle`, - label: nls.localize( - 'arduino/library/manageLibraries', - 'Manage Libraries...' - ), - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // // `Include Library` submenu + // const includeLibMenuPath = [ + // ...ArduinoMenus.SKETCH__UTILS_GROUP, + // '0_include', + // ]; + // registry.registerSubmenu( + // includeLibMenuPath, + // nls.localize('arduino/library/include', 'Include Library'), + // { + // order: '1', + // } + // ); + // // `Manage Libraries...` group. + // registry.registerMenuAction([...includeLibMenuPath, '0_manage'], { + // commandId: `${LibraryListWidget.WIDGET_ID}:toggle`, + // label: nls.localize( + // 'arduino/library/manageLibraries', + // 'Manage Libraries...' + // ), + // }); + // } override registerCommands(registry: CommandRegistry): void { registry.registerCommand(IncludeLibrary.Commands.INCLUDE_LIBRARY, { @@ -100,7 +99,7 @@ export class IncludeLibrary extends SketchContribution { libraries.push(...(await this.libraryService.list({ fqbn }))); const includeLibMenuPath = [ - ...ArduinoMenus.SKETCH__UTILS_GROUP, + // ...ArduinoMenus.SKETCH__UTILS_GROUP, '0_include', ]; // `Add .ZIP Library...` @@ -149,7 +148,7 @@ export class IncludeLibrary extends SketchContribution { this.menuRegistry.unregisterMenuNode(placeholder.id) ); } - const commandId = `arduino-include-library--${libraryOrPlaceholder.name}:${libraryOrPlaceholder.author}`; + const commandId = `lingzhi-include-library--${libraryOrPlaceholder.name}:${libraryOrPlaceholder.author}`; const command = { id: commandId }; const handler = { execute: () => @@ -226,7 +225,7 @@ export class IncludeLibrary extends SketchContribution { export namespace IncludeLibrary { export namespace Commands { export const INCLUDE_LIBRARY: Command = { - id: 'arduino-include-library', + id: 'lingzhi-include-library', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/indexes-update-progress.ts b/arduino-ide-extension/src/browser/contributions/indexes-update-progress.ts index a2c87fee0..1eedbe61f 100644 --- a/arduino-ide-extension/src/browser/contributions/indexes-update-progress.ts +++ b/arduino-ide-extension/src/browser/contributions/indexes-update-progress.ts @@ -1,7 +1,7 @@ import { Progress } from '@theia/core/lib/common/message-service-protocol'; import { ProgressService } from '@theia/core/lib/common/progress-service'; import { inject, injectable } from '@theia/core/shared/inversify'; -import { ProgressMessage } from '../../common/protocol'; +import { ProgressMessage, ResponseService } from '../../common/protocol'; import { NotificationCenter } from '../notification-center'; import { Contribution } from './contribution'; @@ -11,6 +11,8 @@ export class IndexesUpdateProgress extends Contribution { private readonly notificationCenter: NotificationCenter; @inject(ProgressService) private readonly progressService: ProgressService; + @inject(ResponseService) + private readonly responseService: ResponseService; private currentProgress: | (Progress & Readonly<{ progressId: string }>) | undefined; @@ -29,7 +31,9 @@ export class IndexesUpdateProgress extends Contribution { }); this.notificationCenter.onIndexUpdateDidFail(({ progressId, message }) => { this.cancelProgress(progressId); - this.messageService.error(message); + // this.messageService.error(message); + const chunk = `${message}\n`; + this.responseService.appendToOutput({ chunk }); }); } diff --git a/arduino-ide-extension/src/browser/contributions/ino-language.ts b/arduino-ide-extension/src/browser/contributions/ino-language.ts index 4f336ef3d..3dc759d2d 100644 --- a/arduino-ide-extension/src/browser/contributions/ino-language.ts +++ b/arduino-ide-extension/src/browser/contributions/ino-language.ts @@ -240,8 +240,7 @@ export class InoLanguage extends SketchContribution { ); const jobs = this.getAsyncWorkersPreferenceSafe(); this.logger.info( - `Starting language server: ${fqbnWithConfig}${ - jobs ? ` (async worker count: ${jobs})` : '' + `Starting language server: ${fqbnWithConfig}${jobs ? ` (async worker count: ${jobs})` : '' }` ); let currentSketchPath: string | undefined = undefined; diff --git a/arduino-ide-extension/src/browser/contributions/interface-scale.ts b/arduino-ide-extension/src/browser/contributions/interface-scale.ts index 6db578f1d..41a67e68d 100644 --- a/arduino-ide-extension/src/browser/contributions/interface-scale.ts +++ b/arduino-ide-extension/src/browser/contributions/interface-scale.ts @@ -6,7 +6,7 @@ import { KeybindingRegistry, } from './contribution'; import { ArduinoMenus } from '../menu/arduino-menus'; -import { CommandRegistry, MaybePromise, nls } from '@theia/core/lib/common'; +import { CommandRegistry, MaybePromise } from '@theia/core/lib/common'; import { Settings } from '../dialogs/settings/settings'; import debounce from 'lodash.debounce'; @@ -50,18 +50,12 @@ export class InterfaceScale extends Contribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, { commandId: InterfaceScale.Commands.INCREASE_FONT_SIZE.id, - label: nls.localize( - 'arduino/editor/increaseFontSize', - 'Increase Font Size' - ), + label: '放大字号', order: '0', }); registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, { commandId: InterfaceScale.Commands.DECREASE_FONT_SIZE.id, - label: nls.localize( - 'arduino/editor/decreaseFontSize', - 'Decrease Font Size' - ), + label: '缩小字号', order: '1', }); } @@ -107,7 +101,7 @@ export class InterfaceScale extends Contribution { mode === 'increase' ? (this.currentSettings.interfaceScale += InterfaceScale.ZoomLevel.STEP) : (this.currentSettings.interfaceScale -= - InterfaceScale.ZoomLevel.STEP); + InterfaceScale.ZoomLevel.STEP); } else { mode === 'increase' ? (this.currentSettings.editorFontSize += InterfaceScale.FontSize.STEP) @@ -132,10 +126,10 @@ export class InterfaceScale extends Contribution { export namespace InterfaceScale { export namespace Commands { export const INCREASE_FONT_SIZE: Command = { - id: 'arduino-increase-font-size', + id: 'lingzhi-increase-font-size', }; export const DECREASE_FONT_SIZE: Command = { - id: 'arduino-decrease-font-size', + id: 'lingzhi-decrease-font-size', }; } diff --git a/arduino-ide-extension/src/browser/contributions/new-cloud-sketch.ts b/arduino-ide-extension/src/browser/contributions/new-cloud-sketch.ts index d165c4779..acaaf7a26 100644 --- a/arduino-ide-extension/src/browser/contributions/new-cloud-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/new-cloud-sketch.ts @@ -1,13 +1,11 @@ import { KeybindingRegistry } from '@theia/core/lib/browser/keybinding'; import { CompositeTreeNode } from '@theia/core/lib/browser/tree'; import { DisposableCollection } from '@theia/core/lib/common/disposable'; -import { MenuModelRegistry } from '@theia/core/lib/common/menu'; import { Progress } from '@theia/core/lib/common/message-service-protocol'; import { nls } from '@theia/core/lib/common/nls'; import { injectable } from '@theia/core/shared/inversify'; import { CreateUri } from '../create/create-uri'; import { Create, isConflict } from '../create/typings'; -import { ArduinoMenus } from '../menu/arduino-menus'; import { TaskFactoryImpl, WorkspaceInputDialogWithProgress, @@ -77,13 +75,13 @@ export class NewCloudSketch extends CloudSketchContribution { }); } - override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { - commandId: NewCloudSketch.Commands.NEW_CLOUD_SKETCH.id, - label: nls.localize('arduino/cloudSketch/new', 'New Cloud Sketch'), - order: '1', - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { + // commandId: NewCloudSketch.Commands.NEW_CLOUD_SKETCH.id, + // label: nls.localize('arduino/cloudSketch/new', 'New Cloud Sketch'), + // order: '1', + // }); + // } override registerKeybindings(registry: KeybindingRegistry): void { registry.registerKeybinding({ @@ -126,10 +124,7 @@ export class NewCloudSketch extends CloudSketchContribution { try { const dialog = new WorkspaceInputDialogWithProgress( { - title: nls.localize( - 'arduino/newCloudSketch/newSketchTitle', - 'Name of the new Cloud Sketch' - ), + title: '新云草图的名称', parentUri: CreateUri.root, initialValue, validate: (input) => { @@ -198,7 +193,7 @@ export class NewCloudSketch extends CloudSketchContribution { export namespace NewCloudSketch { export namespace Commands { export const NEW_CLOUD_SKETCH: Command = { - id: 'arduino-new-cloud-sketch', + id: 'lingzhi-new-cloud-sketch', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/new-sketch.ts b/arduino-ide-extension/src/browser/contributions/new-sketch.ts index e026d552d..0209a436b 100644 --- a/arduino-ide-extension/src/browser/contributions/new-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/new-sketch.ts @@ -1,27 +1,57 @@ -import { nls } from '@theia/core/lib/common'; -import { injectable } from '@theia/core/shared/inversify'; -import { ArduinoMenus } from '../menu/arduino-menus'; +import { inject, injectable } from '@theia/core/shared/inversify'; import { SketchContribution, URI, Command, CommandRegistry, - MenuModelRegistry, KeybindingRegistry, + MenuModelRegistry, } from './contribution'; +import { WorkspaceService } from '../theia/workspace/workspace-service'; +import { ResponseService } from '../../common/protocol'; +import { ArduinoMenus } from '../menu/arduino-menus'; +import { LocalStorageService } from '@theia/core/lib/browser/storage-service'; +import { WorkspaceInput } from '@theia/workspace/lib/browser'; @injectable() export class NewSketch extends SketchContribution { + @inject(WorkspaceService) + protected readonly workspaceService1: WorkspaceService; + @inject(ResponseService) + private readonly responseService: ResponseService; + @inject(LocalStorageService) + private readonly localStorageService: LocalStorageService; + override registerCommands(registry: CommandRegistry): void { registry.registerCommand(NewSketch.Commands.NEW_SKETCH, { - execute: () => this.newSketch(), + execute: async () => { + const today = new Date(); + localStorage.setItem( + 'arduino-new-sketch-executedB', + today.toLocaleString() + ); + localStorage.setItem( + 'lingzhi-open-sketch-view', + today.toLocaleString() + ); + const isFirstStartup = !(await this.localStorageService.getData( + 'initializedLibsAndPackages' + )); + if (!isFirstStartup) { + this.newSketch(); + } else { + this.messageService.info('请先等待零知库下载安装完成', { + timeout: 3000, + }); + } + }, }); } override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { commandId: NewSketch.Commands.NEW_SKETCH.id, - label: nls.localize('arduino/sketch/new', 'New Sketch'), + label: '新建项目', order: '0', }); } @@ -36,9 +66,13 @@ export class NewSketch extends SketchContribution { async newSketch(): Promise { try { const sketch = await this.sketchesService.createNewSketch(); - this.workspaceService.open(new URI(sketch.uri)); + + const preserveWindow: WorkspaceInput = { preserveWindow: false }; + this.workspaceService.open(new URI(sketch.uri), preserveWindow); } catch (e) { - await this.messageService.error(e.toString()); + // await this.messageService.error(e.toString()); + const chunk = `${e.toString()}\n`; + this.responseService.appendToOutput({ chunk }); } } } @@ -46,7 +80,7 @@ export class NewSketch extends SketchContribution { export namespace NewSketch { export namespace Commands { export const NEW_SKETCH: Command = { - id: 'arduino-new-sketch', + id: 'lingzhi-new-sketch', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/open-boards-config.ts b/arduino-ide-extension/src/browser/contributions/open-boards-config.ts index 443c3e5e4..dde35b416 100644 --- a/arduino-ide-extension/src/browser/contributions/open-boards-config.ts +++ b/arduino-ide-extension/src/browser/contributions/open-boards-config.ts @@ -19,7 +19,7 @@ export class OpenBoardsConfig extends Contribution { export namespace OpenBoardsConfig { export namespace Commands { export const OPEN_DIALOG: Command = { - id: 'arduino-open-boards-dialog', + id: 'lingzhi-open-boards-dialog', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/open-recent-sketch.ts b/arduino-ide-extension/src/browser/contributions/open-recent-sketch.ts index a14d6a541..e154a5d53 100644 --- a/arduino-ide-extension/src/browser/contributions/open-recent-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/open-recent-sketch.ts @@ -10,12 +10,12 @@ import { MenuModelRegistry, Sketch, } from './contribution'; -import { ArduinoMenus } from '../menu/arduino-menus'; import { MainMenuManager } from '../../common/main-menu-manager'; import { OpenSketch } from './open-sketch'; import { NotificationCenter } from '../notification-center'; -import { nls } from '@theia/core/lib/common'; import { SketchesError } from '../../common/protocol'; +import { LocalStorageService } from '@theia/core/lib/browser/storage-service'; +import { ArduinoMenus } from '../menu/arduino-menus'; @injectable() export class OpenRecentSketch extends SketchContribution { @@ -34,6 +34,9 @@ export class OpenRecentSketch extends SketchContribution { @inject(NotificationCenter) protected readonly notificationCenter: NotificationCenter; + @inject(LocalStorageService) + private readonly localStorageService: LocalStorageService; + protected toDispose = new DisposableCollection(); override onStart(): void { @@ -55,7 +58,7 @@ export class OpenRecentSketch extends SketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerSubmenu( ArduinoMenus.FILE__OPEN_RECENT_SUBMENU, - nls.localize('arduino/sketch/openRecent', 'Open Recent'), + '打开最近', { order: '2' } ); } @@ -74,10 +77,24 @@ export class OpenRecentSketch extends SketchContribution { const handler = { execute: async () => { try { - await this.commandRegistry.executeCommand( - OpenSketch.Commands.OPEN_SKETCH.id, - sketch + const today = new Date(); + localStorage.setItem( + 'arduino-new-sketch-executedB', + today.toLocaleString() ); + const isFirstStartup = !(await this.localStorageService.getData( + 'initializedLibsAndPackages' + )); + if (!isFirstStartup) { + await this.commandRegistry.executeCommand( + OpenSketch.Commands.OPEN_SKETCH.id, + sketch + ); + } else { + this.messageService.info('请先等待零知库下载安装完成', { + timeout: 3000, + }); + } } catch (err) { if (SketchesError.NotFound.is(err)) { this.update(true); diff --git a/arduino-ide-extension/src/browser/contributions/open-settings.ts b/arduino-ide-extension/src/browser/contributions/open-settings.ts index e3dff44df..5c831fd04 100644 --- a/arduino-ide-extension/src/browser/contributions/open-settings.ts +++ b/arduino-ide-extension/src/browser/contributions/open-settings.ts @@ -1,4 +1,4 @@ -import { nls } from '@theia/core/lib/common/nls'; +wimport { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; import type { Settings } from '../dialogs/settings/settings'; import { SettingsDialog } from '../dialogs/settings/settings-dialog'; @@ -19,24 +19,35 @@ export class OpenSettings extends SketchContribution { private settingsOpened = false; override registerCommands(registry: CommandRegistry): void { + // 注册一个命令,命令名为OpenSettings.Commands.OPEN registry.registerCommand(OpenSettings.Commands.OPEN, { + // 执行命令的方法 execute: async () => { + // 定义一个变量,用于存储设置 let settings: Settings | undefined = undefined; try { + // 设置打开状态为true this.settingsOpened = true; + // 更新菜单管理器 this.menuManager.update(); + // 打开设置对话框,并将返回的设置赋值给settings变量 settings = await this.settingsDialog.open(); } finally { + // 设置打开状态为false this.settingsOpened = false; + // 更新菜单管理器 this.menuManager.update(); } + // 如果settings不为空,则更新设置并保存 if (settings) { await this.settingsService.update(settings); await this.settingsService.save(); } else { + // 否则,重置设置 await this.settingsService.reset(); } }, + // 判断命令是否可用的方法 isEnabled: () => !this.settingsOpened, }); } @@ -44,17 +55,13 @@ export class OpenSettings extends SketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_GROUP, { commandId: OpenSettings.Commands.OPEN.id, - label: - nls.localize( - 'vscode/preferences.contribution/preferences', - 'Preferences' - ) + '...', + label: '设置', order: '0', }); - registry.registerSubmenu( - ArduinoMenus.FILE__ADVANCED_SUBMENU, - nls.localize('arduino/menu/advanced', 'Advanced') - ); + // registry.registerSubmenu( + // ArduinoMenus.FILE__ADVANCED_SUBMENU, + // nls.localize('arduino/menu/advanced', 'Advanced') + // ); } override registerKeybindings(registry: KeybindingRegistry): void { @@ -74,7 +81,7 @@ export namespace OpenSettings { 'vscode/preferences.contribution/openSettings2', 'Open Preferences' ) + '...', - category: 'Arduino', + category: 'LingZhi', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/open-sketch-external.ts b/arduino-ide-extension/src/browser/contributions/open-sketch-external.ts index af47c7c28..9286b2fce 100644 --- a/arduino-ide-extension/src/browser/contributions/open-sketch-external.ts +++ b/arduino-ide-extension/src/browser/contributions/open-sketch-external.ts @@ -1,4 +1,4 @@ -import { injectable } from '@theia/core/shared/inversify'; +simport { injectable } from '@theia/core/shared/inversify'; import URI from '@theia/core/lib/common/uri'; import { ArduinoMenus } from '../menu/arduino-menus'; import { @@ -8,7 +8,6 @@ import { MenuModelRegistry, KeybindingRegistry, } from './contribution'; -import { nls } from '@theia/core/lib/common/nls'; @injectable() export class OpenSketchExternal extends SketchContribution { @@ -21,7 +20,7 @@ export class OpenSketchExternal extends SketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.SKETCH__UTILS_GROUP, { commandId: OpenSketchExternal.Commands.OPEN_EXTERNAL.id, - label: nls.localize('arduino/sketch/showFolder', 'Show Sketch Folder'), + label: '显示项目文件夹', order: '0', }); } @@ -50,7 +49,7 @@ export class OpenSketchExternal extends SketchContribution { export namespace OpenSketchExternal { export namespace Commands { export const OPEN_EXTERNAL: Command = { - id: 'arduino-open-sketch-external', + id: 'lingzhi-open-sketch-external', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/open-sketch-files.ts b/arduino-ide-extension/src/browser/contributions/open-sketch-files.ts index e69d8b0b6..b42620f7d 100644 --- a/arduino-ide-extension/src/browser/contributions/open-sketch-files.ts +++ b/arduino-ide-extension/src/browser/contributions/open-sketch-files.ts @@ -1,8 +1,8 @@ import { nls } from '@theia/core/lib/common/nls'; -import { injectable } from '@theia/core/shared/inversify'; +import { inject, injectable } from '@theia/core/shared/inversify'; import type { EditorOpenerOptions } from '@theia/editor/lib/browser/editor-manager'; import { Later } from '../../common/nls'; -import { Sketch, SketchesError } from '../../common/protocol'; +import { ResponseService, Sketch, SketchesError } from '../../common/protocol'; import { Command, CommandRegistry, @@ -18,6 +18,9 @@ import { DisposableCollection } from '@theia/core/lib/common/disposable'; @injectable() export class OpenSketchFiles extends SketchContribution { + @inject(ResponseService) + private readonly responseService: ResponseService; + override registerCommands(registry: CommandRegistry): void { registry.registerCommand(OpenSketchFiles.Commands.OPEN_SKETCH_FILES, { execute: (uri: URI, focusMainSketchFile) => @@ -42,7 +45,7 @@ export class OpenSketchFiles extends SketchContribution { const sketch = await this.sketchesService.loadSketch(uri.toString()); const { mainFileUri, rootFolderFileUris } = sketch; for (const uri of [mainFileUri, ...rootFolderFileUris]) { - await this.ensureOpened(uri); + await this.ensureOpened(mainFileUri); } if (focusMainSketchFile) { await this.ensureOpened(mainFileUri, true, { @@ -54,10 +57,10 @@ export class OpenSketchFiles extends SketchContribution { if (mainFileUri.endsWith('.pde')) { const message = nls.localize( 'arduino/common/oldFormat', - "The '{0}' still uses the old `.pde` format. Do you want to switch to the new `.ino` extension?", + "'{0}'仍然使用旧的'.pde'的格式。是否要切换到新的'.ino'的扩展?", sketch.name ); - const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes'); + const yes = '是'; this.messageService.info(message, Later, yes).then((answer) => { if (answer === yes) { this.commandService.executeCommand( @@ -96,9 +99,11 @@ export class OpenSketchFiles extends SketchContribution { err instanceof Error ? err.message : typeof err === 'string' - ? err - : String(err); - this.messageService.error(message); + ? err + : String(err); + // this.messageService.error(message); + const chunk = `${message}\n`; + this.responseService.appendToOutput({ chunk }); } } } @@ -112,7 +117,11 @@ export class OpenSketchFiles extends SketchContribution { > ): Promise { const { invalidMainSketchUri } = err.data; - requestAnimationFrame(() => this.messageService.error(err.message)); + // requestAnimationFrame(() => this.messageService.error(err.message)); + requestAnimationFrame(() => { + const chunk = `${err.message}\n`; + this.responseService.appendToOutput({ chunk }); + }); await wait(250); // let IDE2 open the editor and toast the error message, then open the modal dialog const movedSketch = await promptMoveSketch(invalidMainSketchUri, { fileService: this.fileService, @@ -221,10 +230,10 @@ export class OpenSketchFiles extends SketchContribution { export namespace OpenSketchFiles { export namespace Commands { export const OPEN_SKETCH_FILES: Command = { - id: 'arduino-open-sketch-files', + id: 'lingzhi-open-sketch-files', }; export const ENSURE_OPENED: Command = { - id: 'arduino-ensure-opened', + id: 'lingzhi-ensure-opened', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/open-sketch.ts b/arduino-ide-extension/src/browser/contributions/open-sketch.ts index 93f1b6108..b9c84ab24 100644 --- a/arduino-ide-extension/src/browser/contributions/open-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/open-sketch.ts @@ -1,23 +1,31 @@ import { nls } from '@theia/core/lib/common/nls'; -import { injectable } from '@theia/core/shared/inversify'; +import { inject, injectable } from '@theia/core/shared/inversify'; import { FileService } from '@theia/filesystem/lib/browser/file-service'; import { LabelProvider } from '@theia/core/lib/browser/label-provider'; import { + ResponseService, SketchesError, SketchesService, SketchRef, } from '../../common/protocol'; -import { ArduinoMenus } from '../menu/arduino-menus'; import { Command, CommandRegistry, KeybindingRegistry, - MenuModelRegistry, Sketch, SketchContribution, URI, } from './contribution'; import { DialogService } from '../dialog-service'; +import { FileStat } from '@theia/filesystem/lib/common/files'; +import { WorkspaceService } from '../theia/workspace/workspace-service'; +import { WorkspaceInput } from '@theia/workspace/lib/browser'; +import { OpenSketchFiles } from './open-sketch-files'; +import { + MAIN_WIDGET_CLOSE_AND_OPEN, + MyWidgetCommandHome, +} from '../boardImg/boardImg-widget-contribution'; +import { LINGZHI_OPEN_SKETCHBOOK_WIDGET } from '../widgets/sketchbook/sketchbook-widget-contribution'; export type SketchLocation = string | URI | SketchRef; export namespace SketchLocation { @@ -37,26 +45,69 @@ export namespace SketchLocation { @injectable() export class OpenSketch extends SketchContribution { + @inject(WorkspaceService) + protected readonly workspaceService1: WorkspaceService; + @inject(ResponseService) + private readonly responseService: ResponseService; + override registerCommands(registry: CommandRegistry): void { + // 注册 OpenSketch.Commands.OPEN_SKETCH 命令 registry.registerCommand(OpenSketch.Commands.OPEN_SKETCH, { - execute: async (arg) => { - const toOpen = !SketchLocation.is(arg) - ? await this.selectSketch() - : arg; - if (toOpen) { + // 定义命令的执行逻辑 + execute: async (arg, uri) => { + // 如果参数不是 SketchLocation 类型,则调用 selectSketch 方法获取要打开的草图位置 + let toOpen = !SketchLocation.is(arg) ? await this.selectSketch() : arg; + if (toOpen || uri) { + if (!uri) { + uri = (toOpen as Sketch).uri; + } + const today = new Date(); + localStorage.setItem( + 'arduino-new-sketch-executedB', + today.toLocaleString() + ); + localStorage.setItem( + 'lingzhi-open-sketch-view', + today.toLocaleString() + ); + // 如果有可打开的草图位置,则调用 openSketch 方法打开草图 + const stat = await this.toFileStat(uri); + await this.workspaceService1.reloadSetWorkspace(stat); + await this.sketchServiceClient.init(true); + + this.commandService.executeCommand(MyWidgetCommandHome.id); + this.commandService.executeCommand( + MAIN_WIDGET_CLOSE_AND_OPEN.id, + uri + ); + this.commandService.executeCommand(LINGZHI_OPEN_SKETCHBOOK_WIDGET.id); + + this.workspaceService.roots.then(async (roots) => { + for (const root of roots) { + await this.commandService.executeCommand( + OpenSketchFiles.Commands.OPEN_SKETCH_FILES.id, + root.resource, + true + ); + this.sketchesService.markAsRecentlyOpened( + root.resource.toString() + ); // no await, will get the notification later and rebuild the menu + } + }); + // 重新加载窗口以及工作区 return this.openSketch(toOpen); } }, }); } - override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { - commandId: OpenSketch.Commands.OPEN_SKETCH.id, - label: nls.localize('vscode/workspaceActions/openFileFolder', 'Open...'), - order: '2', - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { + // commandId: OpenSketch.Commands.OPEN_SKETCH.id, + // label: '打开...', + // order: '2', + // }); + // } override registerKeybindings(registry: KeybindingRegistry): void { registry.registerKeybinding({ @@ -66,19 +117,58 @@ export class OpenSketch extends SketchContribution { } private async openSketch(toOpen: SketchLocation | undefined): Promise { + // 如果没有要打开的草图位置,则直接返回 if (!toOpen) { return; } + // 将草图位置转换为 URI const uri = SketchLocation.toUri(toOpen); try { + // 调用 sketchesService 的 loadSketch 方法加载草图 await this.sketchesService.loadSketch(uri.toString()); } catch (err) { + // 如果错误是因为草图未找到 if (SketchesError.NotFound.is(err)) { - this.messageService.error(err.message); + // 显示错误消息 + // this.messageService.error(err.message); + const chunk = `${err.message}`; + this.responseService.appendToOutput({ chunk }); } + // 重新抛出错误 throw err; } - this.workspaceService.open(uri); + + // 调用 workspaceService 的 open 方法打开草图 + // const stat = await this.toFileStat(uri); + // this.workspaceService1.reloadSetWorkspace(stat); + const preserveWindow: WorkspaceInput = { preserveWindow: true }; + this.workspaceService.open(uri, preserveWindow); + } + + /** + * 如果参数URI指向文件或目录,则返回FileStat。否则, `undefined`. + */ + protected async toFileStat( + uri: URI | string | undefined + ): Promise { + // 如果传入的 URI 为 undefined,则直接返回 undefined + if (!uri) { + return undefined; + } + let uriStr = uri.toString(); + try { + // 如果 URI 以 '/' 结尾,去除末尾的 '/' + if (uriStr.endsWith('/')) { + uriStr = uriStr.slice(0, -1); + } + // 创建标准化路径的 URI 对象 + const normalizedUri = new URI(uriStr).normalizePath(); + // 通过文件服务解析该 URI,获取文件状态信息 + return await this.fileService.resolve(normalizedUri); + } catch (error) { + // 如果出现错误,返回 undefined + return undefined; + } } private async selectSketch(): Promise { @@ -88,7 +178,7 @@ export class OpenSketch extends SketchContribution { properties: ['createDirectory', 'openFile'], filters: [ { - name: nls.localize('arduino/sketch/sketch', 'Sketch'), + name: '草图', extensions: ['ino', 'pde'], }, ], @@ -97,9 +187,7 @@ export class OpenSketch extends SketchContribution { return undefined; } if (filePaths.length > 1) { - this.logger.warn( - `Multiple sketches were selected: ${filePaths}. Using the first one.` - ); + this.logger.warn(`多个草图被选中: ${filePaths}. 用第一个。`); } const sketchFilePath = filePaths[0]; const sketchFileUri = await this.fileSystemExt.getUri(sketchFilePath); @@ -121,7 +209,7 @@ export class OpenSketch extends SketchContribution { export namespace OpenSketch { export namespace Commands { export const OPEN_SKETCH: Command = { - id: 'arduino-open-sketch', + id: 'lingzhi-open-sketch', }; } } @@ -142,18 +230,13 @@ export async function promptMoveSketch( const name = uri.path.name; const nameWithExt = labelProvider.getName(uri); const { response } = await dialogService.showMessageBox({ - title: nls.localize('arduino/sketch/moving', 'Moving'), + title: nls.localize('arduino/sketch/moving', '移动'), type: 'question', buttons: [ - nls.localize('vscode/issueMainService/cancel', 'Cancel'), - nls.localize('vscode/issueMainService/ok', 'OK'), + nls.localize('vscode/issueMainService/cancel', '取消'), + nls.localize('vscode/issueMainService/ok', '确定'), ], - message: nls.localize( - 'arduino/sketch/movingMsg', - 'The file "{0}" needs to be inside a sketch folder named "{1}".\nCreate this folder, move the file, and continue?', - nameWithExt, - name - ), + message: `文件“${nameWithExt}”需要在名为“${name}”的草图文件夹中。创建这个文件夹,移动文件,然后继续?`, }); if (response === 1) { // OK @@ -162,12 +245,8 @@ export async function promptMoveSketch( if (exists) { await dialogService.showMessageBox({ type: 'error', - title: nls.localize('vscode/dialog/dialogErrorMessage', 'Error'), - message: nls.localize( - 'arduino/sketch/cantOpen', - 'A folder named "{0}" already exists. Can\'t open sketch.', - name - ), + title: '错误', + message: `已经存在名为“${name}”的文件夹。不能打开草图。`, }); return undefined; } diff --git a/arduino-ide-extension/src/browser/contributions/quit-app.ts b/arduino-ide-extension/src/browser/contributions/quit-app.ts index 1563b00f1..bc71d5e4f 100644 --- a/arduino-ide-extension/src/browser/contributions/quit-app.ts +++ b/arduino-ide-extension/src/browser/contributions/quit-app.ts @@ -8,7 +8,6 @@ import { CommandRegistry, } from './contribution'; import { ArduinoMenus } from '../menu/arduino-menus'; -import { nls } from '@theia/core/lib/common/nls'; import { AppService } from '../app-service'; @injectable() @@ -29,7 +28,7 @@ export class QuitApp extends Contribution { if (!isOSX) { registry.registerMenuAction(ArduinoMenus.FILE__QUIT_GROUP, { commandId: QuitApp.Commands.QUIT_APP.id, - label: nls.localize('vscode/bulkEditService/quit', 'Quit'), + label: '退出', order: '0', }); } @@ -48,7 +47,7 @@ export class QuitApp extends Contribution { export namespace QuitApp { export namespace Commands { export const QUIT_APP: Command = { - id: 'arduino-quit-app', + id: 'lingzhi-quit-app', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/rename-cloud-sketch.ts b/arduino-ide-extension/src/browser/contributions/rename-cloud-sketch.ts index 5cee63f0e..77a0ac0b4 100644 --- a/arduino-ide-extension/src/browser/contributions/rename-cloud-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/rename-cloud-sketch.ts @@ -80,10 +80,7 @@ export class RenameCloudSketch extends CloudSketchContribution { try { const dialog = new WorkspaceInputDialogWithProgress( { - title: nls.localize( - 'arduino/renameCloudSketch/renameSketchTitle', - 'New name of the Cloud Sketch' - ), + title: '云草图的新名称', parentUri, initialValue, validate: (input) => { @@ -160,7 +157,7 @@ export class RenameCloudSketch extends CloudSketchContribution { export namespace RenameCloudSketch { export namespace Commands { export const RENAME_CLOUD_SKETCH: Command = { - id: 'arduino-rename-cloud-sketch', + id: 'lingzhi-rename-cloud-sketch', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/save-as-sketch.ts b/arduino-ide-extension/src/browser/contributions/save-as-sketch.ts index 1c4747225..bd65e7a75 100644 --- a/arduino-ide-extension/src/browser/contributions/save-as-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/save-as-sketch.ts @@ -1,4 +1,3 @@ -import { Dialog } from '@theia/core/lib/browser/dialogs'; import { NavigatableWidget } from '@theia/core/lib/browser/navigatable'; import { Saveable } from '@theia/core/lib/browser/saveable'; import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell'; @@ -8,7 +7,7 @@ import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; import { EditorManager } from '@theia/editor/lib/browser/editor-manager'; import { WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service'; -import { SketchesError } from '../../common/protocol'; +import { ResponseService, SketchesError } from '../../common/protocol'; import { StartupTasks } from '../../electron-common/startup-task'; import { ArduinoMenus } from '../menu/arduino-menus'; import { CurrentSketch } from '../sketches-service-client-impl'; @@ -27,6 +26,7 @@ import { RenameCloudSketchParams, } from './rename-cloud-sketch'; import { assertConnectedToBackend } from './save-sketch'; +import { Dialog } from '../theia/dialogs/theiaDialogs/dialogs'; @injectable() export class SaveAsSketch extends CloudSketchContribution { @@ -34,6 +34,8 @@ export class SaveAsSketch extends CloudSketchContribution { private readonly shell: ApplicationShell; @inject(WindowService) private readonly windowService: WindowService; + @inject(ResponseService) + private readonly responseService1: ResponseService; override registerCommands(registry: CommandRegistry): void { registry.registerCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH, { @@ -46,7 +48,7 @@ export class SaveAsSketch extends CloudSketchContribution { if (SketchesError.SketchAlreadyContainsThisFile.is(err)) { message = nls.localize( 'arduino/sketch/sketchAlreadyContainsThisFileMessage', - 'Failed to save sketch "{0}" as "{1}". {2}', + '将草图“{0}”保存为“{1}”失败。{2}', err.data.sourceSketchName, err.data.targetSketchName, err.message @@ -57,7 +59,9 @@ export class SaveAsSketch extends CloudSketchContribution { } else if (err instanceof Error) { message = err.message; } - this.messageService.error(message); + // this.messageService.error(message); + const chunk = `${message}\n`; + this.responseService1.appendToOutput({ chunk }); } }, }); @@ -66,7 +70,7 @@ export class SaveAsSketch extends CloudSketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { commandId: SaveAsSketch.Commands.SAVE_AS_SKETCH.id, - label: nls.localizeByDefault('Save As...'), + label: '另存为...', order: '7', }); } @@ -92,7 +96,7 @@ export class SaveAsSketch extends CloudSketchContribution { } = params; assertConnectedToBackend({ connectionStatusService: this.connectionStatusService, - messageService: this.messageService, + responseService: this.responseService1, }); const sketch = await this.sketchServiceClient.currentSketch(); if (!CurrentSketch.isValid(sketch)) { @@ -167,8 +171,8 @@ export class SaveAsSketch extends CloudSketchContribution { const containerDirUri = isTemp ? sketchbookDirUri : !sketchbookDirUri.isEqualOrParent(sketchUri) - ? sketchbookDirUri - : sketchUri.parent; + ? sketchbookDirUri + : sketchUri.parent; const exists = await this.fileService.exists( containerDirUri.resolve(sketch.name) ); @@ -195,10 +199,7 @@ export class SaveAsSketch extends CloudSketchContribution { let sketchFolderDestinationUri: string | undefined; while (!sketchFolderDestinationUri) { const { filePath } = await this.dialogService.showSaveDialog({ - title: nls.localize( - 'arduino/sketch/saveFolderAs', - 'Save sketch folder as...' - ), + title: '将项目文件夹另存为…', defaultPath, }); if (!filePath) { @@ -210,19 +211,9 @@ export class SaveAsSketch extends CloudSketchContribution { let dialogContent: InvalidSketchFolderDialogContent | undefined; if (new URI(sketch.uri).isEqualOrParent(new URI(destinationUri))) { dialogContent = { - message: nls.localize( - 'arduino/sketch/invalidSketchFolderLocationMessage', - "Invalid sketch folder location: '{0}'", - filePath - ), - details: nls.localize( - 'arduino/sketch/invalidSketchFolderLocationDetails', - 'You cannot save a sketch into a folder inside itself.' - ), - question: nls.localize( - 'arduino/sketch/editInvalidSketchFolderLocationQuestion', - 'Do you want to try saving the sketch to a different location?' - ), + message: `无效的草图文件夹位置:‘${filePath}’`, + details: '不能将草图保存到其内部的文件夹中。', + question: '您想尝试将草图保存到其他位置吗?', }; } if (!dialogContent) { @@ -230,16 +221,9 @@ export class SaveAsSketch extends CloudSketchContribution { const errorMessage = Sketch.validateSketchFolderName(sketchFolderName); if (errorMessage) { dialogContent = { - message: nls.localize( - 'arduino/sketch/invalidSketchFolderNameMessage', - "Invalid sketch folder name: '{0}'", - sketchFolderName - ), + message: `无效的草图文件夹名称:‘${sketchFolderName}’`, details: errorMessage, - question: nls.localize( - 'arduino/sketch/editInvalidSketchFolderQuestion', - 'Do you want to try saving the sketch with a different name?' - ), + question: '您想尝试用不同的名称保存草图吗?', }; } } @@ -276,7 +260,7 @@ interface InvalidSketchFolderDialogContent { export namespace SaveAsSketch { export namespace Commands { export const SAVE_AS_SKETCH: Command = { - id: 'arduino-save-as-sketch', + id: 'lingzhi-save-as-sketch', }; } export interface Options { diff --git a/arduino-ide-extension/src/browser/contributions/save-sketch.ts b/arduino-ide-extension/src/browser/contributions/save-sketch.ts index ac20d8aa6..ee2abff47 100644 --- a/arduino-ide-extension/src/browser/contributions/save-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/save-sketch.ts @@ -1,7 +1,6 @@ import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution'; -import { MessageService } from '@theia/core/lib/common/message-service'; import { nls } from '@theia/core/lib/common/nls'; -import { injectable } from '@theia/core/shared/inversify'; +import { inject, injectable } from '@theia/core/shared/inversify'; import { ArduinoMenus } from '../menu/arduino-menus'; import { CurrentSketch } from '../sketches-service-client-impl'; import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service'; @@ -13,9 +12,13 @@ import { SketchContribution, } from './contribution'; import { SaveAsSketch } from './save-as-sketch'; +import { ResponseService } from '../../common/protocol'; @injectable() export class SaveSketch extends SketchContribution { + @inject(ResponseService) + private readonly responseService: ResponseService; + override registerCommands(registry: CommandRegistry): void { registry.registerCommand(SaveSketch.Commands.SAVE_SKETCH, { execute: () => this.saveSketch(), @@ -25,7 +28,7 @@ export class SaveSketch extends SketchContribution { override registerMenus(registry: MenuModelRegistry): void { registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, { commandId: SaveSketch.Commands.SAVE_SKETCH.id, - label: nls.localize('vscode/fileCommands/save', 'Save'), + label: nls.localize('vscode/fileCommands/save', '保存'), order: '7', }); } @@ -40,7 +43,7 @@ export class SaveSketch extends SketchContribution { async saveSketch(): Promise { assertConnectedToBackend({ connectionStatusService: this.connectionStatusService, - messageService: this.messageService, + responseService: this.responseService, }); const sketch = await this.sketchServiceClient.currentSketch(); if (!CurrentSketch.isValid(sketch)) { @@ -65,7 +68,7 @@ export class SaveSketch extends SketchContribution { export namespace SaveSketch { export namespace Commands { export const SAVE_SKETCH: Command = { - id: 'arduino-save-sketch', + id: 'lingzhi-save-sketch', }; } } @@ -73,14 +76,15 @@ export namespace SaveSketch { // https://github.com/arduino/arduino-ide/issues/2081 export function assertConnectedToBackend(param: { connectionStatusService: ApplicationConnectionStatusContribution; - messageService: MessageService; + responseService: ResponseService; }): void { if (param.connectionStatusService.offlineStatus === 'backend') { const message = nls.localize( 'theia/core/couldNotSave', - 'Could not save the sketch. Please copy your unsaved work into your favorite text editor, and restart the IDE.' + '无法保存草图。请将未保存的工作复制到您最喜欢的文本编辑器中,然后重新启动IDE。' ); - param.messageService.error(message); + const chunk = `${message}\n`; + param.responseService.appendToOutput({ chunk }); throw new Error(message); } } diff --git a/arduino-ide-extension/src/browser/contributions/selected-board.ts b/arduino-ide-extension/src/browser/contributions/selected-board.ts index 00fbba575..f4ee9fbb5 100644 --- a/arduino-ide-extension/src/browser/contributions/selected-board.ts +++ b/arduino-ide-extension/src/browser/contributions/selected-board.ts @@ -10,6 +10,7 @@ import type { } from '../../common/protocol/board-list'; import { BoardsServiceProvider } from '../boards/boards-service-provider'; import { Contribution } from './contribution'; +import { WindowService } from '@theia/core/lib/browser/window/window-service'; @injectable() export class SelectedBoard extends Contribution { @@ -17,6 +18,8 @@ export class SelectedBoard extends Contribution { private readonly statusBar: StatusBar; @inject(BoardsServiceProvider) private readonly boardsServiceProvider: BoardsServiceProvider; + @inject(WindowService) + protected readonly windowService: WindowService; override onStart(): void { this.boardsServiceProvider.onBoardListDidChange((boardList) => @@ -32,28 +35,49 @@ export class SelectedBoard extends Contribution { boardList: BoardList = this.boardsServiceProvider.boardList ): void { const { selectedBoard, selectedPort } = boardList.boardsConfig; + function name(fqbn: string | undefined, name: string): string { + if (!fqbn) { + return ''; + } + const lastColonIndex = fqbn.lastIndexOf(':'); + const valueAfterLastColon = fqbn.slice(lastColonIndex + 1); + switch (valueAfterLastColon) { + case 'lzesp32': + return '零知-ESP32'; + case 'lzesp8266': + return '零知-ESP8266'; + case 'lingzhistandard': + return '零知-标准板'; + case 'lingzhiMini': + return '零知-迷你板'; + case 'lingzhiM4': + return '零知-增强板'; + case 'lz_ble52': + return '零知-BLE52'; + default: + return name; + } + } this.statusBar.setElement('arduino-selected-board', { - alignment: StatusBarAlignment.RIGHT, - text: selectedBoard - ? `$(microchip) ${selectedBoard.name}` - : `$(close) ${nls.localize( + alignment: StatusBarAlignment.LEFT, + text: + '型号:' + + (selectedBoard + ? `$(microchip) ${name(selectedBoard.fqbn, selectedBoard.name)}` + : `$(close) ${nls.localize( 'arduino/common/noBoardSelected', 'No board selected' - )}`, + )}`), className: 'arduino-selected-board', }); if (selectedBoard) { const notConnectedLabel = nls.localize( 'arduino/common/notConnected', - '[not connected]' + '串口:[未连接]' ); let portLabel = notConnectedLabel; if (selectedPort) { - portLabel = nls.localize( - 'arduino/common/selectedOn', - 'on {0}', - selectedPort.address - ); + portLabel = `在${selectedPort.address}上`; const selectedItem: BoardListItem | undefined = boardList.items[boardList.selectedIndex]; if (!selectedItem) { @@ -61,12 +85,34 @@ export class SelectedBoard extends Contribution { } } this.statusBar.setElement('arduino-selected-port', { - alignment: StatusBarAlignment.RIGHT, + alignment: StatusBarAlignment.LEFT, text: portLabel, className: 'arduino-selected-port', }); } else { this.statusBar.removeElement('arduino-selected-port'); } + this.statusBar.setElement('lingzhi-common-problem', { + alignment: StatusBarAlignment.RIGHT, + text: '常见问题', + className: 'lingzhi-common-problem', + onclick: () => { + this.windowService.openNewWindow( + 'http://www.lingzhilab.com/lzbbs/resources.html?ecid=206', + { external: true } + ); + }, + }); + this.statusBar.setElement('lingzhi-official-website', { + alignment: StatusBarAlignment.RIGHT, + text: '官网: www.lingzhilab.com', + color: '#ff0000', + className: 'lingzhi-official-website', + onclick: () => { + this.windowService.openNewWindow('https://www.lingzhilab.com/', { + external: true, + }); + }, + }); } } diff --git a/arduino-ide-extension/src/browser/contributions/sketch-control.ts b/arduino-ide-extension/src/browser/contributions/sketch-control.ts index 64bbb1ce9..073c95614 100644 --- a/arduino-ide-extension/src/browser/contributions/sketch-control.ts +++ b/arduino-ide-extension/src/browser/contributions/sketch-control.ts @@ -5,7 +5,6 @@ import { Disposable, DisposableCollection, } from '@theia/core/lib/common/disposable'; -import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; import { WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands'; import { ArduinoMenus } from '../menu/arduino-menus'; @@ -32,6 +31,7 @@ export class SketchControl extends SketchContribution { protected readonly toDisposeBeforeCreateNewContextMenu = new DisposableCollection(); + public determiningWhetherToExpand = true; override registerCommands(registry: CommandRegistry): void { registry.registerCommand( @@ -39,13 +39,18 @@ export class SketchControl extends SketchContribution { { isVisible: (widget) => this.shell.getWidgets('main').indexOf(widget) !== -1, - execute: async () => { + execute: async (b) => { this.toDisposeBeforeCreateNewContextMenu.dispose(); let parentElement: HTMLElement | undefined = undefined; - const target = document.getElementById( - SketchControl.Commands.OPEN_SKETCH_CONTROL__TOOLBAR.id - ); + let target: HTMLElement | null; + if (b === true) { + target = document.getElementById('lingzhi-daima-contextmenu-menu'); + } else { + target = document.getElementById( + SketchControl.Commands.OPEN_SKETCH_CONTROL__TOOLBAR.id + ); + } if (target instanceof HTMLElement) { parentElement = target.parentElement ?? undefined; } @@ -62,7 +67,7 @@ export class SketchControl extends SketchContribution { ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, { commandId: WorkspaceCommands.FILE_RENAME.id, - label: nls.localize('vscode/fileActions/rename', 'Rename'), + label: '重命名', order: '1', } ); @@ -78,7 +83,7 @@ export class SketchControl extends SketchContribution { ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, { commandId: WorkspaceCommands.FILE_DELETE.id, - label: nls.localize('vscode/fileActions/delete', 'Delete'), + label: '删除', order: '2', } ); @@ -89,6 +94,36 @@ export class SketchControl extends SketchContribution { ) ) ); + if (this.determiningWhetherToExpand) { + this.menuRegistry.registerMenuAction( + ArduinoMenus.SKETCH_CONTROL__CONTEXT__NAVIGATION_GROUP, + { + commandId: CommonCommands.PREVIOUS_TAB.id, + label: '上一个选项卡', + order: '0', + } + ); + this.toDisposeBeforeCreateNewContextMenu.push( + Disposable.create(() => + this.menuRegistry.unregisterMenuAction( + CommonCommands.PREVIOUS_TAB + ) + ) + ); + this.menuRegistry.registerMenuAction( + ArduinoMenus.SKETCH_CONTROL__CONTEXT__NAVIGATION_GROUP, + { + commandId: CommonCommands.NEXT_TAB.id, + label: '下一个选项卡', + order: '0', + } + ); + this.toDisposeBeforeCreateNewContextMenu.push( + Disposable.create(() => + this.menuRegistry.unregisterMenuAction(CommonCommands.NEXT_TAB) + ) + ); + } const { mainFileUri, rootFolderFileUris } = sketch; const uris = [mainFileUri, ...rootFolderFileUris]; @@ -105,30 +140,37 @@ export class SketchControl extends SketchContribution { this.toDisposeBeforeCreateNewContextMenu.push( registry.registerCommand(command, handler) ); - this.menuRegistry.registerMenuAction( - ArduinoMenus.SKETCH_CONTROL__CONTEXT__RESOURCES_GROUP, - { - commandId: command.id, - label: this.labelProvider.getName(uri), - order: String(i).padStart(4), - } - ); - this.toDisposeBeforeCreateNewContextMenu.push( - Disposable.create(() => - this.menuRegistry.unregisterMenuAction(command) - ) - ); + if (this.determiningWhetherToExpand) { + this.menuRegistry.registerMenuAction( + ArduinoMenus.SKETCH_CONTROL__CONTEXT__RESOURCES_GROUP, + { + commandId: command.id, + label: this.labelProvider.getName(uri), + order: String(i).padStart(4), + } + ); + this.toDisposeBeforeCreateNewContextMenu.push( + Disposable.create(() => + this.menuRegistry.unregisterMenuAction(command) + ) + ); + } } const options = { + // 定义菜单路径,通常是一个特定的标识符,用于确定要显示的菜单内容 menuPath: ArduinoMenus.SKETCH_CONTROL__CONTEXT, anchor: { + // 锚点的 x 坐标,设置为父元素的左边界位置 x: parentElement.getBoundingClientRect().left, + // 锚点的 y 坐标,设置为父元素的上边界位置加上父元素的高度 y: parentElement.getBoundingClientRect().top + parentElement.offsetHeight, }, + // 是否显示禁用的菜单项 showDisabled: true, }; + // 调用上下文菜单渲染器来渲染菜单,传入配置选项 this.contextMenuRenderer.render(options); }, } @@ -140,24 +182,7 @@ export class SketchControl extends SketchContribution { ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, { commandId: WorkspaceCommands.NEW_FILE.id, - label: nls.localize('vscode/menubar/mNewTab', 'New Tab'), - order: '0', - } - ); - - registry.registerMenuAction( - ArduinoMenus.SKETCH_CONTROL__CONTEXT__NAVIGATION_GROUP, - { - commandId: CommonCommands.PREVIOUS_TAB.id, - label: nls.localize('vscode/menubar/mShowPreviousTab', 'Previous Tab'), - order: '0', - } - ); - registry.registerMenuAction( - ArduinoMenus.SKETCH_CONTROL__CONTEXT__NAVIGATION_GROUP, - { - commandId: CommonCommands.NEXT_TAB.id, - label: nls.localize('vscode/menubar/mShowNextTab', 'Next Tab'), + label: '新建标签页', order: '0', } ); @@ -189,8 +214,8 @@ export class SketchControl extends SketchContribution { export namespace SketchControl { export namespace Commands { export const OPEN_SKETCH_CONTROL__TOOLBAR: Command = { - id: 'arduino-open-sketch-control--toolbar', - iconClass: 'fa fa-arduino-sketch-tabs-menu', + id: 'lingzhi-open-sketch-control--toolbar', + iconClass: 'fa lingzhi-a-24gf-ellipsisVertical', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/sketchbook.ts b/arduino-ide-extension/src/browser/contributions/sketchbook.ts index 3e6bca2ec..295c1fb92 100644 --- a/arduino-ide-extension/src/browser/contributions/sketchbook.ts +++ b/arduino-ide-extension/src/browser/contributions/sketchbook.ts @@ -5,7 +5,6 @@ import { ArduinoMenus } from '../menu/arduino-menus'; import { Examples } from './examples'; import { SketchContainer, SketchesError } from '../../common/protocol'; import { OpenSketch } from './open-sketch'; -import { nls } from '@theia/core/lib/common/nls'; @injectable() export class Sketchbook extends Examples { @@ -28,7 +27,7 @@ export class Sketchbook extends Examples { override registerMenus(registry: MenuModelRegistry): void { registry.registerSubmenu( ArduinoMenus.FILE__SKETCHBOOK_SUBMENU, - nls.localize('arduino/sketch/sketchbook', 'Sketchbook'), + '项目文件夹', { order: '3' } ); } diff --git a/arduino-ide-extension/src/browser/contributions/survey-notification.ts b/arduino-ide-extension/src/browser/contributions/survey-notification.ts index e1a4817a6..56e94f418 100644 --- a/arduino-ide-extension/src/browser/contributions/survey-notification.ts +++ b/arduino-ide-extension/src/browser/contributions/survey-notification.ts @@ -9,16 +9,13 @@ import { SurveyNotificationService } from '../../common/protocol/survey-service' const SURVEY_MESSAGE = nls.localize( 'arduino/survey/surveyMessage', - 'Please help us improve by answering this super short survey. We value our community and would like to get to know our supporters a little better.' + '请通过回答这个超级简短的调查来帮助我们改进。我们重视我们的社区,并希望更好地了解我们的支持者。' ); const DO_NOT_SHOW_AGAIN = nls.localize( 'arduino/survey/dismissSurvey', - "Don't show again" -); -const GO_TO_SURVEY = nls.localize( - 'arduino/survey/answerSurvey', - 'Answer survey' + '不再弹出' ); +const GO_TO_SURVEY = nls.localize('arduino/survey/answerSurvey', '回答调查'); const SURVEY_BASE_URL = 'https://surveys.hotjar.com/'; const surveyId = '17887b40-e1f0-4bd6-b9f0-a37f229ccd8b'; diff --git a/arduino-ide-extension/src/browser/contributions/update-indexes.ts b/arduino-ide-extension/src/browser/contributions/update-indexes.ts index fc4e6d078..aeab133ad 100644 --- a/arduino-ide-extension/src/browser/contributions/update-indexes.ts +++ b/arduino-ide-extension/src/browser/contributions/update-indexes.ts @@ -1,7 +1,7 @@ import { LocalStorageService } from '@theia/core/lib/browser/storage-service'; import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; -import { CoreService, IndexType } from '../../common/protocol'; +import { CoreService, IndexType, ResponseService } from '../../common/protocol'; import { NotificationCenter } from '../notification-center'; import { WindowServiceExt } from '../theia/core/window-service-ext'; import { Command, CommandRegistry, Contribution } from './contribution'; @@ -16,6 +16,8 @@ export class UpdateIndexes extends Contribution { private readonly coreService: CoreService; @inject(NotificationCenter) private readonly notificationCenter: NotificationCenter; + @inject(ResponseService) + private readonly responseService: ResponseService; protected override init(): void { super.init(); @@ -56,12 +58,14 @@ export class UpdateIndexes extends Contribution { if (await this.windowService.isFirstWindow()) { const summary = await this.coreService.indexUpdateSummaryBeforeInit(); if (summary.message) { - this.messageService.error(summary.message); + // this.messageService.error(summary.message); + const chunk = `${summary.message}`; + this.responseService.appendToOutput({ chunk }); } const typesToCheck = IndexType.All.filter((type) => !(type in summary)); if (Object.keys(summary).length) { console.debug( - `[update-indexes]: Detected an index update summary before the core gRPC client initialization. Updating local storage with ${JSON.stringify( + `[update-indexes]: 在核心gRPC客户端初始化之前检测到索引更新摘要。更新本地存储 ${JSON.stringify( summary )}` ); @@ -79,10 +83,7 @@ export class UpdateIndexes extends Contribution { } } - private async updateIndexes( - types: IndexType[], - force = false - ): Promise { + public async updateIndexes(types: IndexType[], force = false): Promise { const updatedAt = new Date().toISOString(); return Promise.all( types.map((type) => this.needsIndexUpdate(type, updatedAt, force)) @@ -127,8 +128,7 @@ export class UpdateIndexes extends Contribution { const diff = new Date(now).getTime() - lastUpdateDateTime; const needsIndexUpdate = diff >= this.threshold; console.debug( - `[update-indexes]: Update for index type '${type}' is ${ - needsIndexUpdate ? '' : 'not ' + `[update-indexes]: Update for index type '${type}' is ${needsIndexUpdate ? '' : 'not ' }required. Now: ${now}, Last index update date time: ${new Date( lastUpdateDateTime ).toISOString()}, diff: ${diff} ms, threshold: ${this.threshold} ms.` @@ -166,28 +166,28 @@ export class UpdateIndexes extends Contribution { export namespace UpdateIndexes { export namespace Commands { export const UPDATE_INDEXES: Command & { label: string } = { - id: 'arduino-update-indexes', + id: 'lingzhi-update-indexes', label: nls.localize( 'arduino/updateIndexes/updateIndexes', 'Update Indexes' ), - category: 'Arduino', + category: 'LingZhi', }; export const UPDATE_PLATFORM_INDEX: Command & { label: string } = { - id: 'arduino-update-package-index', + id: 'lingzhi-update-package-index', label: nls.localize( 'arduino/updateIndexes/updatePackageIndex', 'Update Package Index' ), - category: 'Arduino', + category: 'LingZhi', }; export const UPDATE_LIBRARY_INDEX: Command & { label: string } = { - id: 'arduino-update-library-index', + id: 'lingzhi-update-library-index', label: nls.localize( 'arduino/updateIndexes/updateLibraryIndex', 'Update Library Index' ), - category: 'Arduino', + category: 'LingZhi', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/upload-certificate.ts b/arduino-ide-extension/src/browser/contributions/upload-certificate.ts index a6385cb2a..e6c2f03b7 100644 --- a/arduino-ide-extension/src/browser/contributions/upload-certificate.ts +++ b/arduino-ide-extension/src/browser/contributions/upload-certificate.ts @@ -20,7 +20,6 @@ import { ArduinoFirmwareUploader, UploadCertificateParams, } from '../../common/protocol/arduino-firmware-uploader'; -import { nls } from '@theia/core/lib/common'; @injectable() export class UploadCertificate extends Contribution { @@ -97,11 +96,11 @@ export class UploadCertificate extends Contribution { } override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.TOOLS__FIRMWARE_UPLOADER_GROUP, { - commandId: UploadCertificate.Commands.OPEN.id, - label: UploadCertificate.Commands.OPEN.label, - order: '1', - }); + // registry.registerMenuAction(ArduinoMenus.TOOLS__FIRMWARE_UPLOADER_GROUP, { + // commandId: UploadCertificate.Commands.OPEN.id, + // label: UploadCertificate.Commands.OPEN.label, + // order: '1', + // }); registry.registerMenuAction(ArduinoMenus.ROOT_CERTIFICATES__CONTEXT, { commandId: UploadCertificate.Commands.REMOVE_CERT.id, @@ -115,29 +114,26 @@ export namespace UploadCertificate { export namespace Commands { export const OPEN: Command = { id: 'arduino-upload-certificate-open', - label: nls.localize( - 'arduino/certificate/uploadRootCertificates', - 'Upload SSL Root Certificates' - ), - category: 'Arduino', + label: '上传 SSL 根证书', + category: 'LingZhi', }; export const OPEN_CERT_CONTEXT: Command = { id: 'arduino-certificate-open-context', - label: nls.localize('arduino/certificate/openContext', 'Open context'), - category: 'Arduino', + label: '打开上下文', + category: 'LingZhi', }; export const REMOVE_CERT: Command = { id: 'arduino-certificate-remove', - label: nls.localize('arduino/certificate/remove', 'Remove'), - category: 'Arduino', + label: '移除', + category: 'LingZhi', }; export const UPLOAD_CERT: Command = { id: 'arduino-certificate-upload', - label: nls.localize('arduino/certificate/upload', 'Upload'), - category: 'Arduino', + label: '上传', + category: 'LingZhi', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/upload-firmware.ts b/arduino-ide-extension/src/browser/contributions/upload-firmware.ts index 7ed85c996..af6cf8f61 100644 --- a/arduino-ide-extension/src/browser/contributions/upload-firmware.ts +++ b/arduino-ide-extension/src/browser/contributions/upload-firmware.ts @@ -1,13 +1,6 @@ import { inject, injectable } from '@theia/core/shared/inversify'; -import { - Command, - MenuModelRegistry, - CommandRegistry, - Contribution, -} from './contribution'; -import { ArduinoMenus } from '../menu/arduino-menus'; +import { Command, CommandRegistry, Contribution } from './contribution'; import { UploadFirmwareDialog } from '../dialogs/firmware-uploader/firmware-uploader-dialog'; -import { nls } from '@theia/core/lib/common'; @injectable() export class UploadFirmware extends Contribution { @@ -32,21 +25,21 @@ export class UploadFirmware extends Contribution { }); } - override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.TOOLS__FIRMWARE_UPLOADER_GROUP, { - commandId: UploadFirmware.Commands.OPEN.id, - label: UploadFirmware.Commands.OPEN.label, - order: '0', - }); - } + // override registerMenus(registry: MenuModelRegistry): void { + // registry.registerMenuAction(ArduinoMenus.TOOLS__FIRMWARE_UPLOADER_GROUP, { + // commandId: UploadFirmware.Commands.OPEN.id, + // label: UploadFirmware.Commands.OPEN.label, + // order: '0', + // }); + // } } export namespace UploadFirmware { export namespace Commands { export const OPEN: Command = { id: 'arduino-upload-firmware-open', - label: nls.localize('arduino/firmware/updater', 'Firmware Updater'), - category: 'Arduino', + label: '固件更新', + category: 'LingZhi', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/upload-sketch.ts b/arduino-ide-extension/src/browser/contributions/upload-sketch.ts index 0c2418797..59d8c2eb3 100644 --- a/arduino-ide-extension/src/browser/contributions/upload-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/upload-sketch.ts @@ -1,8 +1,12 @@ import { Emitter } from '@theia/core/lib/common/event'; -import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; +import { + CoreService, + MonitorManagerProxyClient, + Port, + ResponseService, +} from '../../common/protocol'; import { FQBN } from 'fqbn'; -import { CoreService } from '../../common/protocol'; import { ArduinoMenus } from '../menu/arduino-menus'; import { CurrentSketch } from '../sketches-service-client-impl'; import { ArduinoToolbar } from '../toolbar/arduino-toolbar'; @@ -16,23 +20,59 @@ import { } from './contribution'; import { UserFields } from './user-fields'; import type { VerifySketchParams } from './verify-sketch'; +import { SidebarMenu } from '@theia/core/lib/browser/shell/sidebar-menu-widget'; +import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; +import { CreateFeatures } from '../create/create-features'; +import { ApplicationShell } from '@theia/core/lib/browser'; +import { MonitorWidget } from '../serial/monitor/monitor-widget'; + +export const uploadMenu: SidebarMenu = { + id: 'lingzhi-upload-sketch', + iconClass: 'fa lingzhi-upload', + title: '上传', + menuPath: ArduinoMenus.UPLOAD_SKETCH, + order: 1, +}; @injectable() export class UploadSketch extends CoreServiceContribution { @inject(UserFields) private readonly userFields: UserFields; + @inject(ApplicationShell) + private readonly applicationShell: ApplicationShell; + @inject(MonitorManagerProxyClient) + private readonly monitorManagerProxy: MonitorManagerProxyClient; + @inject(CoreService) + private readonly coreService1: CoreService; + @inject(ResponseService) + private readonly responseService1: ResponseService; private readonly onDidChangeEmitter = new Emitter(); private readonly onDidChange = this.onDidChangeEmitter.event; private uploadInProgress = false; + @inject(CreateFeatures) + private app: FrontendApplication; + override onStart(app: FrontendApplication): void { + this.app = app; + + // 在 onStart 方法中添加新菜单 + const handler = this.app.shell.leftPanelHandler; + handler.addBottomMenu(uploadMenu); + } + override registerCommands(registry: CommandRegistry): void { + // 注册一个命令,命令名为UPLOAD_SKETCH registry.registerCommand(UploadSketch.Commands.UPLOAD_SKETCH, { + // 执行命令的方法 execute: async () => { + // 检查用户字段对话框 if (await this.userFields.checkUserFieldsDialog()) { + // 上传草图 this.uploadSketch(); } }, + // 判断命令是否可用的方法 isEnabled: () => !this.uploadInProgress, }); registry.registerCommand(UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION, { @@ -51,8 +91,8 @@ export class UploadSketch extends CoreServiceContribution { } ); registry.registerCommand(UploadSketch.Commands.UPLOAD_SKETCH_TOOLBAR, { - isVisible: (widget) => - ArduinoToolbar.is(widget) && widget.side === 'left', + isVisible: (widget, showToolbar: boolean) => + showToolbar && ArduinoToolbar.is(widget) && widget.side === 'left', isEnabled: () => !this.uploadInProgress, isToggled: () => this.uploadInProgress, execute: () => @@ -61,19 +101,22 @@ export class UploadSketch extends CoreServiceContribution { } override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { + // registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { + // commandId: UploadSketch.Commands.UPLOAD_SKETCH.id, + // label: nls.localize('arduino/sketch/upload', 'Upload'), + // order: '1', + // }); + + registry.registerMenuAction(ArduinoMenus.UPLOAD_SKETCH, { commandId: UploadSketch.Commands.UPLOAD_SKETCH.id, - label: nls.localize('arduino/sketch/upload', 'Upload'), + label: '上传', order: '1', }); registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { commandId: UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER.id, - label: nls.localize( - 'arduino/sketch/uploadUsingProgrammer', - 'Upload Using Programmer' - ), - order: '3', + label: '使用编程器上传', + order: '2', }); } @@ -92,7 +135,7 @@ export class UploadSketch extends CoreServiceContribution { registry.registerItem({ id: UploadSketch.Commands.UPLOAD_SKETCH_TOOLBAR.id, command: UploadSketch.Commands.UPLOAD_SKETCH_TOOLBAR.id, - tooltip: nls.localize('arduino/sketch/upload', 'Upload'), + tooltip: '上传', priority: 1, onDidChange: this.onDidChange, }); @@ -104,79 +147,133 @@ export class UploadSketch extends CoreServiceContribution { } try { - const autoVerify = this.preferences['arduino.upload.autoVerify']; // toggle the toolbar button and menu item state. // uploadInProgress will be set to false whether the upload fails or not + const autoVerify = this.preferences['arduino.upload.autoVerify']; + // 设置上传状态为正在进行 this.uploadInProgress = true; + // 更新菜单管理器 this.menuManager.update(); + // 触发onDidChangeEmitter事件 this.onDidChangeEmitter.fire(); + // 清除可见的通知 this.clearVisibleNotification(); + // this.boardsServiceProvider.onBoardListDidChange((boardList) => { + // const { selectedBoard } = boardList.boardsConfig; + // if (selectedBoard) { + // const chunk = '\n未连接开发板\n'; + // this.responseService1.appendToOutput({ chunk }); + // } + // }); + + const boardList = this.boardsServiceProvider.boardList; + + const groupedPorts = boardList.portsGroupedByProtocol(); + + const { selectedBoard } = boardList.boardsConfig; + if (!selectedBoard) { + const chunk = '\n未选择开发板!\n'; + const severity = 0; + this.responseService1.appendToOutput({ chunk, severity }); + return; + } + + let newPort: Port | undefined = undefined; + Object.entries(groupedPorts).forEach(([protocol, ports]) => { + const { port } = ports[0]; + newPort = port; + }); + + if (!newPort) { + const chunk = '\n未连接开发板!\n'; + const severity = 0; + this.responseService1.appendToOutput({ chunk, severity }); + return; + } + + // 调用命令服务执行命令,获取编译选项 + // 执行命令,获取编译选项 const verifyOptions = await this.commandService.executeCommand( - 'arduino-verify-sketch', + 'lingzhi-verify-sketch', { + // 不导出二进制文件 exportBinaries: false, mode: autoVerify ? 'auto' : 'dry-run', } ); + // 如果没有获取到编译选项,则返回 if (!verifyOptions) { return; } + // 调用uploadOptions方法,获取上传选项 const uploadOptions = await this.uploadOptions( usingProgrammer, verifyOptions ); - + // 如果没有获取到上传选项,则返回 if (!uploadOptions) { return; } + // 检查用户字段是否满足上传条件 if (!this.userFields.checkUserFieldsForUpload()) { return; } - const uploadResponse = await this.doWithProgress({ - progressText: nls.localize('arduino/sketch/uploading', 'Uploading...'), - task: async (progressId, coreService, token) => { - try { - return await coreService.upload( - { ...uploadOptions, progressId }, - token - ); - } catch (err) { - if (err.code === 4005) { - const uploadWithProgrammerOptions = await this.uploadOptions( - true, - verifyOptions - ); - if (uploadWithProgrammerOptions) { - return coreService.upload( - { ...uploadWithProgrammerOptions, progressId }, - token - ); - } - } else { - throw err; - } - } - }, - keepOutput: true, - cancelable: true, - }); - - if (!uploadResponse) { - return; + let wiget = this.applicationShell.getWidgetById(MonitorWidget.ID); + if (wiget !== undefined) { + wiget.close(); } + //关闭串口绘图仪 + await this.monitorManagerProxy.stopLastMonitor(); - // the port update is NOOP if nothing has changed - this.boardsServiceProvider.updateConfig(uploadResponse.portAfterUpload); + // 调用doWithProgress方法,执行上传操作 + // const uploadResponse = await this.doWithProgress({ + // progressText: nls.localize('arduino/sketch/uploading', 'Uploading...'), + // task: async (progressId, coreService, token) => { + // try { + // return await coreService.upload( + // { ...uploadOptions, progressId }, + // token + // ); + // } catch (err) { + // if (err.code === 4005) { + // const uploadWithProgrammerOptions = await this.uploadOptions( + // true, + // verifyOptions + // ); + // if (uploadWithProgrammerOptions) { + // return coreService.upload( + // { ...uploadWithProgrammerOptions, progressId }, + // token + // ); + // } + // } else { + // throw err; + // } + // } + // }, + // keepOutput: true, + // cancelable: true, + // }); - this.messageService.info( - nls.localize('arduino/sketch/doneUploading', 'Done uploading.'), - { timeout: 3000 } - ); + // if (!uploadResponse) { + // return; + // } + + await this.coreService1.upload({ ...uploadOptions }); + // // the port update is NOOP if nothing has changed + // this.boardsServiceProvider.updateConfig(uploadResponse.portAfterUpload); + + // this.messageService.info( + // nls.localize('arduino/sketch/doneUploading', 'Done uploading.'), + // { timeout: 3000 } + // ); + const chunk = '\n完成上传.\n'; + this.responseService1.appendToOutput({ chunk }); } catch (e) { this.userFields.notifyFailedWithError(e); this.handleError(e); @@ -226,21 +323,18 @@ export class UploadSketch extends CoreServiceContribution { export namespace UploadSketch { export namespace Commands { export const UPLOAD_SKETCH: Command = { - id: 'arduino-upload-sketch', + id: 'lingzhi-upload-sketch', }; export const UPLOAD_WITH_CONFIGURATION: Command & { label: string } = { id: 'arduino-upload-with-configuration-sketch', - label: nls.localize( - 'arduino/sketch/configureAndUpload', - 'Configure and Upload' - ), - category: 'Arduino', + label: '配置并上传', + category: 'LingZhi', }; export const UPLOAD_SKETCH_USING_PROGRAMMER: Command = { - id: 'arduino-upload-sketch-using-programmer', + id: 'lingzhi-upload-sketch-using-programmer', }; export const UPLOAD_SKETCH_TOOLBAR: Command = { - id: 'arduino-upload-sketch--toolbar', + id: 'lingzhi-upload-sketch--toolbar', }; } } diff --git a/arduino-ide-extension/src/browser/contributions/user-fields.ts b/arduino-ide-extension/src/browser/contributions/user-fields.ts index 00f2817c6..4f7f5f500 100644 --- a/arduino-ide-extension/src/browser/contributions/user-fields.ts +++ b/arduino-ide-extension/src/browser/contributions/user-fields.ts @@ -1,6 +1,9 @@ -import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; -import { BoardUserField, CoreError } from '../../common/protocol'; +import { + BoardUserField, + CoreError, + ResponseService, +} from '../../common/protocol'; import { BoardsServiceProvider } from '../boards/boards-service-provider'; import { UserFieldsDialog } from '../dialogs/user-fields/user-fields-dialog'; import { ArduinoMenus } from '../menu/arduino-menus'; @@ -19,6 +22,9 @@ export class UserFields extends Contribution { @inject(BoardsServiceProvider) private readonly boardsServiceProvider: BoardsServiceProvider; + @inject(ResponseService) + private readonly responseService: ResponseService; + protected override init(): void { super.init(); this.boardsServiceProvider.onBoardsConfigDidChange(() => this.refresh()); @@ -32,7 +38,7 @@ export class UserFields extends Contribution { registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { commandId: UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.id, label: UploadSketch.Commands.UPLOAD_WITH_CONFIGURATION.label, - order: '2', + order: '3', }); } @@ -99,12 +105,14 @@ export class UserFields extends Contribution { this.userFieldsSet = true; return true; } - this.messageService.error( - nls.localize( - 'arduino/sketch/userFieldsNotFoundError', - "Can't find user fields for connected board" - ) - ); + // this.messageService.error( + // nls.localize( + // 'arduino/sketch/userFieldsNotFoundError', + // '找不到连接板的用户字段' + // ) + // ); + const chunk = '找不到已连接开发板的用户字段\n'; + this.responseService.appendToOutput({ chunk }); this.userFieldsSet = false; return false; } diff --git a/arduino-ide-extension/src/browser/contributions/validate-sketch.ts b/arduino-ide-extension/src/browser/contributions/validate-sketch.ts index fb7de55f1..869e13ab2 100644 --- a/arduino-ide-extension/src/browser/contributions/validate-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/validate-sketch.ts @@ -1,5 +1,3 @@ -import { Dialog } from '@theia/core/lib/browser/dialogs'; -import { nls } from '@theia/core/lib/common/nls'; import { Deferred, waitForEvent } from '@theia/core/lib/common/promise-util'; import { injectable } from '@theia/core/shared/inversify'; import { WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands'; @@ -7,6 +5,7 @@ import { CurrentSketch } from '../sketches-service-client-impl'; import { CloudSketchContribution } from './cloud-contribution'; import { Sketch, URI } from './contribution'; import { SaveAsSketch } from './save-as-sketch'; +import { Dialog } from '../theia/dialogs/theiaDialogs/dialogs'; @injectable() export class ValidateSketch extends CloudSketchContribution { @@ -18,12 +17,8 @@ export class ValidateSketch extends CloudSketchContribution { const result = await this.promptFixActions(); if (!result) { const yes = await this.prompt( - nls.localize('arduino/validateSketch/abortFixTitle', 'Invalid sketch'), - nls.localize( - 'arduino/validateSketch/abortFixMessage', - "The sketch is still invalid. Do you want to fix the remaining problems? By clicking '{0}', a new sketch will open.", - Dialog.NO - ), + '无效的草图', + `草图仍然无效。你想解决剩下的问题吗?点击“${Dialog.NO}”,将打开一个新的草图。`, [Dialog.NO, Dialog.YES] ); if (yes) { @@ -126,7 +121,7 @@ export class ValidateSketch extends CloudSketchContribution { const [sketch, dataDirUri] = await Promise.all([ this.currentSketch(), maybeDataDirUri ?? - waitForEvent(this.configService.onDidChangeDataDirUri, 5_000), + waitForEvent(this.configService.onDidChangeDataDirUri, 5_000), ]); const fixActions = this.validateSketch(sketch, dataDirUri); for (const fixAction of fixActions) { @@ -143,16 +138,8 @@ export class ValidateSketch extends CloudSketchContribution { error: string ): Promise { return this.prompt( - nls.localize( - 'arduino/validateSketch/renameSketchFolderTitle', - 'Invalid sketch name' - ), - nls.localize( - 'arduino/validateSketch/renameSketchFolderMessage', - "The sketch '{0}' cannot be used. {1} To get rid of this message, rename the sketch. Do you want to rename the sketch now?", - sketch.name, - error - ) + `无效的草图名称`, + `草图“${sketch.name}”不能使用。${error}要删除此消息,请重命名草图。现在要重命名草图吗?` ); } @@ -161,16 +148,8 @@ export class ValidateSketch extends CloudSketchContribution { error: string ): Promise { return this.prompt( - nls.localize( - 'arduino/validateSketch/renameSketchFileTitle', - 'Invalid sketch filename' - ), - nls.localize( - 'arduino/validateSketch/renameSketchFileMessage', - "The sketch file '{0}' cannot be used. {1} Do you want to rename the sketch file now?", - uri.path.base, - error - ) + '无效的草图文件名', + `不能使用草图文件‘${uri.path.base}’。${error}现在要重命名草图文件吗?` ); } diff --git a/arduino-ide-extension/src/browser/contributions/verify-sketch.ts b/arduino-ide-extension/src/browser/contributions/verify-sketch.ts index 4d8b445e3..8aebdb67c 100644 --- a/arduino-ide-extension/src/browser/contributions/verify-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/verify-sketch.ts @@ -1,19 +1,25 @@ -import { Emitter } from '@theia/core/lib/common/event'; -import { nls } from '@theia/core/lib/common/nls'; import { inject, injectable } from '@theia/core/shared/inversify'; -import type { CoreService } from '../../common/protocol'; +import { Emitter } from '@theia/core/lib/common/event'; import { ArduinoMenus } from '../menu/arduino-menus'; -import { CurrentSketch } from '../sketches-service-client-impl'; import { ArduinoToolbar } from '../toolbar/arduino-toolbar'; import { + CoreServiceContribution, Command, CommandRegistry, - CoreServiceContribution, - KeybindingRegistry, MenuModelRegistry, + KeybindingRegistry, TabBarToolbarRegistry, } from './contribution'; +import { CurrentSketch } from '../sketches-service-client-impl'; +import { + CoreService, + ResponseService, + ResponseServiceClient, +} from '../../common/protocol'; import { CoreErrorHandler } from './core-error-handler'; +import { SidebarMenu } from '@theia/core/lib/browser/shell/sidebar-menu-widget'; +import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; +import { CreateFeatures } from '../create/create-features'; export type VerifySketchMode = /** @@ -40,6 +46,14 @@ export interface VerifySketchParams { readonly mode?: VerifySketchMode; } +export const verifyMenu: SidebarMenu = { + id: 'lingzhi-verify-sketch', + iconClass: 'fa lingzhi-build-ok', + title: '验证', + menuPath: ArduinoMenus.SKETCH_COMMAND_ID, + order: 2, +}; + /** * - `"idle"` when neither verify, nor upload is running */ @@ -49,11 +63,27 @@ type VerifyProgress = 'idle' | VerifySketchMode; export class VerifySketch extends CoreServiceContribution { @inject(CoreErrorHandler) private readonly coreErrorHandler: CoreErrorHandler; + @inject(ResponseService) + private readonly responseService1: ResponseService; + @inject(CoreService) + private readonly coreService1: CoreService; + @inject(ResponseServiceClient) + private readonly responseServiceClient: ResponseServiceClient; private readonly onDidChangeEmitter = new Emitter(); private readonly onDidChange = this.onDidChangeEmitter.event; private verifyProgress: VerifyProgress = 'idle'; + @inject(CreateFeatures) + private app: FrontendApplication; + override onStart(app: FrontendApplication): void { + this.app = app; + + // 在 onStart 方法中添加新菜单 + const handler = this.app.shell.leftPanelHandler; + handler.addBottomMenu(verifyMenu); + } + override registerCommands(registry: CommandRegistry): void { registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH, { execute: (params?: VerifySketchParams) => this.verifySketch(params), @@ -64,8 +94,8 @@ export class VerifySketch extends CoreServiceContribution { isEnabled: () => this.verifyProgress === 'idle', }); registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR, { - isVisible: (widget) => - ArduinoToolbar.is(widget) && widget.side === 'left', + isVisible: (widget, showToolbar: boolean) => + showToolbar && ArduinoToolbar.is(widget) && widget.side === 'left', isEnabled: () => this.verifyProgress !== 'explicit', // toggled only when verify is running, but not toggled when automatic verify is running before the upload // https://github.com/arduino/arduino-ide/pull/1750#pullrequestreview-1214762975 @@ -76,17 +106,21 @@ export class VerifySketch extends CoreServiceContribution { } override registerMenus(registry: MenuModelRegistry): void { - registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { - commandId: VerifySketch.Commands.VERIFY_SKETCH.id, - label: nls.localize('arduino/sketch/verifyOrCompile', 'Verify/Compile'), + registry.registerMenuAction(ArduinoMenus.SKETCH_COMMAND_ID, { + commandId: verifyMenu.id, + label: verifyMenu.title, order: '0', }); + + // registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { + // commandId: VerifySketch.Commands.VERIFY_SKETCH.id, + // label: nls.localize('arduino/sketch/verify', 'Verify'), + // order: '0', + // }); + registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { commandId: VerifySketch.Commands.EXPORT_BINARIES.id, - label: nls.localize( - 'arduino/sketch/exportBinary', - 'Export Compiled Binary' - ), + label: '导出已编译的二进制文件', order: '4', }); } @@ -106,7 +140,7 @@ export class VerifySketch extends CoreServiceContribution { registry.registerItem({ id: VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR.id, command: VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR.id, - tooltip: nls.localize('arduino/sketch/verify', 'Verify'), + tooltip: '验证', priority: 0, onDidChange: this.onDidChange, }); @@ -125,14 +159,21 @@ export class VerifySketch extends CoreServiceContribution { } try { + // 根据params参数的silent属性,设置verifyProgress的值 this.verifyProgress = params?.mode ?? 'explicit'; + // 触发onDidChangeEmitter事件 this.onDidChangeEmitter.fire(); + // 更新menuManager this.menuManager.update(); + // 清除可见的通知 this.clearVisibleNotification(); + // 重置coreErrorHandler this.coreErrorHandler.reset(); const dryRun = this.verifyProgress === 'dry-run'; + // 根据params参数的exportBinaries属性,获取options const options = await this.options(params?.exportBinaries); + // 如果options为空,则返回undefined if (!options) { return undefined; } @@ -141,25 +182,34 @@ export class VerifySketch extends CoreServiceContribution { return options; } - await this.doWithProgress({ - progressText: nls.localize( - 'arduino/sketch/compile', - 'Compiling sketch...' - ), - task: (progressId, coreService, token) => - coreService.compile( - { - ...options, - progressId, - }, - token - ), - cancelable: true, + // 使用doWithProgress方法,执行编译任务 + // await this.doWithProgress({ + // progressText: nls.localize( + // 'arduino/sketch/compile', + // 'Compiling sketch...' + // ), + // task: (progressId, coreService, token) => + // coreService.compile( + // { + // ...options, + // progressId, + // }, + // token + // ), + // cancelable: true, + // }); + // this.messageService.info( + // nls.localize('arduino/sketch/doneCompiling', 'Done compiling.'), + // { timeout: 3000 } + // ); + + this.responseServiceClient.clearOutput(); + await this.coreService1.compile({ + // 将options和progressId作为参数传递给compile方法 + ...options, }); - this.messageService.info( - nls.localize('arduino/sketch/doneCompiling', 'Done compiling.'), - { timeout: 3000 } - ); + const chunk = '编译完成.\n\n'; + this.responseService1.appendToOutput({ chunk }); // Returns with the used options for the compilation // so that follow-up tasks (such as upload) can reuse the compiled code. // Note that the `fqbn` is already decorated with the board settings, if any. @@ -186,7 +236,7 @@ export class VerifySketch extends CoreServiceContribution { this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn), this.sourceOverride(), this.commandService.executeCommand( - 'arduino-is-optimize-for-debug' + 'lingzhi-is-optimize-for-debug' ), ]); const verbose = this.preferences.get('arduino.compile.verbose'); @@ -206,13 +256,13 @@ export class VerifySketch extends CoreServiceContribution { export namespace VerifySketch { export namespace Commands { export const VERIFY_SKETCH: Command = { - id: 'arduino-verify-sketch', + id: 'lingzhi-verify-sketch', }; export const EXPORT_BINARIES: Command = { - id: 'arduino-export-binaries', + id: 'lingzhi-export-binaries', }; export const VERIFY_SKETCH_TOOLBAR: Command = { - id: 'arduino-verify-sketch--toolbar', + id: 'lingzhi-verify-sketch--toolbar', }; } } diff --git a/arduino-ide-extension/src/browser/data/default.color-theme.json b/arduino-ide-extension/src/browser/data/default.color-theme.json index e81e4baa0..e2ce858e5 100644 --- a/arduino-ide-extension/src/browser/data/default.color-theme.json +++ b/arduino-ide-extension/src/browser/data/default.color-theme.json @@ -7,41 +7,43 @@ "list.activeSelectionBackground": "#00818433", "list.inactiveSelectionForeground": "#4e5b61", "list.inactiveSelectionBackground": "#dae3e3", - "list.hoverBackground": "#ecf1f1", + "list.hoverBackground": "#f0f0f0", "list.activeSelectionIconForeground": "#008184", - "progressBar.background": "#005c5f", + "progressBar.background": "#1dbef9", "editor.background": "#ffffff", "editor.foreground": "#4e5b61", "editor.lineHighlightBackground": "#434f5410", "editor.selectionBackground": "#7fcbcdb3", "editorCursor.foreground": "#4e5b61", "editorWhitespace.foreground": "#bfbfbf", - "editorWidget.background": "#f7f9f9", + "editorWidget.background": "#f0f0f0", "editorWidget.foreground": "#4e5b61", - "focusBorder": "#7fcbcd", + "focusBorder": "#bbd9f2", "menubar.selectionBackground": "#ffffff", "menubar.selectionForeground": "#212121", "menu.selectionBackground": "#dae3e3", "menu.selectionForeground": "#212121", - "editorGroupHeader.tabsBackground": "#ecf1f1", - "button.background": "#008184", - "button.foreground": "#f7f9f9", - "button.hoverBackground": "#005C5F", - "titleBar.activeBackground": "#006d70", + "editorGroupHeader.tabsBackground": "#f0f0f0", + "button.background": "#f7f7f7", + "button.foreground": "#000000", + "button.hoverBackground": "#fbfbfb", + "titleBar.activeBackground": "#f0f0f0", "titleBar.activeForeground": "#f7f9f9", - "terminal.background": "#000000", - "terminal.foreground": "#ffffff", + "terminal.background": "#ffffff", + "terminal.foreground": "#000000", "dropdown.border": "#dae3e3", "dropdown.background": "#ffffff", "dropdown.foreground": "#4e5b61", - "activityBar.background": "#ecf1f1", - "activityBar.foreground": "#4e5b61", - "activityBar.inactiveForeground": "#bdc7c7", - "activityBar.activeBorder": "#008184", - "statusBar.background": "#006d70", - "secondaryButton.background": "#ff000000", - "secondaryButton.foreground": "#008184", - "secondaryButton.hoverBackground": "#005c5f1a", + "activityBar.background": "#aeabab", + "activityBar.foreground": "#1dbef9", + "activityBar.inactiveForeground": "#1dbef9", + "activityBar.activeBorder": "#a0a0a0", + "activityBar.activeBackground": "#cdcccc", + "statusBar.background": "#d7d7d7", + "statusBar.foreground": "#6471fa", + "secondaryButton.background": "#f7f7f7", + "secondaryButton.foreground": "#bbd9f2", + "secondaryButton.hoverBackground": "#ffffff", "arduino.branding.primary": "#008184", "arduino.branding.secondary": "#b5c8c9", "arduino.foreground": "#edf1f1", @@ -59,15 +61,15 @@ "arduino.toolbar.dropdown.option.backgroundHover": "#ecf1f1", "arduino.toolbar.dropdown.option.backgroundSelected": "#dae3e3", "arduino.toolbar.toggleBackground": "#f1c40f", - "sideBar.background": "#f7f9f9", - "sideBar.foreground": "#4e5b61", + "sideBar.background": "#f0f0f0", + "sideBar.foreground": "#000000", "input.background": "#ffffff", - "foreground": "#4e5b61", + "foreground": "#000000", "settings.headerForeground": "#4e5b61", "tree.indentGuidesStroke": "#dae3e3", "tab.unfocusedActiveForeground": "#4e5b61", "tab.inactiveBackground": "#ecf1f1", - "textLink.foreground": "#008184", + "textLink.foreground": "#5500ff", "errorForeground": "#df7365" }, "tokenColors": [ diff --git a/arduino-ide-extension/src/browser/dialogs/Keymaps/keymaps-dialog.tsx b/arduino-ide-extension/src/browser/dialogs/Keymaps/keymaps-dialog.tsx new file mode 100644 index 000000000..6116ba871 --- /dev/null +++ b/arduino-ide-extension/src/browser/dialogs/Keymaps/keymaps-dialog.tsx @@ -0,0 +1,158 @@ +/* eslint-disable prettier/prettier */ +import { inject, injectable } from '@theia/core/shared/inversify'; +import { AbstractDialog } from '../../theia/dialogs/dialogs'; +import { DialogProps } from '@theia/core/lib/browser/dialogs'; +import { ThemeService } from '@theia/core/lib/browser/theming'; + +@injectable() +export class KeymapsDialogProps extends DialogProps { } + +@injectable() +export class KeymapsDialog extends AbstractDialog> { + private mainDiv: HTMLDivElement; + + @inject(ThemeService) + private readonly themeService: ThemeService; + + constructor( + @inject(KeymapsDialogProps) + protected override readonly props: KeymapsDialogProps + ) { + super(props); + this.node.id = 'lingzhi-keymaps-dialog-container'; + this.contentNode.classList.add('lingzhi-keymaps-dialog'); + + this.contentNode.style.width = '100%'; + this.contentNode.style.height = '260px'; + + this.initLayout(); + } + + private initLayout() { + const topDiv = document.createElement('div'); + topDiv.className = 'lingzhi-ide-keymaps-top' + this.contentNode.appendChild(topDiv); + + const titleDiv = document.createElement('div'); + titleDiv.style.width = '100%'; + titleDiv.style.height = '30px'; + titleDiv.style.display = 'flex'; + titleDiv.style.alignItems = 'center'; + titleDiv.style.justifyContent = 'center'; + topDiv.appendChild(titleDiv); + + const nameDiv = document.createElement('div'); + nameDiv.className = 'lingzhi-ide-keymaps-title' + nameDiv.textContent = '功能' + titleDiv.appendChild(nameDiv); + + const shortcutKeyDiv = document.createElement('div'); + shortcutKeyDiv.className = 'lingzhi-ide-keymaps-title' + shortcutKeyDiv.textContent = '快捷键' + titleDiv.appendChild(shortcutKeyDiv); + + const spring = document.createElement('div'); + spring.style.width = '10px'; + titleDiv.appendChild(spring); + + const mainDiv = document.createElement('div'); + mainDiv.className = 'lingzhi-ide-keymaps-main'; + topDiv.appendChild(mainDiv); + this.mainDiv = mainDiv; + + const keymapsData = [ + ['撤销', 'Ctrl+Z'], ['恢复', 'Ctrl+Shift+Z'], ['剪切', 'Ctrl+X'], ['复制', 'Ctrl+C'], + ['粘贴', 'Ctrl+V'], ['全选', 'Ctrl+A'], ['转到行/列...', 'Ctrl+L'], ['注释/取消注释', 'Ctrl+/'], + ['自动格式化', 'Ctrl+T'], ['放大字号', 'Ctrl+='], ['缩小字号', 'Ctrl+-'], ['查找', 'Ctrl+F'], + ['查找上一个', 'Ctrl+G'], ['查找下一个', 'Ctrl+Shift+G'], ['查找选定内容', 'Ctrl+E'], + ['设置', 'Ctrl+逗号'], ['保存', 'Ctrl+S'], ['另存为...', 'Ctrl+Shift+S'], + ['键盘快捷方式参考', 'Alt+Shift+逗号'], ['退出', 'Ctrl+Q'], ['串口监视器', 'Ctrl+Shift+M'], + ['使用编程器上传', 'Ctrl+Shift+U'], ['导出以编译的二进制文件', 'Alt+Ctrl+S'], ['显示项目文件', 'Alt+Ctrl+K'], + ['在参考文件寻找', 'Ctrl+Shift+F'], ['转到定义', 'Ctrl+F12'], ['转到编辑器的符号...', 'Ctrl+Shift+O'], + ['查看定义', 'Alt+F12'], ['重命名符号', 'F2'], ['更改所有事件', 'Ctrl+F2'], + ['格式化文件', 'Alt+Shift+F'] + ] + + keymapsData.forEach((raw) => { + const keymapsRawDiv = document.createElement('div'); + keymapsRawDiv.style.width = '100%'; + keymapsRawDiv.style.height = '30px'; + keymapsRawDiv.style.display = 'flex'; + keymapsRawDiv.style.alignItems = 'center'; + keymapsRawDiv.style.justifyContent = 'center'; + keymapsRawDiv.style.backgroundColor = '#ffffff'; + mainDiv.appendChild(keymapsRawDiv); + + this.onclickKeymapsRawDiv(keymapsRawDiv); + + const keymapsNameDiv = document.createElement('div'); + keymapsNameDiv.className = 'lingzhi-ide-keymaps-raw' + keymapsNameDiv.textContent = raw[0]; + keymapsRawDiv.appendChild(keymapsNameDiv); + + const keymapsShortcutKeyDiv = document.createElement('div'); + keymapsShortcutKeyDiv.className = 'lingzhi-ide-keymaps-raw' + keymapsShortcutKeyDiv.textContent = raw[1]; + keymapsRawDiv.appendChild(keymapsShortcutKeyDiv); + + }) + } + + private onclickKeymapsRawDiv(keymapsRawDiv: HTMLDivElement) { + keymapsRawDiv.addEventListener('click', () => { + keymapsRawDiv.style.backgroundColor = '#1283dc'; + const childs = this.mainDiv.children; + for (let i = 0; i < childs.length; i++) { + const child = childs[i] as HTMLDivElement; + if (child !== keymapsRawDiv) { + child.style.backgroundColor = '#ffffff'; + } + } + }); + } + + override get value(): Promise { + throw new Error('Method not implemented.'); + } + + override close(): void { + if (this.resolve) { + if (this.activeElement) { + this.activeElement.focus({ preventScroll: true }); + } + this.resolve(undefined); + } + + const childs = this.mainDiv.children; + for (let i = 0; i < childs.length; i++) { + const child = childs[i] as HTMLDivElement; + child.style.backgroundColor = '#ffffff'; + } + + this.activeElement = undefined; + super.close(); + } + + override async open(): Promise | undefined> { + // 获取打开前主题的id + const themeIdBeforeOpen = this.themeService.getCurrentTheme().id; + // 调用父类open方法 + const result = await super.open(); + // 如果打开失败 + if (!result) { + // 如果当前主题id与打开前主题id不同 + if (this.themeService.getCurrentTheme().id !== themeIdBeforeOpen) { + // 将当前主题设置为打开前主题 + this.themeService.setCurrentTheme(themeIdBeforeOpen); + } + } + // 返回结果 + return result; + } + +} + +export interface Keymaps { + path: string; + model: string; +} diff --git a/arduino-ide-extension/src/browser/dialogs/Keymaps/open-keymaps.ts b/arduino-ide-extension/src/browser/dialogs/Keymaps/open-keymaps.ts new file mode 100644 index 000000000..b540bd00e --- /dev/null +++ b/arduino-ide-extension/src/browser/dialogs/Keymaps/open-keymaps.ts @@ -0,0 +1,24 @@ +/* eslint-disable prettier/prettier */ +import { inject, injectable } from '@theia/core/shared/inversify'; +import { + Command, + CommandRegistry, + SketchContribution, +} from '../../contributions/contribution'; +import { KeymapsDialog } from './keymaps-dialog'; + +@injectable() +export class OpenKeymaps extends SketchContribution { + @inject(KeymapsDialog) + private readonly keymapsDialog: KeymapsDialog; + + override registerCommands(command: CommandRegistry): void { + command.registerCommand(KEYMAPS_OPEN, { + execute: async () => { await this.keymapsDialog.open() }, + }) + } +} + +export const KEYMAPS_OPEN: Command = { + id: 'lingzhi-keymaps-open', +} diff --git a/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-component.tsx b/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-component.tsx index 0429ff487..3abb4f2d7 100644 --- a/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-component.tsx +++ b/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-component.tsx @@ -176,10 +176,7 @@ export const CertificateUploaderComponent = ({ {installFeedback === 'fail' && (
- {nls.localize( - 'arduino/certificate/uploadFailed', - 'Upload failed. Please try again.' - )} + {'上传失败。请再试一次。'}
)}
@@ -189,7 +186,7 @@ export const CertificateUploaderComponent = ({ onClick={installCertificates} disabled={selectedCerts.length === 0 || !selectedItem} > - {nls.localize('arduino/certificate/upload', 'Upload')} + {'上传'}
diff --git a/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-dialog.tsx b/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-dialog.tsx index 921807d6f..8ac173984 100644 --- a/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-dialog.tsx +++ b/arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-dialog.tsx @@ -6,7 +6,6 @@ import { } from '@theia/core/lib/browser/preferences/preference-service'; import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget'; import { CommandRegistry } from '@theia/core/lib/common/command'; -import { nls } from '@theia/core/lib/common/nls'; import type { Message } from '@theia/core/shared/@phosphor/messaging'; import { Widget } from '@theia/core/shared/@phosphor/widgets'; import { @@ -127,7 +126,7 @@ export class UploadCertificateDialogWidget extends ReactWidget { } @injectable() -export class UploadCertificateDialogProps extends DialogProps {} +export class UploadCertificateDialogProps extends DialogProps { } @injectable() export class UploadCertificateDialog extends AbstractDialog { @@ -141,10 +140,7 @@ export class UploadCertificateDialog extends AbstractDialog { protected override readonly props: UploadCertificateDialogProps ) { super({ - title: nls.localize( - 'arduino/certificate/uploadRootCertificates', - 'Upload SSL Root Certificates' - ), + title: '上传 SSL 根证书', }); this.node.id = 'certificate-uploader-dialog-container'; this.contentNode.classList.add('certificate-uploader-dialog'); @@ -155,6 +151,10 @@ export class UploadCertificateDialog extends AbstractDialog { return; } + public accept1() { + this.accept(); + } + protected override onAfterAttach(msg: Message): void { if (this.widget.isAttached) { Widget.detach(this.widget); diff --git a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx index 091e0a06a..839bb3518 100644 --- a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx +++ b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx @@ -1,4 +1,3 @@ -import { nls } from '@theia/core/lib/common/nls'; import React from '@theia/core/shared/react'; // @ts-expect-error see https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1319854183 import type { Options } from 'react-markdown'; @@ -20,7 +19,7 @@ export interface UpdateProgress { export interface IDEUpdaterComponentProps { updateInfo: UpdateInfo; updateProgress: UpdateProgress; - openExternal: (url: string) => undefined; + contentNode: HTMLDivElement; } export const IDEUpdaterComponent = ({ @@ -31,7 +30,7 @@ export const IDEUpdaterComponent = ({ progressInfo, error, }, - openExternal, + contentNode, }: IDEUpdaterComponentProps): React.ReactElement => { const { version, releaseNotes } = updateInfo; const [changelog, setChangelog] = React.useState(''); @@ -41,104 +40,62 @@ export const IDEUpdaterComponent = ({ typeof releaseNotes === 'string' ? releaseNotes : releaseNotes.reduce( - (acc, item) => (item.note ? (acc += `${item.note}\n\n`) : acc), - '' - ) + (acc, item) => (item.note ? (acc += `${item.note}\n\n`) : acc), + '' + ) ); } }, [releaseNotes, changelog]); - const DownloadCompleted: () => React.ReactElement = () => ( -
-
- {nls.localize( - 'arduino/ide-updater/versionDownloaded', - 'Arduino IDE {0} has been downloaded.', - version - )} + const DownloadCompleted: () => React.ReactElement = () => { + contentNode.style.height = '45px'; + return ( +
+
{`Lingzhi IDE ${version} 已经下载。`}
+
{'关闭软件并安装更新。'}
-
- {nls.localize( - 'arduino/ide-updater/closeToInstallNotice', - 'Close the software and install the update on your machine.' - )} -
-
- ); + ); + }; - const DownloadStarted: () => React.ReactElement = () => ( -
-
- {nls.localize( - 'arduino/ide-updater/downloadingNotice', - 'Downloading the latest version of the Arduino IDE.' - )} + const DownloadStarted: () => React.ReactElement = () => { + contentNode.style.height = 'auto'; + return ( +
+
{'正在下载 Lingzhi IDE 的最新版本。'}
+
- -
- ); + ); + }; - const PreDownload: () => React.ReactElement = () => ( -
-
-
-
-
-
-
- {nls.localize( - 'arduino/ide-updater/updateAvailable', - 'Update Available' - )} -
-
-
- {nls.localize( - 'arduino/ide-updater/newVersionAvailable', - 'A new version of Arduino IDE ({0}) is available for download.', - version + const PreDownload: () => React.ReactElement = () => { + contentNode.style.height = '200px'; + return ( +
+
+ {releaseNotes && ( +
+ {releaseNotes as string} +
)}
- {changelog && ( -
-
- -
-
- } - > - ( - href && openExternal(href)} {...props}> - {children} - - ), - }} - > - {changelog} - -
-
-
- )}
-
- ); + ); + }; - const GoToDownloadPage: () => React.ReactElement = () => ( -
-
- {nls.localize( - 'arduino/ide-updater/goToDownloadPage', - "An update for the Arduino IDE is available, but we're not able to download and install it automatically. Please go to the download page and download the latest version from there." - )} + const GoToDownloadPage: () => React.ReactElement = () => { + contentNode.style.height = '40px'; + return ( +
+
+ { + 'lingzhiLab IDE可以更新,但我们无法自动下载和安装。请转到下载页面并下载最新版本手动安装。' + } +
-
- ); + ); + }; + console.log('===========================updateError', error); return (
{!!error ? ( diff --git a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx index 0598b2853..41bd2e9b8 100644 --- a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx +++ b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx @@ -7,7 +7,6 @@ import { import { DialogProps } from '@theia/core/lib/browser/dialogs'; import { Message } from '@theia/core/shared/@phosphor/messaging'; import { ReactDialog } from '../../theia/dialogs/dialogs'; -import { nls } from '@theia/core'; import { IDEUpdaterComponent, UpdateProgress } from './ide-updater-component'; import { IDEUpdater, @@ -18,9 +17,10 @@ import { import { LocalStorageService } from '@theia/core/lib/browser'; import { WindowService } from '@theia/core/lib/browser/window/window-service'; import { sanitize } from 'dompurify'; +import { nls } from '@theia/core'; @injectable() -export class IDEUpdaterDialogProps extends DialogProps {} +export class IDEUpdaterDialogProps extends DialogProps { } @injectable() export class IDEUpdaterDialog extends ReactDialog { @@ -44,14 +44,17 @@ export class IDEUpdaterDialog extends ReactDialog { protected override readonly props: IDEUpdaterDialogProps ) { super({ - title: nls.localize( - 'arduino/ide-updater/ideUpdaterDialog', - 'Software Update' - ), + title: '软件更新', }); this.node.id = 'ide-updater-dialog-container'; this.contentNode.classList.add('ide-updater-dialog'); this.acceptButton = undefined; + + this.contentNode.style.width = '300px'; + this.contentNode.style.height = '200px'; + this.contentNode.style.borderBottom = '1px solid #f0f0f0'; + this.contentNode.style.padding = '5px 28px 0'; + this.contentNode.style.backgroundColor = '#ffffff'; } @postConstruct() @@ -75,13 +78,15 @@ export class IDEUpdaterDialog extends ReactDialog { ) ); } + // 定义一个私有只读的openExternal方法,用于打开一个新的窗口 private readonly openExternal = (url: string) => + // 调用windowService的openNewWindow方法,传入url和{ external: true }参数 this.windowService.openNewWindow(url, { external: true }); get value(): UpdateInfo | undefined { @@ -102,9 +107,8 @@ export class IDEUpdaterDialog extends ReactDialog { } private appendNotNowButton(): void { - this.appendCloseButton( - nls.localize('arduino/ide-updater/notNowButton', 'Not now') - ); + // 添加关闭按钮 + this.appendCloseButton('下次再说'); if (this.closeButton) { this.addCloseAction(this.closeButton, 'click'); } @@ -113,9 +117,7 @@ export class IDEUpdaterDialog extends ReactDialog { private appendInitialButtons(): void { this.clearButtons(); - const skipVersionButton = this.createButton( - nls.localize('arduino/ide-updater/skipVersionButton', 'Skip Version') - ); + const skipVersionButton = this.createButton('忽略更新'); skipVersionButton.classList.add('secondary'); skipVersionButton.classList.add('skip-version-button'); this.addAction(skipVersionButton, this.skipVersion.bind(this), 'click'); @@ -123,11 +125,13 @@ export class IDEUpdaterDialog extends ReactDialog { this.appendNotNowButton(); - const downloadButton = this.createButton( - nls.localize('arduino/ide-updater/downloadButton', 'Download') - ); + // 创建一个下载按钮 + const downloadButton = this.createButton('下载'); + // 为下载按钮添加点击事件,点击时调用startDownload方法 this.addAction(downloadButton, this.startDownload.bind(this), 'click'); + // 将下载按钮添加到控制面板中 this.controlPanel.appendChild(downloadButton); + // 将下载按钮设置为焦点 downloadButton.focus(); } @@ -135,12 +139,7 @@ export class IDEUpdaterDialog extends ReactDialog { this.clearButtons(); this.appendNotNowButton(); - const closeAndInstallButton = this.createButton( - nls.localize( - 'arduino/ide-updater/closeAndInstallButton', - 'Close and Install' - ) - ); + const closeAndInstallButton = this.createButton('关闭并安装'); this.addAction( closeAndInstallButton, this.closeAndInstall.bind(this), @@ -154,9 +153,7 @@ export class IDEUpdaterDialog extends ReactDialog { this.clearButtons(); this.appendNotNowButton(); - const goToDownloadPageButton = this.createButton( - nls.localize('arduino/ide-updater/goToDownloadButton', 'Go To Download') - ); + const goToDownloadPageButton = this.createButton('去下载'); this.addAction( goToDownloadPageButton, this.openDownloadPage.bind(this), @@ -212,28 +209,36 @@ export class IDEUpdaterDialog extends ReactDialog { } private openDownloadPage(): void { - this.openExternal('https://www.arduino.cc/en/software'); + this.openExternal('https://www.lingzhilab.com/download.html'); this.close(); } + // 跳过版本更新 private skipVersion(): void { + // 如果没有更新信息,则打印警告信息并返回 if (!this.updateInfo) { - console.warn(`Nothing to skip. No update info is available`); + console.warn(`没有什么可以忽略的。没有更新信息可用`); return; } + // 将跳过的版本号存储到localStorage中 this.localStorageService.setData( SKIP_IDE_VERSION, this.updateInfo.version ); + // 关闭更新窗口 this.close(); } + // 开始下载 private startDownload(): void { + // 设置下载开始标志 this.mergeUpdateProgress({ downloadStarted: true, }); + // 清除按钮 this.clearButtons(); this.appendDonateFooter(); + // 开始下载更新 this.updater.downloadUpdate(); } @@ -255,8 +260,11 @@ export class IDEUpdaterDialog extends ReactDialog { return this._updateProgress; } + // 合并更新进度 private mergeUpdateProgress(updateProgress: UpdateProgress): void { + // 将_updateProgress和updateProgress合并 this._updateProgress = { ...this._updateProgress, ...updateProgress }; + // 更新 this.update(); } diff --git a/arduino-ide-extension/src/browser/dialogs/librarys/librarys-dialog.tsx b/arduino-ide-extension/src/browser/dialogs/librarys/librarys-dialog.tsx new file mode 100644 index 000000000..a1bd030fc --- /dev/null +++ b/arduino-ide-extension/src/browser/dialogs/librarys/librarys-dialog.tsx @@ -0,0 +1,268 @@ +/* eslint-disable prettier/prettier */ +import { inject, injectable } from '@theia/core/shared/inversify'; +import { AbstractDialog } from '../../theia/dialogs/dialogs'; +import { DialogProps } from '@theia/core/lib/browser/dialogs'; +import { ThemeService } from '@theia/core/lib/browser/theming'; +import { LibraryService } from '../../../common/protocol/library-service'; +import { FileDialogService } from '@theia/filesystem/lib/browser/file-dialog/file-dialog-service'; +import { FileService } from '@theia/filesystem/lib/browser/file-service'; + +@injectable() +export class LibrarysDialogProps extends DialogProps { } + +@injectable() +export class LibrarysDialog extends AbstractDialog> { + private path: string; + private model: string; + private pathInput: HTMLInputElement; + private result: HTMLSpanElement; + + @inject(ThemeService) + private readonly themeService: ThemeService; + @inject(LibraryService) private libraryService: LibraryService; + @inject(FileDialogService) + protected readonly fileDialogService: FileDialogService; + @inject(FileService) + protected readonly fileService: FileService; + + constructor( + @inject(LibrarysDialogProps) + protected override readonly props: LibrarysDialogProps + ) { + super(props); + this.node.id = 'lingzhi-librarys-dialog-container'; + this.contentNode.classList.add('lingzhi-librarys-dialog'); + + this.contentNode.style.width = '100%'; + this.contentNode.style.height = '160px'; + this.contentNode.style.borderTop = '1px solid #4e5b61'; + + this.initLayout(); + } + + private initLayout() { + const initDiv = document.createElement('div'); + initDiv.className = 'librarys-dialog-init'; + this.contentNode.appendChild(initDiv); + + const modelDiv = document.createElement('div'); + modelDiv.className = 'librarys-dialog-model'; + initDiv.appendChild(modelDiv); + this.initModel(modelDiv); + + const pathDiv = document.createElement('div'); + pathDiv.className = 'librarys-dialog-path'; + initDiv.appendChild(pathDiv); + this.initPath(pathDiv); + + const buttonDiv = document.createElement('div'); + buttonDiv.className = 'librarys-dialog-button'; + initDiv.appendChild(buttonDiv); + this.initButton(buttonDiv); + + const resultDiv = document.createElement('div'); + resultDiv.className = 'librarys-dialog-result'; + initDiv.appendChild(resultDiv); + + const result = document.createElement('span'); + this.result = result; + resultDiv.appendChild(result); + } + + private initModel(modelDiv: HTMLDivElement) { + const modelText = document.createElement('span'); + modelText.innerText = '硬件型号:'; + modelDiv.appendChild(modelText); + + const modelSelect = document.createElement('select'); + modelSelect.className = 'librarys-dialog-model-select'; + modelDiv.appendChild(modelSelect); + + const refreshLibrarys = document.createElement('button'); + refreshLibrarys.innerText = '刷新库'; + refreshLibrarys.className = 'librarys-dialog-refresh-librarys'; + // modelDiv.appendChild(refreshLibrarys); + + refreshLibrarys.onclick = async () => { + this.result.innerText = ''; + let data = await this.libraryService.getBoardLibraries(); + if (data.length !== 0) { + modelSelect.innerHTML = ''; + this.modelSelect(modelSelect, data); + } + + this.result.innerText = '刷新库成功!'; + this.result.style.color = 'green'; + this.pathInput.value = ''; + } + + this.modelSelect(modelSelect); + } + + private async modelSelect(modelSelect: HTMLSelectElement, data: string[] = []) { + if (data.length === 0) { + data = ['ESP32', 'ESP8266', 'nrf52832', 'STM32F1', 'STM32HAL'] + } + + const GPLibrary = document.createElement('option'); + GPLibrary.innerText = '通用库'; + GPLibrary.value = 'GPLibrary'; + modelSelect.appendChild(GPLibrary); + + data.forEach((board) => { + const option = document.createElement('option'); + switch (board) { + case 'STM32F1': + const mini = document.createElement('option'); + mini.innerText = '零知-标准板'; + mini.value = board; + modelSelect.appendChild(mini); + option.innerText = '零知-迷你板'; + break; + case 'ESP8266': + option.innerText = '零知-ESP8266'; + break; + case 'nrf52832': + option.innerText = '零知-BLE52'; + break; + case 'ESP32': + option.innerText = '零知-ESP32'; + break; + case 'STM32HAL': + option.innerText = '零知-增强板'; + break; + } + option.value = board; + modelSelect.appendChild(option); + }) + modelSelect.value = 'GPLibrary'; + this.model = modelSelect.value; + modelSelect.addEventListener('change', () => { + this.model = modelSelect.value; + }); + } + + private initPath(pathDiv: HTMLDivElement) { + const pathText = document.createElement('span'); + pathText.innerText = '文件夹路径:'; + pathDiv.appendChild(pathText); + + const pathInput = document.createElement('input'); + pathInput.className = 'librarys-dialog-path-input'; + pathInput.type = 'text'; + pathDiv.appendChild(pathInput); + this.pathInput = pathInput; + + pathInput.addEventListener('change', () => { + this.path = pathInput.value; + }) + + const pathButton = document.createElement('button'); + pathButton.className = 'librarys-dialog-path-button'; + pathButton.innerText = '...'; + + pathDiv.appendChild(pathButton); + + pathButton.addEventListener('click', async () => { + const uri = await this.fileDialogService.showOpenDialog({ + title: '选择本地软件库目录', + openLabel: '选择文件夹', + canSelectFiles: false, + canSelectMany: false, + canSelectFolders: true, + modal: true, + }); + + if (uri) { + this.path = await this.fileService.fsPath(uri); + pathInput.value = this.path; + this.result.innerText = ''; + } else { + this.result.innerText = '未选择任何目录!'; + this.result.style.color = 'red'; + pathInput.value = ''; + } + + }) + } + + private initButton(buttonDiv: HTMLDivElement) { + const installButton = document.createElement('button'); + installButton.className = 'librarys-dialog-button-button'; + installButton.innerText = '安装'; + buttonDiv.appendChild(installButton); + + + const cancelButton = document.createElement('button'); + cancelButton.className = 'librarys-dialog-button-button'; + cancelButton.innerText = '退出'; + buttonDiv.appendChild(cancelButton); + cancelButton.addEventListener('click', () => { + this.close(); + }) + + + this.installLibrary(installButton); + } + + private installLibrary(installButton: HTMLButtonElement) { + installButton.addEventListener('click', async () => { + const path = this.path; + const model = this.model; + if (!path) { + this.result.innerText = '未选择任何目录!'; + this.result.style.color = 'red'; + return; + } + const result = await this.libraryService.installLibrary(path, model); + if (result[1]) { + this.result.innerText = result[0]; + this.result.style.color = 'green'; + } else { + this.result.innerText = result[0]; + this.result.style.color = 'red'; + } + + }) + } + + override get value(): Promise { + throw new Error('Method not implemented.'); + } + + override close(): void { + if (this.resolve) { + if (this.activeElement) { + this.activeElement.focus({ preventScroll: true }); + } + this.resolve(undefined); + } + this.pathInput.value = ''; + this.result.innerText = ''; + this.activeElement = undefined; + super.close(); + } + + override async open(): Promise | undefined> { + // 获取打开前主题的id + const themeIdBeforeOpen = this.themeService.getCurrentTheme().id; + // 调用父类open方法 + const result = await super.open(); + // 如果打开失败 + if (!result) { + // 如果当前主题id与打开前主题id不同 + if (this.themeService.getCurrentTheme().id !== themeIdBeforeOpen) { + // 将当前主题设置为打开前主题 + this.themeService.setCurrentTheme(themeIdBeforeOpen); + } + } + // 返回结果 + return result; + } + +} + +export interface Lidrarys { + path: string; + model: string; +} diff --git a/arduino-ide-extension/src/browser/dialogs/librarys/open-librarys.ts b/arduino-ide-extension/src/browser/dialogs/librarys/open-librarys.ts new file mode 100644 index 000000000..8faffb9ee --- /dev/null +++ b/arduino-ide-extension/src/browser/dialogs/librarys/open-librarys.ts @@ -0,0 +1,24 @@ +/* eslint-disable prettier/prettier */ +import { inject, injectable } from '@theia/core/shared/inversify'; +import { + Command, + CommandRegistry, + SketchContribution, +} from '../../contributions/contribution'; +import { LibrarysDialog } from './librarys-dialog'; + +@injectable() +export class OpenLibrarys extends SketchContribution { + @inject(LibrarysDialog) + private readonly librarysDialog: LibrarysDialog; + + override registerCommands(command: CommandRegistry): void { + command.registerCommand(LIBRARYS_OPEN, { + execute: async () => { await this.librarysDialog.open() }, + }) + } +} + +export const LIBRARYS_OPEN: Command = { + id: 'lingzhi-librarys-open', +} diff --git a/arduino-ide-extension/src/browser/dialogs/settings/settings-component.tsx b/arduino-ide-extension/src/browser/dialogs/settings/settings-component.tsx index 347c712bf..71ec94881 100644 --- a/arduino-ide-extension/src/browser/dialogs/settings/settings-component.tsx +++ b/arduino-ide-extension/src/browser/dialogs/settings/settings-component.tsx @@ -1,5 +1,5 @@ import React from '@theia/core/shared/react'; -import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; +import { Tabs, TabList, TabPanel } from 'react-tabs'; import 'react-tabs/style/react-tabs.css'; import { Disable } from 'react-disable'; import { deepClone } from '@theia/core/lib/common/objects'; @@ -18,15 +18,11 @@ import { import { nls } from '@theia/core/lib/common'; import { Settings, SettingsService } from './settings'; import { AdditionalUrlsDialog } from './settings-dialog'; -import { - AsyncLocalizationProvider, - LanguageInfo, -} from '@theia/core/lib/common/i18n/localization'; +import { AsyncLocalizationProvider } from '@theia/core/lib/common/i18n/localization'; import SettingsStepInput from './settings-step-input'; import { InterfaceScale } from '../../contributions/interface-scale'; import { userConfigurableThemes, - themeLabelForSettings, arduinoThemeTypeOf, } from '../../theia/core/theming'; import { Theme } from '@theia/core/lib/common/theme'; @@ -63,7 +59,7 @@ export class SettingsComponent extends React.Component< this.state && prevState && JSON.stringify(SettingsComponent.State.toSettings(this.state)) !== - JSON.stringify(SettingsComponent.State.toSettings(prevState)) + JSON.stringify(SettingsComponent.State.toSettings(prevState)) ) { this.props.settingsService.update( SettingsComponent.State.toSettings(this.state), @@ -101,8 +97,8 @@ export class SettingsComponent extends React.Component< return ( - {nls.localize('vscode/settingsTree/settings', 'Settings')} - {nls.localize('arduino/preferences/network', 'Network')} + {/* {nls.localize('vscode/settingsTree/settings', 'Settings')} + {nls.localize('arduino/preferences/network', 'Network')} */} {this.renderSettings()} {this.renderNetwork()} @@ -115,25 +111,28 @@ export class SettingsComponent extends React.Component< return (
- {nls.localize( - 'arduino/preferences/sketchbook.location', - 'Sketchbook location' - ) + ':'} -
- - +
+ {'软件库路径设置'} +
+
+ 库路径: + + +
+
-