@doubao-apps/create 0.0.29 → 0.0.30
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/template-empty/package.json +2 -2
- package/dist/template-empty/references/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +118 -2535
- package/dist/template-empty/references/reference/open-api/02-/345/256/232/344/275/215.md +135 -0
- package/dist/template-empty/references/reference/open-api/03-/345/255/230/345/202/250.md +409 -0
- package/dist/template-empty/references/reference/open-api/04-/350/267/257/347/224/261.md +165 -0
- package/dist/template-empty/references/reference/open-api/05-/347/225/214/351/235/242-/344/272/244/344/272/222.md +432 -0
- package/dist/template-empty/references/reference/open-api/07-/347/275/221/347/273/234.md +468 -0
- package/dist/template-empty/references/reference/open-api/08-/345/252/222/344/275/223.md +346 -0
- package/dist/template-empty/references/reference/open-api/09-/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 +929 -0
- package/dist/{template-starter/references/reference/open-api/04- → template-empty/references/reference/open-api/10-}/346/225/260/346/215/256/345/210/206/346/236/220.md +1 -1
- package/dist/template-empty/references/reference/open-api/README.md +30 -24
- package/dist/template-empty/references/reference/open-api.md +464 -0
- package/dist/template-starter/package.json +2 -2
- package/dist/template-starter/references/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +118 -2535
- package/dist/template-starter/references/reference/open-api/02-/345/256/232/344/275/215.md +135 -0
- package/dist/template-starter/references/reference/open-api/03-/345/255/230/345/202/250.md +409 -0
- package/dist/template-starter/references/reference/open-api/04-/350/267/257/347/224/261.md +165 -0
- package/dist/template-starter/references/reference/open-api/05-/347/225/214/351/235/242-/344/272/244/344/272/222.md +432 -0
- package/dist/template-starter/references/reference/open-api/07-/347/275/221/347/273/234.md +468 -0
- package/dist/template-starter/references/reference/open-api/08-/345/252/222/344/275/223.md +346 -0
- package/dist/template-starter/references/reference/open-api/09-/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 +929 -0
- package/dist/{template-empty/references/reference/open-api/04- → template-starter/references/reference/open-api/10-}/346/225/260/346/215/256/345/210/206/346/236/220.md +1 -1
- package/dist/template-starter/references/reference/open-api/README.md +30 -24
- package/dist/template-starter/references/reference/open-api.md +464 -0
- package/package.json +1 -1
- package/dist/template-empty/references/reference/open-api/02-/350/267/257/347/224/261.md +0 -63
- package/dist/template-starter/references/reference/open-api/02-/350/267/257/347/224/261.md +0 -63
- /package/dist/template-empty/references/reference/open-api/{03- → 06-}/347/225/214/351/235/242-/350/276/223/345/205/245.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{05- → 11-}/350/256/276/345/244/207-/350/223/235/347/211/231.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{06- → 12-}/350/256/276/345/244/207-wi-fi.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{07- → 13-}/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{08- → 14-}/350/256/276/345/244/207-ibeacon.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{09- → 15-}/350/256/276/345/244/207-/347/275/227/347/233/230.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{10- → 16-}/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{11- → 17-}/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{12-ui- → 18-ui-}/350/276/223/345/205/245.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{13- → 19-}/350/256/276/345/244/207-/347/275/221/347/273/234.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{14- → 20-}/350/256/276/345/244/207-/347/237/255/344/277/241.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{15- → 21-}/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{16- → 22-}/350/256/276/345/244/207-/347/224/265/346/261/240.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{17- → 23-}/350/256/276/345/244/207-/346/227/245/345/216/206.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{18- → 24-}/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{19- → 25-}/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{20- → 26-}/350/256/276/345/244/207-/345/212/240/345/257/206.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{21- → 27-}/350/256/276/345/244/207-/347/224/265/350/257/235.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{22- → 28-}/350/256/276/345/244/207-/346/211/253/347/240/201.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{23- → 29-}/350/256/276/345/244/207-/345/261/217/345/271/225.md" +0 -0
- /package/dist/template-empty/references/reference/open-api/{24- → 30-}/350/256/276/345/244/207-/351/234/207/345/212/250.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{03- → 06-}/347/225/214/351/235/242-/350/276/223/345/205/245.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{05- → 11-}/350/256/276/345/244/207-/350/223/235/347/211/231.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{06- → 12-}/350/256/276/345/244/207-wi-fi.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{07- → 13-}/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{08- → 14-}/350/256/276/345/244/207-ibeacon.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{09- → 15-}/350/256/276/345/244/207-/347/275/227/347/233/230.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{10- → 16-}/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{11- → 17-}/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{12-ui- → 18-ui-}/350/276/223/345/205/245.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{13- → 19-}/350/256/276/345/244/207-/347/275/221/347/273/234.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{14- → 20-}/350/256/276/345/244/207-/347/237/255/344/277/241.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{15- → 21-}/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{16- → 22-}/350/256/276/345/244/207-/347/224/265/346/261/240.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{17- → 23-}/350/256/276/345/244/207-/346/227/245/345/216/206.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{18- → 24-}/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{19- → 25-}/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{20- → 26-}/350/256/276/345/244/207-/345/212/240/345/257/206.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{21- → 27-}/350/256/276/345/244/207-/347/224/265/350/257/235.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{22- → 28-}/350/256/276/345/244/207-/346/211/253/347/240/201.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{23- → 29-}/350/256/276/345/244/207-/345/261/217/345/271/225.md" +0 -0
- /package/dist/template-starter/references/reference/open-api/{24- → 30-}/350/256/276/345/244/207-/351/234/207/345/212/250.md" +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Open API: 定位
|
|
2
|
+
|
|
3
|
+
获取设备当前的地理位置信息。
|
|
4
|
+
|
|
5
|
+
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [getLocation](#getlocation) | 获取设备当前的地理位置信息。<br><br>可能涉及定位授权。 |
|
|
12
|
+
|
|
13
|
+
## API 详情
|
|
14
|
+
|
|
15
|
+
<a id="getlocation"></a>
|
|
16
|
+
### getLocation()
|
|
17
|
+
|
|
18
|
+
> **getLocation**(`params`?): `Promise`\<[`GetLocationResponse`](#getlocationresponse)\>
|
|
19
|
+
|
|
20
|
+
获取设备当前的地理位置信息。
|
|
21
|
+
|
|
22
|
+
#### Parameters
|
|
23
|
+
|
|
24
|
+
• **params?**: [`GetLocationParams`](#getlocationparams)
|
|
25
|
+
|
|
26
|
+
#### Returns
|
|
27
|
+
|
|
28
|
+
`Promise`\<[`GetLocationResponse`](#getlocationresponse)\>
|
|
29
|
+
|
|
30
|
+
返回一个 Promise,成功时解析为包含地理位置信息的对象,包含:
|
|
31
|
+
- `latitude`: number - 纬度。
|
|
32
|
+
- `longitude`: number - 经度。
|
|
33
|
+
- `timestamp`: string - 时间戳。
|
|
34
|
+
- `speed`: number - 行进速度,单位:米/秒。
|
|
35
|
+
- `accuracy`: number - 定位精度,单位:米。
|
|
36
|
+
参考 [GetLocationResponse](#getlocationresponse)。
|
|
37
|
+
|
|
38
|
+
#### Throws
|
|
39
|
+
|
|
40
|
+
如果调用失败(例如,用户拒绝权限、定位服务关闭等),则抛出此错误。
|
|
41
|
+
|
|
42
|
+
#### Remarks
|
|
43
|
+
|
|
44
|
+
可能涉及定位授权。
|
|
45
|
+
|
|
46
|
+
#### Example
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { getLocation } from '@doubao-apps/framework';
|
|
50
|
+
|
|
51
|
+
async function fetchLocation() {
|
|
52
|
+
try {
|
|
53
|
+
const locationData = await getLocation();
|
|
54
|
+
console.log('纬度:', locationData.latitude);
|
|
55
|
+
console.log('经度:', locationData.longitude);
|
|
56
|
+
console.log('时间戳:', locationData.timestamp);
|
|
57
|
+
console.log('行进速度:', locationData.speed);
|
|
58
|
+
console.log('定位精度:', locationData.accuracy);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('获取位置失败:', error);
|
|
61
|
+
// 处理错误,例如提示用户开启定位权限
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fetchLocation();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 相关类型
|
|
69
|
+
|
|
70
|
+
<a id="getlocationparams"></a>
|
|
71
|
+
### GetLocationParams
|
|
72
|
+
|
|
73
|
+
#### Properties
|
|
74
|
+
|
|
75
|
+
##### maxCacheMs?
|
|
76
|
+
|
|
77
|
+
> `optional` **maxCacheMs**: `number`
|
|
78
|
+
|
|
79
|
+
缓存时间,单位毫秒,默认为0
|
|
80
|
+
|
|
81
|
+
##### mode?
|
|
82
|
+
|
|
83
|
+
> `optional` **mode**: `number`
|
|
84
|
+
|
|
85
|
+
定位模式
|
|
86
|
+
0:低功耗
|
|
87
|
+
1:仅设备
|
|
88
|
+
2:高精度(默认)
|
|
89
|
+
|
|
90
|
+
##### source?
|
|
91
|
+
|
|
92
|
+
> `optional` **source**: `string`
|
|
93
|
+
|
|
94
|
+
调用业务方
|
|
95
|
+
|
|
96
|
+
##### timeoutMs?
|
|
97
|
+
|
|
98
|
+
> `optional` **timeoutMs**: `number`
|
|
99
|
+
|
|
100
|
+
超时时间,单位毫秒,默认 30000
|
|
101
|
+
|
|
102
|
+
<a id="getlocationresponse"></a>
|
|
103
|
+
### GetLocationResponse
|
|
104
|
+
|
|
105
|
+
#### Properties
|
|
106
|
+
|
|
107
|
+
##### accuracy
|
|
108
|
+
|
|
109
|
+
> **accuracy**: `number`
|
|
110
|
+
|
|
111
|
+
定位精度,单位:米
|
|
112
|
+
|
|
113
|
+
##### latitude
|
|
114
|
+
|
|
115
|
+
> **latitude**: `number`
|
|
116
|
+
|
|
117
|
+
纬度
|
|
118
|
+
|
|
119
|
+
##### longitude
|
|
120
|
+
|
|
121
|
+
> **longitude**: `number`
|
|
122
|
+
|
|
123
|
+
经度
|
|
124
|
+
|
|
125
|
+
##### speed
|
|
126
|
+
|
|
127
|
+
> **speed**: `number`
|
|
128
|
+
|
|
129
|
+
行进速度,单位:米/秒
|
|
130
|
+
|
|
131
|
+
##### timestamp
|
|
132
|
+
|
|
133
|
+
> **timestamp**: `string`
|
|
134
|
+
|
|
135
|
+
时间戳
|
|
@@ -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
|
+
| [navigateTo](#navigateto) | 保留当前页面,跳转到应用内的某个页面。 |
|
|
12
|
+
| [redirectTo](#redirectto) | 关闭当前页面,跳转到应用内的某个页面。 |
|
|
13
|
+
| [reLaunch](#relaunch) | 关闭所有页面并跳转到应用内页面。 |
|
|
14
|
+
| [navigateBack](#navigateback) | 关闭当前页面,返回上一页面或多级页面。 |
|
|
15
|
+
| [exitApp](#exitapp) | 退出当前所有页面。<br><br>会退出当前所有页面。 |
|
|
16
|
+
| [close](#close) | 关闭栈顶页面。<br><br>已废弃,使用 navigateBack。 |
|
|
17
|
+
|
|
18
|
+
## API 详情
|
|
19
|
+
|
|
20
|
+
<a id="navigateto"></a>
|
|
21
|
+
### navigateTo()
|
|
22
|
+
|
|
23
|
+
> **navigateTo**(`params`): `Promise`\<`object`\>
|
|
24
|
+
|
|
25
|
+
保留当前页面,跳转到应用内的某个页面。
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
• **params**: [`NavigateToParams`](#navigatetoparams)
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`Promise`\<`object`\>
|
|
34
|
+
|
|
35
|
+
<a id="redirectto"></a>
|
|
36
|
+
### redirectTo()
|
|
37
|
+
|
|
38
|
+
> **redirectTo**(`params`): `Promise`\<`object`\>
|
|
39
|
+
|
|
40
|
+
关闭当前页面,跳转到应用内的某个页面。
|
|
41
|
+
|
|
42
|
+
#### Parameters
|
|
43
|
+
|
|
44
|
+
• **params**: [`NavigateToParams`](#navigatetoparams)
|
|
45
|
+
|
|
46
|
+
#### Returns
|
|
47
|
+
|
|
48
|
+
`Promise`\<`object`\>
|
|
49
|
+
|
|
50
|
+
<a id="relaunch"></a>
|
|
51
|
+
### reLaunch()
|
|
52
|
+
|
|
53
|
+
> **reLaunch**(`params`): `Promise`\<`object`\>
|
|
54
|
+
|
|
55
|
+
关闭所有页面并跳转到应用内页面。
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
• **params**: [`NavigateToParams`](#navigatetoparams)
|
|
60
|
+
|
|
61
|
+
#### Returns
|
|
62
|
+
|
|
63
|
+
`Promise`\<`object`\>
|
|
64
|
+
|
|
65
|
+
<a id="navigateback"></a>
|
|
66
|
+
### navigateBack()
|
|
67
|
+
|
|
68
|
+
> **navigateBack**(`params`?): `Promise`\<`object`\>
|
|
69
|
+
|
|
70
|
+
关闭当前页面,返回上一页面或多级页面。
|
|
71
|
+
|
|
72
|
+
#### Parameters
|
|
73
|
+
|
|
74
|
+
• **params?**: [`NavigateBackParams`](#navigatebackparams)
|
|
75
|
+
|
|
76
|
+
#### Returns
|
|
77
|
+
|
|
78
|
+
`Promise`\<`object`\>
|
|
79
|
+
|
|
80
|
+
<a id="exitapp"></a>
|
|
81
|
+
### exitApp()
|
|
82
|
+
|
|
83
|
+
> **exitApp**(): `Promise`\<`object`\>
|
|
84
|
+
|
|
85
|
+
退出当前所有页面。
|
|
86
|
+
|
|
87
|
+
#### Returns
|
|
88
|
+
|
|
89
|
+
`Promise`\<`object`\>
|
|
90
|
+
|
|
91
|
+
#### Remarks
|
|
92
|
+
|
|
93
|
+
会退出当前所有页面。
|
|
94
|
+
|
|
95
|
+
<a id="close"></a>
|
|
96
|
+
### close()
|
|
97
|
+
|
|
98
|
+
> **close**(`params`?): `Promise`\<`object`\>
|
|
99
|
+
|
|
100
|
+
关闭栈顶页面。
|
|
101
|
+
|
|
102
|
+
#### Parameters
|
|
103
|
+
|
|
104
|
+
• **params?**: [`CloseParams`](#closeparams)
|
|
105
|
+
|
|
106
|
+
#### Returns
|
|
107
|
+
|
|
108
|
+
`Promise`\<`object`\>
|
|
109
|
+
|
|
110
|
+
返回一个 Promise,在关闭操作成功发起时解析
|
|
111
|
+
|
|
112
|
+
#### Deprecated
|
|
113
|
+
|
|
114
|
+
使用 [navigateBack](#navigateback)
|
|
115
|
+
|
|
116
|
+
#### Example
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { close } from '@doubao-apps/framework/api';
|
|
120
|
+
|
|
121
|
+
async function closeTopPage() {
|
|
122
|
+
try {
|
|
123
|
+
await close();
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.error('关闭页面失败', e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
closePage();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 相关类型
|
|
133
|
+
|
|
134
|
+
<a id="navigatetoparams"></a>
|
|
135
|
+
### NavigateToParams
|
|
136
|
+
|
|
137
|
+
#### Properties
|
|
138
|
+
|
|
139
|
+
##### url
|
|
140
|
+
|
|
141
|
+
> **url**: `string`
|
|
142
|
+
|
|
143
|
+
跳转的页面的路径,如 'path?key=value&key2=value2'
|
|
144
|
+
|
|
145
|
+
<a id="navigatebackparams"></a>
|
|
146
|
+
### NavigateBackParams
|
|
147
|
+
|
|
148
|
+
#### Properties
|
|
149
|
+
|
|
150
|
+
##### delta?
|
|
151
|
+
|
|
152
|
+
> `optional` **delta**: `number`
|
|
153
|
+
|
|
154
|
+
返回的页面数,如果 delta 大于现有页面数,则返回到页面栈中只剩一个页面为止。
|
|
155
|
+
|
|
156
|
+
<a id="closeparams"></a>
|
|
157
|
+
### CloseParams
|
|
158
|
+
|
|
159
|
+
#### Properties
|
|
160
|
+
|
|
161
|
+
##### containerID?
|
|
162
|
+
|
|
163
|
+
> `optional` **containerID**: `string`
|
|
164
|
+
|
|
165
|
+
指定一个要关闭的页面
|