Skip to content

Commit af4d9a6

Browse files
committed
merge from branch vue2
1 parent 61abf02 commit af4d9a6

File tree

8 files changed

+98
-39
lines changed

8 files changed

+98
-39
lines changed

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,26 @@ body, html, #app {
122122

123123
Terminal tag supports attribute parameter table.
124124

125-
| Argument | Description | Type | Default |
126-
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|--------------------------------------------------|
127-
| name | Terminal instance name, the name of the same vue instance must be unique, this value is also used in API. | string | terminal |
128-
| context | Context text. | string | /vue-web-terminal |
129-
| title | The title displayed in the header. | string | vue-web-terminal |
130-
| show-header | Whether to display the header, this switch will affect the drag and [drop](#Drag) function. Only when the header is displayed can the drag and drop function provided by default be used. | boolean | true |
131-
| init-log | The log displayed when Terminal is initialized. It is an array composed of [Message](#Message), `null` is not displayed. | array | / |
132-
| warn-log-count-limit | If the current Terminal log number exceeds this limit, a warning will be issued. Setting a value of `<= 0` will not issue a warning. | number | 200 |
133-
| auto-help | Whether to enable the command line automatic search prompt function. | boolean | true |
134-
| enable-example-hint | Whether to show sample prompts, provided that `auto-help` is enabled. | boolean | true |
135-
| command-store | Customized command library, the search prompt function will scan this library, see [Command Definition](#Command) | array | [Local Commands](#Local) |
136-
| command-store-sort | Command line library sorting function, the display collation of the custom command library. | function | function(a,b) |
137-
| input-filter | Custom input filter, the return value is the filtered string, must be plain text, no html tags. | function | function(当前输入字符char, 输入框内字符串value, input事件event) |
138-
| drag-conf | Drag and drop window configuration items. **If you do not configure it, the parent element will be filled with 100%, and the window width and height are equal to the width and height of the parent element.** | object | [Drag](#Drag) |
139-
| command-formatter | Command display formatting function, pass in the current command and return a new command, support html. If not set, the internally defined highlight style will be used. | function | function(cmd) |
140-
| tab-key-handler | The logic processing method when the user types the Tab key can be used in conjunction with the `helpCmd` slot. | function | function(event) |
141-
| search-handler | User-defined command search prompt implementation, the callback needs to resolve a command object, the specific format see [Command Definition format](#Command), can be used with `helpCmd` this slot | function | function(commandStore, key, callback) |
125+
| Argument | Description | Type | Default |
126+
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|--------------------------------------------------|
127+
| name | Terminal instance name, the name of the same vue instance must be unique, this value is also used in API. | string | terminal |
128+
| context | Context text. | string | /vue-web-terminal |
129+
| title | The title displayed in the header. | string | vue-web-terminal |
130+
| show-header | Whether to display the header, this switch will affect the drag and [drop](#Drag) function. Only when the header is displayed can the drag and drop function provided by default be used. | boolean | true |
131+
| init-log | The log displayed when Terminal is initialized. It is an array composed of [Message](#Message), `null` is not displayed. | array | / |
132+
| warn-log-count-limit | If the current Terminal log number exceeds this limit, a warning will be issued. Setting a value of `<= 0` will not issue a warning. | number | 200 |
133+
| auto-help | Whether to enable the command line automatic search prompt function. | boolean | true |
134+
| enable-example-hint | Whether to show sample prompts, provided that `auto-help` is enabled. | boolean | true |
135+
| command-store | Customized command library, the search prompt function will scan this library, see [Command Definition](#Command) | array | [Local Commands](#Local) |
136+
| command-store-sort | Command line library sorting function, the display collation of the custom command library. | function | function(a,b) |
137+
| input-filter | Custom input filter, the return value is the filtered string, must be plain text, no html tags. | function | function(当前输入字符char, 输入框内字符串value, input事件event) |
138+
| drag-conf | Drag and drop window configuration items. **If you do not configure it, the parent element will be filled with 100%, and the window width and height are equal to the width and height of the parent element.** | object | [Drag](#Drag) |
139+
| command-formatter | Command display formatting function, pass in the current command and return a new command, support html. If not set, the internally defined highlight style will be used. | function | function(cmd) |
140+
| tab-key-handler | The logic processing method when the user types the Tab key can be used in conjunction with the `helpCmd` slot. | function | function(event) |
141+
| search-handler | User-defined command search prompt implementation, the callback needs to resolve a command object, the specific format see [Command Definition format](#Command), can be used with `helpCmd` this slot | function | function(commandStore, key, callback) |
142+
| scroll-mode | Scroll bar mode. | string | smooth |
143+
| push-message-before | A hook function that fires before the push message is displayed. | function | function(message, name) |
144+
142145
> Below are the removed properties
143146
>
144147
> * ~~**show-log-time**~~: Removed after `2.0.14` and `3.0.13` versions.

README_ZH.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ terminal标签支持的属性参数表
124124
|----------------------|---------------------------------------------------------------------------|----------|--------------------------------------------------|
125125
| name | Terminal实例名称,同一页面的name必须唯一,API中使用也需用到此值 | string | terminal |
126126
| context | 上下文内容 | string | /vue-web-terminal |
127-
| scrollMode | 滚动条模式 | string | smooth/auto |
128127
| title | 窗口头部显示的标题 | string | vue-web-terminal |
129128
| show-header | 是否显示窗口头部,此开关会影响[拖拽功能](#拖拽功能),只有显示头部才能使用默认提供的拖拽功能 | boolean | true |
130129
| init-log | Terminal初始化时显示的日志,是由[消息对象](#消息对象)组成的数组,设为`null`则不显示 | array ||
@@ -138,9 +137,11 @@ terminal标签支持的属性参数表
138137
| command-formatter | 命令显示格式化函数,一般用于输入命令高亮显示,传入当前命令返回新的命令,支持html。如果不设置将使用内部定义的高亮样式 | function | function(cmd) |
139138
| tab-key-handler | 用户键入Tab键时的逻辑处理方法,可配合`helpCmd`这个slot使用 | function | function(event) |
140139
| search-handler | 用户自定义命令搜索提示实现,callback需接收一个命令对象,具体格式见[命令定义格式](#命令定义),可配合`helpCmd`这个slot使用 | function | function(commandStore, key, callback) |
141-
140+
| scroll-mode | 滚动条模式 | string | smooth |
141+
| push-message-before | 在推送消息显示之前触发的钩子函数 | function | function(message, name) |
142+
142143
> 下面是已移除属性
143-
>
144+
>
144145
> * ~~**show-log-time**~~: `2.0.14``3.0.13`版本之后移除
145146
> * ~~**warn-log-byte-limit**~~: `2.1.0``3.1.0`版本之后移除
146147
> * ~~**warn-log-limit-enable**~~: `2.1.1``3.1.1`版本之后移除
@@ -774,10 +775,10 @@ let flashInterval = setInterval(() => {
774775
通过`new TerminalAsk()`创建一个新的ask对象,传入success回调中,ask对象提供两个方法:
775776

776777
* `ask(options)`: 发起一个用户询问输入,options是一个对象,其属性解释如下(*号表示必填):
777-
* `question`: string,询问的问题,或者可以理解为用户输入的前缀字串
778-
* `callback`: function,用户键入回车时的回调,参数值为用户输入的内容
779-
* `autoReview`: bool,用户键入回车时是否自动追加当前的显示内容
780-
* `isPassword`: bool,是否是密码输入
778+
* `question`: string,询问的问题,或者可以理解为用户输入的前缀字串
779+
* `callback`: function,用户键入回车时的回调,参数值为用户输入的内容
780+
* `autoReview`: bool,用户键入回车时是否自动追加当前的显示内容
781+
* `isPassword`: bool,是否是密码输入
781782
* `finish()`: 结束执行
782783

783784
```js

src/Terminal.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import {
88
_getClipboardText,
99
_getSelection,
1010
_html,
11-
_isEmpty, _isPad,
12-
_isParentDom, _isPhone,
11+
_isEmpty,
12+
_isPad,
13+
_isParentDom,
14+
_isPhone,
1315
_isSafari,
1416
_nonEmpty,
1517
_openUrl,
@@ -413,6 +415,9 @@ export default {
413415
this._fullscreen()
414416
} else if (key === 'minScreen' && this.fullscreenState) {
415417
this._fullscreen()
418+
} else if (key === 'pin' && this.showHeader) {
419+
let pinned = this.dragConf.pinned || false
420+
this.dragConf.pinned = !pinned;
416421
}
417422

418423
this.$emit('on-click', key, this.getName())
@@ -760,9 +765,7 @@ export default {
760765
message.content = _parseANSI(message.content)
761766
}
762767

763-
this._filterMessageType(message)
764-
765-
this.terminalLog.push(message)
768+
this._pushMessage0(message)
766769
if (!ignoreCheck) {
767770
this._checkTerminalLog()
768771
}
@@ -775,13 +778,19 @@ export default {
775778
},
776779
_pushMessageBatch(messages, ignoreCheck = false) {
777780
for (let m of messages) {
778-
this._filterMessageType(m)
779-
this.terminalLog.push(m)
781+
this._pushMessage0(m)
780782
}
781783
if (!ignoreCheck) {
782784
this._checkTerminalLog()
783785
}
784786
},
787+
_pushMessage0(message) {
788+
this._filterMessageType(message)
789+
if (message.type !== MESSAGE_TYPE.CMD_LINE && this.pushMessageBefore) {
790+
this.pushMessageBefore(message, this.getName())
791+
}
792+
this.terminalLog.push(message)
793+
},
785794
_jumpToBottom() {
786795
nextTick(() => {
787796
let box = this.terminalWindow
@@ -1099,6 +1108,9 @@ export default {
10991108
})
11001109
},
11011110
_dragging(x, y) {
1111+
if (this.dragConf.pinned === true) {
1112+
return
1113+
}
11021114
let clientWidth = document.body.clientWidth
11031115
let clientHeight = document.body.clientHeight
11041116
let container = this.terminalContainer

0 commit comments

Comments
 (0)