Skip to content

Commit 060c1dc

Browse files
committed
fix 使用TerminalApi调用clearLog报错 #73
1 parent b6283d1 commit 060c1dc

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

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": "3.2.2",
3+
"version": "3.2.3",
44
"description": "A lightweight and powerful web terminal plugin, suitable for vue3. 轻量、功能强大的网页端Terminal插件,适配vue3",
55
"license": "Apache-2.0",
66
"private": false,

src/types/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class TerminalFlash extends TerminalCallback {
146146
// 每个terminal实例最多保存100条记录
147147
const MAX_STORE_SIZE = 100
148148
const DEFAULT_STORAGE_KEY = 'terminal'
149+
149150
export class TerminalStore {
150151
storageKey: string = DEFAULT_STORAGE_KEY
151152
dataMap: Object
@@ -239,7 +240,7 @@ export class TerminalApi {
239240

240241
post(name: string = 'terminal', event: string, options?: any) {
241242
console.debug(`Api receive event '${event}' from terminal '${name}' and attach options ${options}`)
242-
let listener:TerminalApiListenerFunc = this.data.pool[name]
243+
let listener: TerminalApiListenerFunc = this.data.pool[name]
243244
if (listener != null) {
244245
return listener(event, options)
245246
}
@@ -284,6 +285,11 @@ export class TerminalApi {
284285
textEditorClose(name: string, options?: any): string | any {
285286
return this.post(name, 'textEditorClose', options)
286287
}
288+
289+
clearLog(name: string, options?: any): any {
290+
return this.post(name, 'clearLog', options)
291+
}
292+
287293
}
288294

289295
export interface EditorSetting {

test/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const terminals = ref<any>([
1313
{
1414
show: true,
1515
name: 'terminal-test',
16-
context: '/vue-web-terminal/test<br/>123',
16+
context: '/vue-web-terminal/test<br/>123/线上服/2',
1717
dragConf: {
1818
width: "60%",
1919
height: "50%",
@@ -184,6 +184,9 @@ const onExecCmd = (key: string, command: Command, success: SuccessFunc, failed:
184184
let content = command.split(" ")[1]
185185
TerminalApi.appendMessage(name, content)
186186
success()
187+
} else if (key === 'doclear') {
188+
TerminalApi.clearLog(name)
189+
success()
187190
} else {
188191
failed("Unknown command: " + key)
189192
}

0 commit comments

Comments
 (0)