Getting Started
复制一个包含安装步骤和此插件的完整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 -
安装 Capacitor+ 包
终端窗口 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
Capacitor+ 兼容 API,因此您的现有 code 不需要任何更改:
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');与官方Capacitor插件
标题:与官方Capacitor插件所有官方Capacitor插件都可以无缝工作:
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' });与Capgo插件
标题:与Capgo插件Capgo插件与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();同步的工作原理
标题:同步的工作原理┌─────────────────────┐ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────────┐│ 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 请求提交到
plus分支 - CI 验证: 全套测试 (lint, 单元测试, iOS 构建, Android 构建)
- 安全审查: AI 强化分析检查漏洞和破坏性更改
- 自动合并: 只有 CI 通过 AND 安全审查通过
- 自动发布: 最新版本发布到 npm 下
@capacitor-plus/*
安全审查详情
标题:安全审查详情每次上游同步都会分析:
| 检查 | 它捕获了什么 |
|---|---|
| 安全 | 命令注入、XSS、路径遍历、硬编码密钥 |
| 更改 | 删除/重命名的 API、签名改变、配置更改 |
| 稳定性 | 空指针异常、未处理的异常、竞争条件、内存泄漏 |
| 数据安全 | 数据丢失场景、隐私泄露、不安全存储 |
| Code完整性 | 混淆的code、可疑的网络调用、后门 |
提交您的PR
标题:提交您的PR您的PR在官方Capacitor仓库中卡住了?在Capacitor+中获取它合并:
-
打开一个问题 在 Capacitor+ 仓库 链接到您的上游 PR
-
或直接提交 作为上游的
plusbranch -
团队将审查、运行 CI,并合并如果它通过
这样您和其他人可以立即从您的工作中受益,而不必等待上游发布周期
FAQ
题目:FAQ是否是生产就绪?
题目:是否是生产就绪?Yes. Capacitor+ is used in production apps. Every release passes the same test suite as official Capacitor, plus additional security analysis.
我的官方插件是否仍然有效?
标题:我的官方插件是否仍然有效?是。所有 @capacitor/* 插件都可以直接使用Capacitor+。
如果上游发布了破坏性更改?
标题:如果上游发布了破坏性更改?AI 安全审查会标记破坏性更改进行手动审查。您将在更改被合并之前看到这些更改的文档。
如何报告问题?
标题:如何报告问题?在 Capacitor+ GitHub中提交问题。对于影响官方Capacitor的同时的问题,我们将协调上游的帮助。
我可以贡献吗?
贡献当然!PR都欢迎。您可以直接提交修复或要求特定上游PR被合并。
继续Getting Started
继续如果您正在使用 Getting Started 来规划原生插件工作,连接它与 使用 Capacitor+ (@capacitor-plus) Packages 为原生能力在使用 Capacitor+ (@capacitor-plus) Packages Capgo 插件目录 为产品工作流程在 Capgo Plugin Directory Capacitor 插件由 Capgo 提供 了解 Capacitor 插件由 Capgo 的实现细节 添加或更新插件 了解添加或更新插件的实现细节 Ionic 企业插件替代方案 了解 Ionic 企业插件替代方案的产品工作流程