@doubao-apps/create 0.0.25 → 0.0.27
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/dist/36.js +4 -4
- package/dist/template-empty/.ai/examples/common-patterns.md +53 -43
- package/dist/template-empty/.ai/examples/component-basics.md +0 -17
- package/dist/template-empty/.ai/guides/component-development.md +96 -214
- package/dist/template-empty/.ai/guides/system-prompt.md +14 -14
- package/dist/template-empty/.ai/reference/framework-api-quick-ref.md +46 -85
- package/dist/template-empty/.ai/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +699 -0
- package/dist/template-empty/.ai/reference/open-api/02-/345/255/230/345/202/250.md +409 -0
- package/dist/template-empty/.ai/reference/open-api/03-/350/267/257/347/224/261.md +165 -0
- package/dist/template-empty/.ai/reference/open-api/04-/347/225/214/351/235/242-/344/272/244/344/272/222.md +432 -0
- package/dist/template-empty/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
- package/dist/template-empty/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
- package/dist/template-empty/.ai/reference/open-api/07-/345/252/222/344/275/223.md +346 -0
- package/dist/template-empty/.ai/reference/open-api/08-/345/274/200/346/224/276/350/203/275/345/212/233-/344/270/232/345/212/241/350/203/275/345/212/233.md +546 -0
- package/dist/template-empty/.ai/reference/open-api/09-/350/256/276/345/244/207-/350/223/235/347/211/231.md +961 -0
- package/dist/template-empty/.ai/reference/open-api/10-/350/256/276/345/244/207-wi-fi.md +277 -0
- package/dist/template-empty/.ai/reference/open-api/11-/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md +104 -0
- package/dist/template-empty/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
- package/dist/template-empty/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
- package/dist/template-empty/.ai/reference/open-api/14-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +70 -0
- package/dist/template-empty/.ai/reference/open-api/15-/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md +104 -0
- package/dist/template-empty/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
- package/dist/template-empty/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
- package/dist/template-empty/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
- package/dist/template-empty/.ai/reference/open-api/19-/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md +43 -0
- package/dist/template-empty/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
- package/dist/template-empty/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
- package/dist/template-empty/.ai/reference/open-api/22-/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md +70 -0
- package/dist/template-empty/.ai/reference/open-api/23-/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md +270 -0
- package/dist/template-empty/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
- package/dist/template-empty/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
- package/dist/template-empty/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
- package/dist/template-empty/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
- package/dist/template-empty/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
- package/dist/template-empty/.ai/reference/open-api/README.md +36 -0
- package/dist/template-empty/.ai/reference/open-api.md +1758 -266
- package/dist/template-empty/.ai/rules/dos-and-donts.md +50 -37
- package/dist/template-empty/AGENTS.md +56 -33
- package/dist/template-empty/README.md +57 -10
- package/dist/template-empty/package.json +2 -2
- package/dist/template-empty/src/app.config.ts +6 -0
- package/dist/template-empty/src/app.ts +0 -6
- package/dist/template-empty/tsconfig.json +2 -0
- package/dist/template-starter/.ai/examples/common-patterns.md +53 -43
- package/dist/template-starter/.ai/examples/component-basics.md +0 -17
- package/dist/template-starter/.ai/guides/component-development.md +96 -214
- package/dist/template-starter/.ai/guides/system-prompt.md +14 -14
- package/dist/template-starter/.ai/reference/framework-api-quick-ref.md +46 -85
- package/dist/template-starter/.ai/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +699 -0
- package/dist/template-starter/.ai/reference/open-api/02-/345/255/230/345/202/250.md +409 -0
- package/dist/template-starter/.ai/reference/open-api/03-/350/267/257/347/224/261.md +165 -0
- package/dist/template-starter/.ai/reference/open-api/04-/347/225/214/351/235/242-/344/272/244/344/272/222.md +432 -0
- package/dist/template-starter/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
- package/dist/template-starter/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
- package/dist/template-starter/.ai/reference/open-api/07-/345/252/222/344/275/223.md +346 -0
- package/dist/template-starter/.ai/reference/open-api/08-/345/274/200/346/224/276/350/203/275/345/212/233-/344/270/232/345/212/241/350/203/275/345/212/233.md +546 -0
- package/dist/template-starter/.ai/reference/open-api/09-/350/256/276/345/244/207-/350/223/235/347/211/231.md +961 -0
- package/dist/template-starter/.ai/reference/open-api/10-/350/256/276/345/244/207-wi-fi.md +277 -0
- package/dist/template-starter/.ai/reference/open-api/11-/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md +104 -0
- package/dist/template-starter/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
- package/dist/template-starter/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
- package/dist/template-starter/.ai/reference/open-api/14-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +70 -0
- package/dist/template-starter/.ai/reference/open-api/15-/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md +104 -0
- package/dist/template-starter/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
- package/dist/template-starter/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
- package/dist/template-starter/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
- package/dist/template-starter/.ai/reference/open-api/19-/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md +43 -0
- package/dist/template-starter/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
- package/dist/template-starter/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
- package/dist/template-starter/.ai/reference/open-api/22-/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md +70 -0
- package/dist/template-starter/.ai/reference/open-api/23-/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md +270 -0
- package/dist/template-starter/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
- package/dist/template-starter/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
- package/dist/template-starter/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
- package/dist/template-starter/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
- package/dist/template-starter/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
- package/dist/template-starter/.ai/reference/open-api/README.md +36 -0
- package/dist/template-starter/.ai/reference/open-api.md +1758 -266
- package/dist/template-starter/.ai/rules/dos-and-donts.md +50 -37
- package/dist/template-starter/AGENTS.md +56 -33
- package/dist/template-starter/README.md +6 -1
- package/dist/template-starter/package.json +2 -2
- package/dist/template-starter/src/app.config.ts +35 -0
- package/dist/template-starter/src/app.ts +0 -6
- package/dist/template-starter/src/pages/applet/index.tsx +0 -5
- package/dist/template-starter/src/pages/home/index.tsx +0 -5
- package/dist/template-starter/src/pages/lynx/index.tsx +0 -4
- package/dist/template-starter/src/pages/react-lynx/index.tsx +0 -5
- package/dist/template-starter/src/widgets/weather-card/index.tsx +0 -4
- package/dist/template-starter/tsconfig.json +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
# Open API: 存储
|
|
2
|
+
|
|
3
|
+
本地缓存;带 Sync 后缀的是同步 API。
|
|
4
|
+
|
|
5
|
+
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [setStorage](#setstorage) | 将数据写入本地缓存。 |
|
|
12
|
+
| [setStorageSync](#setstoragesync) | 将数据写入本地缓存。<br><br>同步 API。 |
|
|
13
|
+
| [getStorage](#getstorage) | 从本地缓存读取数据。 |
|
|
14
|
+
| [getStorageSync](#getstoragesync) | 从本地缓存同步读取数据。<br><br>同步 API。 |
|
|
15
|
+
| [removeStorage](#removestorage) | 删除本地缓存中指定 key 的数据。 |
|
|
16
|
+
| [removeStorageSync](#removestoragesync) | 删除本地缓存中指定 key 的数据。<br><br>同步 API。 |
|
|
17
|
+
| [clearStorage](#clearstorage) | 清空本地缓存。 |
|
|
18
|
+
| [clearStorageSync](#clearstoragesync) | 清空本地缓存。<br><br>同步 API。 |
|
|
19
|
+
| [getStorageInfo](#getstorageinfo) | 获取本地缓存信息。 |
|
|
20
|
+
| [getStorageInfoSync](#getstorageinfosync) | 同步获取本地缓存信息。<br><br>同步 API。 |
|
|
21
|
+
|
|
22
|
+
## API 详情
|
|
23
|
+
|
|
24
|
+
<a id="setstorage"></a>
|
|
25
|
+
### setStorage()
|
|
26
|
+
|
|
27
|
+
> **setStorage**\<`TData`\>(`params`): `Promise`\<`object`\>
|
|
28
|
+
|
|
29
|
+
将数据写入本地缓存。
|
|
30
|
+
|
|
31
|
+
#### Type parameters
|
|
32
|
+
|
|
33
|
+
• **TData** = `unknown`
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
• **params**: [`SetStorageParams`](#setstorageparamstdata)\<`TData`\>
|
|
38
|
+
|
|
39
|
+
存储参数,字段见 [SetStorageParams](#setstorageparamstdata)。
|
|
40
|
+
|
|
41
|
+
#### Returns
|
|
42
|
+
|
|
43
|
+
`Promise`\<`object`\>
|
|
44
|
+
|
|
45
|
+
返回一个 Promise,写入完成后 resolve。
|
|
46
|
+
|
|
47
|
+
#### Remarks
|
|
48
|
+
|
|
49
|
+
#### Example
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { setStorage } from '@doubao-apps/framework/api';
|
|
53
|
+
|
|
54
|
+
await setStorage({
|
|
55
|
+
key: 'profile',
|
|
56
|
+
data: { name: 'Tom', age: 18 },
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
<a id="setstoragesync"></a>
|
|
61
|
+
### setStorageSync()
|
|
62
|
+
|
|
63
|
+
> **setStorageSync**\<`TData`\>(`params`): `object`
|
|
64
|
+
|
|
65
|
+
将数据写入本地缓存。
|
|
66
|
+
|
|
67
|
+
#### Type parameters
|
|
68
|
+
|
|
69
|
+
• **TData** = `unknown`
|
|
70
|
+
|
|
71
|
+
#### Parameters
|
|
72
|
+
|
|
73
|
+
• **params**: [`SetStorageParams`](#setstorageparamstdata)\<`TData`\>
|
|
74
|
+
|
|
75
|
+
存储参数,字段见 [SetStorageParams](#setstorageparamstdata)。
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
`object`
|
|
80
|
+
|
|
81
|
+
同步写入完成后返回。
|
|
82
|
+
|
|
83
|
+
#### Remarks
|
|
84
|
+
|
|
85
|
+
#### Example
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { setStorageSync } from '@doubao-apps/framework/api';
|
|
89
|
+
|
|
90
|
+
setStorageSync({
|
|
91
|
+
key: 'profile',
|
|
92
|
+
data: { name: 'Tom', age: 18 },
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
<a id="getstorage"></a>
|
|
97
|
+
### getStorage()
|
|
98
|
+
|
|
99
|
+
> **getStorage**\<`TData`\>(`params`): `Promise`\<[`GetStorageResult`](#getstorageresulttdata)\<`TData`\>\>
|
|
100
|
+
|
|
101
|
+
从本地缓存读取数据。
|
|
102
|
+
|
|
103
|
+
#### Type parameters
|
|
104
|
+
|
|
105
|
+
• **TData** = `unknown`
|
|
106
|
+
|
|
107
|
+
#### Parameters
|
|
108
|
+
|
|
109
|
+
• **params**: [`GetStorageParams`](#getstorageparams)
|
|
110
|
+
|
|
111
|
+
查询参数,字段见 [GetStorageParams](#getstorageparams)。
|
|
112
|
+
|
|
113
|
+
#### Returns
|
|
114
|
+
|
|
115
|
+
`Promise`\<[`GetStorageResult`](#getstorageresulttdata)\<`TData`\>\>
|
|
116
|
+
|
|
117
|
+
返回一个 Promise,解析为 [GetStorageResult](#getstorageresulttdata)。
|
|
118
|
+
|
|
119
|
+
#### Remarks
|
|
120
|
+
|
|
121
|
+
#### Example
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { getStorage } from '@doubao-apps/framework/api';
|
|
125
|
+
|
|
126
|
+
const result = await getStorage<{ name: string; age: number }>({
|
|
127
|
+
key: 'profile',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
console.log(result.data.name, result.data.age);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
<a id="getstoragesync"></a>
|
|
134
|
+
### getStorageSync()
|
|
135
|
+
|
|
136
|
+
> **getStorageSync**\<`TData`\>(`params`): [`GetStorageResult`](#getstorageresulttdata)\<`TData`\>
|
|
137
|
+
|
|
138
|
+
从本地缓存同步读取数据。
|
|
139
|
+
|
|
140
|
+
#### Type parameters
|
|
141
|
+
|
|
142
|
+
• **TData** = `unknown`
|
|
143
|
+
|
|
144
|
+
#### Parameters
|
|
145
|
+
|
|
146
|
+
• **params**: [`GetStorageParams`](#getstorageparams)
|
|
147
|
+
|
|
148
|
+
查询参数,字段见 [GetStorageParams](#getstorageparams)。
|
|
149
|
+
|
|
150
|
+
#### Returns
|
|
151
|
+
|
|
152
|
+
[`GetStorageResult`](#getstorageresulttdata)\<`TData`\>
|
|
153
|
+
|
|
154
|
+
返回 [GetStorageResult](#getstorageresulttdata)。
|
|
155
|
+
|
|
156
|
+
#### Remarks
|
|
157
|
+
|
|
158
|
+
#### Example
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { getStorageSync } from '@doubao-apps/framework/api';
|
|
162
|
+
|
|
163
|
+
const result = getStorageSync<{ name: string; age: number }>({
|
|
164
|
+
key: 'profile',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
console.log(result.data.name, result.data.age);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
<a id="removestorage"></a>
|
|
171
|
+
### removeStorage()
|
|
172
|
+
|
|
173
|
+
> **removeStorage**(`params`): `Promise`\<`object`\>
|
|
174
|
+
|
|
175
|
+
删除本地缓存中指定 key 的数据。
|
|
176
|
+
|
|
177
|
+
#### Parameters
|
|
178
|
+
|
|
179
|
+
• **params**: [`RemoveStorageParams`](#removestorageparams)
|
|
180
|
+
|
|
181
|
+
删除参数,字段见 [RemoveStorageParams](#removestorageparams)。
|
|
182
|
+
|
|
183
|
+
#### Returns
|
|
184
|
+
|
|
185
|
+
`Promise`\<`object`\>
|
|
186
|
+
|
|
187
|
+
返回一个 Promise,删除完成后 resolve。
|
|
188
|
+
|
|
189
|
+
#### Example
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { removeStorage } from '@doubao-apps/framework/api';
|
|
193
|
+
|
|
194
|
+
await removeStorage({ key: 'profile' });
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
<a id="removestoragesync"></a>
|
|
198
|
+
### removeStorageSync()
|
|
199
|
+
|
|
200
|
+
> **removeStorageSync**(`params`?): `object`
|
|
201
|
+
|
|
202
|
+
删除本地缓存中指定 key 的数据。
|
|
203
|
+
|
|
204
|
+
#### Parameters
|
|
205
|
+
|
|
206
|
+
• **params?**: [`RemoveStorageParams`](#removestorageparams)
|
|
207
|
+
|
|
208
|
+
删除参数,字段见 [RemoveStorageParams](#removestorageparams)。
|
|
209
|
+
|
|
210
|
+
#### Returns
|
|
211
|
+
|
|
212
|
+
`object`
|
|
213
|
+
|
|
214
|
+
同步删除完成后返回。
|
|
215
|
+
|
|
216
|
+
#### Example
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import { removeStorageSync } from '@doubao-apps/framework/api';
|
|
220
|
+
|
|
221
|
+
removeStorageSync({ key: 'profile' });
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
<a id="clearstorage"></a>
|
|
225
|
+
### clearStorage()
|
|
226
|
+
|
|
227
|
+
> **clearStorage**(`params`?): `Promise`\<`object`\>
|
|
228
|
+
|
|
229
|
+
清空本地缓存。
|
|
230
|
+
|
|
231
|
+
#### Parameters
|
|
232
|
+
|
|
233
|
+
• **params?**: `object`
|
|
234
|
+
|
|
235
|
+
#### Returns
|
|
236
|
+
|
|
237
|
+
`Promise`\<`object`\>
|
|
238
|
+
|
|
239
|
+
返回一个 Promise,清空完成后 resolve。
|
|
240
|
+
|
|
241
|
+
#### Example
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { clearStorage } from '@doubao-apps/framework/api';
|
|
245
|
+
|
|
246
|
+
await clearStorage();
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
<a id="clearstoragesync"></a>
|
|
250
|
+
### clearStorageSync()
|
|
251
|
+
|
|
252
|
+
> **clearStorageSync**(`params`?): `object`
|
|
253
|
+
|
|
254
|
+
清空本地缓存。
|
|
255
|
+
|
|
256
|
+
#### Parameters
|
|
257
|
+
|
|
258
|
+
• **params?**: `object`
|
|
259
|
+
|
|
260
|
+
#### Returns
|
|
261
|
+
|
|
262
|
+
`object`
|
|
263
|
+
|
|
264
|
+
同步清空完成后返回。
|
|
265
|
+
|
|
266
|
+
#### Example
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { clearStorageSync } from '@doubao-apps/framework/api';
|
|
270
|
+
|
|
271
|
+
clearStorageSync();
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
<a id="getstorageinfo"></a>
|
|
275
|
+
### getStorageInfo()
|
|
276
|
+
|
|
277
|
+
> **getStorageInfo**(`params`?): `Promise`\<[`GetStorageInfoResult`](#getstorageinforesult)\>
|
|
278
|
+
|
|
279
|
+
获取本地缓存信息。
|
|
280
|
+
|
|
281
|
+
#### Parameters
|
|
282
|
+
|
|
283
|
+
• **params?**
|
|
284
|
+
|
|
285
|
+
#### Returns
|
|
286
|
+
|
|
287
|
+
`Promise`\<[`GetStorageInfoResult`](#getstorageinforesult)\>
|
|
288
|
+
|
|
289
|
+
返回一个 Promise,解析为 [GetStorageInfoResult](#getstorageinforesult)。
|
|
290
|
+
|
|
291
|
+
#### Example
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { getStorageInfo } from '@doubao-apps/framework/api';
|
|
295
|
+
|
|
296
|
+
const result = await getStorageInfo();
|
|
297
|
+
|
|
298
|
+
console.log(result.keys, result.currentSize, result.limitSize);
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
<a id="getstorageinfosync"></a>
|
|
302
|
+
### getStorageInfoSync()
|
|
303
|
+
|
|
304
|
+
> **getStorageInfoSync**(`params`?): [`GetStorageInfoResult`](#getstorageinforesult)
|
|
305
|
+
|
|
306
|
+
同步获取本地缓存信息。
|
|
307
|
+
|
|
308
|
+
#### Parameters
|
|
309
|
+
|
|
310
|
+
• **params?**
|
|
311
|
+
|
|
312
|
+
#### Returns
|
|
313
|
+
|
|
314
|
+
[`GetStorageInfoResult`](#getstorageinforesult)
|
|
315
|
+
|
|
316
|
+
返回 [GetStorageInfoResult](#getstorageinforesult)。
|
|
317
|
+
|
|
318
|
+
#### Example
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
import { getStorageInfoSync } from '@doubao-apps/framework/api';
|
|
322
|
+
|
|
323
|
+
const result = getStorageInfoSync();
|
|
324
|
+
|
|
325
|
+
console.log(result.keys, result.currentSize, result.limitSize);
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## 相关类型
|
|
329
|
+
|
|
330
|
+
<a id="setstorageparamstdata"></a>
|
|
331
|
+
### SetStorageParams<TData>
|
|
332
|
+
|
|
333
|
+
#### Type parameters
|
|
334
|
+
|
|
335
|
+
• **TData** = `unknown`
|
|
336
|
+
|
|
337
|
+
#### Properties
|
|
338
|
+
|
|
339
|
+
##### data
|
|
340
|
+
|
|
341
|
+
> **data**: `TData`
|
|
342
|
+
|
|
343
|
+
待存储的数据
|
|
344
|
+
|
|
345
|
+
##### key
|
|
346
|
+
|
|
347
|
+
> **key**: `string`
|
|
348
|
+
|
|
349
|
+
本地缓存键名
|
|
350
|
+
|
|
351
|
+
<a id="getstorageparams"></a>
|
|
352
|
+
### GetStorageParams
|
|
353
|
+
|
|
354
|
+
#### Properties
|
|
355
|
+
|
|
356
|
+
##### key
|
|
357
|
+
|
|
358
|
+
> **key**: `string`
|
|
359
|
+
|
|
360
|
+
本地缓存键名
|
|
361
|
+
|
|
362
|
+
<a id="getstorageresulttdata"></a>
|
|
363
|
+
### GetStorageResult<TData>
|
|
364
|
+
|
|
365
|
+
#### Type parameters
|
|
366
|
+
|
|
367
|
+
• **TData** = `unknown`
|
|
368
|
+
|
|
369
|
+
#### Properties
|
|
370
|
+
|
|
371
|
+
##### data
|
|
372
|
+
|
|
373
|
+
> **data**: `TData`
|
|
374
|
+
|
|
375
|
+
key 对应的数据
|
|
376
|
+
|
|
377
|
+
<a id="removestorageparams"></a>
|
|
378
|
+
### RemoveStorageParams
|
|
379
|
+
|
|
380
|
+
#### Properties
|
|
381
|
+
|
|
382
|
+
##### key
|
|
383
|
+
|
|
384
|
+
> **key**: `string`
|
|
385
|
+
|
|
386
|
+
本地缓存键名
|
|
387
|
+
|
|
388
|
+
<a id="getstorageinforesult"></a>
|
|
389
|
+
### GetStorageInfoResult
|
|
390
|
+
|
|
391
|
+
#### Properties
|
|
392
|
+
|
|
393
|
+
##### currentSize
|
|
394
|
+
|
|
395
|
+
> **currentSize**: `number`
|
|
396
|
+
|
|
397
|
+
当前占用的空间大小,单位 KB
|
|
398
|
+
|
|
399
|
+
##### keys
|
|
400
|
+
|
|
401
|
+
> **keys**: `string`[]
|
|
402
|
+
|
|
403
|
+
当前 storage 中所有的 key
|
|
404
|
+
|
|
405
|
+
##### limitSize
|
|
406
|
+
|
|
407
|
+
> **limitSize**: `number`
|
|
408
|
+
|
|
409
|
+
限制的空间大小,单位 KB
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Open API: 路由
|
|
2
|
+
|
|
3
|
+
应用内页面跳转和关闭。
|
|
4
|
+
|
|
5
|
+
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [close](#close) | 关闭栈顶页面。<br><br>已废弃,使用 navigateBack。 |
|
|
12
|
+
| [navigateTo](#navigateto) | 保留当前页面,跳转到应用内的某个页面。 |
|
|
13
|
+
| [redirectTo](#redirectto) | 关闭当前页面,跳转到应用内的某个页面。 |
|
|
14
|
+
| [reLaunch](#relaunch) | 关闭所有页面并跳转到应用内页面。 |
|
|
15
|
+
| [navigateBack](#navigateback) | 关闭当前页面,返回上一页面或多级页面。 |
|
|
16
|
+
| [exitApp](#exitapp) | 退出当前所有页面。<br><br>会退出当前所有页面。 |
|
|
17
|
+
|
|
18
|
+
## API 详情
|
|
19
|
+
|
|
20
|
+
<a id="close"></a>
|
|
21
|
+
### close()
|
|
22
|
+
|
|
23
|
+
> **close**(`params`?): `Promise`\<`object`\>
|
|
24
|
+
|
|
25
|
+
关闭栈顶页面。
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
• **params?**: [`CloseParams`](#closeparams)
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`Promise`\<`object`\>
|
|
34
|
+
|
|
35
|
+
返回一个 Promise,在关闭操作成功发起时解析
|
|
36
|
+
|
|
37
|
+
#### Deprecated
|
|
38
|
+
|
|
39
|
+
使用 [navigateBack](#navigateback)
|
|
40
|
+
|
|
41
|
+
#### Example
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { close } from '@doubao-apps/framework/api';
|
|
45
|
+
|
|
46
|
+
async function closeTopPage() {
|
|
47
|
+
try {
|
|
48
|
+
await close();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error('关闭页面失败', e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
closePage();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<a id="navigateto"></a>
|
|
58
|
+
### navigateTo()
|
|
59
|
+
|
|
60
|
+
> **navigateTo**(`params`): `Promise`\<`object`\>
|
|
61
|
+
|
|
62
|
+
保留当前页面,跳转到应用内的某个页面。
|
|
63
|
+
|
|
64
|
+
#### Parameters
|
|
65
|
+
|
|
66
|
+
• **params**: [`NavigateToParams`](#navigatetoparams)
|
|
67
|
+
|
|
68
|
+
#### Returns
|
|
69
|
+
|
|
70
|
+
`Promise`\<`object`\>
|
|
71
|
+
|
|
72
|
+
<a id="redirectto"></a>
|
|
73
|
+
### redirectTo()
|
|
74
|
+
|
|
75
|
+
> **redirectTo**(`params`): `Promise`\<`object`\>
|
|
76
|
+
|
|
77
|
+
关闭当前页面,跳转到应用内的某个页面。
|
|
78
|
+
|
|
79
|
+
#### Parameters
|
|
80
|
+
|
|
81
|
+
• **params**: [`NavigateToParams`](#navigatetoparams)
|
|
82
|
+
|
|
83
|
+
#### Returns
|
|
84
|
+
|
|
85
|
+
`Promise`\<`object`\>
|
|
86
|
+
|
|
87
|
+
<a id="relaunch"></a>
|
|
88
|
+
### reLaunch()
|
|
89
|
+
|
|
90
|
+
> **reLaunch**(`params`): `Promise`\<`object`\>
|
|
91
|
+
|
|
92
|
+
关闭所有页面并跳转到应用内页面。
|
|
93
|
+
|
|
94
|
+
#### Parameters
|
|
95
|
+
|
|
96
|
+
• **params**: [`NavigateToParams`](#navigatetoparams)
|
|
97
|
+
|
|
98
|
+
#### Returns
|
|
99
|
+
|
|
100
|
+
`Promise`\<`object`\>
|
|
101
|
+
|
|
102
|
+
<a id="navigateback"></a>
|
|
103
|
+
### navigateBack()
|
|
104
|
+
|
|
105
|
+
> **navigateBack**(`params`?): `Promise`\<`object`\>
|
|
106
|
+
|
|
107
|
+
关闭当前页面,返回上一页面或多级页面。
|
|
108
|
+
|
|
109
|
+
#### Parameters
|
|
110
|
+
|
|
111
|
+
• **params?**: [`NavigateBackParams`](#navigatebackparams)
|
|
112
|
+
|
|
113
|
+
#### Returns
|
|
114
|
+
|
|
115
|
+
`Promise`\<`object`\>
|
|
116
|
+
|
|
117
|
+
<a id="exitapp"></a>
|
|
118
|
+
### exitApp()
|
|
119
|
+
|
|
120
|
+
> **exitApp**(): `Promise`\<`object`\>
|
|
121
|
+
|
|
122
|
+
退出当前所有页面。
|
|
123
|
+
|
|
124
|
+
#### Returns
|
|
125
|
+
|
|
126
|
+
`Promise`\<`object`\>
|
|
127
|
+
|
|
128
|
+
#### Remarks
|
|
129
|
+
|
|
130
|
+
会退出当前所有页面。
|
|
131
|
+
|
|
132
|
+
## 相关类型
|
|
133
|
+
|
|
134
|
+
<a id="closeparams"></a>
|
|
135
|
+
### CloseParams
|
|
136
|
+
|
|
137
|
+
#### Properties
|
|
138
|
+
|
|
139
|
+
##### containerID?
|
|
140
|
+
|
|
141
|
+
> `optional` **containerID**: `string`
|
|
142
|
+
|
|
143
|
+
指定一个要关闭的页面
|
|
144
|
+
|
|
145
|
+
<a id="navigatetoparams"></a>
|
|
146
|
+
### NavigateToParams
|
|
147
|
+
|
|
148
|
+
#### Properties
|
|
149
|
+
|
|
150
|
+
##### url
|
|
151
|
+
|
|
152
|
+
> **url**: `string`
|
|
153
|
+
|
|
154
|
+
跳转的页面的路径,如 'path?key=value&key2=value2'
|
|
155
|
+
|
|
156
|
+
<a id="navigatebackparams"></a>
|
|
157
|
+
### NavigateBackParams
|
|
158
|
+
|
|
159
|
+
#### Properties
|
|
160
|
+
|
|
161
|
+
##### delta?
|
|
162
|
+
|
|
163
|
+
> `optional` **delta**: `number`
|
|
164
|
+
|
|
165
|
+
返回的页面数,如果 delta 大于现有页面数,则返回到页面栈中只剩一个页面为止。
|