跳到正文
Skillpedia
网站与界面(前端)48k · #5151

makepad-platform

它能做什么

这个工具帮助你了解并为不同的操作系统(如 Windows、macOS、Linux、Android、iOS 和 Web)编写代码,基于 Makepad 平台。它会说明支持哪些系统,以及代码如何适配每个系统。

适用场景

  • ✓想了解你的 Makepad 应用可以运行在哪些系统上(移动端、桌面端、网页)时。
  • ✓需要编写只在特定系统上运行的代码段时(例如只在 Windows 上运行)。
  • ✓想了解 Makepad 在各个系统上如何使用不同的图形技术(如 Metal、OpenGL)时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/makepad-platform/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/makepad-platform/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我怎样让我的 Makepad 应用同时能在 Android 和网页浏览器中运行?”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会查阅 Makepad 支持的平台信息,以及代码如何适配这些平台的资料。它会结合对 Makepad 的通用知识,以及文档文件中的具体信息(如果有的话)。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Supporting material availability

This catalog copy contains the inline guidance below, but does not include the following supporting paths. They are external prerequisites, not bundled files:

  • ./references/platform-support.md

Ask for the original supporting material or an existing installation before using a step that depends on these paths; this catalog does not identify a verified download source for them. Resolve each path relative to that installation, inspect its contents, and verify any applicable license and execution prerequisites. Do not run a command or claim a referenced procedure was followed until its required file exists. Do not fabricate the missing scripts or treat an unrelated file with the same name as equivalent. Independent steps fully documented here can proceed within the user’s authorized scope; report any dependent step as unavailable.

Makepad Platform Skill

Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19

Check for updates: https://crates.io/crates/makepad-widgets

You are an expert at Makepad cross-platform development. Help users by:

  • Understanding platforms: Explain supported platforms and backends
  • Platform-specific code: Help with conditional compilation and platform APIs

When to Use

  • You need to understand or target specific platforms and graphics backends in Makepad.
  • The task involves platform compatibility, conditional compilation, or OS-specific behavior across desktop, mobile, or web.
  • You need guidance on backend differences such as Metal, D3D11, OpenGL, WebGL, or platform modules.

Documentation

Refer to the local files for detailed documentation:

  • ./references/platform-support.md - Platform details and OsType

IMPORTANT: Documentation Completeness Check

Before answering questions, Claude MUST:

  1. Read the relevant reference file(s) listed above
  2. If file read fails or file is empty:
    • Inform user: "本地文档不完整,建议运行 /sync-crate-skills makepad --force 更新文档"
    • Still answer based on SKILL.md patterns + built-in knowledge
  3. If reference file exists, incorporate its content into the answer

Supported Platforms

Platform Graphics Backend OS Module
macOS Metal apple/metal_*.rs, apple/cocoa_*.rs
iOS Metal apple/metal_*.rs, apple/ios_*.rs
Windows D3D11 mswindows/d3d11_*.rs, mswindows/win32_*.rs
Linux OpenGL linux/opengl_*.rs, linux/x11*.rs, linux/wayland*.rs
Web WebGL2 web/*.rs, web_browser/*.rs
Android OpenGL ES android/*.rs
OpenHarmony OHOS open_harmony/*.rs
OpenXR VR/AR open_xr/*.rs

OsType Enum

pub enum OsType {
    Unknown,
    Windows,
    Macos,
    Linux { custom_window_chrome: bool },
    Ios,
    Android(AndroidParams),
    OpenHarmony,
    Web(WebParams),
    OpenXR,
}

// Check platform in code
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
    match cx.os_type() {
        OsType::Macos => { /* macOS-specific */ }
        OsType::Windows => { /* Windows-specific */ }
        OsType::Web(_) => { /* Web-specific */ }
        _ => {}
    }
}

Platform Detection

// In Cx
impl Cx {
    pub fn os_type(&self) -> OsType;
    pub fn gpu_info(&self) -> &GpuInfo;
    pub fn xr_capabilities(&self) -> &XrCapabilities;
    pub fn cpu_cores(&self) -> usize;
}

Conditional Compilation

// Compile-time platform detection
#[cfg(target_os = "macos")]
fn macos_only() { }

#[cfg(target_os = "windows")]
fn windows_only() { }

#[cfg(target_os = "linux")]
fn linux_only() { }

#[cfg(target_arch = "wasm32")]
fn web_only() { }

#[cfg(target_os = "android")]
fn android_only() { }

#[cfg(target_os = "ios")]
fn ios_only() { }

Platform-Specific Features

Desktop (macOS/Windows/Linux)

  • Window management (resize, minimize, maximize)
  • File dialogs
  • System menu
  • Drag and drop
  • Multiple monitors

Mobile (iOS/Android)

  • Touch input
  • Virtual keyboard
  • Screen orientation
  • App lifecycle (foreground/background)

Web (WebGL2)

  • DOM integration
  • Browser events
  • Local storage
  • HTTP requests

Entry Point

// App entry macro
app_main!(App);

pub struct App {
    ui: WidgetRef,
}

impl LiveRegister for App {
    fn live_register(cx: &mut Cx) {
        // Register components
        crate::makepad_widgets::live_design(cx);
    }
}

impl AppMain for App {

…
常见问题

什么是“图形后端”(graphics backends)?

这是 Makepad 在每个系统上用来把内容绘制到屏幕上的技术。例如 Metal(适用于 Apple 系统)、D3D11(适用于 Windows)和 OpenGL(适用于 Linux 和 Android)。

代码怎么知道自己运行在哪个系统上?

有两种方式:一种是在运行时(程序运行期间)使用 `cx.os_type()` 进行判断;另一种是在编译时(程序构建之前)使用 `#[cfg(target_os = '...')]` 进行判断。

“Makepad 跨平台”是什么意思?

意思是 Makepad 让你可以编写适用于多种操作系统(桌面、移动端、网页)的代码,而不必为每个系统重写所有代码。

详情

作者的原始描述

CRITICAL: Use for Makepad cross-platform support. Triggers on: makepad platform, makepad os, makepad macos, makepad windows, makepad linux, makepad android, makepad ios, makepad web, makepad wasm, makepad metal, makepad d3d11, makepad opengl, makepad webgl, OsType, CxOs, makepad 跨平台, makepad 平台支持

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5151
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能