Skip to content

Commit 55b0392

Browse files
committed
publish 2.0.12
1 parent 396c976 commit 55b0392

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A web-side command line plugin built by `Vue`, supports multiple message formats
1111
## Feature Support
1212

1313
* Supported message formats: `text`, `table`, `json`, `code`/multiline text, `html`
14-
* `Highlight`, `Codemirror` code highlighting
14+
* `Highlight.js`, `Codemirror.js` code highlighting
1515
* ← → key cursor switch
1616
* ↑ ↓ key history command toggle
1717
* Full-screen display
@@ -192,20 +192,22 @@ The dragConf structure is as follows:
192192

193193
![dragging.gif](public/dragging.gif)
194194

195-
In addition to mouse control, you can also [call API to simulate dragging](#dragging)
195+
In addition to mouse control, you can also [call API to simulate dragging](#dragging())
196196

197197
## Api
198198

199199
This plugin provides some APIs that can use Vue to actively initiate event requests to the plugin.
200200

201+
PS:**All api calls require the name of the terminal.**
202+
201203
```js
202204
import Terminal from "vue-web-terminal"
203205

204206
// det api
205207
Terminal.$api
206208
```
207209

208-
### pushMessage
210+
### pushMessage()
209211

210212
```js
211213
// Each terminal will define a name, see the previous document for details
@@ -219,7 +221,7 @@ let message = {
219221
Terminal.$api.pushMessage(name, message)
220222
```
221223

222-
### updateContext
224+
### updateContext()
223225

224226
For example, */vue-web-terminal/tzfun* in the current input line `$ /vue-web-terminal/tzfun > ` is the context, and the context text can be freely set by the developer, but you need to use `.sync` to bind a variable.
225227

@@ -249,22 +251,24 @@ export default {
249251
</script>
250252
```
251253

252-
### fullscreen
254+
### fullscreen()
253255

254256
Make the current terminal enter or exit full screen.
255257

256258
```js
257259
Terminal.$api.fullscreen('my-terminal')
258260
```
259261

262+
### isFullscreen()
263+
260264
Determine if the current state is full screen.
261265

262266
```js
263267
// true or false
264268
let fullscreen = Terminal.$api.isFullscreen('my-terminal')
265269
```
266270

267-
### dragging
271+
### dragging()
268272

269273
When [Feature Drag](#Drag) is enabled, you can use the following method to simulate drag to change the window position, where the parameter `x` is the distance from the left border of the terminal to the left border of the browser's visible range, in px, `y ` is the distance from the upper border of the terminal to the upper border of the browser's visible range.
270274

@@ -275,15 +279,15 @@ Terminal.$api.dragging('my-terminal', {
275279
})
276280
```
277281

278-
### execute
282+
### execute()
279283

280284
You can use the api to execute a command to the Terminal, and the execution process will be echoed in the Terminal window. This is a way to use a script to simulate the user executing the command.
281285

282286
```js
283287
Terminal.$api.execute('my-terminal', 'help :local')
284288
```
285289

286-
### getPosition
290+
### getPosition()
287291

288292
When in drag mode, this interface can get the position of the window.
289293

@@ -292,6 +296,13 @@ let pos = Terminal.$api.getPosition('my-terminal')
292296
console.log(pos.x, pos.y)
293297
```
294298

299+
### focus()
300+
301+
Get input focus
302+
```js
303+
Terminal.$api.focus('my-terminal')
304+
```
305+
295306
## Message
296307

297308
This plugin defines a message object, any message must be defined in this format to display correctly.

README_ZH.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,24 @@ dragConf结构如下:
192192

193193
![dragging.gif](public/dragging.gif)
194194

195-
除了鼠标控制之外你还可以[调用API模拟拖拽](#拖拽)
195+
除了鼠标控制之外你还可以[调用API模拟拖拽](#dragging())
196196

197197
## Api
198198

199199
本插件提供了一些 Api 可以使用 Vue 主动向插件发起事件请求。
200200

201+
注意:**所有的API接口调用都需要用到Terminal的`name`**
202+
201203
```js
202204
import Terminal from "vue-web-terminal"
203205

204206
// 获取api
205207
Terminal.$api
206208
```
207209

208-
### 向Terminal推送一条消息
210+
### pushMessage()
211+
212+
向Terminal推送一条消息
209213

210214
```js
211215
let name = 'my-terminal' // 每一个terminal都会定义一个name,详情见前面文档
@@ -218,7 +222,7 @@ let message = {
218222
Terminal.$api.pushMessage(name, message)
219223
```
220224

221-
### 修改上下文
225+
### updateContext()
222226

223227
比如当前输入行`$ /vue-web-terminal/tzfun > `*/vue-web-terminal/tzfun* 就是上下文,上下文文本可以由开发者自由设置
224228
,但是需使用`.sync`绑定一个变量
@@ -249,22 +253,24 @@ export default {
249253
</script>
250254
```
251255

252-
### Fullscreen
256+
### fullscreen()
253257

254258
使当前terminal进入或退出全屏
255259

256260
```js
257261
Terminal.$api.fullscreen('my-terminal')
258262
```
259263

264+
### isFullscreen()
265+
260266
判断当前是否处于全屏状态
261267

262268
```js
263269
// true or false
264270
let fullscreen = Terminal.$api.isFullscreen('my-terminal')
265271
```
266272

267-
### 拖拽
273+
### dragging()
268274

269275
当开启[拖拽功能](#拖拽功能)时可以使用下面这种方式模拟拖拽来改变窗口位置,其中参数`x`
270276
是terminal左边框到浏览器可视范围左边框的距离,单位px,`y`是terminal上边框到浏览器可视范围上边框的距离。
@@ -276,15 +282,15 @@ Terminal.$api.dragging('my-terminal', {
276282
})
277283
```
278284

279-
### 执行命令
285+
### execute()
280286

281287
可以使用api向Terminal执行一个命令,执行过程会回显在Terminal窗口中,这是一种用脚本模拟用户执行命令的方式
282288

283289
```js
284290
Terminal.$api.execute('my-terminal', 'help :local')
285291
```
286292

287-
### 获取位置
293+
### getPosition()
288294

289295
当处于拖拽模式时,此接口可获取窗口所在位置
290296

@@ -293,6 +299,14 @@ let pos = Terminal.$api.getPosition('my-terminal')
293299
console.log(pos.x, pos.y)
294300
```
295301

302+
### focus()
303+
304+
获取输入焦点
305+
306+
```js
307+
Terminal.$api.focus('my-terminal')
308+
```
309+
296310
## 消息对象
297311

298312
本插件定义了消息对象,任何消息需按照此格式定义才能正确显示。

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-web-terminal",
3-
"version": "2.0.11",
3+
"version": "2.0.12",
44
"description": "网页端命令行插件,适配vue3",
55
"license":"Apache-2.0",
66
"private": false,

0 commit comments

Comments
 (0)