Skip to content

Commit f08dc80

Browse files
committed
[vue3] publish test
1 parent 5e51a08 commit f08dc80

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/Terminal.vue

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ const tips = reactive({
265265
top:0,
266266
left:0
267267
},
268+
cursorIdx: 0,
268269
items: <InputTipItem[]>[],
269270
helpBox: {
270271
// 避免默认提示板与输入框遮挡,某些情况下需要隐藏提示板
@@ -822,6 +823,7 @@ const _execute = () => {
822823
showInputLine.value = false
823824
let _success: SuccessFunc = (message) => {
824825
let _finish = () => {
826+
_jumpToBottom()
825827
showInputLine.value = true
826828
_endExecCallBack()
827829
}
@@ -831,6 +833,7 @@ const _execute = () => {
831833
if (message instanceof TerminalFlash) {
832834
message.onFlush((msg: string) => {
833835
flash.content = msg
836+
_jumpToBottom()
834837
})
835838
message.onFinish(() => {
836839
flash.open = false
@@ -846,6 +849,7 @@ const _execute = () => {
846849
ask.callback = options.callback
847850
ask.autoReview = options.autoReview
848851
_focus()
852+
_jumpToBottom()
849853
})
850854
851855
message.onFinish(() => {
@@ -1169,11 +1173,7 @@ const _inputKeyUp = () => {
11691173
} else {
11701174
idx = tips.items.length - 1
11711175
}
1172-
let viewItem = terminalCmdTipsRef.value.querySelector(".t-cmd-tips-item:nth-child(" + (idx + 1) + ")")
1173-
if (viewItem) {
1174-
viewItem.scrollIntoView({block: "start", behavior: "smooth"})
1175-
}
1176-
tips.selectedIndex = idx
1176+
_switchTipsSelectedIdx(idx)
11771177
} else {
11781178
_switchPreCmd()
11791179
}
@@ -1187,16 +1187,25 @@ const _inputKeyDown = () => {
11871187
} else {
11881188
idx = 0
11891189
}
1190-
let viewItem = terminalCmdTipsRef.value.querySelector(".t-cmd-tips-item:nth-child(" + (idx + 1) + ")")
1191-
if (viewItem) {
1192-
viewItem.scrollIntoView({block: "start", behavior: "smooth"})
1193-
}
1194-
tips.selectedIndex = idx
1190+
_switchTipsSelectedIdx(idx)
11951191
} else {
11961192
_switchNextCmd()
11971193
}
11981194
}
11991195
1196+
const _switchTipsSelectedIdx = (idx:number) => {
1197+
let viewItem = terminalCmdTipsRef.value.querySelector(".t-cmd-tips-item:nth-child(" + (idx + 1) + ")")
1198+
if (viewItem) {
1199+
viewItem.scrollIntoView({block: "start", behavior: "smooth"})
1200+
}
1201+
tips.selectedIndex = idx
1202+
1203+
let input = terminalCmdInputRef.value
1204+
if (input) {
1205+
input.setSelectionRange(tips.cursorIdx, tips.cursorIdx)
1206+
}
1207+
}
1208+
12001209
const _switchPreCmd = () => {
12011210
let cmdLog = store.getLog(getName())
12021211
let cmdIdx = store.getIdx(getName())
@@ -1617,6 +1626,7 @@ const _switchAllFoldState = (fold: boolean) => {
16171626
const _calculateTipsPos = (autoOpen: boolean = false) => {
16181627
if (autoOpen) {
16191628
tips.style.opacity = 0
1629+
tips.cursorIdx = terminalCmdInputRef.value.selectionStart
16201630
tips.open = true
16211631
}
16221632
if (tips.open) {

src/css/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
.t-log-box {
1717
display: block;
1818
position: relative;
19+
line-height: var(--t-font-height);
1920
}
2021

2122
.t-container {
@@ -123,6 +124,7 @@
123124
.t-window div,
124125
.t-crude-font {
125126
font-size: var(--t-font-size);
127+
font-family: none;
126128
/*font-family: Monaco, Menlo, Consolas, monospace;*/
127129
}
128130

@@ -294,6 +296,7 @@
294296
letter-spacing: 0;
295297
position: relative;
296298
margin-bottom: 15px;
299+
line-height: var(--t-font-height);
297300
}
298301

299302
/*手机*/

0 commit comments

Comments
 (0)