@h-ai/cli 0.1.0-alpha.54 → 0.1.0-alpha.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +7 -7
- package/templates/base/package.json.hbs +1 -1
- package/templates/skills/AGENTS.md +8 -22
- package/templates/skills/CLAUDE.md +3 -16
- package/templates/skills/bridges/admin/AGENTS.md +3 -16
- package/templates/skills/bridges/admin/CLAUDE.md +3 -11
- package/templates/skills/bridges/admin/copilot-instructions.md +2 -39
- package/templates/skills/bridges/api/AGENTS.md +5 -18
- package/templates/skills/bridges/api/CLAUDE.md +3 -11
- package/templates/skills/bridges/api/copilot-instructions.md +3 -38
- package/templates/skills/bridges/fullstack/AGENTS.md.hbs +24 -59
- package/templates/skills/bridges/fullstack/CLAUDE.md.hbs +1 -15
- package/templates/skills/bridges/fullstack/copilot-instructions.md.hbs +5 -45
- package/templates/skills/bridges/h5/AGENTS.md +4 -17
- package/templates/skills/bridges/h5/CLAUDE.md +3 -11
- package/templates/skills/bridges/h5/copilot-instructions.md +2 -37
- package/templates/skills/bridges/mobile-app/AGENTS.md +5 -18
- package/templates/skills/bridges/mobile-app/CLAUDE.md +3 -11
- package/templates/skills/bridges/mobile-app/copilot-instructions.md +2 -38
- package/templates/skills/bridges/website/AGENTS.md +4 -17
- package/templates/skills/bridges/website/CLAUDE.md +3 -11
- package/templates/skills/bridges/website/copilot-instructions.md +2 -37
- package/templates/skills/copilot-instructions.md +2 -36
- package/templates/skills/hai-ai/SKILL.md +35 -389
- package/templates/skills/hai-ai/guide.md +383 -0
- package/templates/skills/hai-ai/reference.md +1 -1
- package/templates/skills/hai-api-client/SKILL.md +6 -6
- package/templates/skills/hai-api-contract/SKILL.md +10 -25
- package/templates/skills/hai-app-create/SKILL.md +29 -388
- package/templates/skills/hai-app-create/reference.md +350 -0
- package/templates/skills/hai-app-review/SKILL.md +9 -23
- package/templates/skills/hai-app-tests/SKILL.md +29 -494
- package/templates/skills/hai-app-tests/reference.md +442 -0
- package/templates/skills/hai-audit/SKILL.md +6 -6
- package/templates/skills/hai-build/SKILL.md +19 -338
- package/templates/skills/hai-build/reference.md +326 -0
- package/templates/skills/hai-cache/SKILL.md +27 -32
- package/templates/skills/hai-capacitor/SKILL.md +19 -366
- package/templates/skills/hai-capacitor/reference.md +352 -0
- package/templates/skills/hai-ci/SKILL.md +6 -21
- package/templates/skills/hai-core/SKILL.md +25 -566
- package/templates/skills/hai-core/reference.md +533 -0
- package/templates/skills/hai-crypto/SKILL.md +6 -20
- package/templates/skills/hai-datapipe/SKILL.md +9 -23
- package/templates/skills/hai-deploy/SKILL.md +6 -24
- package/templates/skills/hai-framework-sync/SKILL.md +8 -20
- package/templates/skills/hai-iam/SKILL.md +27 -371
- package/templates/skills/hai-iam/reference.md +343 -0
- package/templates/skills/hai-kit/SKILL.md +6 -6
- package/templates/skills/hai-payment/SKILL.md +6 -26
- package/templates/skills/hai-pr-review/SKILL.md +6 -22
- package/templates/skills/hai-reach/SKILL.md +19 -317
- package/templates/skills/hai-reach/reference.md +303 -0
- package/templates/skills/hai-reldb/SKILL.md +19 -472
- package/templates/skills/hai-reldb/reference.md +452 -0
- package/templates/skills/hai-scheduler/SKILL.md +6 -6
- package/templates/skills/hai-serv/SKILL.md +27 -759
- package/templates/skills/hai-serv/reference.md +736 -0
- package/templates/skills/hai-storage/SKILL.md +7 -25
- package/templates/skills/hai-ui/SKILL.md +29 -625
- package/templates/skills/hai-ui/reference.md +598 -0
- package/templates/skills/hai-vecdb/SKILL.md +18 -303
- package/templates/skills/hai-vecdb/reference.md +291 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: hai-capacitor
|
|
3
|
-
description: 使用 @h-ai/capacitor
|
|
3
|
+
description: "使用 @h-ai/capacitor 接入原生设备、相机、推送、状态栏和安全 Token 存储。"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# hai-capacitor
|
|
@@ -9,373 +9,26 @@ description: 使用 @h-ai/capacitor 桥接 Capacitor 原生能力(Token 安全
|
|
|
9
9
|
|
|
10
10
|
| 项目 | 契约 |
|
|
11
11
|
| --- | --- |
|
|
12
|
-
| 能力 | 使用 @h-ai/capacitor
|
|
13
|
-
| 适用场景 |
|
|
14
|
-
| 输入 |
|
|
15
|
-
| 输出 |
|
|
16
|
-
| 限制 |
|
|
12
|
+
| 能力 | 使用 @h-ai/capacitor 接入原生设备、相机、推送、状态栏和安全 Token 存储 |
|
|
13
|
+
| 适用场景 | Android/iOS 原生壳集成与平台差异处理 |
|
|
14
|
+
| 输入 | Capacitor 配置、原生插件、设备权限和平台状态 |
|
|
15
|
+
| 输出 | 原生操作结果及 TokenStorage 适配器 |
|
|
16
|
+
| 限制 | 区分浏览器与 Android/iOS;安全存储需原生插件,Web 不降级到 localStorage。H5 验证不能代替真机验证。 |
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
## 使用路径
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## 运行环境
|
|
23
|
-
|
|
24
|
-
> **浏览器端 / 原生 App 专用。** 在 Capacitor 原生环境(Android/iOS)中提供完整能力;`createCapacitorTokenStorage()` 仅在原生环境持久化 token,纯 Web 不做不安全回退。`capacitor.preferences` 仍可用于普通偏好数据。
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 适用场景
|
|
29
|
-
|
|
30
|
-
- Android/iOS 原生应用开发(Svelte 5 + Vite + Capacitor)
|
|
31
|
-
- Token 安全存储(`@aparajita/capacitor-secure-storage`)
|
|
32
|
-
- 设备信息获取(平台、型号、版本)
|
|
33
|
-
- 推送通知注册与监听(FCM / APNs)
|
|
34
|
-
- 原生相机拍照 / 相册选取
|
|
35
|
-
- 状态栏配置(沉浸式、颜色、样式)
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## 使用步骤
|
|
40
|
-
|
|
41
|
-
### 1. 初始化与关闭
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
45
|
-
|
|
46
|
-
// 应用启动时初始化(检测 Capacitor 环境可用性)
|
|
47
|
-
const result = await capacitor.init()
|
|
48
|
-
if (!result.success) {
|
|
49
|
-
// result.error.code === HaiCapacitorError.NOT_AVAILABLE.code
|
|
50
|
-
// 非 Capacitor 环境(纯 Web)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// 检查状态
|
|
54
|
-
capacitor.isInitialized // boolean
|
|
55
|
-
capacitor.getPlatform() // 'android' | 'ios' | 'web'
|
|
56
|
-
capacitor.isNative() // true = 原生 App
|
|
57
|
-
|
|
58
|
-
// 关闭模块(重置状态)
|
|
59
|
-
await capacitor.close()
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 2. Token 安全存储(与 api-client 配合)
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import { apiClient } from '@h-ai/api-client'
|
|
66
|
-
import { createCapacitorTokenStorage } from '@h-ai/capacitor'
|
|
67
|
-
|
|
68
|
-
await apiClient.init({
|
|
69
|
-
baseUrl: import.meta.env.PUBLIC_API_BASE,
|
|
70
|
-
auth: {
|
|
71
|
-
storage: createCapacitorTokenStorage(),
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
`createCapacitorTokenStorage()` 返回 `TokenStorage` 实例(兼容 `@h-ai/api-client`),底层使用 `@aparajita/capacitor-secure-storage`:
|
|
77
|
-
|
|
78
|
-
- Android → Android KeyStore + 加密 SharedPreferences
|
|
79
|
-
- iOS → Keychain
|
|
80
|
-
- Web → **不回退到 localStorage**;`get*()` 返回 `null`,`set*()` / `clear()` 为 no-op
|
|
81
|
-
|
|
82
|
-
所有方法内置 try-catch;原生安全存储异常时 get 返回 `null`、set/clear 静默失败并记录日志。
|
|
83
|
-
|
|
84
|
-
#### Preferences 子操作
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
88
|
-
|
|
89
|
-
// 返回 HaiResult<string | null>
|
|
90
|
-
const result = await capacitor.preferences.get('my_key')
|
|
91
|
-
if (result.success) {
|
|
92
|
-
// result.data — 值或 null
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
await capacitor.preferences.set('my_key', 'value')
|
|
96
|
-
await capacitor.preferences.remove('my_key')
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### 3. 设备信息
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
103
|
-
|
|
104
|
-
const info = await capacitor.device.getInfo()
|
|
105
|
-
if (info.success) {
|
|
106
|
-
info.data.platform // 'android' | 'ios' | 'web'
|
|
107
|
-
info.data.model // 'Pixel 7'
|
|
108
|
-
info.data.osVersion // '14'
|
|
109
|
-
info.data.manufacturer // 'Google'
|
|
110
|
-
info.data.isVirtual // false
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const version = await capacitor.device.getAppVersion()
|
|
114
|
-
if (version.success) {
|
|
115
|
-
version.data.version // '1.0.0'
|
|
116
|
-
version.data.build // '42'
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### 4. 推送通知
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
124
|
-
|
|
125
|
-
// 注册推送(请求权限 + 获取设备 Token)
|
|
126
|
-
const reg = await capacitor.push.register()
|
|
127
|
-
if (reg.success) {
|
|
128
|
-
// 将 reg.data.token 上报给后端
|
|
129
|
-
await api.post('/push/register', { token: reg.data.token })
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// 监听推送事件(返回 HaiResult 包裹的 async 清理函数)
|
|
133
|
-
const listenResult = await capacitor.push.listen({
|
|
134
|
-
onReceived: (notification) => {
|
|
135
|
-
// 前台收到推送
|
|
136
|
-
// notification: { id, title?, body?, data? }
|
|
137
|
-
},
|
|
138
|
-
onActionPerformed: (notification) => {
|
|
139
|
-
// 用户点击推送
|
|
140
|
-
},
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
// 停止监听
|
|
144
|
-
if (listenResult.success) {
|
|
145
|
-
await listenResult.data()
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### 5. 相机
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
153
|
-
|
|
154
|
-
const photo = await capacitor.camera.takePhoto({
|
|
155
|
-
quality: 80, // 0-100
|
|
156
|
-
source: 'camera', // 'camera' | 'photos' | 'prompt'
|
|
157
|
-
resultType: 'base64', // 'uri' | 'base64' | 'dataUrl'
|
|
158
|
-
width: 800, // 最大宽度(可选)
|
|
159
|
-
height: 600, // 最大高度(可选)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
if (photo.success) {
|
|
163
|
-
const imgSrc = `data:image/${photo.data.format};base64,${photo.data.data}`
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### 6. 状态栏
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
171
|
-
|
|
172
|
-
await capacitor.statusBar.configure({
|
|
173
|
-
backgroundColor: '#ffffff',
|
|
174
|
-
style: 'dark', // 'dark' | 'light' | 'default'(文字颜色)
|
|
175
|
-
overlay: true, // 沉浸式
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
await capacitor.statusBar.hide()
|
|
179
|
-
await capacitor.statusBar.show()
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## 核心 API
|
|
185
|
-
|
|
186
|
-
| API | 用途 | 返回值 |
|
|
187
|
-
| --- | --- | --- |
|
|
188
|
-
| `capacitor.init()` | 初始化模块(检测环境) | `HaiResult<void>` |
|
|
189
|
-
| `capacitor.close()` | 关闭模块,重置状态 | `Promise<void>` |
|
|
190
|
-
| `capacitor.getPlatform()` | 获取当前平台 | `'android' \| 'ios' \| 'web'` |
|
|
191
|
-
| `capacitor.isNative()` | 是否为原生环境 | `boolean` |
|
|
192
|
-
| `capacitor.isInitialized` | 是否已初始化 | `boolean` |
|
|
193
|
-
| `createCapacitorTokenStorage()` | 创建 Token 存储 | `TokenStorage`(兼容 api-client) |
|
|
194
|
-
| `capacitor.preferences.get(key)` | 安全读取 Preference | `HaiResult<string \| null>` |
|
|
195
|
-
| `capacitor.preferences.set(key, value)` | 安全写入 Preference | `HaiResult<void>` |
|
|
196
|
-
| `capacitor.preferences.remove(key)` | 安全删除 Preference | `HaiResult<void>` |
|
|
197
|
-
| `capacitor.device.getInfo()` | 设备信息 | `HaiResult<DeviceInfo>` |
|
|
198
|
-
| `capacitor.device.getAppVersion()` | 应用版本 | `HaiResult<{ version, build }>` |
|
|
199
|
-
| `capacitor.push.register()` | 注册推送 | `HaiResult<PushRegistration>` |
|
|
200
|
-
| `capacitor.push.listen(callbacks)` | 监听推送事件 | `HaiResult<() => Promise<void>>`(async 清理函数) |
|
|
201
|
-
| `capacitor.camera.takePhoto(options?)` | 拍照 / 选取图片 | `HaiResult<PhotoResult>` |
|
|
202
|
-
| `capacitor.statusBar.configure(config)` | 配置状态栏 | `HaiResult<void>` |
|
|
203
|
-
| `capacitor.statusBar.show()` | 显示状态栏 | `HaiResult<void>` |
|
|
204
|
-
| `capacitor.statusBar.hide()` | 隐藏状态栏 | `HaiResult<void>` |
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## 错误码 — `HaiCapacitorError`
|
|
209
|
-
|
|
210
|
-
| 错误码 | code | 说明 |
|
|
211
|
-
| -------------------------------------------- | ---------------------- | -------------------- |
|
|
212
|
-
| `HaiCapacitorError.INIT_FAILED` | `hai:capacitor:001` | 初始化失败 |
|
|
213
|
-
| `HaiCapacitorError.NOT_AVAILABLE` | `hai:capacitor:002` | Capacitor 不可用 |
|
|
214
|
-
| `HaiCapacitorError.INIT_IN_PROGRESS` | `hai:capacitor:003` | 正在初始化中 |
|
|
215
|
-
| `HaiCapacitorError.NOT_INITIALIZED` | `hai:capacitor:010` | 模块未初始化 |
|
|
216
|
-
| `HaiCapacitorError.PREFERENCES_GET_FAILED` | `hai:capacitor:011` | Preferences 读取失败 |
|
|
217
|
-
| `HaiCapacitorError.PREFERENCES_SET_FAILED` | `hai:capacitor:012` | Preferences 写入失败 |
|
|
218
|
-
| `HaiCapacitorError.PREFERENCES_REMOVE_FAILED`| `hai:capacitor:013` | Preferences 删除失败 |
|
|
219
|
-
| `HaiCapacitorError.DEVICE_INFO_FAILED` | `hai:capacitor:020` | 获取设备信息失败 |
|
|
220
|
-
| `HaiCapacitorError.APP_VERSION_FAILED` | `hai:capacitor:021` | 获取应用版本失败 |
|
|
221
|
-
| `HaiCapacitorError.PUSH_REGISTER_FAILED` | `hai:capacitor:030` | 推送注册失败 |
|
|
222
|
-
| `HaiCapacitorError.PUSH_LISTEN_FAILED` | `hai:capacitor:031` | 推送监听失败 |
|
|
223
|
-
| `HaiCapacitorError.CAMERA_FAILED` | `hai:capacitor:040` | 拍照/相册失败 |
|
|
224
|
-
| `HaiCapacitorError.STATUS_BAR_FAILED` | `hai:capacitor:050` | 状态栏配置失败 |
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## 常见模式
|
|
229
|
-
|
|
230
|
-
### Mobile App 标准初始化
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
233
|
-
// src/lib/capacitor.ts
|
|
234
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
235
|
-
|
|
236
|
-
export async function initCapacitor() {
|
|
237
|
-
const result = await capacitor.init()
|
|
238
|
-
if (!result.success) {
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (capacitor.isNative()) {
|
|
243
|
-
await capacitor.statusBar.configure({
|
|
244
|
-
backgroundColor: '#ffffff',
|
|
245
|
-
style: 'light',
|
|
246
|
-
overlay: false,
|
|
247
|
-
})
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
```svelte
|
|
253
|
-
<!-- src/App.svelte -->
|
|
254
|
-
<script lang='ts'>
|
|
255
|
-
import { onMount } from 'svelte'
|
|
256
|
-
import { initCapacitor } from './lib/capacitor'
|
|
257
|
-
|
|
258
|
-
onMount(() => { initCapacitor() })
|
|
259
|
-
</script>
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### SPA 模式配置(必需)
|
|
263
|
-
|
|
264
|
-
Capacitor 应用使用 Vite 构建 SPA,并让原生壳读取 `dist`:
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
// capacitor.config.ts
|
|
268
|
-
import type { CapacitorConfig } from '@capacitor/cli'
|
|
269
|
-
|
|
270
|
-
const config: CapacitorConfig = {
|
|
271
|
-
appId: 'com.example.app',
|
|
272
|
-
appName: 'Example App',
|
|
273
|
-
webDir: 'dist',
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export default config
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### Token 存储 + 认证流程
|
|
280
|
-
|
|
281
|
-
```typescript
|
|
282
|
-
// src/lib/api.ts
|
|
283
|
-
import { apiClient } from '@h-ai/api-client'
|
|
284
|
-
import { createCapacitorTokenStorage } from '@h-ai/capacitor'
|
|
285
|
-
|
|
286
|
-
export async function initApi() {
|
|
287
|
-
return apiClient.init({
|
|
288
|
-
baseUrl: `${import.meta.env.PUBLIC_API_BASE}/api/v1`,
|
|
289
|
-
auth: {
|
|
290
|
-
storage: createCapacitorTokenStorage(),
|
|
291
|
-
},
|
|
292
|
-
})
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export { apiClient }
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
### 推送通知完整流程
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
302
|
-
|
|
303
|
-
export async function setupPush() {
|
|
304
|
-
if (!capacitor.isNative()) {
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const reg = await capacitor.push.register()
|
|
309
|
-
if (!reg.success) {
|
|
310
|
-
return
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// 上报 Token 给后端
|
|
314
|
-
await api.post('/push/register', {
|
|
315
|
-
token: reg.data.token,
|
|
316
|
-
platform: capacitor.getPlatform(),
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
// 监听推送
|
|
320
|
-
const listenResult = await capacitor.push.listen({
|
|
321
|
-
onReceived: (n) => {
|
|
322
|
-
// 前台通知处理
|
|
323
|
-
},
|
|
324
|
-
onActionPerformed: (n) => {
|
|
325
|
-
// 用户点击跳转
|
|
326
|
-
},
|
|
327
|
-
})
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### 拍照上传
|
|
332
|
-
|
|
333
|
-
```typescript
|
|
334
|
-
import { capacitor } from '@h-ai/capacitor'
|
|
335
|
-
|
|
336
|
-
async function captureAndUpload() {
|
|
337
|
-
const photo = await capacitor.camera.takePhoto({
|
|
338
|
-
source: 'camera',
|
|
339
|
-
resultType: 'base64',
|
|
340
|
-
quality: 80,
|
|
341
|
-
width: 1024,
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
if (!photo.success) {
|
|
345
|
-
return
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// 上传 base64 给后端
|
|
349
|
-
await api.post('/files/upload', {
|
|
350
|
-
data: photo.data.data,
|
|
351
|
-
format: photo.data.format,
|
|
352
|
-
})
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
---
|
|
357
|
-
|
|
358
|
-
## 插件依赖
|
|
359
|
-
|
|
360
|
-
| 插件 | 类型 | 用于 |
|
|
361
|
-
| --- | --- | --- |
|
|
362
|
-
| `@capacitor/core` | peerDependency(必需) | 核心运行时 |
|
|
363
|
-
| `@aparajita/capacitor-secure-storage` | 可选 peerDependency(原生 token 存储必需) | `createCapacitorTokenStorage()` |
|
|
364
|
-
| `@capacitor/preferences` | peerDependency(必需) | `capacitor.preferences.*` 普通偏好数据 |
|
|
365
|
-
| `@capacitor/device` | 可选 | `getDeviceInfo()` |
|
|
366
|
-
| `@capacitor/app` | 可选 | `getAppVersion()` |
|
|
367
|
-
| `@capacitor/push-notifications` | 可选 | `registerPush()` / `listenPush()` |
|
|
368
|
-
| `@capacitor/camera` | 可选 | `takePhoto()` |
|
|
369
|
-
| `@capacitor/status-bar` | 可选 | `configureStatusBar()` / `show/hide` |
|
|
370
|
-
|
|
371
|
-
可选插件未安装时,对应 API 调用会返回 `err`(动态 import 失败被 catch)。
|
|
372
|
-
|
|
373
|
-
---
|
|
20
|
+
- 先判断平台和插件可用性,复用已有 SPA 入口;原生 UI 变化验证权限拒绝、取消和返回路径。
|
|
21
|
+
- TokenStorage 在原生端使用安全插件;Web 下不伪造持久化成功。
|
|
374
22
|
|
|
375
|
-
##
|
|
23
|
+
## 按需参考
|
|
376
24
|
|
|
377
|
-
|
|
378
|
-
- `hai-iam`:认证流程(登录获取 Token → 存储到 Capacitor)
|
|
379
|
-
- `hai-ui`:移动端 UI 组件(SafeArea、BottomNav 等)
|
|
25
|
+
详细配置、API 签名、错误码和范本在 [reference.md](reference.md)。按下列标题定位所需小节,不默认通读;用例中的业务变量需结合当前应用补齐。
|
|
380
26
|
|
|
381
|
-
|
|
27
|
+
- 运行环境
|
|
28
|
+
- 适用场景
|
|
29
|
+
- 使用步骤
|
|
30
|
+
- 核心 API
|
|
31
|
+
- 错误码 — `HaiCapacitorError`
|
|
32
|
+
- 常见模式
|
|
33
|
+
- 插件依赖
|
|
34
|
+
- 相关 Skills
|