Skip to content

Commit

Permalink
docs: optimize documents
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgao365 committed Oct 8, 2024
1 parent 7333710 commit c8d2954
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
24 changes: 13 additions & 11 deletions packages/vscode-webview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,45 @@ npm add @tomjs/vscode-webview

## Usage

### vscodeWebview.getState()
### WebviewApi

#### getState()

Get the persistent state stored for this webview.

### vscodeWebview.setState(state)
#### setState(state)

Set the persistent state stored for this webview.

### vscodeWebview.postMessage(message)
#### postMessage(message)

Post a message to the owner of the webview

### vscodeWebview.post(type, message, options)
#### post(type, message, options)

Send message

- type: message type
- message: message content
- options: configuration items

### vscodeWebview.postAndReceive(type, message, options): Promise<any>
#### postAndReceive(type, message, options): Promise<any>

Send and receive messages

- type: message type
- message: message content
- options: configuration items

### vscodeWebview.on(type, success[, fail])
#### on(type, success[, fail])

Listen for messages

- type: message type
- success: listener success callback function
- fail: listener error callback function

### vscodeWebview.off(type)
#### off(type)

Cancel listening for messages

Expand All @@ -76,7 +78,7 @@ Cancel listening for messages

**Breaking Updates:**

- Export the `WebviewApiWrapper` class that wraps `WebviewApi`
- Modify the `postMessage` method to be consistent with the method of the `WebviewApi` instance
- Change the original `postMessage` and `postAndReceiveMessage` method names to `post` and `postAndReceive`
- Delete the `WebviewApiWrapper` instances: `vscodeWebview` and `webviewApi`, which need to be manually introduced and instantiated
- Export the `WebviewApi` class wrapped by the `WebviewApi` of the official [@types/vscode-webview](https://www.npmjs.com/package/@types/vscode-webview)
- The `postMessage` method is modified to be consistent with the method of the official `WebviewApi` instance
- The original `postMessage` and `postAndReceiveMessage` method names are changed to `post` and `postAndReceive`
- Delete the `WebviewApi` instances: `vscodeWebview` and `webviewApi`, which need to be manually imported and instantiated
22 changes: 12 additions & 10 deletions packages/vscode-webview/README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,45 @@ npm add @tomjs/vscode-webview

## 使用

### vscodeWebview.getState(): any
### WebviewApi

#### getState(): any

获取此 webview 存储的持久状态。

### vscodeWebview.setState(state: any): any
#### setState(state: any): any

设置此 webview 存储的持久状态。

### vscodeWebview.postMessage(message:any)
#### postMessage(message:any)

向 WebView 的所有者发布消息

### vscodeWebview.post(type, message, options)
#### post(type, message, options)

发送消息

- type: 消息类型
- message: 消息内容
- options: 配置项

### vscodeWebview.postAndReceive(type, message, options): Promise<any>
#### postAndReceive(type, message, options): Promise<any>

发送并接收消息

- type: 消息类型
- message: 消息内容
- options: 配置项

### vscodeWebview.on(type, success[, fail])
#### on(type, success[, fail])

监听消息

- type: 消息类型
- success: 监听成功回调函数
- fail: 监听失败回调函数

### vscodeWebview.off(type)
#### off(type)

取消监听消息

Expand All @@ -76,7 +78,7 @@ npm add @tomjs/vscode-webview

**破坏性更新:**

- 导出 `WebviewApi` 的封装 `WebviewApiWrapper`
- `postMessage` 方法修改为与 `WebviewApi` 实例的方法一致
- 导出由官方 [@types/vscode-webview](https://www.npmjs.com/package/@types/vscode-webview)`WebviewApi` 来封装的 `WebviewApi`
- `postMessage` 方法修改为与官方的 `WebviewApi` 实例的方法一致
-`postMessage``postAndReceiveMessage` 方法名改为 `post``postAndReceive`
- 删除 `WebviewApiWrapper` 的实例:`vscodeWebview``webviewApi`,需要手动引入并实例化
- 删除 `WebviewApi` 的实例:`vscodeWebview``webviewApi`,需要手动引入并实例化

0 comments on commit c8d2954

Please sign in to comment.