ce55be4a-fb5f-4981-b507-0f4.../README.zh-CN.md
徐翔宇 c4080b5cb9 v1.0.0: initial AirDrop plugin for MioIsland
Quick-access AirDrop from the notch panel. Tap the card body, pick
files via NSOpenPanel, hand off to NSSharingService(.sendViaAirDrop).
No private APIs, no entitlements, no network — just a thin wrapper
around the same AirDrop API Finder uses.

Design constraint: drag-and-drop is intentionally not implemented.
MioIsland's notch panel auto-collapses on click-outside, which
breaks the Cmd-Tab-to-Finder / grab / drag-back workflow before
the drop target reaches. Tap-to-choose is rock solid by comparison.

Requires MioIsland host v2.2.0+ (panel size clamp floor was
lowered to 120pt in that release).
2026-04-22 08:20:47 +08:00

2.2 KiB

隔空投送插件(Mio Island)

在 Mio Island 面板里一键打开系统隔空投送。点一下中间的卡片区域,选 文件,系统原生的 AirDrop 弹窗就会出现,发给附近的设备或联系人。

English

功能

  • 一键选文件 — 弹出系统原生 NSOpenPanel,支持多选、文件夹
  • 原生 AirDrop 弹窗 — 用 NSSharingService(.sendViaAirDrop), Finder 发 AirDrop 就是用这个 API。不涉及私有 API,不需要 entitlements
  • 中英双语 — 跟随 Mio Island 的 appLanguage 设置(zh / en)
  • 零权限要求 — 不需要辅助功能、自动化、网络,所有发送走 macOS 内置 AirDrop

为什么不做拖拽?

Mio Island 的刘海面板在用户点击面板外区域时会自动收起 —— 这使得 "展开 Island → Cmd-Tab 到 Finder → 抓文件 → 拖回来" 这条交互无 法成立,因为拖拽目标在用户还没到之前就消失了。我们尝试过三次修改 host 的事件路由来支持持久化,每次都暴出新 bug(乱触、卡顿、冻结 UI)。

所以这个插件只做点击选择文件这条路径,稳如老狗。

如果你想要拖拽的体验,未来 Mio Island 主程序可能会加一个全局 拖拽触发机制(类似 Atoll 的 Dynamic Island),届时这个插件会自 动受益。

系统要求

  • macOS 15.0+
  • Mio Island v2.2.0+

本地构建

./build.sh

产物在 build/airdrop.bundlebuild/airdrop.zip。复制 bundle 到 ~/.config/codeisland/plugins/ 即可本地测试。

代码结构

Sources/
├── MioPlugin.swift          ← 协议副本(@objc 运行时按签名匹配)
├── AirDropPlugin.swift      ← principal 类,对应 Info.plist 的 NSPrincipalClass
├── AirDropState.swift       ← @MainActor ObservableObject,状态机
├── services/
│   └── AirDropService.swift ← NSSharingService 的薄封装
├── ui/
│   ├── ExpandedView.swift   ← 卡片容器布局
│   └── DropZoneView.swift   ← 可点击目标,根据 phase 做视觉反馈
└── support/
    ├── Localization.swift
    └── HostVersionCheck.swift

许可

MIT — 见 LICENSE