菜单

Web 实现

相关源文件

本页面介绍了Tabby的Web实现,它允许终端应用程序在浏览器环境中运行。本页面涵盖了Web版本的架构、组件和技术细节,与桌面Electron实现(在 Electron Implementation 中介绍)有所区别。

1. 概述

Tabby的Web实现允许用户直接通过Web浏览器访问终端功能,而无需安装桌面应用程序。它使用特定于Web的技术实现了核心的Platform Service接口,同时在可能的情况下保持了功能的一致性。

来源: tabby-web/src/platform.ts14-149 tabby-core/src/api/platform.ts112-242

2. Platform Service Implementation

Web实现的核心是WebPlatformService类,它继承自核心API的抽象PlatformService。它将Tabby的平台无关接口适配到浏览器环境。

来源: tabby-web/src/platform.ts14-149 tabby-core/src/api/platform.ts65-85 tabby-core/src/api/platform.ts244-281

2.1 Web Platform Service

The WebPlatformService uses browser APIs to implement all platform-specific operations.

操作实现细节
剪贴板Uses copyToClipboard utility, limited to text content
文件上传Uses HTML file input element with change handlers
File DownloadCreates downloadable Blobs with temporary links
上下文菜单Uses Vaadin custom element for popup menus
配置Delegates to connector service
Dialog BoxesUses Angular NgbModal service

来源: tabby-web/src/platform.ts38-149 tabby-core/src/api/platform.ts65-85 tabby-core/src/api/platform.ts244-281

3. File Operations

3.1 Upload Implementation

Web版本的下载通过HTML文件输入和File API处理。当用户发起上传时

  1. 隐藏的文件输入元素被触发以打开浏览器的文件选择对话框
  2. 选定的文件被包装在 HTMLFileUpload 对象中
  3. 文件数据通过 ReadableStream 接口访问

来源: tabby-web/src/platform.ts117-136 tabby-core/src/api/platform.ts244-281

3.2 Download Implementation

Downloads are handled by

  1. Collecting file data in memory buffers
  2. Creating a Blob from the accumulated data
  3. Creating a temporary anchor element with a download attribute
  4. Triggering a click to initiate the browser download

来源: tabby-web/src/platform.ts151-194

3.3 Drag and Drop Support

The web implementation also supports drag-and-drop file operations through the HTML5 Drag and Drop API

来源: tabby-core/src/directives/dropZone.directive.ts1-47 tabby-core/src/api/platform.ts133-179

4. UI Components

4.1 Context Menus

The web implementation uses Vaadin's context menu component to provide right-click menus

来源: tabby-web/src/platform.ts70-78

4.2 Message Boxes

Message boxes are implemented using Angular's NgbModal service

来源: tabby-web/src/platform.ts93-105

5. Plugin System and Web Compatibility

The web implementation works with the same plugin architecture as the desktop version, with some adaptations for web environments.

来源: app/src/plugins.ts190-226 app/src/plugins.ts228-262 app/src/entry.ts34-55 app/src/entry.ts57-82

5.1 Plugin Filtering for Web

When running in web mode, the application specifically includes web-compatible plugins and excludes desktop-only functionality

This filtering ensures that only web-compatible plugins are loaded in the browser environment.

来源: app/src/entry.ts67

6. Web-Specific Limitations

The web implementation has certain limitations compared to the desktop version

功能Web 实现Electron 实现
文件系统访问Limited to browser sandboxFull file system access
Shell 集成不支持Supported on compatible platforms
Native ClipboardLimited functionalityFull functionality
Directory Upload有限支持完全支持
进程管理不支持支持
Font DetectionLimited to browser fontsAccess to system fonts

来源: tabby-web/src/platform.ts138-140 tabby-electron/src/services/platform.service.ts108-122 tabby-electron/src/services/platform.service.ts160-178

7. Terminal Integration

Terminal features like ZModem file transfer protocol are adapted to work with the web platform's file handling capabilities

来源: tabby-terminal/src/features/zmodem.ts76-96 tabby-ssh/src/components/sftpPanel.component.ts178-186 tabby-ssh/src/components/sftpPanel.component.pug24-30

8. SFTP Support in Web

The web implementation includes support for SFTP operations, allowing users to

  • Browse remote file systems
  • Upload files
  • Download files
  • 创建目录

The SFTP panel adapts to the web platform's file handling capabilities

来源: tabby-ssh/src/components/sftpPanel.component.ts178-186 tabby-ssh/src/components/sftpPanel.component.pug24-30

9. 总结

Tabby的Web实现提供了一个基于浏览器的终端体验,它保留了核心功能,同时适应了浏览器限制。它利用现代Web API进行文件处理、UI组件和终端仿真。虽然与桌面版本相比,某些功能受到限制,但Web实现提供了无需安装即可访问的优势。