快速入门
复制包含安装步骤和该插件完整 Markdown 指南的配置 prompt。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-pretty-toast`
Run the required Capacitor sync/update step after installation.
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/pretty-toast/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 辅助设置来安装插件。使用以下命令将 Capgo skills 添加到你的 AI 工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下 prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-pretty-toast` plugin in my project.如果你更想手动设置,请运行以下命令安装插件,并按照下方各平台的说明操作:
npm install @capgo/capacitor-pretty-toastnpx cap sync导入
“导入”章节import { toast } from '@capgo/capacitor-pretty-toast';快速入门
章节标题为“快速入门”import { toast } from '@capgo/capacitor-pretty-toast';
toast.success('Saved', { message: 'Draft synced.' });常见坑点
章节标题为“常见陷阱”- 加载 ID:调用时保留 ID
toast.update(). - 防抖:快速错误应合并为一个 toast。
- 品牌定制:按平台调整图标和颜色。
显示 Toast 提示
“显示 Toast”章节toast.success('Saved', { message: 'Your changes are ready.',});更新 Loading Toast
“更新 Loading Toast”章节const id = toast.loading('Uploading', { message: 'Waiting for the server response.',});
setTimeout(() => { toast.update(id, { title: 'Upload complete', message: 'The file was stored successfully.', icon: 'checkmark.circle.fill', autoDismiss: true, });}, 1500);追踪 Promise
“追踪 Promise”章节await toast.promise(uploadFile(), { loading: { title: 'Uploading', message: 'Keep the app open while the file is sent.', }, success: 'Uploaded', error: 'Upload failed',});图标与图片
“图标与图片”章节使用 icon 可输入符号名称或原始 SVG 标记:
toast.info('New message', { icon: 'message.fill', message: 'Open the inbox to reply.',});使用 iconSource 用于 URI 类图像。它支持 https://, http://, file://, data:, blob:,绝对文件路径,或 { uri }.
toast.show({ title: 'Profile updated', message: 'Your avatar changed.', iconSource: 'https://example.com/avatar.png',});iconSource 优先于 icon.
从入门指南继续
“从入门指南继续”章节如果你正在使用 快速入门 要规划原生插件工作,请将其与 Capgo 插件目录 查看 Capgo 插件目录中的产品工作流, Capgo 提供的 Capacitor 插件 查看由 Capgo 提供的 Capacitor 插件中的实现细节, 添加或更新插件 查看添加或更新插件中的实现细节, Ionic Enterprise 插件替代方案 查看 Ionic Enterprise 插件替代方案中的产品工作流,以及 Capgo Native Build 查看 Capgo Native Builds 中的产品工作流。