{"_id":"@capacitor-ohos/action-sheet","_rev":"2-6959a9ae0c33ae47a6ef59c483d4c98e","name":"@capacitor-ohos/action-sheet","dist-tags":{"latest":"8.0.2"},"versions":{"8.0.1":{"name":"@capacitor-ohos/action-sheet","version":"8.0.1","keywords":["capacitor","plugin","native"],"author":{"url":"Group","name":"Huawei Device Co., Ltd and iSoftStone Information Technology"},"license":"MIT","_id":"@capacitor-ohos/action-sheet@8.0.1","maintainers":[{"name":"luqi_tan","email":"295099422@qq.com"}],"bugs":{"url":"https://gitcode.com/CPF-Ionic/capacitor-action-sheet/issues"},"dist":{"shasum":"88330bd895f1c7a0be7384e015a72d5028f128c1","tarball":"https://registry.npmjs.org/@capacitor-ohos/action-sheet/-/action-sheet-8.0.1.tgz","fileCount":10,"integrity":"sha512-yITHRZVeVT6EG511KUlhAXClPK5BuQFI82ONer4QJ+w6loMMLAcH3H5BJiYSzco8beysLpwBlUFW5CXPKAq47g==","signatures":[{"sig":"MEUCIQD1zsSS/QkHP8EpEdTS15uMriuC5SR1G/VZAmQhCicolwIgBp+MSLhZlGx90LW0f54q2a3Yv7cPPp47cTVQMsMuRaU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34039},"gitHead":"244fb5b3d8c9c785939ea098a6134df258abc81b","_npmUser":{"name":"luqi_tan","email":"295099422@qq.com"},"capacitor":{"id":"@capacitor/action-sheet","platforms":["openharmony"]},"repository":{"url":"gitcode:CPF-Ionic/capacitor-action-sheet","type":"git"},"_npmVersion":"10.5.1","description":"The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.","directories":{},"_nodeVersion":"22.0.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/action-sheet_8.0.1_1777543597381_0.09425223358265478","host":"s3://npm-registry-packages-npm-production"}},"8.0.2":{"name":"@capacitor-ohos/action-sheet","version":"8.0.2","description":"The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.","capacitor":{"id":"@capacitor/action-sheet","platforms":["openharmony"]},"repository":{"type":"git","url":"gitcode:CPF-Ionic/capacitor-action-sheet"},"bugs":{"url":"https://gitcode.com/CPF-Ionic/capacitor-action-sheet/issues"},"keywords":["capacitor","plugin","native"],"author":{"name":"Huawei Device Co., Ltd and iSoftStone Information Technology","url":"Group"},"license":"MIT","_id":"@capacitor-ohos/action-sheet@8.0.2","gitHead":"610c98e38bc4a7718f7350c42a3eff60a9492b22","_nodeVersion":"22.0.0","_npmVersion":"10.5.1","dist":{"integrity":"sha512-SuGOokoKTHnPwS2PwbaeoRStc5zb59A7w+wz3wCfq5ylpHTvO2lQbhUvjk/FeCQaU8gHXOs+zrYgJ3rSt7rPLA==","shasum":"e4ecb27196ca1b7c37d1fa1a7beefc941e42cffd","tarball":"https://registry.npmjs.org/@capacitor-ohos/action-sheet/-/action-sheet-8.0.2.tgz","fileCount":10,"unpackedSize":34063,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCQQyOic0jWW4wY9nDgfdP+8CgZ+DJzwxfZQQWWzhxycAIgY+UKYwD6o0yDMwsOeizKTba61U5PH3RFb1VatMXjLgw="}]},"_npmUser":{"name":"luqi_tan","email":"295099422@qq.com"},"directories":{},"maintainers":[{"name":"luqi_tan","email":"295099422@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/action-sheet_8.0.2_1784788805130_0.6103298566724065"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-30T10:06:37.229Z","modified":"2026-07-23T06:40:05.471Z","8.0.1":"2026-04-30T10:06:37.545Z","8.0.2":"2026-07-23T06:40:05.300Z"},"bugs":{"url":"https://gitcode.com/CPF-Ionic/capacitor-action-sheet/issues"},"author":{"name":"Huawei Device Co., Ltd and iSoftStone Information Technology","url":"Group"},"license":"MIT","keywords":["capacitor","plugin","native"],"repository":{"type":"git","url":"gitcode:CPF-Ionic/capacitor-action-sheet"},"description":"The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.","maintainers":[{"name":"luqi_tan","email":"295099422@qq.com"}],"readme":"# <center>@capacitor/action-sheet</center>\r\n[![zh-CN](https://img.shields.io/badge/lang-中文-blue.svg)](README.md)\r\n[![en](https://img.shields.io/badge/lang-English-blue.svg)](README.en.md)\r\n\r\n本项目基于 [@capacitor/action-sheet@8.0.0](https://www.npmjs.com/package/@capacitor/action-sheet) 开发。\r\n\r\n## 简介\r\n\r\n`@capacitor/action-sheet` 是 capacitor 生态系统中的核心插件，提供对原生操作表的访问，为跨平台应用开发提供设备差异化适配能力，兼容 capacitor 的 Android、iOS 等主流移动平台及浏览器环境，本文档主要说明在 OpenHarmony 系统中的使用。\r\n\r\n该插件允许调用原生的操作表组件，展示一系列操作选项供用户选择，常用于分享、更多操作等场景。\r\n\r\n## 支持平台\r\n\r\n- **OpenHarmony**：5.0+\r\n\r\n## 下载安装\r\n\r\n通过命令行或手动引入即可快速安装插件，支持从npm仓库获取。\r\n\r\n### 命令行安装（推荐）\r\n\r\n安装hionic CLI：\r\n\r\n```bash\r\nnpm install -g hionic\r\n```\r\n\r\n以下两种方式中**任选其一**即可，无需重复操作：\r\n\r\nnpm安装：\r\n\r\n```bash\r\n# 安装插件\r\nnpm install @capacitor/action-sheet\r\n\r\n# 同步插件\r\nhionic sync openharmony\r\n```\r\n\r\nhionic CLI安装：\r\n\r\n```bash\r\nhionic plugin add @capacitor/action-sheet\r\n```\r\n\r\n### 手动引入安装\r\n\r\n根据插件源码中 `plugin.xml` 配置在项目中引入插件：\r\n\r\n#### 1. 添加插件配置\r\n根据 `plugin.xml` 的 `config-json` 项，通过 `target` 字段找到 `entry` 模块中 `capacitor.plugins.json` 文件，并根据 `param` 标签添加配置如下：\r\n\r\n```json\r\n{\r\n    \"pkg\": \"@capacitor/action-sheet\",\r\n    \"classpath\": \"ActionSheet\"\r\n}\r\n```\r\n\r\n#### 2. 修改 CMake 配置\r\n根据 `plugin.xml` 的 `CMakeLists` 项，通过 `modules-name` 字段找到模块 capacitor，路径为 `target` 字段的 `CMakeLists.txt` 文件，并根据 `param` 标签添加 `add_subdirectory` 和 `target_link_libraries` 如下：\r\n\r\n```cmake\r\n#START_ADD_SUBDIRECTORY\r\n// ...\r\nadd_subdirectory(ActionSheet)\r\n// ...\r\n#END_ADD_SUBDIRECTORY\r\n\r\n// ...\r\n\r\ntarget_link_libraries(capacitor PUBLIC\r\n  \"-Wl,--whole-archive\"\r\n  // ...\r\n  ActionSheet\r\n  // ...\r\n  \"-Wl,--no-whole-archive\"\r\n)\r\n```\r\n\r\n#### 3. 复制源码文件\r\n根据 `plugin.xml` 的 `source-file` 项，根据 `src` 字段找到需要复制的文件，并根据 `modules-name` 字段和 `target-dir` 字段找到文件复制的具体模块和目录：\r\n\r\n将源码中 src/main/cpp/ActionSheet 目录下的 ActionSheet.cpp、ActionSheet.h、CMakeLists.txt 文件引入到 capacitor 模块中 src/main/cpp/ActionSheet 目录下。\r\n\r\n将源码中 src/main/ets/components/ActionSheet 目录下的 ActionSheet.ets 文件引入到 capacitor 模块中 src/main/ets/components/ActionSheet 目录下。\r\n\r\n#### 4. 添加 ArkTS 配置\r\n在 capacitor 模块的 `build-profile.json5` 文件中，`buildOption/arkOptions/runtimeOnly/sources` 配置项数组中加入步骤 3 中拷贝的 ets 文件路径：\r\n\r\n```json\r\n\"buildOption\": {\r\n   // ...\r\n    \"arkOptions\": {\r\n      \"runtimeOnly\": {\r\n        \"sources\": [\r\n         // ...\r\n             \"./src/main/ets/components/ActionSheet/ActionSheet.ets\"\r\n         // ...\r\n        ]\r\n      }\r\n    }\r\n}\r\n```\r\n\r\n## 卸载\r\n\r\n```bash\r\n# 卸载 action-sheet 插件\r\nhionic plugin remove @capacitor/action-sheet\r\n```\r\n\r\n## 约束与限制\r\n\r\n### 兼容性\r\n\r\n在以下版本中已测试通过：\r\n\r\n1. SDK: 5.0.5(17); IDE: DevEco Studio: 6.0.0; ROM: 5.1.0.150;\r\n\r\n## 使用示例\r\n\r\n### 基础示例：显示 action sheet\r\n\r\n```javascript\r\nimport { ActionSheet, ActionSheetButtonStyle } from '@capacitor/action-sheet';\r\n\r\nconst showActions = async () => {\r\n  const result = await ActionSheet.showActions({\r\n    title: 'Photo Options',\r\n    message: 'Select an option to perform',\r\n    options: [\r\n      {\r\n        title: 'Upload',\r\n      },\r\n      {\r\n        title: 'Share',\r\n      },\r\n      {\r\n        title: 'Remove',\r\n        style: ActionSheetButtonStyle.Destructive,\r\n      },\r\n    ],\r\n  });\r\n\r\n  console.log('Action Sheet result:', result);\r\n};\r\n```\r\n\r\n## 使用说明\r\n\r\n### 接口方法\r\n\r\n| 方法名 | 返回类型 | 描述 |\r\n| ---- | ---- | ---- |\r\n| showActions(options: [ShowActionsOptions](#showactionsoptions)) | Promise&lt;[ShowActionsResult](#showactionsresult)&gt; | 显示一个操作表样式的模态框，其中包含各种选项供用户选择 |\r\n\r\n### 数据结构\r\n\r\n#### ShowActionsResult\r\n\r\n操作表选择结果：\r\n\r\n| 属性名      | 类型   | 描述                       |\r\n| ----------- | ------ | -------------------------- |\r\n| **`index`** | number | 点击选项的索引（从零开始） |\r\n\r\n#### ShowActionsOptions\r\n\r\n操作表配置选项：\r\n\r\n| 属性名        | 类型                   | 描述                 | 备注       |\r\n| ------------- | ---------------------- | -------------------- | ---------- |\r\n| **`title`**   | string              | 操作表的标题。       |            |\r\n| **`message`** | string              | 标题下方显示的消息。 | 仅支持 iOS |\r\n| **`options`** | [ActionSheetButton[]](#actionsheetbutton) | 用户可选择的选项。   |            |\r\n\r\n#### ActionSheetButton\r\n\r\n操作表按钮选项：\r\n\r\n| 属性名      | 类型                   | 描述                       | 备注              |\r\n| ----------- | ---------------------- | -------------------------- | ----------------- |\r\n| **`title`** | string               | 选项的标题                 |                   |\r\n| **`style`** | [ActionSheetButtonStyle](#actionsheetbuttonstyle) | 该选项的样式。             | 仅在 iOS 上受支持 |\r\n| **`icon`**  | string               | 选项图标（图标命名规则）。 | 仅在 Web 上受支持 |\r\n\r\n#### ActionSheetButtonStyle\r\n\r\n按钮样式枚举：\r\n\r\n| 成员              | 值              | 描述                        | 备注              |\r\n| ----------------- | --------------- | --------------------------- | ----------------- |\r\n| **`Default`**     | `'DEFAULT'`     | 选项的默认样式              | 仅在 iOS 上受支持 |\r\n| **`Destructive`** | `'DESTRUCTIVE'` | 用于破坏性选项的样式         | 仅在 iOS 上受支持 |\r\n| **`Cancel`**      | `'CANCEL'`      | 用于取消操作表的选项的样式     | 仅在 iOS 上受支持 |\r\n\r\n## 目录结构\r\n\r\n```\r\n|---- 项目根目录\r\n|     |---- src\r\n|           |---- main\r\n|                 |---- cpp\r\n|                       |---- ActionSheet   # 插件核心 C++ 实现\r\n|                             |---- ActionSheet.cpp\r\n|                             |---- ActionSheet.h\r\n|                             |---- CMakeLists.txt\r\n|                 |---- ets\r\n|                       |---- components\r\n|                             |---- ActionSheet   # ArkTS 组件实现\r\n|                                   |---- ActionSheet.ets\r\n|     |---- README.md                # 说明文档\r\n|     |---- package.json             # npm 配置文件\r\n|     |---- plugin.xml              # capacitor 插件配置\r\n|     |---- LICENSE                 # 许可证文件\r\n```\r\n\r\n## 贡献代码\r\n\r\n使用过程中发现任何问题都可以提 [Issue](https://gitcode.com/CPF-Ionic/capacitor-action-sheet/issues)，当然，也非常欢迎发 [PR](https://gitcode.com/CPF-Ionic/capacitor-action-sheet/pulls) 共建。\r\n\r\n## 许可证\r\n\r\n本插件基于 **MIT License** 开源，详见 [LICENSE](./LICENSE) 文件。\r\n","readmeFilename":"README.md"}