@kbapp/js-bridge 1.0.13-alpha.0 → 1.0.15-alpha.0
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 +108 -1323
- package/docs/api/check-for-new-version.md +38 -0
- package/docs/api/close-web-view.md +38 -0
- package/docs/api/define-app-share-model.md +75 -0
- package/docs/api/define-app-share-panel-state.md +42 -0
- package/docs/api/define-bridge-callback.md +44 -0
- package/docs/api/define-permission-usage.md +47 -0
- package/docs/api/generate-kbsign.md +44 -0
- package/docs/api/get-app-base-info.md +39 -0
- package/docs/api/get-app-login-info.md +42 -0
- package/docs/api/get-app-subscribe-notify-status.md +40 -0
- package/docs/api/is-app-version-support.md +40 -0
- package/docs/api/on-app-share-panel-show.md +32 -0
- package/docs/api/on-loop-check-app-login.md +32 -0
- package/docs/api/open-app-share-panel.md +46 -0
- package/docs/api/open-app-subscribe-notify-settings.md +38 -0
- package/docs/api/open-post-editor.md +91 -0
- package/docs/api/report-daevent.md +43 -0
- package/docs/api/run-action.md +44 -0
- package/docs/api/run-bridge-api-response.md +46 -0
- package/docs/api/run-bridge-api.md +34 -0
- package/docs/api/save-image-to-local.md +46 -0
- package/docs/api/save-video-to-local.md +46 -0
- package/docs/api/scan-qrcode.md +38 -0
- package/docs/api/set-screen-orientation.md +52 -0
- package/docs/api/set-web-view-title.md +46 -0
- package/docs/api/share-image.md +46 -0
- package/docs/api/trigger-app-login.md +45 -0
- package/package.json +3 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# openPostEditor
|
|
2
|
+
|
|
3
|
+
> 唤起发帖器
|
|
4
|
+
|
|
5
|
+
### openPostEditor
|
|
6
|
+
|
|
7
|
+
> 唤起发帖器
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ----------------------------- | --------------------------------- | ---- | ---------------------------- |
|
|
13
|
+
| `postRule.hint` | `string` | 否 | 文本输入框提示文案 |
|
|
14
|
+
| `postRule.initialText` | `string` | 否 | 初始化文本内容 |
|
|
15
|
+
| `postRule.audio` | `boolean` | 否 | 是否显示音频按钮,默认 true |
|
|
16
|
+
| `postRule.image` | `boolean` | 否 | 是否显示图片按钮,默认 true |
|
|
17
|
+
| `postRule.video` | `boolean` | 否 | 是否显示视频按钮,默认 true |
|
|
18
|
+
| `postRule.address` | `boolean` | 否 | 是否显示定位按钮,默认 true |
|
|
19
|
+
| `postRule.asset_video` | `boolean` | 否 | 是否显示媒资视频,默认 false |
|
|
20
|
+
| `postRule.audio_must` | `boolean` | 否 | 音频是否必传 |
|
|
21
|
+
| `postRule.image_must` | `boolean` | 否 | 图片是否必传 |
|
|
22
|
+
| `postRule.max_image_count` | `number` | 否 | 图片最大张数,默认 9 |
|
|
23
|
+
| `postRule.min_image_count` | `number` | 否 | 图片最小张数,默认 0 |
|
|
24
|
+
| `postRule.video_must` | `boolean` | 否 | 视频是否必传 |
|
|
25
|
+
| `postRule.text_must` | `boolean` | 否 | 文本内容是否必传 |
|
|
26
|
+
| `postRule.content_max_length` | `number` | 否 | 文本最大长度,默认 1000 |
|
|
27
|
+
| `postRule.content_min_length` | `number` | 否 | 文本最小长度,默认 0 |
|
|
28
|
+
| `success` | `(res: PostEditorResult) => void` | 否 | 成功回调 |
|
|
29
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
30
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
31
|
+
|
|
32
|
+
#### 返回值
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
Promise<{
|
|
36
|
+
content: string
|
|
37
|
+
street?: string
|
|
38
|
+
audio?: unknown
|
|
39
|
+
video?: unknown
|
|
40
|
+
images?: { url: string; width: number; height: number }[]
|
|
41
|
+
}>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### 示例代码
|
|
45
|
+
|
|
46
|
+
推荐使用 `generatePostEditorParamsByThreadPostRule` 构造参数
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { generatePostEditorParamsByThreadPostRule, openPostEditor, KbRequirement } from '@kbapp/js-bridge'
|
|
50
|
+
|
|
51
|
+
openPostEditor({
|
|
52
|
+
postRule: generatePostEditorParamsByThreadPostRule({
|
|
53
|
+
textMin: 0,
|
|
54
|
+
textMax: 1000,
|
|
55
|
+
/** 帖子中, 图片的最大张数 */
|
|
56
|
+
imageMax: 9,
|
|
57
|
+
|
|
58
|
+
/** 帖子中, 图片的最小张数 */
|
|
59
|
+
imageMin: 0,
|
|
60
|
+
|
|
61
|
+
/** 音频限制 */
|
|
62
|
+
audioRqr: KbRequirement.FREE,
|
|
63
|
+
|
|
64
|
+
/** 视频限制 */
|
|
65
|
+
videoRqr: KbRequirement.FREE,
|
|
66
|
+
|
|
67
|
+
/** 媒资限制 */
|
|
68
|
+
mediaRqr: KbRequirement.FORBID,
|
|
69
|
+
|
|
70
|
+
/** 位置-逆地理信息限制 */
|
|
71
|
+
streetRqr: KbRequirement.FREE
|
|
72
|
+
}),
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
openPostEditor({
|
|
76
|
+
postRule: {
|
|
77
|
+
hint: '请输入内容',
|
|
78
|
+
initialText: '默认内容',
|
|
79
|
+
image: true,
|
|
80
|
+
max_image_count: 9,
|
|
81
|
+
},
|
|
82
|
+
success(result) {
|
|
83
|
+
console.log('发帖内容', result)
|
|
84
|
+
},
|
|
85
|
+
fail(error) {
|
|
86
|
+
console.log('打开发帖器失败', error)
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# reportDAEvent
|
|
2
|
+
|
|
3
|
+
> 上报数据埋点
|
|
4
|
+
|
|
5
|
+
### reportDAEvent
|
|
6
|
+
|
|
7
|
+
> 上报数据埋点
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ------------- | ----------------------------- | ---- | ---------------- |
|
|
13
|
+
| `eventName` | `string` | 是 | 事件名 |
|
|
14
|
+
| `eventParams` | `object` | 否 | 上报参数 |
|
|
15
|
+
| `eventType` | `string` | 否 | 开始结束类型传递 |
|
|
16
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
17
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
18
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
19
|
+
|
|
20
|
+
#### 返回值
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
Promise<void>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 示例代码
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { reportDAEvent } from '@kbapp/js-bridge'
|
|
30
|
+
|
|
31
|
+
reportDAEvent({
|
|
32
|
+
eventName: 'page_view',
|
|
33
|
+
eventParams: { page: 'home' },
|
|
34
|
+
success() {
|
|
35
|
+
console.log('上报数据成功')
|
|
36
|
+
},
|
|
37
|
+
fail(error) {
|
|
38
|
+
console.log('上报数据失败', error)
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# runAction
|
|
2
|
+
|
|
3
|
+
> 执行 action
|
|
4
|
+
|
|
5
|
+
### runAction
|
|
6
|
+
|
|
7
|
+
> app 执行 Action
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| -------------- | ----------------------------- | ---- | ------------ |
|
|
13
|
+
| `action` | `string` | 是 | action |
|
|
14
|
+
| `actionParams` | `object` | 否 | actionParams |
|
|
15
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
16
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
17
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
18
|
+
|
|
19
|
+
#### 返回值
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
Promise<void>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### 示例代码
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { runAction } from '@kbapp/js-bridge'
|
|
29
|
+
|
|
30
|
+
runAction({
|
|
31
|
+
action: 'pageWeb',
|
|
32
|
+
actionParams: {
|
|
33
|
+
url: 'https://www.baidu.com',
|
|
34
|
+
},
|
|
35
|
+
success() {
|
|
36
|
+
console.log('执行成功')
|
|
37
|
+
},
|
|
38
|
+
fail(error) {
|
|
39
|
+
console.log('执行失败', error)
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# runBridgeApiResponse
|
|
2
|
+
|
|
3
|
+
> 执行桥接(等待响应)
|
|
4
|
+
|
|
5
|
+
### runBridgeApiResponse
|
|
6
|
+
|
|
7
|
+
> 执行 app 桥接方法(等待响应)
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ------------------------------------- | ---- | ------------------------ |
|
|
13
|
+
| `name` | `string` | 是 | 任务名称 |
|
|
14
|
+
| `params` | `{ type: number; data?: any }` | 是 | 任务参数 |
|
|
15
|
+
| `timeout` | `number` | 否 | 超时时间(毫秒) |
|
|
16
|
+
| `success` | `(result: Result) => void` | 否 | 执行成功回调 |
|
|
17
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 执行失败回调 |
|
|
18
|
+
| `complete` | `() => void` | 否 | 完成回调(成功/失败均触发) |
|
|
19
|
+
|
|
20
|
+
#### 返回值
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
Promise<Result>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 示例代码
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { runBridgeApiResponse } from '@kbapp/js-bridge'
|
|
30
|
+
|
|
31
|
+
runBridgeApiResponse({
|
|
32
|
+
name: 'OpenActRequest',
|
|
33
|
+
params: {
|
|
34
|
+
type: 60001,
|
|
35
|
+
data: {},
|
|
36
|
+
},
|
|
37
|
+
success(result) {
|
|
38
|
+
console.log('成功', result)
|
|
39
|
+
},
|
|
40
|
+
fail(error) {
|
|
41
|
+
console.log('失败', error)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# runBridgeApi
|
|
2
|
+
|
|
3
|
+
> 执行桥接(无返回值)
|
|
4
|
+
|
|
5
|
+
### runBridgeApi
|
|
6
|
+
|
|
7
|
+
> 执行 app 桥接方法(无响应)
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| -------- | ---------------------------- | ---- | ---------------- |
|
|
13
|
+
| `name` | `string` | 是 | 任务名称 |
|
|
14
|
+
| `params` | `{ type: number; data?: any }` | 是 | 桥接参数 |
|
|
15
|
+
|
|
16
|
+
#### 返回值
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
void
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
#### 示例代码
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { runBridgeApi } from '@kbapp/js-bridge'
|
|
26
|
+
|
|
27
|
+
runBridgeApi({
|
|
28
|
+
name: 'OpenActRequest',
|
|
29
|
+
params: {
|
|
30
|
+
type: 60001,
|
|
31
|
+
data: {},
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# saveImageToLocal
|
|
2
|
+
|
|
3
|
+
> 保存图片到本地
|
|
4
|
+
|
|
5
|
+
### saveImageToLocal
|
|
6
|
+
|
|
7
|
+
> 保存图片到本地
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ----------------------------- | ---- | ------------ |
|
|
13
|
+
| `imageUrl` | `string` | 是 | 图片网络地址 |
|
|
14
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
15
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
16
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
17
|
+
|
|
18
|
+
#### 返回值
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
Promise<void>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 异常返回值
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
Promise<{ errCode: BridgeCode }>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### 示例代码
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { saveImageToLocal, BridgeCode } from '@kbapp/js-bridge'
|
|
34
|
+
|
|
35
|
+
saveImageToLocal({
|
|
36
|
+
imageUrl: 'https://static.kaiba315.com.cn/kaiba-logo.png',
|
|
37
|
+
success() {
|
|
38
|
+
console.log('保存图片成功')
|
|
39
|
+
},
|
|
40
|
+
fail(error) {
|
|
41
|
+
console.log('保存图片失败', error)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# saveVideoToLocal
|
|
2
|
+
|
|
3
|
+
> 保存视频到本地
|
|
4
|
+
|
|
5
|
+
### saveVideoToLocal
|
|
6
|
+
|
|
7
|
+
> 保存视频到本地
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ----------------------------- | ---- | ------------ |
|
|
13
|
+
| `videoUrl` | `string` | 是 | 视频网络地址 |
|
|
14
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
15
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
16
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
17
|
+
|
|
18
|
+
#### 返回值
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
Promise<void>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 异常返回值
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
Promise<{ errCode: BridgeCode }>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### 示例代码
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { saveVideoToLocal } from '@kbapp/js-bridge'
|
|
34
|
+
|
|
35
|
+
saveVideoToLocal({
|
|
36
|
+
videoUrl: 'https://example.com/video.mp4',
|
|
37
|
+
success() {
|
|
38
|
+
console.log('保存视频成功')
|
|
39
|
+
},
|
|
40
|
+
fail(error) {
|
|
41
|
+
console.log('保存视频失败', error)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# scanQRCode
|
|
2
|
+
|
|
3
|
+
> 扫描二维码
|
|
4
|
+
|
|
5
|
+
### scanQRCode
|
|
6
|
+
|
|
7
|
+
> 扫描二维码
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ----------------------------- | ---- | ---------------------- |
|
|
13
|
+
| `success` | `(res: string) => void` | 否 | 成功回调,返回扫描结果 |
|
|
14
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
15
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
16
|
+
|
|
17
|
+
#### 返回值
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
Promise<string>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
#### 示例代码
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { scanQRCode } from '@kbapp/js-bridge'
|
|
27
|
+
|
|
28
|
+
scanQRCode({
|
|
29
|
+
success(result) {
|
|
30
|
+
console.log('扫描结果', result)
|
|
31
|
+
},
|
|
32
|
+
fail(error) {
|
|
33
|
+
console.log('扫描失败', error)
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# setScreenOrientation
|
|
2
|
+
|
|
3
|
+
> 设置屏幕方向
|
|
4
|
+
|
|
5
|
+
### setScreenOrientation
|
|
6
|
+
|
|
7
|
+
> 设置屏幕方向
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ------------- | ----------------------------- | ---- | ---------------------- |
|
|
13
|
+
| `orientation` | `number` | 是 | 屏幕方向 0:竖屏 1:横屏 |
|
|
14
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
15
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
16
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
17
|
+
|
|
18
|
+
#### 返回值
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
Promise<void>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 示例代码
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { setScreenOrientation } from '@kbapp/js-bridge'
|
|
28
|
+
|
|
29
|
+
// 设置为横屏
|
|
30
|
+
setScreenOrientation({
|
|
31
|
+
orientation: 1,
|
|
32
|
+
success() {
|
|
33
|
+
console.log('设置横屏成功')
|
|
34
|
+
},
|
|
35
|
+
fail(error) {
|
|
36
|
+
console.log('设置横屏失败', error)
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// 设置为竖屏
|
|
41
|
+
setScreenOrientation({
|
|
42
|
+
orientation: 0,
|
|
43
|
+
success() {
|
|
44
|
+
console.log('设置竖屏成功')
|
|
45
|
+
},
|
|
46
|
+
fail(error) {
|
|
47
|
+
console.log('设置竖屏失败', error)
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# setWebViewTitle
|
|
2
|
+
|
|
3
|
+
> 设置网页标题
|
|
4
|
+
|
|
5
|
+
### setWebViewTitle
|
|
6
|
+
|
|
7
|
+
> 设置网页标题(建议通过 document.title 设置)
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ----------------------------- | ---- | ---------------- |
|
|
13
|
+
| `title` | `string` | 是 | webview 标题文案 |
|
|
14
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
15
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
16
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
17
|
+
|
|
18
|
+
#### 返回值
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
Promise<void>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 异常返回值
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
Promise<{ errCode: BridgeCode }>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### 示例代码
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { setWebViewTitle } from '@kbapp/js-bridge'
|
|
34
|
+
|
|
35
|
+
setWebViewTitle({
|
|
36
|
+
title: '页面标题',
|
|
37
|
+
success() {
|
|
38
|
+
console.log('设置标题成功')
|
|
39
|
+
},
|
|
40
|
+
fail(error) {
|
|
41
|
+
console.log('设置标题失败', error)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# shareImage
|
|
2
|
+
|
|
3
|
+
> 分享海报
|
|
4
|
+
|
|
5
|
+
### shareImage
|
|
6
|
+
|
|
7
|
+
> 分享海报
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ----------------------------- | ---- | ------------------------------------- |
|
|
13
|
+
| `imageUrl` | `string` | 是 | 分享的图片链接,仅支持网络地址,png/jpg |
|
|
14
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
15
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
16
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
17
|
+
|
|
18
|
+
#### 返回值
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
Promise<void>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 异常返回值
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
Promise<{ errCode: BridgeCode }>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### 示例代码
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { shareImage } from '@kbapp/js-bridge'
|
|
34
|
+
|
|
35
|
+
shareImage({
|
|
36
|
+
imageUrl: 'https://example.com/poster.png',
|
|
37
|
+
success() {
|
|
38
|
+
console.log('分享海报成功')
|
|
39
|
+
},
|
|
40
|
+
fail(error) {
|
|
41
|
+
console.log('分享海报失败', error)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> 支持 Promise 风格调用
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# triggerAppLogin
|
|
2
|
+
|
|
3
|
+
> 触发 app 登录
|
|
4
|
+
|
|
5
|
+
### triggerAppLogin
|
|
6
|
+
|
|
7
|
+
> 触发 app 登录
|
|
8
|
+
|
|
9
|
+
#### 请求参数
|
|
10
|
+
|
|
11
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
12
|
+
| ---------- | ----------------------------- | ---- | -------- |
|
|
13
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
14
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
15
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
16
|
+
|
|
17
|
+
#### 返回值
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
Promise<void>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
#### 示例代码
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { triggerAppLogin, onLoopCheckAppLogin } from '@kbapp/js-bridge'
|
|
27
|
+
|
|
28
|
+
// 监听登录成功
|
|
29
|
+
const handle = onLoopCheckAppLogin((loginInfo) => {
|
|
30
|
+
console.log('登录成功', loginInfo)
|
|
31
|
+
handle() // 停止监听
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// 触发登录
|
|
35
|
+
triggerAppLogin({
|
|
36
|
+
success() {
|
|
37
|
+
console.log('触发登录成功')
|
|
38
|
+
},
|
|
39
|
+
fail(error) {
|
|
40
|
+
console.log('触发登录失败', error)
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> 支持 Promise 风格调用
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.15-alpha.0",
|
|
7
7
|
"description": "开吧客户端桥接",
|
|
8
8
|
"author": "along",
|
|
9
9
|
"main": "./dist/umd/index.js",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"dist",
|
|
29
29
|
"package.json",
|
|
30
30
|
"README.md",
|
|
31
|
-
"examples"
|
|
31
|
+
"examples",
|
|
32
|
+
"docs"
|
|
32
33
|
],
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@vitest/ui": "^4.1.2",
|