Co-Pilot / 辅助式
更新于 a month ago

gpui-component

Llongbridge
9.9k
longbridge/gpui-component
80
Agent 评分

💡 摘要

GPUI 组件提供了一套丰富的可定制 UI 组件,用于在 Rust 中构建跨平台桌面应用程序。

🎯 适合人群

希望构建桌面应用程序的 Rust 开发者希望获得可定制组件的 UI/UX 设计师对跨平台解决方案感兴趣的软件工程师希望增强 UI 库的开源贡献者需要图表功能的数据可视化专家

🤖 AI 吐槽:看起来很能打,但别让配置把人劝退。

安全分析高风险

风险:High。建议检查:是否执行 shell/命令行指令;是否发起外网请求(SSRF/数据外发);文件读写范围与路径穿越风险。以最小权限运行,并在生产环境启用前审计代码与依赖。

GPUI Component

Build Status Docs Crates.io

UI components for building fantastic desktop applications using GPUI.

Features

  • Richness: 60+ cross-platform desktop UI components.
  • Native: Inspired by macOS and Windows controls, combined with shadcn/ui design for a modern experience.
  • Ease of Use: Stateless RenderOnce components, simple and user-friendly.
  • Customizable: Built-in Theme and ThemeColor, supporting multi-theme and variable-based configurations.
  • Versatile: Supports sizes like xs, sm, md, and lg.
  • Flexible Layout: Dock layout for panel arrangements, resizing, and freeform (Tiles) layouts.
  • High Performance: Virtualized Table and List components for smooth large-data rendering.
  • Content Rendering: Native support for Markdown and simple HTML.
  • Charting: Built-in charts for visualizing your data.
  • Editor: High performance code editor (support up to 200K lines) with LSP (diagnostics, completion, hover, etc).
  • Syntax Highlighting: Syntax highlighting for editor and markdown components using Tree Sitter.

Showcase

Here is the first application: Longbridge Pro, built using GPUI Component.

Usage

gpui = "0.2.2" gpui-component = "0.5.0"

Basic Example

use gpui::*; use gpui_component::{button::*, *}; pub struct HelloWorld; impl Render for HelloWorld { fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement { div() .v_flex() .gap_2() .size_full() .items_center() .justify_center() .child("Hello, World!") .child( Button::new("ok") .primary() .label("Let's Go!") .on_click(|_, _, _| println!("Clicked!")), ) } } fn main() { let app = Application::new(); app.run(move |cx| { // This must be called before using any GPUI Component features. gpui_component::init(cx); cx.spawn(async move |cx| { cx.open_window(WindowOptions::default(), |window, cx| { let view = cx.new(|_| HelloWorld); // This first level on the window, should be a Root. cx.new(|cx| Root::new(view, window, cx)) })?; Ok::<_, anyhow::Error>(()) }) .detach(); }); }

Icons

GPUI Component has an Icon element, but it does not include SVG files by default.

The example uses Lucide icons, but you can use any icons you like. Just name the SVG files as defined in IconName. You can add any icons you need to your project.

Development

We have a gallery of applications built with GPUI Component.

cargo run

More examples can be found in the examples directory. You can run them with cargo run --example <example_name>.

Check out CONTRIBUTING.md for more details.

Compare to others

| Features | GPUI Component | Iced | egui | Qt 6 | | --------------------- | ------------------------------ | ------------------ | --------------------- | ------------------------------------------------- | | Language | Rust | Rust | Rust | C++/QML | | Core Render | GPUI | wgpu | wgpu | QT | | License | Apache 2.0 | MIT | MIT/Apache 2.0 | Commercial/LGPL | | Min Binary Size [^1] | 12MB | 11MB | 5M | 20MB [^2] | | Cross-Platform | Yes | Yes | Yes | Yes | | Documentation | Simple | Simple | Simple | Good | | Web | No | Yes | Yes | Yes | | UI Style | Modern | Basic | Basic | Basic | | CJK Support | Yes | Yes | Bad | Yes | | Chart | Yes | No | No | Yes | | Table (Large dataset) | Yes(Virtual Rows, Columns) | No | Yes(Virtual Rows) | Yes(Virtual Rows, Columns) | | Table Column Resize | Yes | No | Yes | Yes | | Text base | Rope | COSMIC Text [^3] | trait TextBuffer [^4] | QTextDocument | | CodeEditor | Simple | Simple | Simple | Basic API | | Dock Layout | Yes | Yes | Yes | Yes | | Syntax Highlight | Tree Sitter | Syntect | Syntect | QSyntaxHighlighter | | Markdown Rendering | Yes | Yes | Basic | No | | Markdown mix HTML | Yes | No | No | No | | HTML Rendering | Basic | No | No | Basic | | Text Selection | TextView | No | Any Label | Yes | | Custom Theme | Yes | Yes | Yes | Yes | | Built Themes | Yes | No | No | No | | I18n | Yes | Yes | Yes | Yes |

Please submit an issue or PR if any mistakes or outdated are found.

[^1]: Release builds by use simple hello world example.

[^2]: Reducing Binary Size of Qt Applications

[^3]: Iced Editor: https://github.com/iced-rs/iced/blob/db5a1f6353b9f8520c4f9633d1cdc90242c2afe1/graphics/src/text/editor.rs#L65-L68

[^4]: egui TextBuffer: https://github.com/emilk/egui/blob/0a81372cfd3a4deda640acdecbbaf24bf78bb6a2/crates/egui/src/widgets/text_edit/text_buffer.rs#L20

License

Apache-2.0

五维分析
清晰度8/10
创新性8/10
实用性9/10
完整性8/10
可维护性7/10
优缺点分析

优点

  • 丰富的 60 多个 UI 组件
  • 跨平台兼容性
  • 虚拟化组件的高性能
  • 可定制的主题和布局

缺点

  • 高级功能的文档有限
  • 依赖于 Rust 生态系统
  • 没有内置的 SVG 图标
  • 复杂应用程序可能需要额外的设置

相关技能

pytorch

S
toolCode Lib / 代码库
92/ 100

“它是深度学习的瑞士军刀,但祝你好运能从47种安装方法里找到那个不会搞崩你系统的那一个。”

agno

S
toolCode Lib / 代码库
90/ 100

“它承诺成为智能体领域的Kubernetes,但得看开发者有没有耐心学习又一个编排层。”

nuxt-skills

S
toolCo-Pilot / 辅助式
90/ 100

“这本质上是一份组织良好的小抄,能把你的 AI 助手变成一只 Nuxt 框架的复读机。”

免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。

版权归原作者所有 longbridge.