开始
复制一个设置提示,包含安装步骤和该插件的完整 Markdown 指南。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these packages:
- `@capacitor-plus/core`
- `@capacitor-plus/cli`
- `@capacitor-plus/android` if the project targets Android
- `@capacitor-plus/ios` if the project targets iOS
Complete the required Capacitor initialization, platform, sync, native setup, and configuration work.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/capacitor-plus/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
新项目安装
标题为“新项目安装”的部分您可以使用我们的 AI 助手设置来安装 Capacitor+。将 Capgo 技能添加到您的 AI 工具中,使用以下命令:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capacitor-plus/core`, `@capacitor-plus/cli`, `@capacitor-plus/android`, and `@capacitor-plus/ios` packages in my project.如果您更喜欢手动设置,请运行以下命令安装包并按照以下平台特定说明进行操作:
-
安装核心包
终端窗口 npm install @capacitor-plus/core @capacitor-plus/cli -
添加平台包
终端窗口 npm install @capacitor-plus/android # for Androidnpm install @capacitor-plus/ios # for iOS -
初始化Capacitor
平安窗口 npx cap init平安窗口 pnpm cap init平安窗口 yarn cap init平安窗口 bunx cap init -
添加籿米
当前窗絁算名 npx cap add android当前窗絁算名 pnpm cap add android当前窗絁算名 yarn cap add android当前窗絁算名 bunx cap add android笔统窗类 npx cap add ios笔统窗类 pnpm cap add ios笔统窗类 yarn cap add ios笔统窗类 bunx cap add ios
Migrating from Official Capacitor
Section titled “Migrating from Official Capacitor”If you have an existing Capacitor project, migrating to Capacitor+ is simple:
-
移除官方包
终端窗口 npm uninstall @capacitor/core @capacitor/cli @capacitor/android @capacitor/ios -
Install Capacitor+ packages
终端窗口 npm install @capacitor-plus/core @capacitor-plus/clinpm install @capacitor-plus/android # if using Androidnpm install @capacitor-plus/ios # if using iOS -
同步您的项目
终端窗口 npx cap sync终端窗口 pnpm cap sync终端窗口 yarn cap sync终端窗口 bunx cap sync
使用
使用Since Capacitor+ is API-compatible, your existing code works without changes:
import { Capacitor } from '@capacitor/core';import { registerPlugin } from '@capacitor/core';
// Check platformconst platform = Capacitor.getPlatform();console.log('Running on:', platform);
// Check if nativeif (Capacitor.isNativePlatform()) { console.log('Running on native platform');}
// Register a custom pluginconst MyPlugin = registerPlugin('MyPlugin');With Official Capacitor Plugins
Section titled “With Official Capacitor Plugins”All official Capacitor plugins work seamlessly:
import { Camera, CameraResultType } from '@capacitor/camera';import { Geolocation } from '@capacitor/geolocation';import { Storage } from '@capacitor/preferences';
// Cameraconst photo = await Camera.getPhoto({ quality: 90, resultType: CameraResultType.Uri});
// Geolocationconst position = await Geolocation.getCurrentPosition();
// Storageawait Storage.set({ key: 'name', value: 'John' });With Capgo Plugins
Section titled “With Capgo Plugins”Capgo plugins work perfectly with Capacitor+:
import { CapacitorUpdater } from '@capgo/capacitor-updater';import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';import { CapacitorFlash } from '@capgo/capacitor-flash';
// Live updatesawait CapacitorUpdater.notifyAppReady();
// Screen orientationawait ScreenOrientation.lock({ orientation: 'portrait' });
// Flashlightawait CapacitorFlash.toggle();How the Sync Works
How the Sync Works┌─────────────────────┐ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────────┐│ ionic-team/ │ │ CI/CD │ │ Claude Code │ │ npm publish ││ capacitor │────▶│ Pipeline │────▶│ Security Review │────▶│ @capacitor-plus││ (upstream) │ │ (daily sync) │ │ (AI analysis) │ │ packages │└─────────────────────┘ └──────────────────┘ └──────────────────┘ └─────────────────┘- 每日同步: GitHub 动作从
ionic-team/capacitor - PR 创建: 提案作为 pull 请求到
plusbranch - CI 验证: 全套测试 (lint, 单元测试, iOS 构建, Android 构建)
- 安全审查: AI 驱动分析检查漏洞和破坏性更改
- 自动合并: 只有当 CI 通过并且安全审查通过时
- 自动发布: 新版本发布到 npm 下
@capacitor-plus/*
安全审查细节
标题为“安全审查细节”每次上游同步都会分析:
| 检查 | 它捕获了什么 |
|---|---|
| 安全 | 命令注入、XSS、路径遍历、硬编码密钥 |
| 更改记录 | API的更改 |
| 稳定性 | 内存泄露 |
| 数据安全 | 数据丢失场景、隐私泄露、不安全的存储 |
| Code完整性 | 混淆的code、可疑的网络调用、后门 |
提交您的PR
提交您的PR有一个 PR 卡在官方 Capacitor 仓库里?让它在 Capacitor+ 中被合并:
-
打开一个问题 在 Capacitor+ 仓库 链接到您的上游 PR
-
或者直接提交 作为
plusbranch -
团队会审查、运行 CI,如果通过则合并
这样您和其他人可以立即从您的工作中受益,而不必等待上游发布周期
是否该用于生产环境?
标题:是否该用于生产环境?是。Capacitor+已在生产应用中使用。每个版本都通过同一测试套件(官方Capacitor)以及额外的安全分析。
我的官方插件是否仍然有效?
标题:我的官方插件是否仍然有效?是。所有 @capacitor/* 插件都可以直接使用Capacitor+。
如果上游发布了破坏性更新?
标题:如果上游发布了破坏性更新?人工安全审查会标记破坏性更新进行手动审查。您将在合并之前看到这些更新的文档。
如何报告问题?
标题:如何报告问题?File issues on the Capacitor+ GitHub。对于影响官方Capacitor的issue,我们会协助上游处理。
我可以贡献吗?
Section titled “我可以贡献吗?”当然!PRs都欢迎。您可以直接提交修复或要求特定的上游PR被合并。
继续从Getting Started
Section titled “继续从Getting Started”如果您正在使用 Getting Started 来规划原生插件工作,连接它与 使用Capacitor+ (@capacitor-plus) Packages 为使用 Capacitor+ (@capacitor-plus) 包的本机能力 Capgo 插件目录 为 Capgo 插件目录中的产品流程 Capacitor 由 Capgo 提供的插件 为 Capacitor 由 Capgo 提供的插件中的实现细节 添加或更新插件 为添加或更新插件中的实现细节, 和 Ionic 企业插件替代方案 为 Ionic 企业插件替代方案中的产品流程